# Usage of Vector3.Project ??????

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

## Recommended Posts

Here is a sample of what we tried: 1) we draw a ball at position (0,0,-200) 2) we used the code snippet below to draw a line starting at position (0,0,-200) [ball position]. To do so, we used the Vector3.Project() passing the (0,0,-200) value to get a coordinate in screen space so as to feed the Direct3D.Line()) --> The rendered line does not (AT ALL) start at the ball position.... We are lost ... and the MS documentation, on this subject, is by far the worste we have seen so far. Thanks for any help, José Code snippet: -------------- translationX = 0.0f; translationY = 0.0f; translationZ = -200.0f; UpdateTranslationAndRotation(); // Update the Device.Transform.World equalizerlightTest.Render(device, true, false); // Render mesh in the 3D environment // Get the 2D represention Vector3 v3D = new Vector3(translationX, translationY, translationZ); v3D .Project(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World); // Draw a line (using Direct3D.Line) Vector2[] v = new Vector2[2]{new Vector2(v3D .X, v3D .Y), new Vector2(v3D .X + 300, v3D .Y+ 300)}; _lin.Begin(); _lin.Draw(v, Color.Red); _lin.End();

##### Share on other sites
Why are you adding 300 to the resulting x,y positions?

edit - nevermind. I see what you're doing.

Have you tried using DrawTransform()? That way,you can specify the line in 3D coordinates. It might be easier to get the results you want.

[Edited by - Dave Hunt on November 15, 2004 1:32:01 PM]

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

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631768
• Total Posts
3002242
×