Jump to content

  • Log In with Google      Sign In   
  • Create Account

Map not updating correctly with camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 burnt_casadilla   Members   -  Reputation: 443

Like
0Likes
Like

Posted 04 July 2013 - 12:53 AM

As of yesterday, I've rewritten my whole method of drawing cubes and chunks so I can get some culling to work. Both frustum and occlusion culling work fine, but so much has changed in the code that when I move the player, the camera doesn't look right at all. Before all the changes, my third person camera worked fine. Nothing has changed within my player or camera class. My player model is just a sphere right now, so nothing too confusing.

 

Imagine a first person camera with it's crosshairs. My player model would be the crosshairs of that camera. You can move around the map as if you're using a first person camera, but the sphere is always drawn behind the map so you can rarely see it. I don't know why this is happening, but I'm pretty sure it's because of some of the matrices used in the new class. Normally with a third person camera, you'd press left or right and the camera would rotate around the player without actually moving the player. This isn't happening anymore

WorldMatrix = Matrix.CreateWorld(Vector3.Zero, Vector3.Forward, Vector3.Up);    //Quad's created position and scale.
            WorldMatrix *= Matrix.CreateScale(VoxelScale);                                  //Resize the quad to match defined scale.

            TopQuadWorldMatrix = WorldMatrix * Matrix.CreateTranslation(new Vector3(0f, VoxelScale / 2, 0f));
            BottomQuadWorldMatrix = WorldMatrix * Matrix.CreateRotationX(MathHelper.Pi) * Matrix.CreateTranslation(new Vector3(0f, -VoxelScale / 2, 0f));
            FarQuadWorldMatrix = WorldMatrix * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateTranslation(new Vector3(0f, 0f, -VoxelScale / 2));
            NearQuadWorldMatrix = WorldMatrix * Matrix.CreateRotationX(MathHelper.PiOver2) * Matrix.CreateTranslation(new Vector3(0f, 0f, VoxelScale / 2));
            LeftQuadWorldMatrix = WorldMatrix * Matrix.CreateRotationZ(MathHelper.PiOver2) * Matrix.CreateTranslation(new Vector3(-VoxelScale / 2, 0f, 0f));
            RightQuadWorldMatrix = WorldMatrix * Matrix.CreateRotationZ(-MathHelper.PiOver2) * Matrix.CreateTranslation(new Vector3(VoxelScale / 2, 0f, 0f));

Matrices used to draw the cubes.

 Effect.Projection = CamerasProjectionMatrix;
            Effect.View = CamerasViewMatrix;

These two lines are in my draw method of the cubes class. Both the variables are set in the update method of my main game class:

CubeGrid.ProjectionMatrix = Camera.proj;
            CubeGrid.ViewMatrix = Camera.view;
            CubeGrid.CamerasViewFrustrum = Camera.frustum;

As you can see, there's a lot going on in this new class and there may be more than one error that I can't find. 


Edited by burnt_casadilla, 04 July 2013 - 01:00 AM.

If you see a post from me, you can safely assume its C# and XNA :)


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS