Game Development Community

Adding Mounted Shapes to Vehicle Collision List

by Demolishun · in Torque Game Engine · 05/21/2006 (1:56 pm) · 6 replies

Has anyone added mounted shapes to the vehicle collision list?

I am working on a mecha style walker and I want to be able to walk under the vehicle between its legs. I have been able to add the legs by mounting static shapes to mount points that act as leg bones. The code base is a modified wheeled vehicle. The physics for walking are not quite figured out yet. I can shoot the legs, but when I walk into something or fall down the legs act as though they are not colliding. It makes sense because they are mounted to the vehicle and because they are static shapes, are not adding to the collision list of the vehicle.

Has someone tackled anything similar to this? I really like the idea of shooting the legs. I was thinking if I could add an object similar to staticshape that I could add collision checking to and report that collision to the parent object that might work.

Thanks,
Frank Carney

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
05/21/2006 (3:22 pm)
Is this something I would do inside of the buildPolyList function? It seems to me I could add sphere collisions to for each bone that defines a part that is attached that I want to collide with. I could use the bone length/2 to determine the radius of the sphere and place it midway on the bone. I could determine where the bone is in 3d space and have the collision sphere always match the bone position.

Is this a reasonable approach?
#2
05/21/2006 (3:45 pm)
What about grabbing the bounding geometry from the attached shapes? That would allow me to add the collision based on the geometry of the attached object.
#3
05/21/2006 (5:11 pm)
// Add leg info here
   // work through the list of all attached objects 
   for(int cnt = 0; cnt < getMountedObjectCount(); cnt++) 
   {
      //Convex * tempConvex = getMountedObject(cnt)->mConvexList;
      //AbstractPolyList * tempList = 
      //->mConvexList->getPolyList();
      ShapeBase * tempBase = getMountedObject(cnt);
      Box3F x;
      SphereF y;
      tempBase->buildPolyList(polyList, x, y);
      // only process if of type staticshape
      if (tempBase->getType() && StaticShapeObjectType) 
      {
         // get polylist
         //AbstractPolyList * tempList;
         //Box3F x;
         //SphereF y;
         //tempBase->buildPolyList(tempList, x, y);
         //tempBase->buildPolyList(polyList, x, y);
         
         // add to the vehicle polylist
         
      }
   }

is this on the right track?
#4
05/24/2006 (1:58 am)
I haven't begun digging in the vehicular part of torque yet (but I will implement walkers aswell). What I have done though, is scratching my beard and having headaches.

To be able to create a good simulation of a walker you'd need to implement Inverse Kinematics and a bit of physics. Weight for parts of your models, friction, resting objects.. and well.. a bit more. If you want to be completely uber, you could make an AI-controlled animation like these guys:

http://www.naturalmotion.com/pages/technology.htm

For an introduction to Inverse Kinematics, look here:

http://www.gotoandplay.it/_articles/2004/12/inverseKinematics.php

It only shows examples in 2D though, but it's still usable.

I read an article written by a FASA developer about Mechwarrior 4 somewhere. They had used blending of different animations to create a natural motion. I don't believe in their technique though. I believe that it is viable to have the animations be created on the fly.

IK + The foot following a generated bezier path = Sex
#5
05/24/2006 (8:34 pm)
I will eventually want to do that. For now, all I want is to have my attached static shapes work with the collision on the vehicle so when it falls down it actually hits the ground.

Right now I have a mecha structure that has two wheels as legs and will stand until something collides with the main vehicle mesh. Another thing is as it leans forward or backward it will move in that direction because of the force being applied by the wheels. This may help in doing my walking as I can just lean forward to move. I will have to time the animation of the legs to keep up with the movement and apply speed limits of course. I will also have to add forces to make it stable at rest.

Yes, I do think inverse kinematics is the way to go and thank you for the links. I had started working through the leg system and came up with 5 or 6 degrees of freedom for the foot, lower leg, and upper leg together. I also started thinking about how to use a fuzzy system to perform the leg placement. The nice part of a video game is the solution does not have to be optimal so the tuning of the inputs and outputs does not have to be very fine. I think this would be a good enough scenario. However, for the physics, I think faking it will be the best way to get this working. Like I said I am treating the legs like wheels. For instance the blend animation applied to the legs for spring deflection of the wheel hubs. So the legs look like they bounce a bit under the load of the vehicle and can deform over uneven terrain.

I think I will work on the physics until I get a better idea of how the collision works. My above attempt does not help at all. I have another approach for the legs that would involve tighly sprung spings in the direction of the bones. If they ray casts make contact with the ground the vehicle will apply force until it is not touching. Have to be careful it does not bounce, hence tight springs. It is a hack, but it would take advantage fo the shape of the geometry of the vehicle to the semi-collision physics. At least it will let me mock some stuff up.

Let me know if you want to mock up some IK code. I really think for that is version 2 type stuff for now, but I would be willing to try some things out.
#6
05/28/2006 (11:11 pm)
I'll surely mock something up, but not in a while. I'm working on terrain generation atm *one-man gamehouse*