Jump to content
  • Advertisement
Sign in to follow this  

Relative to the Camera

This topic is 2035 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



Im working on a Procedural Planet, but i have (like all the others) floating precision problems.



So i read this great Article (http://britonia.wordpress.com/2009/05/23/scale-and-32-bit-imprecision/).


This guy told me i render everything relative to the Camera (That means, the Camera Position is always at Vector3.Zero)


The first deviation is, i generate the Sphere with the Mathlab funktion (http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html), so the sphere-center must always stay at the World Origin (0,0,0).


Britonia say i should create a new Worldmatrix with  position - cameraPosition, but here this function from Mathproofs doesen't match not longer..


So i build a second "WorldMatrix" 

worldNew = Matrix.CreateTranslation(position - cam.Position) * Matrix.CreateFromYawPitchRoll(cam.deltaX * 0.0005f, cam.deltaY * 0.0005f, 0);

So i multiply this new Matrix in the Shader with the View matrix like:

float4x4 xx = mul(View, worldNew);

and now the output.Position is:

output.Position = mul(mul(scaled, xx), Projection);




So it works, the Camera is at 0,0,0 and my Planet are in front of me.


Now the problem join in:



Before i move the Camera to look/move around.


Now instead to move the Camera i must move the Object in the Scene (in my case the Planet)

  private void MoveForwBackw(float amount)
            Position += Forward * amount;

        private void MoveLeftRight(float amount)
            Right = Vector3.Cross(Up, Forward);
            Position += Right * amount;

Forward, Backward, Left, Right work fine, but when the Mouse come in, the Y Axis on my Camera is always Zero  (i mean the Camera don't follow the perspective of my mouse.



here at 0:10sec:



The View Matrix is:

View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward, Vector3.Up);

So whats my line, somebody have an idea how to fix this Problem, maybe i need a Forward and Upvector for my ViewMatrix? sad.png


Or anybody has another option to solve the floating imprecision?



best regards

Edited by montify

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!