I just recently started Doing 3D Game Development in Java with LWJGL Currently Ive Managed to create a Basic Model, and Load it and Render it on screen, but I cant Figure out how to Take a Texture and Apply it to the Model.

I know it has something to do with glBind() or glBindTexture(). and I can figure out how to load a PNG using inputStream, but I cant figure out what to do with the texture AFTER I have it loaded all the tutorials I see Just do 2D with Quads and I'm using 3D and Triangles

Texturing a 3d model involves using texture coordinates to apply a region of a texture to each of the faces on the model. In the end, it's the same idea as texturing a bunch of flat polygons, just more complicated.

This is normally something you'd never do by hand for any complex model. What you need is to look for a "UV Mapper" in your favorite modeling program, such as Blender or Milkshape. This will add texture coordinates to the model so it will be textured when you use a model loader and renderer that understands the model format. UV mapping can be a really tedious, fiddly business that takes a while to get used to (truthfully I never did) so be patient when learning it.

How Did I know someone was going to say that I had to go back to Blender.

But thank you, Right now I'm only doing a simple cube. My Issue is more along the lines that I apply the texture to a Face and it dosn't show. Below is what I currently have, the only thing I can think of would be I need to add glTexCoord3f(); But I dont know what to put as the texture coordinates.

You only need glTexCoord2f, since you're only using 2d textures (3d textures are very uncommon). The tutorials should cover how to texture one square, so just apply the same idea to all the faces of the cube.

Glad to be of help. I spent hours dicking around with things, trying to figure out why it mattered what order I rendered my triangles in. And how would I manage to handle it when I rotate around the damnable cube.

As for your current issue? My guess would be that it's an issue with the order that your triangles are getting formed. However, I don't know how you'd solve it with the way you're doing things currently.

What you need is to look for a "UV Mapper" in your favorite modeling program, such as Blender or Milkshape.

I've heard that term so many times. However, it only just snapped when you said it, heh. I always thought it was an 'Ultra Violet Mapper' or something, not a mapper that helps you select the correct U (& U2) and V (& V2) for your textures when you're doing 3D stuff. xD

Well right now I just use a for loop and map the texture to EVERY face the same way. I have a hard time understanding Exporting to obj WITH textures. I know when you export it to obj thats been triangulated, the faces are in the format f v1/vt1/vn1 v2/vt2/vn2 v3/vt1/vn3 But Every time I export the obj, it never adds vt...

Well right now I just use a for loop and map the texture to EVERY face the same way. I have a hard time understanding Exporting to obj WITH textures. I know when you export it to obj thats been triangulated, the faces are in the format f v1/vt1/vn1 v2/vt2/vn2 v3/vt1/vn3 But Every time I export the obj, it never adds vt...

Yes, I'm just using the default cube right now. My Problem is that whenever I try to add a texture in blender the texture only shows up in render and not in the model view. and when I export it to .obj I cant find the option to export with texture coordinates

also Ive got this working so far but the textures are seemingly mapped weird on every other triangle: I think I understand this part, on the top triangle the coordinates are normal

1) Change one of your display panes to UV/Image Editor (I do it with the top right pane most of the time).2) Create a new Image of whatever dimensions you'd like to use for all of the object's textures.3) On your main screen go into Edit Mode (Select the mesh and press Tab), select all (A).4) Press 'U' then select UV Unwrap or Smart UV Unwrap (Not sure what the difference is, honestly).5) Check whether the unwrap (Which will appear on your Image Editor pane) fits your dimensions. If it doesn't, you might need to select 'Constraint to Image Bounds' in the UVs Menu on that display.6) Go to the properties window (Tends to be lower right) select 'Render' tab, then scroll down to 'Bake'. Expand that, and select 'Texture' from the Bake Mode list. Then click 'Bake'. It will output your current texture (Stretched as needed) to the image you created in step 2 and aligned to your UVs.7) Save that image.

If you need to make sure that certain things will be a specific size, you can mess around with the layout of the UV produced in step 5. This will both output a corrected texture and provide you with your face texture UVs. :3

BEAUTIFUL! The Obj is now showing the texture coordinates and v/vt/vn for the faces. now I just have to modify EVERYTHING(ModelLoader, Model, Face, Render) hahahaha but its an amazing start, Now all I need to learn is Animation.

Check out the LibGDX ObjLoader. It should be able to help you figure out just how to modify it. :3

As for Animation? That's where I'm having trouble myself. I'm torn between doing several .obj files, loading them into a program and then outputting a custom format or something. I mean, there are other options like the MD5 system, however those tend to be expensive (Based on bone movements, it recomputes a lot of stuff each frame or something) to use.

Check out the LibGDX ObjLoader. It should be able to help you figure out just how to modify it. :3

As for Animation? That's where I'm having trouble myself. I'm torn between doing several .obj files, loading them into a program and then outputting a custom format or something. I mean, there are other options like the MD5 system, however those tend to be expensive (Based on bone movements, it recomputes a lot of stuff each frame or something) to use.

Definitely will check that out

As for animation, I know what you mean, I cant seem to find any other way besides MD5 or coming up with your own system.

EDIT: I think I figured it out. I'm only storing one of the texture coordinate indexes in the Face therefore its not mapping at all.Second edit: in the ModelLoader I got the x coordinate every time... Now it shows again but the UV Map isnt working

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org