Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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

in the geometry shader

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 this post

Link to post
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!