Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


HLSL Camera view angle to object with object rotation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 danromeo   Members   -  Reputation: 238

Like
0Likes
Like

Posted 07 June 2014 - 06:06 PM

How do I determine camera view angle to an object with the object's rotation factored in, to display a 2d "imposter" based on the actual view angle of the object?

 

I can get the camera angle to the object with:



half3 center = mul(input.inPos, xWorld);
half3 EyeVector = normalize(center-CameraPosition); 
float lookYaw = atan2(EyeVector.x, EyeVector.z);



But I'm not having any luck determining the view angle with object rotation factored in either by adding or subtracting the EyeVector with the ObjectRotation vector or by atan2'ing the ObjectRotation vector and adding or subtracting the result with lookYaw.  All vectors in question are normalized.  

 

Hope this makes sense.  Thanks!

 

 



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 6125

Like
0Likes
Like

Posted 07 June 2014 - 08:39 PM

Can you describe what you are trying to accomplish in a little more detail?  Are you trying to make a billboard face toward the camera?  Perhaps there is a simpler way to do what you need, as calculating the arctan in a shader seems a bit more than necessary for aligning a 2D object the right way...



#3 imoogiBG   Members   -  Reputation: 1679

Like
0Likes
Like

Posted 09 June 2014 - 04:27 AM

float lookYaw = atan2(EyeVector.x, EyeVector.z);

atan2 Args are usually in reversed order

float lookYaw = atan2(EyeVector.z, EyeVector.x);

 

However we need more information about the coordinate systems that you're using. If we are talking about the planar case atan2 should do the trick.

 

If you want a billbord effect in 3D space use the lookAt matrix basis to create the billboard orientation.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS