Need Opinions/Methods for Texture Animation

Started by
3 comments, last by Isaac Vanier 23 years, 10 months ago
I know HOW to animate textures, I just want to pick everyones brain regarding structure setup and stuff. My engine uses shared models, and shared textures to save on memory and load times. So there can be multiple copies of a model that all use the same geometry. An Object in the engine is the structure that holds the independant information that needs to be unique for each object, then each object has a model. Models use the shared textures. Anyway, I want to use animated textures, but since everything is shared, it makes it difficult. I''m curious to see how everyone else handles this situation. I could keep the texture indexes/pointers for a model within the Object then update that list in order to cause animation. the Model could keep a default texture list and when a new instance is created, that list is just copied directly from the Model into the Object rather than reloading the texture info from disk. That''s the best way I''ve come up with so far. Should work, but I don''t like the level of seperation. Don''t know that there''s a way to get around it though. I could animate textures at the texture level, but then a single texture animation can only be at a certain frame at any one time. So if I have to identical models that use the same animation, that animation would have to be at the same frame for both models, I can''t have that. Make sense? : ) www.SatelliteMoon.com
Advertisement
weird C++ pseudocode alert.

class TTexture{public:// ctor, dtor, getdata( ), setdata( ), etc..// update function, called for all TTexture instances.   virtual void    Update( ) { }protected:   SColor3         *m_pData;};class TAnimTexture : public TTexture{public:// ctor, dtor, getdata( ), setdata( ), etc..// update function, called for all TTexture instances.   virtual void    Update( ) { m_nFrame = (m_nFrame+1) % m_nTotalFrames; m_pData = m_pAnim[m_nFrame]; }protected:   SColor3         **m_pAnim;   int             m_nFrame, m_nTotalFrames;}; 


i guess this would only work if you want the animating textures to be on the same frame for every object that references this texture. if not, set a random offset for each object and tweak TTexture::Update( ) to actually return the texture data instead of setting it globally, and add the offset to the frame number.

hope this helps.

-goltrpoat


--
Float like a butterfly, bite like a crocodile.



Edited by - goltrpoat on June 10, 2000 5:05:16 AM
--Float like a butterfly, bite like a crocodile.
Wow, I'm having a little trouble comprehending the question Anyway, I would just manipulate the texture vertices of the texture to animate it, unless you're talking in terms of keyframe animation with the textures (animating the actual texture, not just moving it). In that case I think that you're going to have to build a texture object that all of the textured objects share. Have all of the textures loaded in memory and indexed in that object, and whatever is textured with that object can just pull them from the relative place(index). Wow, I think my response is about as clear as dirt. Let me know if you need (or want, hehe) clarification.

-BacksideSnap-

Edited by - -BacksideSnap- on June 12, 2000 8:30:16 PM
to goltrpoat: Yes, I like the virtual functions also! Probably the best thing of OO!

I have a small question regarding this virtual declaration:
- If making a derived class, do you need to use the virtual again, or does the compiler already know there''s only one function?

yes, you have to declare it virtual throughout.

--
Float like a butterfly, bite like a crocodile.

--Float like a butterfly, bite like a crocodile.

This topic is closed to new replies.

Advertisement