Archived

This topic is now archived and is closed to further replies.

Jabba

3d environment and sprite animation:how?

Recommended Posts

Hi all, this question may be a FAQ so please accept my apollogies if it has been raised before.Just direct me to the right place.If not, here I go: I wonder how did they perform the troop animation in Shogun''s tactical battles.The troops are clearly sprity,but they obey however quite well to the laws of 3d(especially height) and perspective. My impression has always been that these kind of games (which are using sprites in a 3d environment to similate LOTS of troops - that could not be created using REAL 3d objects) are using simple billboarding with dynamic texturing, the textures being the appropriate sprites.By alternating the sprites on the surface of the billboarded rectangle, the animation effect is produced. However , now it appears (from baskuenen ''s thread regarding fast texture switching and and my OpenGL tests) that alternating textures - at least using glBindTexture - is tooo slow. How are they doing it , then?Any ideas? My new idea would be that they are stretching the sprites according to their position in space and throw them directly on the screen - as sprites , that is , and not as textures.However, this is not easy possible in a Win32+OpenGL environment and the stretching algorithm, well, I don''t want to think about it :-) Regards, Jabba The Truth Is Not To Be Spoken In A Loud Voice

Share this post


Link to post
Share on other sites
I''ve never actually seen that game - but if they are being billboarded then maybe all the sprites for each character are held in one big texture and texture coords are being adjusted accordingly to show the needed sprite animation.
Is glBindTexture that slow?

Chris

Share this post


Link to post
Share on other sites
glBindTexture is quite slow.It has to be - bassically it''s a texture mapping operation.
Is texture adjustment faster?I must check...

The Truth Is Not To Be Spoken In A Loud Voice

Share this post


Link to post
Share on other sites
The problems with using one huge texture (1024x1024 for example) is that some 3D cards don''t support them. The largest standard still is 256x256. Although switching textures is slow, it is unavoidable. If you have let''s say 100 textures, and you would use them all that should be no problem (assuming you also switch 100 times). The problem arrises when you must switch for every polygon you draw (lets say 100000 polygons). If you switch textures 100000 times per frame - performance is gone.

If you''re using 3D (hardware) for sprites, you probably don''t have much polygons (<100000), and switching a few times should be no problem

Share this post


Link to post
Share on other sites
I solved this problem a while ago when I was trying to play an AVI file onto a polygon.

The trick is NOT to use the glBingTexture to keep updating the texture.You have to use glTexSubimage2D() everytime you want to change the buffer data.What this function basically does is it changes just the buffer data.In each frame,you have supply it with a pointer to the new buffer (frame x in an AVI file for example) and it will update it for you and this is a hell of a lot faster than creating tons of textures and you keep binding them every frame.If you need a demo program and source,just drop me an email at thegecko@tbaytel.net

Hope that helps.Just check out the glTexSubImage2D() function.

Share this post


Link to post
Share on other sites