Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vector3D


    gl.glEnd();
  }

  public void drawNormals() {
    Vector3D a,b;

    gl.glBegin(GL.GL_LINES);
      // near
      a = (ntr .getAdded( ntl).getAdded(nbr).getAdded(nbl)).scaleLocal(0.25f);
      b = a.getAdded(planes[NEARP].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);

      // far
      a = (ftr .getAdded( ftl).getAdded(fbr).getAdded(fbl)).scaleLocal(0.25f);
      b = a.getAdded(planes[FARP].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);

      // left
      a = (ftl .getAdded( fbl).getAdded(nbl).getAdded(ntl)).scaleLocal(0.25f);
      b = a.getAdded(planes[LEFT].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);
     
      // right
      a = (ftr .getAdded( nbr).getAdded(fbr).getAdded(ntr)).scaleLocal(0.25f);
      b = a.getAdded(planes[RIGHT].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);
     
      // top
      a = (ftr .getAdded( ftl).getAdded(ntr).getAdded(ntl)).scaleLocal(0.25f);
      b = a.getAdded(planes[TOP].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);
     
      // bottom
      a = (fbr .getAdded( fbl).getAdded(nbr).getAdded(nbl)).scaleLocal(0.25f);
      b = a.getAdded(planes[BOTTOM].normal);
      gl.glVertex3f(a.x,a.y,a.z);
      gl.glVertex3f(b.x,b.y,b.z);

    gl.glEnd();
  }
View Full Code Here


    knobRight.setUseDisplayList(false);
    float origHeight = knobRight.getHeightXY(TransformSpace.LOCAL);
   
    //Snap to upper left 0,0
    Vertex[] originalVerts = knobRight.getVerticesLocal();
    originalVerts = Vertex.translateArray(originalVerts, Vector3D.ZERO_VECTOR.getSubtracted(new Vector3D(originalVerts[0])));
   
    upDownOrderVerticalRightOut = Vertex.getDeepVertexArrayCopy(originalVerts);
    //Scale to desired height
    Vertex.scaleVectorArray(upDownOrderVerticalRightOut, Vector3D.ZERO_VECTOR, (1f/origHeight) * tileHeight, (1f/origHeight) * tileHeight, 1);
       
    downUpOrderVerticalRightOut = getInvertOrderCopy(upDownOrderVerticalRightOut);
//    MTPolygon p1 = new MTPolygon(getMTApplication(), downUpOrderVerticalRightOut);
//    getCanvas().addChild(p1);
   
    upDownOrderVerticalLeftOut = Vertex.getDeepVertexArrayCopy(upDownOrderVerticalRightOut);
    Vertex.scaleVectorArray(upDownOrderVerticalLeftOut, new Vector3D(0,origHeight/2f), -1, 1, 1);
//    MTPolygon p2 = new MTPolygon(getMTApplication(), vertsVerticalLeftOut);
//    getCanvas().addChild(p2);
   
    downUpOrderVerticalLeftOut = getInvertOrderCopy(upDownOrderVerticalLeftOut);
   
    leftRightHorizontalUpOut = Vertex.getDeepVertexArrayCopy(originalVerts);
    Vertex.rotateZVectorArray(leftRightHorizontalUpOut, Vector3D.ZERO_VECTOR, -90);
    //Scale to desired width
    Vertex.scaleVectorArray(leftRightHorizontalUpOut, Vector3D.ZERO_VECTOR, (1f/origHeight) * tileWidth, (1f/origHeight) * tileWidth, 1);
//    MTPolygon p3 = new MTPolygon(getMTApplication(), leftRightHorizontalUpOut);
//    getCanvas().addChild(p3);
   
    rightLeftHorizontalUpOut = getInvertOrderCopy(leftRightHorizontalUpOut);
   
    leftRightOrderHorizontalDownOut = Vertex.getDeepVertexArrayCopy(leftRightHorizontalUpOut);
    Vertex.scaleVectorArray(leftRightOrderHorizontalDownOut, new Vector3D(origHeight/2f,0), 1, -1, 1);
//    MTPolygon p4 = new MTPolygon(getMTApplication(), leftRightOrderHorizontalDownOut);
//    getCanvas().addChild(p4);
   
    rightLeftOrderHorizontalDownOut = getInvertOrderCopy(leftRightOrderHorizontalDownOut);
  }
View Full Code Here

       
   
    getCanvas().addChild(list);
    list.rotateZ(list.getCenterPointLocal(), -90, TransformSpace.LOCAL);
//    list.setPositionGlobal(new Vector3D(app.width/2f, app.height - list.getHeightXY(TransformSpace.GLOBAL) - 1));
    list.setPositionGlobal(new Vector3D(app.width/2f, app.height/2f));
//    list.setAnchor(PositionAnchor.UPPER_LEFT);
//    list.setPositionGlobal(new Vector3D(app.width/2f - list.getWidthXY(TransformSpace.GLOBAL)/2f, app.height - 20));
    getCanvas().setFrustumCulling(true);
   
    //Scene transition effect
View Full Code Here

//    text.setPositionRelativeToParent(cell.getPosition(TransformSpace.LOCAL));
//    text.translate(new Vector3D(realListCellWidth - topShift, 0));
//    cell.setAnchor(oldCellAnchor);
   
    text.setPositionRelativeToParent(cell.getCenterPointLocal());
    text.translate(new Vector3D(realListCellWidth*0.5f - text.getHeightXY(TransformSpace.LOCAL)*0.5f, 0));
    ///
  }
View Full Code Here

    clearTails();
   
    this.registerInputProcessor(new MultipleDragProcessor(app));
    this.addGestureListener(MultipleDragProcessor.class, new DragListener());
   
    Vector3D norm = new Vector3D(0,0,1);
    Vector3D pointInPlane = new Vector3D(0,0,0);
    plane = new Plane(pointInPlane, norm);
   
//    /*
    if (useTexture){
      this.setNoStroke(true);
View Full Code Here

  private void advanceGesture(TailGesture gesture) {
    // Move a Gesture one step
    if (gesture.exists) { // check
      int nPts = gesture.nPoints;
      int nPts1 = nPts-1;
      Vector3D path[];
      float jx = gesture.jumpDx;
      float jy = gesture.jumpDy;

      if (nPts > 0) {
        path = gesture.path;
View Full Code Here

 
 
  private class DragListener implements IGestureEventListener{
    public boolean processGestureEvent(MTGestureEvent ge) {
      DragEvent de = (DragEvent)ge;
      Vector3D to = de.getTo();
      switch (de.getId()) {
      case DragEvent.GESTURE_DETECTED:{
        currentGestureID = (currentGestureID+1) % nGestures;
        //System.out.println("New current gesture ID => " + currentGestureID);
        TailGesture G = gestureArray[currentGestureID];
View Full Code Here

          }
        }
        return false;
      }
    });
    r.setPositionGlobal(new Vector3D(r.getWidthXY(TransformSpace.GLOBAL)/2f + 3 , r.getHeightXY(TransformSpace.GLOBAL)/2f + 3));
    this.getCanvas().addChild(r);
   
    //Image list
    float cellWidth = 180;
    float cellHeight = 40;
View Full Code Here

        //Get the faces normal
//        Vector3D faceNormal = Tools3D.getNormal(v0, v1, v2, true); //myFace.normal;//
//        Vector3D faceNormal = myFace.normal.getCopy();
//        faceNormal.normalizeLocal();
       
        Vector3D faceNormal = myFace.normalNormalized;
       
        Vector3D normalP0;
        if (vdP0.getNeighborFaces().size() > 1){
//          logger.debug("Calcing v normal of face: " + myFace.index + " P0");
          normalP0 = vdP0.calcVertexNormalAllNeighbors();
        }else{
          normalP0 = faceNormal;
        }
       
        Vector3D normalP1;
        if (vdP1.getNeighborFaces().size() > 1){
//          logger.debug("Calcing v normal of face: " + myFace.index + " P1");
          normalP1 = vdP1.calcVertexNormalAllNeighbors();
        }else{
          normalP1 = faceNormal;
        }
       
        Vector3D normalP2;
        if (vdP2.getNeighborFaces().size() > 1){
//          logger.debug("Calcing v normal of face: " + myFace.index + " P2");
          normalP2 = vdP2.calcVertexNormalAllNeighbors();
        }else{
          normalP2 = faceNormal;
View Full Code Here

         
          //Hole vertexdata auf das das currentFace an dem aktuellen zeiger (p0,p1,p2) zeigt
          VertexData currentVertexDataP0OrP1OrP2 = vertexDatas.get(currentVertexPointer);
         
          //Get normal saved in the vertexdata at position Face.Px
          Vector3D currentFacesCurrentVDNormal = currentVertexDataP0OrP1OrP2.getUniqueVertexNormal();
         
          //Get vertex normal array calculated and saved in the face for each point Px
          Vector3D[] vertexNormalsCurrentFace = currentFace.getVertexNormals();
         
          //Check if the vertexnormal data at the pointer is null -> thats the case before first time a vertexnormal is set here
          if (currentFacesCurrentVDNormal == null){
            currentVertexDataP0OrP1OrP2.setUniqueVertexNormal(vertexNormalsCurrentFace[i]);
            logger.debug("Face " + j + ", vdP" + i + " (Vertex: " + vertexDatas.get(currentVertexPointer).getVertex() + ")" + " normal not yet set -> set it: " + vertexNormalsCurrentFace[i]);
          }else{//Vertexdata at index already contains a vertexnormal -> check if its the equal to this faces currentVD's
           
            if (currentFacesCurrentVDNormal.equalsVectorWithTolerance(vertexNormalsCurrentFace[i], ToolsMath.ZERO_TOLERANCE)){
              logger.debug("Face " + j + ", vdP" + i +  " (Vertex: " + vertexDatas.get(currentVertexPointer).getVertex() + ")" + " already CONTAINS a normal with the same values as the normal of this faces point ->  we can leave the index and normal at the same place: N:" + vertexNormalsCurrentFace[i]);
            }else{
              int duplicateIndexOfSameVertDiffNormal = currentVertexDataP0OrP1OrP2.getVertDuplicateSameVertDiffNormalListIndex(vertexNormalsCurrentFace[i]);
             
              if (duplicateIndexOfSameVertDiffNormal != -1){ //Es gibt schon ein duplicate mit gleichen tex coords wie dieses hier, adde bei duplicateIndex
View Full Code Here

TOP

Related Classes of org.mt4j.util.math.Vector3D

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.