One of the main goals of Meteor is the ability to efficiently generate triangle representations of arbitrary implicit 3 variable mathmatical functions.
The --equation option (-e short form) accepts an equation. Basic operators used in the c programming language are supported as well as math functions. The equation for a sphere is x^2 + y^2 + z^2 = r^2. To generate a sphere of radius .5:
$ meteor -e "x*x + y*y + z*z = .5*.5"
To get basic statistics about the data, specify --verbose or -v:
compiling sphere.c... 0.044848 seconds No normal function, will use input function to approximate building... 0.017021 seconds Points: 5582 Triangles: 11160
An alternative way to specify an equation is by a source file. Right now only the c language is supported. This is the default option. A models directory in the src/models from the main distribution contains some examples.
If the following code is saved in a file called sphere.c:
double func(double x, double y, double z) { return (x*x + y*y + z*z) - .25; }
Then invoke meteor, the results will be the same as the first example
$ meteor sphere.c
It is possible to specify normals, colors and texture coordinates in addition to position data. To specify colors, add another function to the same source file:
void color(double c[3], double p[3]) { c[0] = fabs(p[0]) + .4; c[1] = fabs(p[1]) + .4; c[2] = fabs(p[2]) + .4; }
Normals are automatically generated, if this is not desired --no-normals or -o will suppress this. Alternatively a normal function can be specified. Replacing the color function with:
void normal(double c[3], double p[3]) { c[0] = p[0]*p[0]; c[1] = p[1]*p[1]; c[2] = p[2]*p[2]; }
Texture coordinates are generated similarly, see the texture coordinate correction section for examples.
Animations can be generated as well, the option --animate or -a must be specified, and an "update" routine should be provided. The complete source for a growing sphere:
static double r = 0; double func(double x, double y, double z) { return (x*x + y*y + z*z) - r*r; } void update(void) { r += .01; }
Now invoke meteor as follows:
$ meteor -a sphere.c
By default the range of -1 to 1 is used for x, y, and z axis, and a step size of .05 is used. These can be modified with the option "-x -10,10" to go from -10 to 10 on the x address. To change the step size --step or -s with a value (eg: -s .01) can be used to increase triangle count.
A function with the name of "init" is called once before anything else happens, this can be useful for complicated algorithms.