What is the best way of doing 3D lines?

Blitz3D Forums/Blitz3D Programming/What is the best way of doing 3D lines?

Ian Thompson(Posted 2003) [#1]
What is the best way of doing 3D lines?

After renderworld (2D line command)is not an option as I need to mix the lines within the 3D world.

I am sure I saw somebody do this with cylinders but I can't find the code in these new forums.


Rottbott(Posted 2003) [#2]
Do you mean any sort of line or a wireframe view of everything?

In any case I'd suggest using boxes rather than cylinders 'cause it's a lot less triangles.

Make a normal box mesh.. then do PositionMesh MyBox, 0, 0, 1 so the centre of the mesh is the start of the box.. then when you need to do a line, CopyEntity the box, ScaleEntity the copy to the length you need (and scale down the width/height to something small, 0.1 maybe), position it at the XYZ position of one end of your line, then rotate it to face the other end of the line (you can use a dummy object and PointEntity), and that should work.


Ian Thompson(Posted 2003) [#3]
Rottbott: I wish to mix lines with 3D objects and preserve Z buffer while doing it.

I had assumed that using a box would result in too many right angled shapes. So when the lines are rotated, the various sides of the box would face then face away from the light source, causing a shimmering effect. I had assumed that using cylinders may minimise this effect?

</moan on>
This is all a bit of pain as DX8 and DX9 both have line primitives.
</moan off>


Ross C(Posted 2003) [#4]
Try using a quad then. Just make sure the x axis rotation is right so it always looks at the camera.


bradford6(Posted 2003) [#5]
look at tformedx y and z

a 3 sided poly is the most efficient. /_\

you need to scale the mesh appropriately.

try entitydistance to get the correct range


Rottbott(Posted 2003) [#6]
I didn't realise you wanted *lit* lines :P

A quad or triangle would be better than a box but tricky to make it point at the camera *and* be aligned properly between your two line end-points.

Not sure how you'd do it with a triangle without it looking triangular.


Rob(Posted 2003) [#7]
search this forum. There's a thread formerly in advanced3d discussion (thats now in this section) that I brought up about 3D wireframing. It's a particularly fast (better than 2D overlay) and more reliable thant wireframe true method.


Ian Thompson(Posted 2003) [#8]
Sounds perfect Rob. I have had a good look and can't find the thread. Can you remember any key words?

Do you have the code from the thread?


rsbrowndog(Posted 2003) [#9]
Try here:

http://www.blitzbasic.co.nz/Community/posts.php?topic=25913

Cheers,

Ryan


Ian Thompson(Posted 2003) [#10]
rsbrowndog: Definately some good pointers on that thread. Skidracers code almost works but the lines mess up at certain angles. I'll have a closer look at the code...