This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > April 2006 > How to drawing some connected 2D lines?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to drawing some connected 2D lines?
|
|
| mehdi.mousavi@gmail.com 2006-04-25, 7:03 pm |
| Hi,
I'm a newbie in VRML, so don't blame me on this post. I would like to
know how am I supposed to draw some connected 2D lines from a given set
of x/y points?
Any help would be highly appreciated,
Cheers,
Mehdi
| |
| Joe D Williams 2006-04-25, 7:03 pm |
|
<mehdi.mousavi@XXXXXXXXXX> wrote in message
> how am I supposed to draw some connected 2D lines from a given set
> of x/y points?
>
You create a list of point coordinate sets,
then a list showing the sequence in which you
wish the points to be connected,
and give it to VRML/X3D in the IndexedLineSet node.
If lines are 2D(?), then one way you draw them in 3D space
is by changing only x and y while holding z constant,
for example.
geometry IndexedLineSet {
coord Coordinate {
point [ 1 0 0, 2 1 0 ]
coordIndex [ 0, 1, -1 ]
}
}
for point 0, x=1 y=0 z=o
then
for point 1, x=2 y=1 z=0.
the coordindex then shows to start at point 9 drawing
a line to point 1, then stop.
Then You could use Transform to position the line
in 3D space wherever you need it.
Many other interesting viz is possible.
Here is an old one:
#VRML V2.0 utf8
Group { children [
Shape {
geometry IndexedLineSet {
coord Coordinate { point [ 0 10 0, 0 0 0, 20 0 0, -1 5 0, 21 5 0 ] }
coordIndex [ 0 1 2 -1 3 4 ]
color Color { color [ 0 0 0, .2 .2 .2 ] }
colorIndex [ 0 1 ]
colorPerVertex FALSE
}
}
Shape {
geometry IndexedLineSet {
coord Coordinate {
point [2 1 0, 5 2 0, 8 1.5 0, 11 9 0, 14 7 0, 17 10 0]}
coordIndex [ 0 1 2 3 4 5 ]
color Color {
color [ .1 .1 .1, .2 .2 .2, .15 .15 .15, .9 .9 .9, .7 .7 .7, 1 1 1 ] }
}
}
Background { skyColor 1 1 1 }
]
}
Here is what it looks like in the standard:
IndexedLineSet : X3DGeometryNode {
MFInt32 [in] set_colorIndex
MFInt32 [in] set_coordIndex
SFNode [in,out] color NULL [X3DColorNode]
SFNode [in,out] coord NULL [X3DCoordinateNode]
SFNode [in,out] metadata NULL [X3DMetadataObject]
MFInt32 [] colorIndex [] [0,?) or -1
SFBool [] colorPerVertex TRUE
MFInt32 [] coordIndex [] [0,?) or -1
}
http://www.web3d.org/x3d/specifications/
ISO-IEC-19775-X3DAbstractSpecification/Part01/
components/rendering.html#IndexedLineSet
Here is an example of a circle where z is 0 at every point.
Transform {
children [
Shape { appearance Appearance { # Orbit Path Line
material Material { diffuseColor 0.9 0 0.7 emissiveColor 0.424956 0.483976
1 } }
geometry DEF Circle IndexedLineSet { coord Coordinate {
point [ 1 0 0, 0.995 0 -0.105, 0.979 0 -0.208, 0.951 0 -0.309, 0.914
0 -0.407, 0.866 0 -0.5, 0.809 0 -0.588, 0.743 0 -0.669, 0.669 0 -0.743, 0.588
0 -0.809, 0.5 0 -0.866, 0.407 0 -0.914, 0.309 0 -0.951, 0.208 0 -0.978, 0.105
0 -0.995, 0 0 -1, -0.105 0 -0.994522, -0.208 0 -0.978, -0.309 0 -0.951, -0.407
0 -0.914, -0.5 0 -0.866, -0.588 0 -0.809, -0.669 0 -0.743, -0.743
0 -0.669, -0.809 0 -0.588, -0.866 0 -0.5, -0.914 0 -0.407, -0.951
0 -0.309, -0.978 0 -0.208, -0.995 0 -0.105, -1 0 0, -0.995 0 0.105, -0.978 0
0.208, -0.951 0 0.309, -0.914 0 0.407, -0.866 0 0.5, -0.809 0 0.588, -0.743 0
0.669, -0.669 0 0.743, -0.588 0 0.809, -0.5 0 0.866, -0.407 0 0.914, -0.309 0
0.951, -0.208 0 0.978, -0.105 0 0.995, 0 0 1, 0.105 0 0.995, 0.208 0 0.978,
0.309 0 0.951, 0.407 0 0.914, 0.5 0 0.866, 0.588 0 0.809, 0.669 0 0.743, 0.743 0
0.669, 0.809 0 0.588, 0.866 0 0.5, 0.914 0 0.407, 0.951 0 0.309, 0.978 0 0.208,
0.995 0 0.104, 1 0 0 ]}
coordIndex [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, -1 ]}
}
> Any help would be highly appreciated,
>
> Cheers,
> Mehdi
Good Luck and Best Regards,
Joe
| |
| mehdi.mousavi@gmail.com 2006-04-26, 6:49 am |
| Well done! I got another question, that I've been thinking about for a
long period of time. The above example, and many others I've seen on
the net, contains some floating point x/y/z coordinates, e.g., 0.105,
0.914 and the like. The question is that how these coordinates are
captured? Is there any specific 3D scanner they use to capture these
flating point units or a special software providing you with these
floating-point units?
Thank you for your time.
Mehdi
| |
| Joe D Williams 2006-04-26, 10:51 pm |
|
<mehdi.mousavi@XXXXXXXXXX> wrote in message
news:1146040671.895812.201640@u72g2000cwu.googlegroups.com...
> Well done!
Thank You.
> I got another question, that I've been thinking about for a
> long period of time.
Great! Everything involved in this X3D/VRML requires
thinking for a long period of time:)
> The above example, and many others I've seen on
> the net, contains some floating point x/y/z coordinates, e.g., 0.105,
> 0.914 and the like. The question is that how these coordinates are
> captured?
For some shapes the numbers can be generated by some
algorithm, like points on a circle or sphere.
For example get some program, even BASIC, running and
list some values out to a file, then use a text editor to
paste them into the coord field, and then figure out your
coordindex numbers.
That is how the points for the circle line set were generated.
I have seen a 3D scanner that makes a map of a face
or other objects, even buildings, using one or multiple views,
Some are very precise at measuring objects and producing
a metrology-grade coordinate set that can be used to vizualize
details of the piece in X3D/VRML.
Motion capture is another technology that finds vertices
on a moving figure.
For any real-life artifact, just define 0 0 0 and start measuring.
> Is there any specific 3D scanner they use to capture these
> floating point units or a special software providing you with these
> floating-point units?
Google may be your best friend in this quest. Every year new
products are shown at SIGGRAPH and other places that make this
task easier.
>
> Thank you for your time.
> Mehdi
>
Good Luck and Best Regards,
Joe
| |
| simon 2006-04-27, 10:56 pm |
| you could use a script node to do the generation of coordinates, by
writing the generator in JS inside the script node then using the
print() function to put them on the console, and cut/paste from there.
FWIW scanning points in 3d, particularly from one point of view, can be
less than half the problem, working out where the surfaces go can be
tricky, and with multiple scans the points arn't the same so matching
the views can be hard.
to avoid this the thing to do is capture known points from multiple
views, which means multiple scanner units all round the object or
somehow having known fixed points on an unmoving object, which isn't
often possible.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|