• Advertisement
Sign in to follow this  

Map not updating correctly with camera

This topic is 1663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement