Example usage for javax.media.j3d TriangleArray setNormals

List of usage examples for javax.media.j3d TriangleArray setNormals

Introduction

In this page you can find the example usage for javax.media.j3d TriangleArray setNormals.

Prototype

public void setNormals(int index, float normals[]) 

Source Link

Document

Sets the normals associated with the vertices starting at the specified index for this object.

Usage

From source file:AppearanceExplorer.java

Shape3D createTriangleArray() {

    Point3f pnt[] = new Point3f[3];
    pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f);
    pnt[1] = new Point3f(1.0f, -1.0f, 0.0f);
    pnt[2] = new Point3f(1.0f, 1.0f, 0.0f);
    Color3f colrs[] = new Color3f[3];
    colrs[0] = red;/*w  w  w.  j  a  v a  2  s.  c  o  m*/
    colrs[1] = green;
    colrs[2] = blue;
    Vector3f norms[] = new Vector3f[3];
    Vector3f triNormal = new Vector3f(0.0f, 0.0f, 1.0f);
    norms[0] = triNormal;
    norms[1] = triNormal;
    norms[2] = triNormal;

    TriangleArray ta = new TriangleArray(3,
            GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS);
    ta.setCoordinates(0, pnt);
    ta.setColors(0, colrs);
    ta.setNormals(0, norms);

    return new Shape3D(ta, appearance);
}