Examples of GeometryInfo


Examples of com.sun.j3d.utils.geometry.GeometryInfo

        primitiveType = GeometryInfo.TRIANGLE_STRIP_ARRAY;
      } else {
        primitiveType = GeometryInfo.POLYGON_ARRAY;
      }
     
      GeometryInfo geometryInfo = new GeometryInfo(primitiveType);
      geometryInfo.setCoordinates(this.geometryVertices);
      geometryInfo.setCoordinateIndices(getIndices(this.geometryVertexOffset));
      if (this.geometryNormals != null) {
        geometryInfo.setNormals(this.geometryNormals);
        geometryInfo.setNormalIndices(getIndices(this.geometryNormalOffset));
      }
      if (this.geometryTextureCoordinates != null) {
        Integer stride = this.sourceAccessorStrides.get(this.geometryTextureCoordinates);
        // Support only UV texture coordinates
        float [] textureCoordinates;
        if (stride > 2) {
          textureCoordinates = new float [this.geometryTextureCoordinates.length / stride * 2];
          for (int i = 0, j = 0; j < this.geometryTextureCoordinates.length; j += stride) {
            textureCoordinates [i++] = this.geometryTextureCoordinates [j];
            textureCoordinates [i++] = this.geometryTextureCoordinates [j + 1];
          }
        } else {
          textureCoordinates = this.geometryTextureCoordinates;
        }
        geometryInfo.setTextureCoordinateParams(1, 2);
        geometryInfo.setTextureCoordinates(0, textureCoordinates);
        geometryInfo.setTextureCoordinateIndices(0, getIndices(this.geometryTextureCoordinatesOffset));
      }
     
      if ("trifans".equals(name)
          || "tristrips".equals(name)) {
        int [] stripCounts = new int [this.facesAndLinesPrimitives.size()];
        for (int i = 0; i < stripCounts.length; i++) {
          stripCounts [i] = this.facesAndLinesPrimitives.get(i).length / this.inputCount;
        }
        geometryInfo.setStripCounts(stripCounts);
      } else if ("polylist".equals(name)) {
        geometryInfo.setStripCounts(this.vcount);
      } else if ("polygons".equals(name)) {
        int [] stripCounts = new int [this.facesAndLinesPrimitives.size() + this.polygonsPrimitives.size()
                                      + this.polygonsHoles.size()];
        int [] contourCounts = new int [this.facesAndLinesPrimitives.size() + this.polygonsPrimitives.size()];
        int stripIndex = 0;
        int countourIndex = 0;
        for (int i = 0; i < this.facesAndLinesPrimitives.size(); i++) {
          stripCounts [stripIndex++] = this.facesAndLinesPrimitives.get(i).length / this.inputCount;
          contourCounts [countourIndex++] = 1; // One polygon
        }
        for (int i = 0; i < this.polygonsPrimitives.size(); i++) {
          stripCounts [stripIndex++] = this.polygonsPrimitives.get(i).length / this.inputCount;
          List<int []> polygonHoles = this.polygonsHoles.get(i);
          for (int j = 0; j < polygonHoles.size(); j++) {
            stripCounts [stripIndex++] = polygonHoles.get(j).length / this.inputCount;
          }
          contourCounts [countourIndex++] = 1 + polygonHoles.size(); // One polygon + its holes count
        }
        geometryInfo.setStripCounts(stripCounts);
        geometryInfo.setContourCounts(contourCounts);
      }

      if (this.geometryNormals == null) {
        new NormalGenerator(Math.PI / 2).generateNormals(geometryInfo);
      }
      return geometryInfo.getGeometryArray(true, true, false);
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

                ? 0
                : getRoomHeightAt(geometryHole [k][0], geometryHole [k][1]);
            coords [j] = new Point3f(geometryHole [k][0], y, geometryHole [k][1]);
          }
        }
        GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        geometryInfo.setCoordinates (coords);
        geometryInfo.setStripCounts(stripCounts);
        geometryInfo.setContourCounts(new int [] {stripCounts.length});
        // Compute room texture coordinates
        if (texture != null) {
          TexCoord2f [] textureCoords = new TexCoord2f [vertexCount];
          for (j = 0; j < geometryPoints.length; j++) {
            textureCoords [j] = new TexCoord2f(geometryPoints [j][0] / texture.getWidth(),
                roomPart == FLOOR_PART
                    ? -geometryPoints [j][1] / texture.getHeight()
                    : geometryPoints [j][1] / texture.getHeight());
          }
          for (float [][] geometryHole : geometryHoles) {
            for (int k = 0; k < geometryHole.length; k++, j++) {
              textureCoords [j] = new TexCoord2f(geometryHole [k][0] / texture.getWidth(),
                  roomPart == FLOOR_PART
                      ? -geometryHole [k][1] / texture.getHeight()
                      : geometryHole [k][1] / texture.getHeight());
            }
          }
          geometryInfo.setTextureCoordinateParams(1, 2);
          geometryInfo.setTextureCoordinates(0, textureCoords);
        }
       
        // Generate normals
        new NormalGenerator(0).generateNormals(geometryInfo);
        geometries [i] = geometryInfo.getIndexedGeometryArray();
      }
      return geometries;
    } else {
      return new Geometry [0];
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

      //Combine triangle data for all islands together in one object.
    NormalGenerator ng = new NormalGenerator();
    for (i = 0; i < islandCounts.length; i++) {
      contourCounts[0] = islandCounts[i].length;
      numPoints += outVerts[i].length;
      GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
      gi.setCoordinates(outVerts[i]);
      gi.setStripCounts(islandCounts[i]);
      gi.setContourCounts(contourCounts);
      ng.generateNormals(gi);

      GeometryArray ga = gi.getGeometryArray(false, false, false);
      vertOffset += ga.getVertexCount();

      triangData.add(ga);
    }
      // Multiply by 2 since we create 2 faces of the font
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

    }

    private static final Shape3D makeECMArea(int range) {
        double[] top = makeECMCoords(range);

        GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        gi.setCoordinates(top);
        gi.setStripCounts(new int[] { top.length/3 });
        gi.setContourCounts(new int[] { 1 });

        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);

        Stripifier st = new Stripifier();
        st.stripify(gi);
       
        return new Shape3D(gi.getGeometryArray());
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

            border[j++] = top[i];
            border[j++] = top[i+1];
            border[j++] = -top[i+2];
        }

        GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);
        gi.setCoordinates(border);
        gi.setStripCounts(new int[] { border.length/3 });

        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);

        Stripifier st = new Stripifier();
        st.stripify(gi);
       
        return new Shape3D(gi.getGeometryArray());
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

class SignModel extends Shape3D {
    static final GeometryArray polygon = makeSign();

    private static final GeometryArray makeSign() {
        GeometryInfo gi = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
        final double top = Math.sqrt(BoardModel.HEX_SIDE_LENGTH/2*BoardModel.HEX_SIDE_LENGTH/2-BoardModel.HEX_DIAMETER/6*BoardModel.HEX_DIAMETER/6);
        double[] coords = {
            -BoardModel.HEX_SIDE_LENGTH/4, BoardModel.HEX_DIAMETER/12, 0.0,
            -BoardModel.HEX_SIDE_LENGTH/4, 0, top,
             BoardModel.HEX_SIDE_LENGTH/4, 0, top,
             BoardModel.HEX_SIDE_LENGTH/4, BoardModel.HEX_DIAMETER/12, 0.0,

             0.0, -BoardModel.HEX_DIAMETER/6, 0.0,
             BoardModel.HEX_SIDE_LENGTH/8, -BoardModel.HEX_DIAMETER/8, top,
            -BoardModel.HEX_SIDE_LENGTH/8, BoardModel.HEX_DIAMETER/8, top,
            -BoardModel.HEX_SIDE_LENGTH/4, BoardModel.HEX_DIAMETER/12, 0.0,

             BoardModel.HEX_SIDE_LENGTH/4, BoardModel.HEX_DIAMETER/12, 0.0,
             BoardModel.HEX_SIDE_LENGTH/8, BoardModel.HEX_DIAMETER/8, top,
            -BoardModel.HEX_SIDE_LENGTH/8, -BoardModel.HEX_DIAMETER/8, top,
             0.0, -BoardModel.HEX_DIAMETER/6, 0.0,
        };
        float[] tcoords = {
            1.0f, 0.0f,
            1.0f, 1.0f,
            0.0f, 1.0f,
            0.0f, 0.0f,

            1.0f, 0.0f,
            1.0f, 1.0f,
            0.0f, 1.0f,
            0.0f, 0.0f,

            1.0f, 0.0f,
            1.0f, 1.0f,
            0.0f, 1.0f,
            0.0f, 0.0f,

        };
        gi.setCoordinates(coords);
        gi.setTextureCoordinateParams(1, 2);
        gi.setTextureCoordinates(0, tcoords);
       
        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);

        Stripifier st = new Stripifier();
        st.stripify(gi);

        return gi.getGeometryArray();
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

    static final GeometryArray polygon = makeArrow();
    static final GeometryArray border = makeArrowOutline();
   
    private static final GeometryArray makeArrow() {
        GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        int[] contours = { 1 };
        float[] normals = {
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
        };
       
        gi.setCoordinates(arrowVertices);
        gi.setStripCounts(arrowStrips);
        gi.setContourCounts(contours);
        gi.setNormals(normals);

        Stripifier st = new Stripifier();
        st.stripify(gi);
       
        return gi.getGeometryArray();
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

        l.setCoordinates(0, arrowVertices);
        return l;
    }

    protected static final GeometryArray makeArrow(double length) {
        GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        int[] contours = { 1 };
        float[] normals = {
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
        };
        double[] vertices = new double[arrowVertices.length];
        System.arraycopy(arrowVertices, 0, vertices, 0, vertices.length);
       
        length -= BoardModel.HEX_DIAMETER/2;
        for (int i = 0; i < 5; i++) vertices[3*i+1] += length;
        vertices[3*5+1] += BoardModel.HEX_DIAMETER/2;
        vertices[3*6+1] += BoardModel.HEX_DIAMETER/2;
        vertices[3*7+1] += length;
       
        gi.setCoordinates(vertices);
        gi.setStripCounts(arrowStrips);
        gi.setContourCounts(contours);
        gi.setNormals(normals);

        Stripifier st = new Stripifier();
        st.stripify(gi);
       
        return gi.getGeometryArray();
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

            addChild(makeQuad(lower.x-0.5, lower.y-0.1, upper.x-lower.x+1, upper.y-lower.y+.6, -.1, app));
        }
    }

    static final Shape3D makeQuad(double orgX, double orgY, double width, double height, double z, Appearance app) {
        GeometryInfo gi = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
        double[] vertices = {
            orgX,       orgY, z,
            orgX+width, orgY, z,
            orgX+width, orgY+height, z,
            orgX,       orgY+height, z,
        };
        float[] texCoords = {
            0.0f, 0.0f,
            1.0f, 0.0f,
            1.0f, 1.0f,
            0.0f, 1.0f,
        };
        float[] normals = {
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
        };
       
        gi.setCoordinates(vertices);
        gi.setNormals(normals);

        gi.setTextureCoordinateParams(1, 2);
        gi.setTextureCoordinates(0, texCoords);

        Stripifier st = new Stripifier();
        st.stripify(gi);
       
        return new Shape3D(gi.getGeometryArray(), app);
    }
View Full Code Here

Examples of com.sun.j3d.utils.geometry.GeometryInfo

                texcoords[toff++] = v[0]/tw;
                texcoords[toff++] = 1.0f-v[1]/th;
            }
        }

        GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);

        gi.setCoordinates(vertices);
        gi.setStripCounts(count);
        gi.setTextureCoordinateParams(1, 2);
        gi.setTextureCoordinates(0, texcoords);

        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);
       
        Stripifier st = new Stripifier();
        st.stripify(gi);

        geom[0] = gi.getGeometryArray();
       
        // top
        int[] strips = new int[scounts.size()];
        for (int i = 0; i < strips.length; i++) {
            strips[i] = scounts.elementAt(i).intValue();
        }
        count = new int[ccnt];
        vertices = new double[total*3];
        texcoords = new float[total*2];
        float[] normals = new float[total*3];
        voff = 0;
        toff = 0;
        int noff = 0;
        for (int i = 0; i < ccnt; i++) {
            Vector<int[]> contour = contours.elementAt(i);
            count[i] = contour.size();
            // reverse path to get front and back face right
            for (int j = count[i]-1; j >= 0; j--) {
                int[] v = contour.elementAt(j);
                vertices[voff++] = v[0]/vw-vo;
                vertices[voff++] = -v[1]/vh+vo;
                vertices[voff++] = 0.5;
                normals[noff++] = 0.0f;
                normals[noff++] = 0.0f;
                normals[noff++] = 1.0f;
                texcoords[toff++] = v[0]/tw;
                texcoords[toff++] = 1.0f-v[1]/th;
            }
        }

        gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);

        gi.setCoordinates(vertices);
        gi.setNormals(normals);
        gi.setContourCounts(strips);
        gi.setStripCounts(count);
        gi.setTextureCoordinateParams(1, 2);
        gi.setTextureCoordinates(0, texcoords);

        st.stripify(gi);

        geom[1] = gi.getIndexedGeometryArray(false);

        voff = toff = noff = 0;
        // bottom
        for (int i = 0; i < ccnt; i++) {
            Vector<int[]> contour = contours.elementAt(i);
            count[i] = contour.size();
            // don't reverse path to get front and back face right
            for (int j = 0; j < count[i]; j++) {
                int[] v = contour.elementAt(j);
                vertices[voff++] = v[0]/vw-vo;
                vertices[voff++] = -v[1]/vh+vo;
                vertices[voff++] = -0.5;
                normals[noff++] = 0.0f;
                normals[noff++] = 0.0f;
                normals[noff++] = -1.0f;
                texcoords[toff++] = v[0]/tw;
                texcoords[toff++] = 1.0f-v[1]/th;
            }
        }

        gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);

        gi.setCoordinates(vertices);
        gi.setNormals(normals);
        gi.setContourCounts(strips);
        gi.setStripCounts(count);
        gi.setTextureCoordinateParams(1, 2);
        gi.setTextureCoordinates(0, texcoords);

        st.stripify(gi);

        geom[2] = gi.getIndexedGeometryArray(false);
       
        return geom;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.