At 2:53 PM -0500 1/30/05, Asher Dunn wrote:
Given a start point X,Y,Z and an end point X,Y,Z of a line...
What's the best way to go about drawing this into
a 3D space so it can be viewed on screen, rotated, orbited around
etc.
Just curios to know how others might go about this ?
If you want to animate these lines dynamically, then it takes a
couple of Declare statements. Download the Armageddon source code,
which uses this to draw the missile trails.
<http://www.codenautics.com/armageddon>
If you don't need to dynamically resize/reposition the line, then you
can simply construct a 3DMF string. The "3DMF Examples" folder on
the CD has two examples of a line. Here's the one for a single color:
3DMetafile ( 1 6 Normal tableofcontents0> )
# This makes a straight 1-pixel-thick line. For documentation, see:
#
http://developer.apple.com/techpubs/quicktime/qtdevdocs/QD3D/qd3dmetafile.27.htm
Container (
Line (
-1 -1 -1 # start (X Y Z)
1 1 1 # end (X Y Z)
)
attributeset2:
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.9 )
)
)
...and here's one where the color varies from one end to the other:
3DMetafile ( 1 6 Normal tableofcontents0> )
# This makes a straight 1-pixel-thick line. For documentation, see:
#
http://developer.apple.com/techpubs/quicktime/qtdevdocs/QD3D/qd3dmetafile.27.htm
Container (
Line (
-1 -1 -1 # start (X Y Z)
1 1 1 # end (X Y Z)
)
Container (
# Using VertexAttributeSetList, we can
specify a different
# color for each end point and have it
interpolate between.
VertexAttributeSetList ( 2 Exclude 0 )
attributeset5:
Container (
AttributeSet ( )
DiffuseColor ( 1 0 0 )
)
attributeset6:
Container (
AttributeSet ( )
DiffuseColor ( 0 0 1 )
)
)
)
Just substitute your own start/end points and color(s) and then use
Object3D.AddShapeFromString, and there you go.
Cheers,
- Joe
--
REAL World 2005 - The REALbasic User Conference
March 23-25, 2005, Austin, Texas
<http://www.realsoftware.com/realworld>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|