Use a parametric surface factory

From JReality Wiki
(Redirected from Parametrized Surfaces)
Jump to: navigation, search

Source file: ParametricSurfaceExample

JavaDoc: ParametricSurfaceFactory

Run as Java webstart

This tutorial assumes that you know how to display a geometry.

Suppose we want to display the parametrized surface <math>(u,v)\mapsto (u-v^2, uv, u^2-4uv^2)</math> (a so called swallowtail singularity).

For this task jReality provides the factory de.jreality.geometry.ParametricSurfaceFactory.

To make our formula available to the ParametricSurfaceFactory we implement the interface ParametricSurfaceFactory.Immersion

public class Swallowtail implements Immersion {
	public void evaluate(double u, double v, double[] xyz, int index) {
	public int getDimensionOfAmbientSpace() { return 3;	}
	public boolean isImmutable() { return true; }

Then we instantiate a ParametricSurfaceFactory with this immersion,

ParametricSurfaceFactory psf = new ParametricSurfaceFactory(new Swallowtail());

set some parameters,


and tell the ParametricSurfaceFactory to update the geometry,


which we may access through ParametricSurfaceFactor.getIndexedFaceSet().

Changing parameters of the ParametricSurfaceFactory and updating the geometry through ParametricSurfaceFactory.update() changes the object provided by ParametricSurfaceFactor.getIndexedFaceSet() rather than creating a new one. In particular, the image in the viewer will change immediately.

Screenshot, showing the example run with the useViewerVR flag set to true.


Previous: Use a quad mesh factory Developer Tutorial: Contents Next: Use a tube factory