Game Development Community

Animated Collision Mesh

by Ian Dale · in Torque Game Engine · 02/01/2005 (9:09 pm) · 3 replies

I'm beginning to feel like Homer Simpson. My brain is registering something but I can't quite make out what.

What I'm trying to do is modify the engine so that a dts collision mesh can be attached to a joint (within the 3d prog i.e. 3ds max) and consequently moved with that joint when it is animated.

I've been looking at shapebase.cc, tsshape & tsshapeinstance.cc, tscollision.cc and tsanimate.cc. From what I can see the following functions have something to do with the collision mesh but I'm not sure what:

tscollision:buildpolylist & computebounds
shapebase::buildpolylist & buildconvex
tsshape::buildconvexhull & computebounds

Is there some guru out there who can enlighten me about DTS collisions and help me on my journey? Any help will be appreciated.

Regards,

#1
02/02/2005 (9:24 am)
I am that guru

you can have animated collision meshes in your model, and attach them to bones/bipeds

theres really not a whole lot to it
here are a few minor changes to the engine to allow you to do collision against animating collision boxes rather than your bounds box

edit player.cc
in Player::castRay
change return true to
return Parent::castRay(start, end, info);
this makes the player class check for collision against collision boxes, like any other shapebase object

in tsCollision.cc
in TSShapeInstance::castRay
around line 160

you can see
MatrixF mat;
MatrixF * previousMat = mMeshObjects[start].getTransform();
mat = *previousMat;
mat.inverse();
mat.mulP(a,&ta);
mat.mulP(b,&tb);

change it to
MatrixF mat;
MatrixF * previousMat = NULL; //mMeshObjects[start].getTransform();
// mat = *previousMat;
// mat.inverse();
// mat.mulP(a,&ta);
// mat.mulP(b,&tb);

(this fixes a crash that can happen sometimes depending on what exporter your using)

just parent your collision meshes (col-1 col-2 .. etc) to the bone you want it to animate with
and have dummy nodes (collision-1 collision-2 etc) under the same parent as your detail nodes

also you dont HAVE to name the collision meshes 'col' i named mine headcol-1 bodycol-2 and stuf like that. also you can have more than one with the same # like i have headcol-1 and heartcol-1

it will thru an error somewhere when its loading, but it doesnt actually effect anything else~!! its like it checks its naming even though the naming is completely irrelivant
#2
02/04/2005 (5:10 pm)
Intangir,

Thanks for the great help. I haven't tried it yet as I'm doing other things. Out of interest though, what do the old lines:

MatrixF * previousMat = mMeshObjects[start].getTransform();
mat = *previousMat;
mat.inverse();
mat.mulP(a,&ta);
mat.mulP(b,&tb);

Actually do?

Regards,
#3
03/19/2005 (9:20 am)
@Charles, I made these changes and now my bots dont see me when I do a containerRayCast