Matrix.CreateBillboard centre rotation problem
Posted
by
Chris88
on Game Development
See other posts from Game Development
or by Chris88
Published on 2012-11-19T11:05:58Z
Indexed on
2012/11/19
11:34 UTC
Read the original article
Hit count: 283
I'm having an issue with Matrix.CreateBillboard and a textured Quad where the center axis seems to be positioned incorrectly to the quad object which is rotating around a center point:
Using:
BasicEffect quadEffect;
Drawing the quad shape:
Left = Vector3.Cross(Normal, Up);
Vector3 uppercenter = (Up * height / 2) + origin;
LowerLeft = uppercenter + (Left * width / 2);
LowerRight = uppercenter - (Left * width / 2);
UpperLeft = LowerLeft - (Up * height);
UpperRight = LowerRight - (Up * height);
Where height and width are float values passed in (it draws a square)
Draw method:
quadEffect.View = camera.view;
quadEffect.Projection = camera.projection;
quadEffect.World = Matrix.CreateBillboard(Origin, camera.cameraPosition, Vector3.Up, camera.cameraDirection);
GraphicsDevice.BlendState = BlendState.Additive;
foreach (EffectPass pass in quadEffect.CurrentTechnique.Passes)
{
pass.Apply();
GraphicsDevice.DrawUserIndexedPrimitives
<VertexPositionNormalTexture>(
PrimitiveType.TriangleList,
Vertices, 0, 4,
Indexes, 0, 2);
}
GraphicsDevice.BlendState = BlendState.Opaque;
In the screenshots below i draw the image at Vector3(32f, 0f, 32f)
The screenshots below show you the position of the quad in relation to the red cross. The red cross shows where it should be drawn http://i.imgur.com/YwRYj.jpg http://i.imgur.com/ZtoHL.jpg It rotates around the red cross position
© Game Development or respective owner