Per-bone Collision Detection

Topics: Developer Forum, Project Management Forum, User Forum
Apr 3, 2008 at 10:39 PM
Edited Apr 4, 2008 at 3:12 PM
I'm trying to use the per-Bone collision detection tutorial, and I would really like to be able to see my Collision Cubes, but for some reason they are not drawing. I'm wondering if anybody else has tried this exmaple and was able to get it to work with XNA 2.0. Do I need to change the Collision Cube code's Draw() method in order to get it to work?

thanks.
Apr 4, 2008 at 7:41 PM
I haven't tried the per-Bone collision tutorial... but have done similar things... other than making sure each drawable collision cube has your camera's veiw and projection settings applied... the only other thing you need to do is make sure you transform the collision cube based on the applicable bone's position within your world.

Apr 4, 2008 at 10:24 PM
Thanks for the reply. I double and triple checked those, so it should be working. Right now I'm trying to at least see if they're colliding, even if I can't see them, that would be a good start.
Apr 6, 2008 at 4:07 AM
So I just realized that I'm much more likely to get a reply and people would be much more willing to look at my problem if I actually posted some code.

in the loadContent() method for my main character I have:

public void LoadContent(Game1 game)
{
model = ContentLoader.getInstance().loadModel(modelName);

...

body = new CollisionCube(game.getGraphicsDeviceManager().GraphicsDevice,
Color.HotPink, 5f);
LArm = new CollisionCube(game.getGraphicsDeviceManager().GraphicsDevice,
Color.HotPink, 5f);
RArm = new CollisionCube(game.getGraphicsDeviceManager().GraphicsDevice,
Color.HotPink, 5f);
LLeg = new CollisionCube(game.getGraphicsDeviceManager().GraphicsDevice,
Color.HotPink, 5f);
RLeg = new CollisionCube(game.getGraphicsDeviceManager().GraphicsDevice,
Color.HotPink, 5f);

//Camera camera = Camera.getInstance();
collisions = new List<CollisionCube>();
collisions.Add(body);
collisions.Add(LArm);
collisions.Add(RArm);
collisions.Add(LLeg);
collisions.Add(RLeg);

foreach (CollisionCube cube in collisions)
{
cube.Projection = Camera.getInstance().getProjection();
}

}

then in my draw method I have:

public void Draw(GameTime gameTime)
{

...

body.World =
ashelyAnimator.GetAbsoluteTransform(ashelyAnimator.BonePoses"Main".Index) *
ashelyAnimator.World;

LArm.World =
ashelyAnimator.GetAbsoluteTransform(ashelyAnimator.BonePoses"LowerArm.L".Index) *
ashelyAnimator.World;

RArm.World =
ashelyAnimator.GetAbsoluteTransform(ashelyAnimator.BonePoses"LowerArm.R".Index) *
ashelyAnimator.World;

LLeg.World =
ashelyAnimator.GetAbsoluteTransform(ashelyAnimator.BonePoses"LowerLeg.L".Index) *
ashelyAnimator.World;

RLeg.World =
ashelyAnimator.GetAbsoluteTransform(ashelyAnimator.BonePoses"LowerLeg.R".Index) *
ashelyAnimator.World;

foreach (CollisionCube cube in collisions)
{
cube.View = Camera.getInstance().getView();
cube.Draw();
}
}

where ashelyAnimator is the animator for my main character. I know that the view and projection Matricies work from the camera object because they work for my main character. So if anybody can see something that I don't I would appreciate the help. I just want to be able to see them. Collision Cube is the name of the class, and I know that in dastle's class the constructor was Cube, but I changed it to CollisionCube so it would match.
Apr 8, 2008 at 12:53 AM
well, I partially solved the problem on my own, and if somebody else has the same problem (I know, it was a small one >_<) I hope that this might help.

I don't really know why, but when I went home (instead of programming at the school) it worked fine. I downloaded XNA 2.0 over Visual Studio 2005 at the school, and at home I only have C# Express Edition 2005. So most people probably won't have or can get around that problem since I imagine they use the Express Edition. However after programming my collisions once I could see my box size and position, I was able to get the collisions to work at school on Visual Studio.