animation and collisions

Arcanor

10-04-2007 17:44:39

How can I have a collision hull be updated efficiently to transform shape/position as its corresponding entity changes animation state?

Obviously, deleting and re-creating the collision hull each frame will be prohibitively bad for performance in a game app with possibly dozens of animations running on-screen simultaneously.

I guess I could theoretically delete and re-create the collision hull less frequently (i.e. once every second) in an animated entity, but this will not really give the effect I'm hoping for.

How have other people handled this issue?

I've searched the forum and not found a lot of conclusions on this topic, so I'm wondering what the current thinking is.

walaber

10-04-2007 21:27:57

can you explain what you are trying to accomplish?

why do you need the hull to match perfectly? what is animating?

Arcanor

10-04-2007 21:37:46

For example, a monster has an animation to die (an Ogre::AnimationState), which finishes with the monster lying on the floor. When the animation finishes, my collision box is still the same as before (when the monster was standing up). I don't want to collide with the standing monster, I want the collision box to move with the animation (and be lying on the floor). The problem is that I don't know how to make the collision box move/transform when the animation moves.

Arcanor

13-04-2007 03:18:41

I guess the answer is that it's not possible with newton, since animations are not based in physics; they only affect the ogre entity.

After thinking about my game's design some more, I've decided that (for several reasons) animated characters will never be allowed to collide, so this won't be a problem for my current project. Collision boxes will only be needed to determine if an animated character is bumping into a landscape or other static item (which won't budge). I want it to be impossible for any object to ever move another object with physics.

Tubez

13-04-2007 10:01:00

I want it to be impossible for any object to ever move another object with physics.

Why bother with physics then?

Arcanor

13-04-2007 10:36:31

This, of course, is a valid question!

I do need the ability to do the following things:

1. fall naturally, in the case of a player jumping in the air, or walking off a cliff

2. define classes of objects which will either collide or ignore each other physically. i.e. players should be limited by static landscape objects like the ground/walls/etc., but ignore each other and walk through other players and monsters like they weren't there at all, even though those other objects still need to be visible.

3. fire arrows/bullets and have them fly naturally through the air (including an appropriate arc due to gravity), then test for collisions with the intended target, although no apparent impact should occur, all results would be in game statistics.

I know I will only need a small fraction of what Newton can do, but I'm not trying to make a 100% realistic physical simulation. I'm trying to make a believable RPG-style world, similar to something like World of Warcraft, which I believe does things in the way I've described above.

Is it easier to do these things without the use of OgreNewt? Is it even possible? I had assumed I needed physics, but maybe I was wrong.

Tubez

13-04-2007 11:22:37

Let's see :P

1) This is a no-brainer to do by had if you are only interested in linear motion. If you wish realistic rotations while falling you need to use an inertia tensor and you are better off using newt.

2) Defining the classes is not the problem, you can do that in your game entity system. Collision detection and response however is. You will need an external library for that of some kind, or an approximation based on the AABB of ogre. Newton is as good as any if you want accurate collision detection.

3) Same as above. Keep in mind that you might need "sweeping" to get fast moving objects to collide properly.

Arcanor

13-04-2007 11:30:47

Thanks again Tubez.

So it seems that I should stick with Newton, since it will do my gravity calculations for me, and it handles my collision detection neatly.

RichTufty

30-10-2007 12:51:21

I want to do exactly what you said in your original message! I'm struggling to find any information about animations and physics!

My requirement is:

- Add an entity to physics = done
- Activate animation by clicking on entity = done
- remove from physics = done
- Animate entity = done
- When animation complete add to physics again with entity in new animated position = Struggling to achieve!!

I am using the Ogre Robot Mesh as a test object, so for example the Robot is Idle, then I animate Die, the Robot is on the floor, i want to be able to click on the robot while it is on the floor, but the physics still has the 'original' position, even though i remove and add it when it's in it's new position.

I'm not worried about real time animated physics, just the last frame position, this must be able to be done? Any ideas or help much appreciated!!

I'm using Mogre and MogreNewt if this makes a difference?

RichTufty

31-10-2007 17:03:52

I eventually worked out how to get the vertices from the animated model by converting this thread in to Mogre/C#:

http://www.ogre3d.org/phpBB2/viewtopic. ... ionrequest