/** * Adds a triangle group with specified vertex coordinates and colors. * @param xyz array of packed vertex coordinates. * @param rgb array of packed color components. * @return the triangle group. */ public TriangleGroup addTriangles(float[] xyz, float[] rgb) { return addTriangles(new TriangleGroup(true,xyz,rgb)); }
/** * Adds a triangle group with specified vertex coordinates. * @param xyz array of packed vertex coordinates. * @return the triangle group. */ public TriangleGroup addTriangles(float[] xyz) { return addTriangles(new TriangleGroup(true,xyz,null)); }
/** * Returns a new simple frame with a triangle group. * @param vn true, for vertex normals; false, for triangle normals. * @param sx sampling of x coordinates; may be non-uniform. * @param sy sampling of y coordinates; may be non-uniform. * @param z array[nx][ny] of z coordinates z = f(x,y). */ public static SimpleFrame asTriangles( boolean vn, Sampling sx, Sampling sy, float[][] z) { return asTriangles(new TriangleGroup(vn,sx,sy,z)); }
/** * Returns a new simple frame with a triangle group. * @param vn true, for vertex normals; false, for triangle normals * @param xyz array of packed vertex coordinates. * @param rgb array of packed color coordinates. * @return the simple frame. */ public static SimpleFrame asTriangles(boolean vn, float[] xyz, float[] rgb) { return asTriangles(new TriangleGroup(vn,xyz,rgb)); }
/** * Adds a triangle group for a sampled function z = f(x,y). * @param sx sampling of x coordinates; may be non-uniform. * @param sy sampling of y coordinates; may be non-uniform. * @param z array[nx][ny] of z coordinates z = f(x,y). */ public TriangleGroup addTriangles(Sampling sx, Sampling sy, float[][] z) { return addTriangles(new TriangleGroup(true,sx,sy,z)); }
/** * Returns a new simple frame with a triangle group. * @param vn true, for vertex normals; false, for triangle normals. * @param sx sampling of x coordinates; may be non-uniform. * @param sy sampling of y coordinates; may be non-uniform. * @param z array[nx][ny] of z coordinates z = f(x,y). * @param r array[nx][ny] of red color components. * @param g array[nx][ny] of green color components. * @param b array[nx][ny] of blue color components. */ public static SimpleFrame asTriangles( boolean vn, Sampling sx, Sampling sy, float[][] z, float[][] r, float[][] g, float[][] b) { return asTriangles(new TriangleGroup(vn,sx,sy,z,r,g,b)); }
public static void go() { float[] xyz = makeSineWave(); xyz = addBulge(xyz); xyz = addTear(xyz); float[] rgb = makeColors(xyz); TriangleGroup tg = new TriangleGroup(true,xyz,rgb); System.out.println("TriangleGroup bounding sphere =\n" + tg.getBoundingSphere(true)); StateSet states = new StateSet(); ColorState cs = new ColorState(); cs.setColor(Color.CYAN); states.add(cs); LightModelState lms = new LightModelState(); lms.setTwoSide(true); states.add(lms); MaterialState ms = new MaterialState(); ms.setColorMaterial(GL_AMBIENT_AND_DIFFUSE); ms.setSpecular(Color.WHITE); ms.setShininess(100.0f); states.add(ms); tg.setStates(states); World world = new World(); world.addChild(tg); DemoFrame frame = new DemoFrame(world); OrbitView view = frame.getOrbitView(); view.setWorldSphere(new BoundingSphere(5,5,5,5)); frame.setSize(new Dimension(800,600)); frame.setVisible(true); }