#### Archived

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

# Geometry problem

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

## 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 on other sites
Rotate the quad about its local-z axis, so that its normal intersects the camera''s forward vector.

yckx

##### 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 on other sites
hi Trienco, can you post some pseudocode ?

##### 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;

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632925
• Total Posts
3009235
• ### Who's Online (See full list)

There are no registered users currently online

×