Textures on a Terrain

Started by paulscode, October 16, 2008, 11:57:17 PM

Previous topic - Next topic

paulscode

Another question about terrains.  It looks as though only one texture can be assigned to an Object3D at any given time, so what is the best way to texture a terrain that has many different graphics on it, like grass, dirt, roads, etc?  My thought was to create a texture that is say 1024 width and a super huge height that has all the texture graphics on it, then do a UV map for each polygon to the desired graphic.  I'm not sure what method to use for this though.  PolygonManager.setPolygonTexture( int polyID, TextureInfo tInf ) looks like it will do the job, but I just wanted to make sure that will work in both software and OpenGL modes (assuming I use a single texture that is).

fireside

#1
You can use more than one texture on an object3d.  It's  more efficient because you can use texture repeat with smaller textures.  It loads them automatically by name so the texture name has to be less than 8 characters and you have to load them before you load the object and name the texture the same as the name in the 3ds file, even the extension needs to be in the name, I think.  Hmm, that's right, you're not using 3ds files.  Well, I don't know how you do it, then.
click here->Fireside 7 Games<-

paulscode

#2
Quote from: fireside on October 17, 2008, 12:19:49 AM
You can use more than one texture on an object3d.  It's  more efficient because you can use texture repeat with smaller textures.  It loads them automatically by name so the texture name has to be less than 8 characters and you have to load them before you load the object and name the texture the same as the name in the 3ds file, even the extension needs to be in the name, I think.
That is one way to get the texture onto the Object3D, you are correct.  However, you can also assign a texture to the Object3D after it is loaded (then you are not limited to the 8 character name length).  The same UV coordinates that were in the 3ds file are used, so no worries there.  That way you can switch out textures as needed (for example using a variety of leaf colors for different coppies of the same tree model).  That is the method I used in the "Camera Orbiter" demo applet for the textures on the tree, and also the method I am using for assigning and switching textures on the terrain in my Map Maker application.

It looks like UV maps can be generated with the TextureInfo class, so I am pretty sure that is the way to do it when you are not starting with an actual .3ds file.

--EDIT--
According to the jPCT JavaDocs, "Multi texturing is supported by the OpenGL renderer only".  Perhaps that only applies to per-polygon though ???  I want to have the option of switching between software and OpenGL modes, so if there is a restriction of one texture per Object3D when in software mode, multiple textures won't work in my situation.

fireside

 There are two software renderers, and I think the default uses opengl, so it might not matter.  I know I used multiple textures in software mode. 
click here->Fireside 7 Games<-

paulscode

Come to think of it, I have too (when I load a 3ds file and "merge" all the sub objects into one).  So I guess this isn't an issue after all.

EgonOlsen

You are confusing multi-texturing with multiple textures. The former means that you apply more than one texture to one polygon. The software renderer doesn't support this. The latter means that you assign multiple textures to one object but with only one per polygon. All renderers support this.

paulscode

Cool.  I thought maybe that is what the JavDoc meant, but I wanted to be sure before I got too far into things.