views:

387

answers:

1

is there a straightforward way to draw 3d lines with graphics.lineTo()/moveTo()? I havent run into anytihng. both of these methods only use x/y for their coordinates.

Im using the 'z' coordinate on my sprites and want to connect them with lines... help is appreciated

+3  A: 

The graphics class only works with 2D coordinates. However, you can still do what you want in a number of ways. The easiest is to place empty sprites inside of your main sprites where you want your lines to connect. Then just loop over those points and use the localToGlobal local3DToGlobal method to transform their coordinates to stage coordinates. Then just draw lines between those coordinates. Flash will handle the projection for you when you use localToGlobal local3DToGlobal. The only thing you're going to have to worry about is Z-sorting of the lines.

Branden Hall
so I should place empty sprites inside sprites that I want to connect, as some sort of connection endpoints and use their coordinates for...? thats whats not clear. use Graphics (and its lineTo/moveTo) inside that sprite?
deepblue
+1 ... very nice idea ... ;)
back2dos
The empty clips are essentially "anchors" for your lines. They should live within the 3D sprites so that they track around with them (hence flash handles the projection math for you with you do localToGlobal on the coordinates). You could draw the lines within those clips or at the stage level above everything else. If you draw within the clips you'll want to go from the deeper of the two clips forward to keep the depth of the lines somewhat correct.
Branden Hall
I understand your nesting hierarchy, but it still seems to me that the z coord would be ignored since Im assuming you're talking about using lineTo for drawing (if no please correct me, as far as what the actual draw call would use); localToGlobal works with Point instances which are x/y based (unless Im unaware of flash10 extensions). My appologies if Im missing something basic/obvious... the z-sorting issue is a given since flash doesnt do correct z-sorted rendering so I'll deal with that separately as you suggest.
deepblue
Yes, I do mean to use lineTo for drawing. However I did misspeak in that you will be using local3DToGlobal not localToGlobal.
Branden Hall
I see. thanks for the function reference. As far as I can see I have to take care and rotate the container sprite inside which the 2d line is drawn, since the anchors that are attached to target 3d sprites are at different z coords... shame that there's no straighforward 3d line drawing way of avoiding these transformation being done manually
deepblue