Seb Lee-Delisle

Menu

Drawing 3D perspective lines in Flash

I love the Line3D in papervision, but wouldn’t it be great if it actually got larger as it came towards you? Currently the lines are just drawn using the Flash drawing API, and the line’s thickness is the same no matter how far away it is.

I’ve been working on a new line drawing algorithm. I wanted the lines to look more like tubes, cylinders in fact. But I obviously don’t want the overhead of drawing actual cylinders! I just want a 3D line that gets bigger as it comes towards you but with a big roundy end like it’s got a spherical end.

So I started drawing pictures on paper and came up with this :

What my brain looks like

I knew I had to draw two circles (one for each end of the line) but I didn’t know which points on the circles to draw the line between. Well I won’t bore you with my working out, but in the end I opted for a trig solution, even though I’m fairly sure there’s a really nice vector solution. (Please comment if you’re a vector maths genius :-)

Here’s the final working swf, you can move the points around and adjust the radii and always get a nice drawn line with no noticable join at each circle.

So now I’ve just got to implement these new lines into PV3D… I’m hoping to do it later today.

This entry was posted in Actionscript, Flash, Flash 3D, Papervision3D. Bookmark the permalink.

11 Responses to Drawing 3D perspective lines in Flash

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *