Click here to Skip to main content
15,891,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Codeproject,

I'm using the following code to draw a 2D sprite on the screen. However, my game uses Vector3(Allowing 3D if I adjusted the Z.)

This code is the matrix I use for my camera:
C#
SpriteBatchMatrix = Matrix.CreateTranslation(-CameraPosition) *

            Matrix.CreateRotationZ(CameraRotation) *

            Matrix.CreateScale(new Vector3(CameraZoom, CameraZoom, 1)) *

            Matrix.CreateTranslation(new Vector3(Viewport.Width * 0.5f, Viewport.Height * 0.5f,0));


This is the code I use to draw my sprites:
C#
SpriteBatch.Begin(SpriteSortMode.Immediate,


BlendState.AlphaBlend,

null,

null,

null,

null,

Universe.Camera.SpriteBatchMatrix);


 foreach (Particle Particle in Universe.Bodies)
 {
     SpriteBatch.Draw(TexturePlanet, new Rectangle((int)Particle.Position.X, (int)Particle.Position.Y, (int)(Particle.Mass), (int)(Particle.Mass)), new Rectangle(0, 0, TexturePlanet.Width, TexturePlanet.Height), Color.Lerp(Color.Black, Color.White, (Particle.Lighting + Particle.AdjacentLighting) / 100f), Particle.Rotation, new Vector2(TexturePlanet.Width / 2, TexturePlanet.Height / 2), SpriteEffects.None, 0f);
 }


 SpriteBatch.End();


How would I use this camera matrix to draw a 3D Triangle Strip(or model)?

Much Regards!
Posted
Comments
[no name] 26-Oct-14 13:18pm    
Vector3 adds an additional z member. I don't see how it would be declared any differently for you to struggle if you can draw in 2D already.

What have you tried for 3D drawing?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900