At any rate, my question is about IndexedLineSet -- my copy of the
draft 1.0 spec doesn't mention it. Is it part of the spec, or would
I be one of the horrid non-compliers if I started using it? ;-)
James
(p.s. My solution for drawing lines using an IndexedFaceSet was to draw
very tight triangles -- it works well enough, so I supposed I don't
*need* IndexedLineSet, but it'd be a lot more efficient.)
Timothy F. Rohaly wrote:
>On May 24, 10:20, James Waldrop wrote:
>> Subject:
>>
>> Here's a simple question for the 3D / Open Inventor experts out there.
>>
>> I need to draw a curved line in VRML. I'm drawing this line on the fly,
>> with a program (cgi-bin for vrml), and I don't know how to do it. :(
>>
>> So, let's say that I had a simple curve of the form:
>>
>> for (y=-10; y <= 10; y++) { x = z = pow(2, y); }
>>
>> This gets me a set of points.
>>
>> How do I draw them? I have some clues, but would appreciate real VRML.
>>
>> Thanks!
>>
>> James
>>-- End of excerpt from James Waldrop
>
>Here is an example program with output:
>------------------------------------------------------------------------------
>--
>
>#include <stdio.h>
>#include <math.h>
>
>/*
> * Program to generate a VRML file for a line given by
> * a functional form. In this case x = z = 2**y.
> *
> */
>main()
>{
> int y;
> float x,z;
>
> printf("#VRML V1.0 ascii\n\n");
> printf("Separator {\n");
> printf(" Coordinate3 {\n");
> printf(" point [\n");
>
> /* Insert your favorite function here */
> for (y = -10; y <= 10; y++) {
> x = z = pow(2, y);
> printf(" %f %f %f,\n", x, (float) y, z);
> }
>
> printf(" ]\n");
> printf(" }\n");
> printf(" IndexedLineSet {\n");
> printf(" coordIndex [\n ");
> for (y = 0; y < 21; y++) { /* This also depends on your function */
> printf("%d, ",y);
> }
> printf("-1,\n");
> printf(" ]\n");
> printf(" }\n");
> printf("}\n");
>
> return 0;
>}
>
>Output:
>------------------------------------------------------------------------------
>--
>
>#VRML V1.0 ascii
>
>Separator {
> Coordinate3 {
> point [
> 0.000977 -10.000000 0.000977,
> 0.001953 -9.000000 0.001953,
> 0.003906 -8.000000 0.003906,
> 0.007812 -7.000000 0.007812,
> 0.015625 -6.000000 0.015625,
> 0.031250 -5.000000 0.031250,
> 0.062500 -4.000000 0.062500,
> 0.125000 -3.000000 0.125000,
> 0.250000 -2.000000 0.250000,
> 0.500000 -1.000000 0.500000,
> 1.000000 0.000000 1.000000,
> 2.000000 1.000000 2.000000,
> 4.000000 2.000000 4.000000,
> 8.000000 3.000000 8.000000,
> 16.000000 4.000000 16.000000,
> 32.000000 5.000000 32.000000,
> 64.000000 6.000000 64.000000,
> 128.000000 7.000000 128.000000,
> 256.000000 8.000000 256.000000,
> 512.000000 9.000000 512.000000,
> 1024.000000 10.000000 1024.000000,
> ]
> }
> IndexedLineSet {
> coordIndex [
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
>19
>, 20, -1,
> ]
> }
>}