Archived

This topic is now archived and is closed to further replies.

Geometry problem

This topic is 5130 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

I''d like to draw an object which always face the camera. Because my english is not so good, i attached three shots of what i''d like to achieve. As you can see i''d like to render an object (also a simple quad, represented by the orange box) which has the position and orientation shown in the shots. Billboarding wouldn''t do, because i lose one axis. http://www.web-discovery.net/temp/1.jpg http://www.web-discovery.net/temp/2.jpg http://www.web-discovery.net/temp/3.jpg

Share this post


Link to post
Share on other sites
a slightly longer explanation of this:

obviously one axis is already given be the orientation of the plane. for the quad to face the viewer as much as possible its normal has to intersect your view direction. sounds difficult to achieve but its simple. take the crossproduct between your given vector and the vector from quad to camera. now you have two out of three needed vectors. for the last one, do the crossproduct between those two. pretty much like billboarding.

Share this post


Link to post
Share on other sites
some old dx code flying around:
"forward" is the z axis here, meaning the direction the beam is going. "up" is the y axis, "right" is the x axis and the one supposed to face the camera. but which is which depends on how your quad is oriented in your case.

Forward=BoltIter->m_WorldTransformation.m[2];
Delta=Cam->m_Position-BoltIter->m_Position;
D3DXVec3Cross(&NewUp, &Delta, &Forward);
float length=D3DXVec3Length(&NewUp);
NewUp/=length;
BoltIter->m_WorldTransformation(1,0)=NewUp.x;
BoltIter->m_WorldTransformation(1,1)=NewUp.y;
BoltIter->m_WorldTransformation(1,2)=NewUp.z;
D3DXVec3Cross(&NewRight, &NewUp, &Forward);
BoltIter->m_WorldTransformation(0,0)=NewRight.x;
BoltIter->m_WorldTransformation(0,1)=NewRight.y;
BoltIter->m_WorldTransformation(0,2)=NewRight.z;

Share this post


Link to post
Share on other sites