www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 Rotated textures for Atlas in TGEA 1.7.0 « View previous topic :: View next topic » 
Author Message
konradk
PostPosted: Tue May 27, 2008 6:59 pm    Post subject: Rotated textures for Atlas in TGEA 1.7.0 Reply with quote



Joined: 13 May 2008
Posts: 6

Hi all. I have started a thread on the GG forums, I'm to make a resource that'd have rotating textures in the engine - Grome style. (I love Grome!)

I had an idea in there for auto-rotation based on affected faces' average normal, if anyone from Quad Software is reading this, could you please take a look - maybe it's something that'd not be too hard, but would help designers position textures over their terrains better.

GG forum thread: http://www.garagegames.com/mg/forums/result.thread.php?qt=75604
Back to top
View user's profile Send private message
ALicu
PostPosted: Wed May 28, 2008 7:10 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi Konrad,

I don’t know how this can be implemented in Atlas but I suspect that it will work only for blended terrain. What I can help you with is to explain how this feature is implemented in Grome.

For each layer (texture) you have the texture mapping planar but the plane can have any orientation (can be horizontal (the standard one), vertical from north to south, from west to east, or at any angle and spin). But it is always planar and doesn’t vary with the terrain surface (applying it differently for each face will not work that easily, we would need to implement an unwrap algorithm).

Finding the best plane angle based on average orientation is also tricky since you will need a way to detect the terrain faces covered by that texture (you need to go thru the texture mask (coverage) and detect what faces are touched by that layer texture).
To actually get the mapping coordinates working it is very easy. You need to create the texture coordinates based on the vertex positions (since the terrain surface is a regular grid). Basically you need to take the vertex x,y,z and apply some transformation to obtain the planar texture coordinates. The transformation can be obtained from the Grome SDK (look for sTextureChannel:: sTextureMapping in the iTerrainMaterialLayer.h in the SDK). I can also send you the code to compute them (texgen_planes and tex_matrix).

To apply them in the engine, with OpenGL, just use tex gen planes to automatically create the texture coordinates based on the vertex positions. You also need to use the texture matrix to apply spinning, offset and texture scaling (tiling). For a good example, you can look at the output produced by the OSG (Open Scene Graph) exporter from Grome (in SDK/Plugins/ExpOSG/ExpOSG.cpp). In the SDK you also have the full source code of the exporter. There you can find the exact steps necessary to produce the correct texture transformation for any orientation. You just need to know a little OpenGL (OSG scene graph is based on OpenGL states).

If you need DirectX states (there you need to apply texture matrix and D3DTSS_TCI_CAMERASPACEPOSITION texture generation mode) let me know. I can send you a sample code for that.

Best Regards,
Adrian L.
Quad Software
Back to top
View user's profile Send private message
konradk
PostPosted: Wed May 28, 2008 7:43 am    Post subject: Reply with quote



Joined: 13 May 2008
Posts: 6

Adrian,

Thank you for your help! For now, I'll experiment with translations, I'll try to do it on the engine level to not have to worry about whether Direct3D or OpenGL is used by the client. I did not mean to apply a texture to each face, that'd require some serious texture morphing, and I still need to grow up to that.

I'll bug you if I get stuck though. Smile Thank you again, I appreciate your help! And keep up the great work & support with Grome, it is definitely the best piece of software I have ever bought!

For now I'll just concentrate on the Torque side of the problem. If it's ready to accept rotation values for spin / vertical / horizontal, then I'll check the Grome to TGEA exporter and make it so when it exports the mission file, I'll make it include the set rotation, and possibly a commented out recommended rotation for each texture by checking the faces for each texture through the distribution layers - just like you said.

I hope I'll get around through the transformation matrices somehow, it will be a good excercise.

Thanks again,
Konrad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group