Package org.mt4j.components.visibleComponents

Examples of org.mt4j.components.visibleComponents.GeometryInfo


   * the normals
   */
  private Vector3D[] getFaceOrVertexNormals(){
    Vector3D[] normals = new Vector3D[this.triangles.length*3];
   
    GeometryInfo geom = this.getGeometryInfo();
    if (geom.isIndexed()){
      //Create smooth vertex normals, smoothed across all neighbors
      int[] indices = geom.getIndices();
      normals = new Vector3D[geom.getVertices().length];
      for (int i = 0; i < indices.length/3; i++) {
        if (normals[indices[i*3]] == null){
          normals[indices[i*3]] = triangles[i].getNormalLocal().getCopy();
        }else{
          normals[indices[i*3]].addLocal(triangles[i].getNormalLocal());
 
View Full Code Here


      System.out.println("\nGroup: \"" + currentGroup.name + "\" ->Vertices: " + currentGroup.verticesForGroup.size()+ " ->TextureCoords: " + currentGroup.texCoordsForGroup.size() + " ->Indices: " + currentGroup.indexArray.length + " ->Texcoord Indices: " + currentGroup.texCoordIndexArray.length );
      System.out.println();

      if (vertices.length > 2){
        GeometryInfo geometry  = null;

        //Load as all vertex normals smoothed if creaseAngle == 180;
        if (creaseAngle == 180){
          geometry = normalGenerator.generateSmoothNormals(pa, vertices , indices, textureCoords, texIndices, creaseAngle, flipTextureY, flipTextureX);
        }else{
View Full Code Here

  private float restituion;
 
  public PhysicsPolygon(Vertex[] vertices, Vector3D position, PApplet applet,
      World world, float density, float friction, float restitution, float worldScale
  ) {
    super(applet, new GeometryInfo(applet, new Vertex[]{}), false);
    this.angle = 0;
    this.world = world;
    this.density = density;
    this.friction = friction;
    this.restituion = restitution;
   
    this.setGestureAllowance(ScaleProcessor.class, false);
    this.setGestureAllowance(RotateProcessor.class, false);
   
    Vertex.scaleVectorArray(vertices, Vector3D.ZERO_VECTOR, 1f/worldScale, 1f/worldScale, 1);
   
    position.scaleLocal(1f/worldScale); //FIXME REALLY?
   
      GluTrianglulator triangulator = new GluTrianglulator(applet);
    List<Vertex> physicsTris = triangulator.tesselate(vertices, GLU.GLU_TESS_WINDING_NONZERO);
    Vertex[] triangulatedBodyVerts = physicsTris.toArray(new Vertex[physicsTris.size()]);
    triangulator.deleteTess();
    //Set the triangulated vertices as the polygons (mesh's) vertices
    this.setGeometryInfo(new GeometryInfo(applet, triangulatedBodyVerts));
   
    this.translate(position);
    Vector3D realBodyCenter = this.getCenterPointGlobal(); //FIXME geht nur if detached from world //rename futurebodycenter?
    //Reset position
    this.translate(position.getScaled(-1));
   
    //Now get the position where the global center will be after setting the shape at the desired position
    this.setPositionGlobal(position);
    Vector3D meshCenterAtPosition = this.getCenterPointGlobal();
   
    //Compute the distance we would have to move the vertices for the body creation
    //so that the body.position(center) is at the same position as our mesh center
    Vector3D realBodyCenterToMeshCenter = meshCenterAtPosition.getSubtracted(realBodyCenter);
    //System.out.println("Diff:" +  realBodyCenterToMeshCenter);
   
    //Move the vertices so the body position is at the center of the shape
    Vertex.translateVectorArray(triangulatedBodyVerts, realBodyCenterToMeshCenter);
   
    this.setGeometryInfo(new GeometryInfo(applet, triangulatedBodyVerts));
   
//    MTPolygon p = new MTPolygon(vertices, applet);
//    p.translate(position);
////    p.setPositionGlobal(position);
//    Vector3D realBodyCenter = p.getCenterPointGlobal(); //FIXME geht nur if detached from world //rename futurebodycenter?
View Full Code Here

   *
   * @param vertices the vertices
   * @param pApplet the applet
   */
  public AbstractShape(Vertex[] vertices, PApplet pApplet) {
    this(new GeometryInfo(pApplet, vertices), pApplet);
  }
View Full Code Here

//    MTTriangleMesh mesh = triangulator.toTriangleMesh(bezierContours, windingRule);
   
    triangulator.tesselate(bezierContours, windingRule);
    List<Vertex> tris = triangulator.getTriList();
    Vertex[] verts = tris.toArray(new Vertex[tris.size()]);
    GeometryInfo geom = new GeometryInfo(pa, verts);
   
//    MTTriangleMesh mesh = new MTTriangleMesh(pa, geom);
    MTTriangleMesh mesh = new SVGMesh(pa, geom);
   
    //TODO put outline contourse in own class SVGMesh!
View Full Code Here

        getCanvas().addChild(cube);
       
        MTSphere sphere = new MTSphere(getMTApplication(), "sphere", 30,30, 130);
        getCanvas().addChild(sphere);
       
        MTTriangleMesh mesh = new MTTriangleMesh(getMTApplication(), new GeometryInfo(getMTApplication(), new Vertex[]{
          new Vertex(0,0,0),
          new Vertex(100,0,0),
          new Vertex(50,50,0),
        }));
        getCanvas().addChild(mesh);
View Full Code Here

     * @param useEvenSlices
     *            Slice sphere evenly along the Z axis
     */
    public MTSphere(PApplet pa, String name, Vector3D center, int zSamples,
            int radialSamples, float radius, boolean useEvenSlices, TextureMode texMode) {
        super(pa, new GeometryInfo(pa, new Vertex[]{}));
        this.textureMode = texMode;
        this.updateGeometry(pa, center, zSamples, radialSamples, radius, useEvenSlices);
       
        this.setBoundsBehaviour(AbstractShape.BOUNDS_ONLY_CHECK);
       
View Full Code Here

    }
      
        //get indices
        int[] indices = this.getIndexData();

      GeometryInfo geomInfo = new GeometryInfo(pa, verts, norms, indices);
      this.setGeometryInfo(geomInfo);
    }
View Full Code Here

   * @param pApplet the applet
   * @param size the size
   */
  public MTCube(PApplet pApplet, float size) {
    super(pApplet,  
        new GeometryInfo(pApplet, new Vertex[]{
//                 new Vertex( 0.0f, 0.0f, 1.0f)
//                ,new Vertex( 1.0f, 0.0f, 1.0f)
//                ,new Vertex( 1.0f, 1.0f, 1.0f)
//                ,new Vertex( 0.0f, 1.0f, 1.0f)
//
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.GeometryInfo

Copyright © 2018 www.massapicom. 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.