- Home /
3D Lines not facing camera
I'm using the wonderful Vectrosity library to draw 3D lines but I have a problem in as much as some of the lines aren't facing the camera.
The camera remains at the world centre (0,0,0) and the lines are created once only at startup and remain in the scene at all times, and they can be drawn anywhere in the world. What I'm seeing is that the line poly normals all seem to face in one direction and not at the camera, which gives the effect of certain lines appearing thinner than others.
Can anyone shed any light on this?
Andy
Answer by Eric5h5 · May 14, 2011 at 05:28 PM
You should call DrawLine3D whenever the line or camera moves, usually in Update or LateUpdate. That way the line will always be drawn correctly. (As a side note, in order to help with just this sort of thing, Vectrosity 1.4 has a DrawLine3DAlways function, so that 3D lines are automatically updated for you when necessary, similar to what the VectorManager does. 1.4 isn't out yet.)
I see. Thanks for the response, and do let us all know when 1.4 is ready :-)
Actually, thinking about it, it seems a bit overkill for me to have to redraw 300 or so lines every Update seeing as the camera position never moves. Is there a way I can adjust your code so when a line is first drawn it's always looking at the camera?
Not quite sure I understand...if the camera is static, and the lines are static, then nothing has to be redrawn. If the lines change, then they have to be redrawn, but not necessarily in Update, only when they actually change. (Using Update would be typical if the lines are constantly changing, but if that's not the case, just call DrawLine3D only when necessary.)
To clarify, when a line is first drawn, it is in fact facing the camera. Or at least it's facing a camera; if you have a multi-camera setup, or your camera isn't tagged $$anonymous$$ain Camera, then you should probably use SetCamera3D() to make sure it's set up correctly.
Yes, I do call setCamera3D (which is a camera that sits at the very centre of the world) before I draw the lines, but they still seem to be facing in strange directions. In one case, I'm drawing a circle around the camera (imagine a horizon line) in 32 segments and it seems that some (but not all) aren't aligned to the camera.
Your answer
Follow this Question
Related Questions
How to stop lag between Vectrosity circle and GUI.Label at mouse cursor? 0 Answers
vectrosity: Draw lines with value of float 0 Answers
Vectrosity - lines disappear on certain camera angles 1 Answer
Draw lines with Vectrosity in the direction transform.forward 1 Answer
How do you select 3d lines in Vectrosity by clicking? 0 Answers