# rotating a billboard?

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

## Recommended Posts

what i mean is that i got the codee to rotate the billboard toward the camera , but the billboard is allways in an upright direction , i want to be able to rotate it around the axis , to spin it but still face the camera

 float3 up = float3(0.0f, 1.0f, 0.0f); float3 look = CameraPos - gIn[0].center; look.y = 0.0f; // y-axis aligned, so project to xz-plane look = normalize(look); float3 right = cross(up, look); float4x4 W; W[0] = float4(right, 0.0f); W[1] = float4(up, 0.0f); W[2] = float4(look, 0.0f); W[3] = float4(gIn[0].center , 1.0f); float4x4 WVP = mul(W,ViewProjMatrix); 

is it a simple case of doing W[0] = float4( cos(right.x * rotate amount )), sin (right.y * rotate amount ) , right.y, 0.0f);

do i cos(rotation amount * matrix position) or cos(rotation amount + matrix position)

cant figure it out , for each of the sin - sin and cos for the rotations

##### Share on other sites
Don't do it by trying to do it with rotations -- that ends in tears. Do it by passing in your modelview matrix as well as the MVP and extracting the basis vectors from that to construct your screenspace X and Y axes to make the billboard corners. Or you could just pass in those two vectors after computing them on the host processor.

That way it all "just works" and you don't faff around with angles at all.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013550
×