Examples of TriangleArray


Examples of com.xith3d.scenegraph.TriangleArray

        super(parent);
    }

    protected Shape3D createShape() {
        float[] coords = GeodeMaker.createGeode(10);
      TriangleArray ta = new TriangleArray(coords.length / 3, GeometryArray.COORDINATES | GeometryArray.NORMALS);
      ta.setCoordinates(0,coords);
      ta.setNormals(0,coords);
     
      Shape3D s = new Shape3D(ta);
        anonymousNodeNumber++;
        name = NodeResourcesManager.getNodeName("Sphere") + ((anonymousNodeNumber == 1) ? "" : String.valueOf(anonymousNodeNumber));
        s.setName(name);
View Full Code Here

Examples of javax.media.j3d.TriangleArray

    }

    // Create a triangle array using NIO.
    // Unfortunately, Sun picking utilities don't handle NIO very well, thus
    // we need to overload a method
    TriangleArray ta = new TriangleArray(triangles.length, GeometryArray.BY_REFERENCE|GeometryArray.USE_NIO_BUFFER|GeometryArray.COORDINATES|GeometryArray.NORMALS|GeometryArray.COLOR_3) {
      public double[] getCoordRefDouble() {
        // When picking, tests have shown that NIO buffer copy has no noticeable impact
        // on performance. So, it is actually better to copy the array each time the picking is
        // done than to hog memory with a permanent copy.
        // It is also still better to copy the buffer only when picking rather than at each rendering
        double[] array = new double[getVertexCount()*3];
        DoubleBuffer db = (DoubleBuffer)super.getCoordRefBuffer().getBuffer();
        db.rewind();
        db.get(array); // optimized get
        return array;
      }
    };
      ta.setCoordRefBuffer(new J3DBuffer(nioCoords));

      // Use Java3D utilities to compute normals
    GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_ARRAY);
    double[] coords = new double[data[0].length*3];
    nioCoords.position(0);
    nioCoords.get(coords);
    gi.setCoordinates(coords);
        // generate normals
        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);
        Vector3f[] n3f = gi.getNormals();
        int[] ni = gi.getNormalIndices();
        float[] tmp = new float[3];
    for (int i=0; i<ni.length; ++i) {
      n3f[ni[i]].get(tmp);
      nioNormals.put(tmp);
    }
    ta.setNormalRefBuffer(new J3DBuffer(nioNormals));
       
    // Setup color buffer
    ta.setColorRefBuffer(new J3DBuffer(nioColors));
      ta.setCapability(TriangleArray.ALLOW_COLOR_WRITE);
      ta.setCapabilityIsFrequent(TriangleArray.ALLOW_COLOR_WRITE);
     
      Shape3D shape3d = new Shape3D(ta);
     
    // The appearance of a shape has many interesting features.
      // In particular, in case one wants to display lines (edges) over the shape,
View Full Code Here

Examples of javax.media.j3d.TriangleArray

          LineArray lineArray = (LineArray)geometryArray;
          for (int i = 0, n = lineArray.getVertexCount(); i < n; i += 2) {
            writeLine(lineArray, i, i + 1, vertexIndexSubstitutes, textureCoordinatesIndexSubstitutes);
          }
        } else if (geometryArray instanceof TriangleArray) {
          TriangleArray triangleArray = (TriangleArray)geometryArray;
          for (int i = 0, n = triangleArray.getVertexCount(); i < n; i += 3) {
            writeTriangle(triangleArray, i, i + 1, i + 2,
                vertexIndexSubstitutes, normalIndexSubstitutes, oppositeSideNormalIndexSubstitutes,  
                normalsDefined, textureCoordinatesIndexSubstitutes, textureCoordinatesGenerated, cullFace);
          }
        } else if (geometryArray instanceof QuadArray) {
View Full Code Here

Examples of javax.media.j3d.TriangleArray

            }
          }
        }
      } else {
        if (geometryArray instanceof TriangleArray) {
          TriangleArray triangleArray = (TriangleArray)geometryArray;
          geometryPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 1000);
          for (int i = 0, triangleIndex = 0; i < vertexCount; i += 3) {
            addTriangleToPath(triangleArray, i, i + 1, i + 2, vertices,
                geometryPath, triangleIndex++, nodeArea);
          }
View Full Code Here

Examples of javax.media.j3d.TriangleArray

            for (int i = 0, n = lineArray.getVertexCount(); i < n; i += 2) {
              exportLine(lineArray, i, i + 1, verticesIndices, i);
            }
          } else {
            if (geometryArray instanceof TriangleArray) {
              TriangleArray triangleArray = (TriangleArray)geometryArray;
              for (int i = 0, n = triangleArray.getVertexCount(), triangleIndex = 0; i < n; i += 3) {
                triangleIndex = exportTriangle(triangleArray, i, i + 1, i + 2,
                    verticesIndices, triangleIndex, vertices, exportedTriangles);
              }
            } else if (geometryArray instanceof QuadArray) {
              QuadArray quadArray = (QuadArray)geometryArray;
View Full Code Here

Examples of javax.media.j3d.TriangleArray

        leafShape3D.setAppearance(appearance);
    }

    private void createLeafGeometry() {
        leafGeometry = new TriangleArray(3, GeometryArray.COORDINATES | GeometryArray.NORMALS);
        leafGeometry.setCapability(TriangleArray.ALLOW_COORDINATE_WRITE);
        resetGeometryPoints();
        leafShape3D.setGeometry(leafGeometry);

        Vector3f polygonNormal = NormalHelper.computeNormal(new Point3d(0, 0, 0), state.getEndPoint1().toPointValue(),
View Full Code Here

Examples of javax.media.j3d.TriangleArray

        leafShape3D.setAppearance(appearance);
    }

    private void createLeafGeometry() {
        leafGeometry = new TriangleArray(3, GeometryArray.COORDINATES | GeometryArray.NORMALS);
        leafGeometry.setCapability(TriangleArray.ALLOW_COORDINATE_WRITE);
        leafGeometry.setCoordinate(0, new Point3d(0, 0, 0));
        resetGeometryPoints();
        leafShape3D.setGeometry(leafGeometry);
View Full Code Here

Examples of javax.media.j3d.TriangleArray

        assertNotNull(leafShape3D);

        // test position and geometry
        Geometry leafGeometry = leafShape3D.getGeometry();
        assertTrue(leafGeometry instanceof TriangleArray);
        TriangleArray leafTriangle = (TriangleArray) leafGeometry;
        assertEquals(3, leafTriangle.getVertexCount());

        Point3d actualStartPoint = new Point3d();
        Point3d actualEndPoint1 = new Point3d();
        Point3d actualEndPoint2 = new Point3d();
        leafTriangle.getCoordinate(0, actualStartPoint);
        leafTriangle.getCoordinate(1, actualEndPoint1);
        leafTriangle.getCoordinate(2, actualEndPoint2);
        PointTestHelper.assertPointEquals(new Point3d(0, 0, 0), actualStartPoint);
        PointTestHelper.assertPointEquals(leaf3DState.getEndPoint1().toPointValue(), actualEndPoint1);
        PointTestHelper.assertPointEquals(leaf3DState.getEndPoint2().toPointValue(), actualEndPoint2);
    }
View Full Code Here

Examples of javax.media.j3d.TriangleArray

/*      */     }
/*      */
/* 2554 */     GeometryArray ga = null;
/* 2555 */     switch (this.prim) {
/*      */     case 1:
/* 2557 */       TriangleArray ta = new TriangleArray(vertexCount, vertexFormat, this.texCoordSetCount, this.texCoordSetMap);
/*      */
/* 2559 */       ga = ta;
/* 2560 */       break;
/*      */     case 2:
/* 2563 */       QuadArray qa = new QuadArray(vertexCount, vertexFormat, this.texCoordSetCount, this.texCoordSetMap);
View Full Code Here

Examples of javax.media.j3d.TriangleArray

/* 402 */       totalVerts += this.currPrimEndVertex[i] - this.currPrimStartVertex[i];
/*     */     }
/*     */
/* 407 */     if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 409 */       obj = new TriangleArray(totalVerts, 35, 1, this.texCoordSetMap);
/*     */     }
/* 416 */     else if (((this.flags & 0x1) == 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 418 */       obj = new TriangleArray(totalVerts, 33, 1, this.texCoordSetMap);
/*     */     }
/* 424 */     else if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) == 0))
/*     */     {
/* 426 */       obj = new TriangleArray(totalVerts, 3);
/*     */     }
/*     */     else
/*     */     {
/* 431 */       obj = new TriangleArray(totalVerts, 1);
/*     */     }
/*     */
/* 435 */     Point3f[] newpts = new Point3f[totalVerts];
/* 436 */     Vector3f[] newnormals = new Vector3f[totalVerts];
/* 437 */     TexCoord2f[] newtcoords = new TexCoord2f[totalVerts];
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.