Almost! But cannot use the billboard…
I managed to create the quad, to understand TriangleList and TriangleStrip, to display it, to texture it, to make it deal with alpha!
I see the sprite, I can move the camera, rotate the camera…
But if I apply a billboard, it disappears.
My quad :
`
quadVertices = new VertexPositionTexture[4];
quadVertices[0].Position = new Vector3(-1, -1, 0); // Lower left
quadVertices[1].Position = new Vector3(-1, 1, 0); // Upper left
quadVertices[2].Position = new Vector3(1, -1, 0); // Lower right
quadVertices[3].Position = new Vector3(1, 1, 0); // Upper right
quadVertices[0].TextureCoordinate = new Vector2(0, 1);
quadVertices[1].TextureCoordinate = new Vector2(0, 0);
quadVertices[2].TextureCoordinate = new Vector2(1, 1);
quadVertices[3].TextureCoordinate = new Vector2(1, 0);
`
How I display the quad:
mySpriteEffect.View = pView;
mySpriteEffect.Projection = pProjection;
mySpriteEffect.World = pWorld;
//mySpriteEffect.World = Matrix.CreateBillboard(Vector3.Zero, cameraPosition, pWorld.Up, pWorld.Forward);
mySpriteEffect.Texture = pTexture;
// No need for this, but it will work with advanced effect with multiple passes
foreach (var pass in mySpriteEffect.CurrentTechnique.Passes)
{
pass.Apply();
graphics.GraphicsDevice.DrawUserPrimitives(
PrimitiveType.TriangleStrip,
pQuad,
0,
2);
}
My camera is at 0,0,10.
My world is : Matrix.Identity
My view is:
view = Matrix.CreateLookAt(
cameraPosition,
targetPosition,
Vector3.Up
);
view = view * Matrix.CreateRotationY(camRotation);
Target position is 0,0,0.
My projection is:
projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45f),
16f/9f,
1f,
100f
);
Any idea?
If I compare Matrix.Identity with the result of CreateBillboard, all seems inverted…