Package com.jme3.math

Examples of com.jme3.math.Vector3f


    m_CenterPoint.x = ((m_Vertex[VERT_A].x + m_Vertex[VERT_B].x + m_Vertex[VERT_C].x) / 3);
    m_CenterPoint.y = ((m_Vertex[VERT_A].y + m_Vertex[VERT_B].y + m_Vertex[VERT_C].y) / 3);
    m_CenterPoint.z = ((m_Vertex[VERT_A].z + m_Vertex[VERT_B].z + m_Vertex[VERT_C].z) / 3);

    // compute the midpoint of each cell wall
    m_WallMidpoint[0] = new Vector3f(
        (m_Vertex[VERT_A].x + m_Vertex[VERT_B].x) / 2.0f,
        (m_Vertex[VERT_A].y + m_Vertex[VERT_B].y) / 2.0f,
        (m_Vertex[VERT_A].z + m_Vertex[VERT_B].z) / 2.0f);
    m_WallMidpoint[1] = new Vector3f(
        (m_Vertex[VERT_C].x + m_Vertex[VERT_B].x) / 2.0f,
        (m_Vertex[VERT_C].y + m_Vertex[VERT_B].y) / 2.0f,
        (m_Vertex[VERT_C].z + m_Vertex[VERT_B].z) / 2.0f);

    m_WallMidpoint[2] = new Vector3f(
        (m_Vertex[VERT_C].x + m_Vertex[VERT_A].x) / 2.0f,
        (m_Vertex[VERT_C].y + m_Vertex[VERT_A].y) / 2.0f,
        (m_Vertex[VERT_C].z + m_Vertex[VERT_A].z) / 2.0f);

    // compute the distances between the wall midpoints
    Vector3f WallVector;
    WallVector = m_WallMidpoint[0].subtract(m_WallMidpoint[1]);
    m_WallDistance[0] = WallVector.length();

    WallVector = m_WallMidpoint[1].subtract(m_WallMidpoint[2]);
    m_WallDistance[1] = WallVector.length();

    WallVector = m_WallMidpoint[2].subtract(m_WallMidpoint[0]);
    m_WallDistance[2] = WallVector.length();

  }
View Full Code Here


    Random rand = new Random();
    Vector2f ret =
    this.m_Side[0].EndPointA().add(this.m_Side[0].GetDirection().mult(rand.nextFloat()).add(
        this.m_Side[1].GetDirection().mult(rand.nextFloat())));
    ForcePointToCellCollumn(ret);
    Vector3f vec = new Vector3f(ret.x, 0, ret.y);
    MapVectorHeightToCell(vec);
    return vec;
  }
View Full Code Here

    m_CellPlane = (Plane) capsule.readSavable("cellplane", new Plane());
    Savable[] sav = capsule.readSavableArray("vertex", new Vector3f[3]);
        for (int i = 0; i < sav.length; i++){
            m_Vertex[i] = (Vector3f) sav[i];
        }
    m_CenterPoint = (Vector3f) capsule.readSavable("center", new Vector3f());
    sav = capsule.readSavableArray("sides", new Line2D[3]);
        for (int i = 0; i < sav.length; i++){
            m_Side[i] = (Line2D) sav[i];
        }
    //done one level above in mesh
View Full Code Here

  //
  // Force a point to be inside the cell
  //
  // -------------------------------------------------------------------------------------://
  public Vector3f SnapPointToCell(Cell Cell, Vector3f Point) {
    Vector3f PointOut = Point;

    if (!Cell.IsPointInCellCollumn(PointOut)) {
      Cell.ForcePointToCellCollumn(PointOut);
    }
View Full Code Here

    float ThisDistance;
    Cell ClosestCell = null;

    for (Cell pCell : mCellArray) {
      if (pCell.IsPointInCellCollumn(Point)) {
        Vector3f NewPosition = new Vector3f(Point);
        pCell.MapVectorHeightToCell(NewPosition);
        if(NewPosition.y <= Point.y || anyNearest){
          ThisDistance = Math.abs(NewPosition.y - Point.y);
 
          if (FoundHomeCell) {
            if (ThisDistance < ClosestHeight) {
              ClosestCell = pCell;
              ClosestHeight = ThisDistance;
            }
          } else {
            ClosestCell = pCell;
            ClosestHeight = ThisDistance;
            FoundHomeCell = true;
          }
        }
      }
     
      if (!FoundHomeCell) {
        Vector2f Start = new Vector2f(pCell.CenterPoint().x, pCell
            .CenterPoint().z);
        Vector2f End = new Vector2f(Point.x, Point.z);
        Line2D MotionPath = new Line2D(Start, End);

        ClassifyResult Result = pCell.ClassifyPathToCell(MotionPath);

        if (Result.result == Cell.PATH_RESULT.EXITING_CELL) {
          Vector3f ClosestPoint3D = new Vector3f(
              Result.intersection.x, 0.0f, Result.intersection.y);
          pCell.MapVectorHeightToCell(ClosestPoint3D);

          ClosestPoint3D = ClosestPoint3D.subtract(Point);

          ThisDistance = ClosestPoint3D.length();

          if (ThisDistance < ClosestDistance) {
            ClosestDistance = ThisDistance;
            ClosestCell = pCell;
          }
View Full Code Here

    Cell ClosestBelow = null;
    float ClosestBelowHeight = ClosestHeight;

    for (Cell pCell : mCellArray) {
      if (pCell.IsPointInCellCollumn(Point)) {
        Vector3f NewPosition = new Vector3f(Point);
        pCell.MapVectorHeightToCell(NewPosition);

        ThisDistance = Math.abs(NewPosition.y - Point.y);

        if (FoundHomeCell) {
View Full Code Here

    // if we found a path, build a waypoint list
    // out of the cells on the path
    if (FoundPath) {
      Cell TestCell = StartCell;
      Vector3f NewWayPoint;

      // Setup the Path object, clearing out any old data
      NavPath.setup(StartPos, StartCell, this);

      // Step through each cell linked by our A* algorythm
 
View Full Code Here

   
    private void dropBox() {
      Geometry g = new Geometry("Box",new Box());
      g.setMaterial(matWireframe);
      Vector3f pos = cam.getLocation().clone();
      singles.getNavManager().snapToGround(pos);
      singles.getSceneManager().changeAnyNode(rootNode, g, Action.ADD);
     
  }
View Full Code Here

          spatial = null;
        }
      } else {
        //update position
        if(spatial != null){
          Vector3f v = spatial.getLocalTranslation();
          v.y+= speed*tpf;
          spatial.setLocalTranslation(v.x, v.y, v.z);
        }
      }
    }
View Full Code Here

      // minus 18*2048
      int yd = (Integer.parseInt(xy[1])) * 256 - (18 * 2048);
     
      // center is in top left corner for nav mesh to be consistent with
      // this for borders move x right, move y up by half size
      Vector3f offset = new Vector3f(xd + 128, 0, yd - 128);
      System.out.println("Offset for "+from.getParentFile().getName()+"/nav2.obj should be at:"+offset);
      }
     
      navMesh.loadFromMesh(g.getMesh(), Vector3f.ZERO, isMeshRelative);
     
View Full Code Here

TOP

Related Classes of com.jme3.math.Vector3f

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.