I’m trying to draw graphs onto some sprites.
So i want to align the 3D Camera of SpriteBatch and the 3D Camera of my Graphs to be the same but i dont get it to work i tried it another time before and searched the web and some threads on this forum for information but something was always missing and i dont understand till this day how to do this.
So what i want is that Vector3(x,y,0)==Vector2(x,y) on screen.
I tried these methods:
…[List goes on with stuff that didnt work out]
Maybe any other solutions?
My current Code:
The important part:
var cameraPosition = new Vector3(350, 350, 350);
var cameraLookAtVector = new Vector3(350, 350, 0);
var cameraUpVector = Vector3.UnitZ;
basicEffect.View = Matrix.CreateLookAt(
cameraPosition, cameraLookAtVector, cameraUpVector);
basicEffect.Projection = Matrix.CreateOrthographicOffCenter(new Rectangle(0, 0, 700, 700), 0.1f, 1000);
My screen size in the project is currently 700x700
Matrix.CreateOrthographicOffCenter(0f, 700f, 700f, 0f, 0f, -1000f);
View (for the Camera):
Matrix.CreateTranslation(-position) * Matrix.CreateTranslation(-origin) * Matrix.CreateRotationZ(-rotation) * Matrix.CreateScale(zoom) * Matrix.CreateTranslation(origin);
World (for an Entity):
Matrix.CreateTranslation(-origin) * Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(origin) * Matrix.CreateTranslation(position);
this works greatly thanks
My resolved code looks like this:
basicEffect.View = Matrix.CreateTranslation(-Vector3.Zero) *
basicEffect.World= Matrix.CreateTranslation(-Vector3.Zero) *
Matrix.CreateFromQuaternion(new Quaternion(Vector4.Zero)) *
basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0f, 700f, 700f, 0f, 0f, -1000f);
giving me this output on my testvertices:
These all create an identity matrix, so the whole thing is equal to Matrix.Identity. Saves you a few lines
Whaat so i finally know the secrets of the identity of the matrix. Nice. Didn’t knew that before xD
This is so nice to know, this explains really a lot why everything didn’t work out before when i always tried to use some function for World and View.