# Problem with axial billboards

This topic is 3001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to implment arbitrary axial billboards. I am doing the implementation in DirectX 9.0 using SlimDX C#.

First I tried to get (0, 0, 1) to work as an arbitrary axis. To get that to work I had to switch the up and forward vectors in the billboard matrix. That felt weird. I tried to see if (0, 1, 0) was working with that configuration as well, of course it didn't, then I had to change around the vectors in some other order, and to get it working with arbitrary axes I realized something else must be wrong than the order of the vectors in the rotationmatrix.

Here is the sourcecode that I am trying to get to work correctly:

private Matrix TurnToCameraAroundAxis(Vector3 axis, Vector3 worldPosBillboard){    // Scene is a global variable containing the camera position.    Vector3 look = Scene.Camera.Position - worldPosBillboard;    look = Vector3.Normalize(look);    Vector3 up = axis;    up = Vector3.Normalize(up);    Vector3 right = Vector3.Cross(look, up);    right = Vector3.Normalize(right);    look = Vector3.Cross(up, right);    look = Vector3.Normalize(look);    // One line of pseudocode    Matrix billboardRotationMatrix = (right, up, forward, worldPosBillboard);    ...    ...}

Any help or advice on this issue would be much appreciated.

Thanks, Patrik

[Edited by - Sealion on September 2, 2010 2:55:32 AM]

##### Share on other sites
What are entity.Translation and positionOfBillboard? If positionOfBillboard is the world position of the billboard, you should use that in your first "look" calc.

Can you explain a little more why you add "pos" to entity.Translation?

##### Share on other sites
I edited the first post to make it more clear. The matter is not solved yet and remains in the same state as described in the first post of this thread.

##### Share on other sites
Ok, problem is now solved.

The correct version of the code looks as follows:

private Matrix TurnToCameraAroundAxis(Vector3 axis, Vector3 worldPosBillboard){    // Scene is a global variable containing the camera position.    Vector3 look = Scene.Camera.Position - worldPosBillboard;    look = Vector3.Normalize(look);    Vector3 forward = axis;    forward = Vector3.Normalize(forward);    Vector3 right = Vector3.Cross(look, forward);    right = Vector3.Normalize(right);    look = Vector3.Cross(forward, right);    look = Vector3.Normalize(look);    Matrix billboardRotationMatrix = Common.Math.MatrixFromVectors(right, look, forward, worldPosBillboard);    return billboardRotationMatrix;}

The guide I originally followed was following OpenGL's coordinate system which is right-handed. I knew that so I changed the order of the parameters given to the cross products. That was not enough. When I was going through the operations I realized a few inconsistencies which are corrected in the code above.

The Common.Math.MatrixFromVectors makes rows out of the parameter vectors. In my previous post I had the function to create columns according to the OpenGL tutorial which also caused troubles.

Regards, Patrik

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011702
• ### Who's Online (See full list)

There are no registered users currently online

×