Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
I have not worked with billboards, but what's origin? is the center of the shape or is the origin of your world, because it makes sense to me that it should be the center of the shape –  Blau Nov 22 '12 at 12:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.