Bug in GetBodyWireframe?

Jan 24, 2009 at 4:40 PM
I'm currently using jiblibx in a game project targeting the XBox360 and i'm impreesed with how easy it is to use.
I have, however, run into problems when trying to draw the wireframes of objects. I have a capsule and a box but they are colliding when the wireframes show that they souldn't. The capsule has a local transform to offset it and it seems this is cousing the problem.
Thanks again for this impressive port.
Jan 24, 2009 at 9:07 PM
Hi Tantor,

Would there be any way you can tell us a little more - maybe a screenshot or the code you are using to draw with?  So far it's worked well for me.

Are you using TransformWireFrame to transform it before you draw?



Alex
Jan 24, 2009 at 11:08 PM
Yes I'm using TransformWireFrame before drawing.
The code to create the box:
mBody = new Body();
mCollision = new CollisionSkin(mBody);
mCollision.AddPrimitive(new Box(new Vector3(0.5f,0.5f,0.5f), Matrix.CreateRotationX(MathHelper.PiOver2), new Vector3(0.2f,0.2f,1.0f)), (int)MaterialTable.MaterialID.UserDefined, new MaterialProperties(0.0f, 1.0f, 1.0f));
mBody.CollisionSkin = this.mCollision;
Vector3 com = SetMass(10f);
mBody.MoveTo(Vector3.Up * 1 + Vector3.Right * 2, Matrix.Identity);
mCollision.ApplyLocalTransform(new Transform(-(com), Matrix.Identity));
mBody.Immovable = false;
mCollision.callbackFn += OnCollision;
mBody.ApplyGravity = false;
mBody.EnableBody();
The code to create the capsule:
mBody = new Body();
mCollision = new CollisionSkin(mBody);
mCollision.AddPrimitive(new Capsule(Vector3.Down, Matrix.CreateRotationX(MathHelper.PiOver2), 0.5f, 1.0f), (int)MaterialTable.MaterialID.UserDefined, new MaterialProperties(0.0f, 1.0f, 1.0f)); mBody.CollisionSkin = this.mCollision;
Vector3 com = SetMass(10f);
mBody.MoveTo(Vector3.Up * 2, Matrix.Identity);
mCollision.ApplyLocalTransform(new Transform(-(com + Vector3.Down), Matrix.Identity));
mBody.Immovable = false;
mController = new EntityController();
mController.Initialise(this);
mController.EnableController();
mBody.EnableBody();
And to draw them using the debug-drawer from the sample:
if (mWireFrame == null)
{
mWireFrame = mBody.GetBodyWireframe();
mWireFrameTransformed = new VertexPositionColor[mWireFrame.Length];
}
mWireFrame.CopyTo(mWireFrameTransformed, 0);
mBody.TransformWireframe(mWireFrameTransformed);
Game.Instance.DebugDrawer.DrawShape(mWireFrameTransformed);

Hope the code is readable.
I have never been known to be good at commenting :P