bone attachments and issues between update & render

Started by
3 comments, last by GalaxyQuest 20 years ago
Im using DirectX .x skin & bone meshes for my animated characters. I dont know if those of you who implemented your own system exporting from 3Dmax or something have the same problem. Because my code is a cleaned up/class based version of the SDK skinmesh demos I have the situation of updating skeleton animations right before I have to render an instance of a mesh. This is bad for a couple of reasons. Namely, when meshes are not in view, the animation is not updating which also means that any attached weapons will not be in ''AIM'' positions when required. But now, I cannot share meshes between game objects because I the bones would be applied from a different animation. Let me clarify some of my implementations so far... GO(Game Objects): ------------------ GOs share meshes, but each has its own animation class. My game objects have an Update(float dt) method. All GOs that implement Update(dt) will do whatever is necessary. However, I dont update mesh animation here. If a GO is in frustum, its mesh is sent to a render queue, where they are sorted. Once a mesh is called for rendering, the animation (controller) is updated to the correct frame, then rendered. This happens for each mesh in the queue. Meshes: -------- A single mesh can be shared by many GOs. But each GO will have its own instance of a mesh animation class(which has a LPD3DXANIMATIONCONTROLLER instance). As examples from the SDK and other sources, the animation controller is usually updated right when your going to render. SO, in order for each GO to correctly render to the correct animation, the animation controller must update right before it is rendered. Because each GO has an instance of LPD3DXANIMATIONCONTROLLER, and this is linked to the bones of a SHARED mesh, I cannot just update bones in the GO->Update(dt) method, because the next GO might also call update() and the bones will be moved again! What can I do to decouple this so I dont have to update my skeleton just so weapons are in correct positions for shooting off-screen, and then update skeleton again if it needs to render? Need h..e..l..p! - John
Advertisement
So if I understand correctly, you''re relying on the weapons'' aim positions to determine where they actually fire? I think this is where it should be decoupled. You should know what direction a character is facing regardless of their animation--unless you''re talking about weapons fire while they''re ragdolling. Hmm.

One solution is to clone the frame hierarchy and associate the clone with the cloned AC. That''s more memory per instance, but they wouldn''t collide. Then you could do things in any order you want.

If you can avoid using the animation to dictate where the weapons fire, that''s my first suggestion.

I like pie.
[sub]My spoon is too big.[/sub]
My post has 2 issues going on: what to do about animated objects when they are not on screen (for things like characters holding weapons), and the fact that I have to update the skeleton right before rendering the mesh.

Am I correct in assuming that updating a skeleton right before rendering it is the WAY to do it, if im going to share meshes??

RenderTarget -
I get your idea. It should work. The problem would be when a bone attached object, such as a gun, releases some smoke for example. If the next frame the character is in view, the smoke would have started in an awkward position.

Here's an idea...
I dont want to be updating the skeleton bones even when its off screen each game tick, because this POTENTIALLY means I have to update the bone matrices twice (in the GO->update(), and GO->Render() calls).

I instead keep track of the animation time along with current animation. If the character needs to fire its weapon, I only update the skeleton, setting the animation to the accumulated time I have been keeping track of. So, I guess if I need to perform an 'event', say once the animation for 'STAND_N_FIRE' is finished or something. This way, if I need the muzzle bone of the weapon to get the correct position (and possibly direction if desired), it would solve the smoke rendering problem above.

(Note: because I want as many units in the world as possible, its not so simple to just say, 'just do the update twice', because i will need that cpu time for other stuff too.)

- john

[edited by - GalaxyQuest on March 19, 2004 9:02:53 PM]
It''s not the WAY, if you clone the frame hierarchy for each instance.

Basically, take a scenegraph approach to it: For each instance, record the last animation update time when you update. Then, even if you call update again for rendering, it''ll note that it''s the same time and that it''s been updated this frame already, and exit early. Of course, like you say, only call update when you need to.

If you absolutely must rely on animation for positioning, I think this is the best way to go.

Incidentally, you don''t need to update animation every frame. Every 30th or 60th of a second is sufficient, even for higher framerates. Basically, when you check the last_update time, ensure it''s not within 1.f/30.f seconds before updating. This will help a little bit.

I like pie.
[sub]My spoon is too big.[/sub]
I appreciate your attention, thank you.

Not that it might not be too hard, but cloning the frame heirarchy for each character instance is something i think i will hold off to try at the moment. Unless it really becomes necessary later on.

I will try the simpler method, then maybe assign priorities or something, such that the higher priority object/meshes get updated everyso often when offscreen, like you suggest.

Trial and error I guess.

This topic is closed to new replies.

Advertisement