ParametricGeometry - thothbot/parallax GitHub Wiki
Parametric Geometry
Class ParametricGeometry
is very very useful to generate parametric surfaces by defining custom function.
Constructor takes three arguments:
- a function object that converts the domain coordinate into a range coordinate;
- the level-of-detail for the U coordinate;
- and the level-of-detail for the V coordinate.
ParametricGeometry geometry = new ParametricGeometry(
new ParametricGeometry.ParametricFunction()
{
@Override
// Converts the domain coordinate into a range coordinate
public Vector3 run(double u, double v)
{
/* code */
}
},
slices, // The level-of-detail for the U coordinate
stacks // The level-of-detail for the V coordinate
);
Lets implement ParametricFunction
interface and write function to create a sphere:
@Override
public Vector3 run(double u, double v)
{
u *= Math.PI;
v *= 2 * Math.PI;
double x = Math.sin(u) * Math.cos(v);
double y = Math.sin(u) * Math.sin(v);
double z = Math.cos(u);
return new Vector3(x, y, z);
}
Built-In Geometries
This is family of the following classes, which are inherited from the ParametricGeometry
Klein bottle
http://thothbot.github.com/parallax/static/docs/klein_bottle.gif
KleinParametricGeometry geometry = new KleinParametricGeometry(10, 20);
Flat Mobius strip
http://thothbot.github.com/parallax/static/docs/mobius_strip.gif
MobiusParametricGeometry geometry = new MobiusParametricGeometry(10, 20);
Mobius 3D
http://thothbot.github.com/parallax/static/docs/mobius_3d.gif
Mobius3dParametricGeometry geometry = new Mobius3dParametricGeometry(10, 20);