Avatar World and Camera2D

Topics: User Forum
Nov 3, 2011 at 2:11 AM

Hello all,

I've had some great success manipulating the Avatar bones with my own ragdoll.
Embarassingly the only thing I'm struggling with is getting my Avatar's world to align with Farseer's world and Camera2D class.

Here's what I'm using to see that my bone transformations are correct, I get the avatar drawing in the center of the screen:

     Matrix view = Matrix.CreateRotationY(MathHelper.ToRadians(0)) * Matrix.CreateRotationX(MathHelper.ToRadians(0)) * Matrix.CreateLookAt(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.Up);

        float aspectRatio = 1.77777779f;
        Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), aspectRatio, 1, 1000);

        avatarRenderer.World = Matrix.Identity * Matrix.CreateRotationY(MathHelper.ToRadians(90));
        avatarRenderer.View = view;
        avatarRenderer.Projection = projection;

Now that my ragdoll is functioning great I want to use the Camera2D to handle the view and projection and translate to my Body's position. 
When I do the following, my character's movement doesn't seem to correlate with the physic's body. 

        avatarRenderer.World = Matrix.CreateScale(2f) * Matrix.CreateTranslation(new Vector3(pos.X, pos.Y, 1)) 
        avatarRenderer.View = Camera.SimView;
        avatarRenderer.Projection = Camera.SimProjection;

When it comes to making 3d and 2d play together nicely on one screen my brain just spits and stutters.

Please help :)

Thank you,


Nov 6, 2011 at 9:00 PM

Since this is the only thing 3D in the game I decided to take a different approach:

I first draw the avatar to a rendertarget2d, then I match the texture up with the body.  It works great, I'd still like to know more on using camera2d with 3d objects for 2.5D gaming in the future though if anyone has any examples are pointers.