Package com.jme3.math

Examples of com.jme3.math.Vector2f


    return (float) Math.sqrt(xdist + ydist);
  }

   public Vector2f GetDirection()
  {
     Vector2f Direction = (m_PointB.subtract(m_PointA));
    return Direction.normalize();
//    return Direction;
  }
View Full Code Here


    m_NormalCalculated = true;
   
  }
 
  public static void selfTest() {
    Line2D a = new Line2D(new Vector2f(-2,0), new Vector2f(2,0));
    Line2D b = new Line2D(new Vector2f(-2,1), new Vector2f(2,-1));
    Line2D.LINE_CLASSIFICATION res = a.Intersection(b, null);
    if(res == LINE_CLASSIFICATION.COLLINEAR || res == LINE_CLASSIFICATION.PARALELL)
      System.out.println("Failed intersection verrification");

    if(a.ClassifyPoint(new Vector2f(0,1), 0.0f) != POINT_CLASSIFICATION.LEFT_SIDE)
      System.out.println("Failed left test");

    if(a.ClassifyPoint(new Vector2f(0,-1), 0.0f) != POINT_CLASSIFICATION.RIGHT_SIDE)
      System.out.println("Failed right test");
   
    if(a.ClassifyPoint(new Vector2f(0,0), 0.0f) != POINT_CLASSIFICATION.ON_LINE)
      System.out.println("Failed on line test");
  }
View Full Code Here

    capsule.write(m_Normal, "m_Normal", null);   
  }

  public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    m_PointA = (Vector2f) capsule.readSavable("m_PointA", new Vector2f());
    m_PointB = (Vector2f) capsule.readSavable("m_PointB", new Vector2f());
    m_Normal = (Vector2f) capsule.readSavable("m_Normal", new Vector2f());
  }
View Full Code Here

    return id;
  }

  private void ComputeCellData() {
    // create 2D versions of our verticies
    Vector2f Point1 = new Vector2f(m_Vertex[VERT_A].x, m_Vertex[VERT_A].z);
    Vector2f Point2 = new Vector2f(m_Vertex[VERT_B].x, m_Vertex[VERT_B].z);
    Vector2f Point3 = new Vector2f(m_Vertex[VERT_C].x, m_Vertex[VERT_C].z);

    // innitialize our sides
    m_Side[SIDE_AB] = new Line2D(Point1, Point2); // line AB
    m_Side[SIDE_BC] = new Line2D(Point2, Point3); // line BC
    m_Side[SIDE_CA] = new Line2D(Point3, Point1); // line CA
View Full Code Here

   * Test to see if a 3D point is within the cell by projecting it down to 2D and calling the above method.
   * @param TestPoint  Point to test if it would be within this cell
   * @return  true if the point would be in that cell, false otherwise
   */
  public boolean IsPointInCellCollumn(Vector3f TestPoint) {
    return (IsPointInCellCollumn(new Vector2f(TestPoint.x, TestPoint.z)));
  }
View Full Code Here

   * --------------------------------------------------------------------------
   * ----------------
   */
  void ProjectPathOnCellWall(int SideNumber, Line2D MotionPath) {
    // compute the normalized vector of the cell wall in question
    Vector2f WallNormal = m_Side[SideNumber].EndPointB().subtract(
        m_Side[SideNumber].EndPointA());
    WallNormal = WallNormal.normalize();

    // determine the vector of our current movement
    Vector2f MotionVector = MotionPath.EndPointB().subtract(
        MotionPath.EndPointA());

    // compute dot product of our MotionVector and the normalized cell wall
    // this gives us the magnatude of our motion along the wall

    float DotResult = MotionVector.dot(WallNormal);

    // our projected vector is then the normalized wall vector times our new
    // found magnatude
    MotionVector = WallNormal.mult(DotResult);

    // redirect our motion path along the new reflected direction
    MotionPath.SetEndPointB(MotionPath.EndPointA().add(MotionVector));

    //
    // Make sure starting point of motion path is within the cell
    //
    Vector2f NewPoint = MotionPath.EndPointA();
    ForcePointToCellCollumn(NewPoint);
    MotionPath.SetEndPointA(NewPoint);

    //
    // Make sure destination point does not intersect this wall again
View Full Code Here

      Distance = Math.abs(Distance);
      Distance = (Epsilon > Distance ? Epsilon : Distance);

      // this point needs adjustment
      Vector2f Normal = m_Side[SideNumber].getNormal();
      Normal = Normal.mult(Distance);
      TestPoint.x += Normal.x;
      TestPoint.y += Normal.y;
      return (true);
    }
    return (false);
View Full Code Here

  //
  // Force a 3D point to the interior side of the specified wall.
  //
  // -------------------------------------------------------------------------------------://
  boolean ForcePointToWallInterior(int SideNumber, Vector3f TestPoint) {
    Vector2f TestPoint2D = new Vector2f(TestPoint.x, TestPoint.z);
    boolean PointAltered = ForcePointToWallInterior(SideNumber, TestPoint2D);

    if (PointAltered) {
      TestPoint.x = TestPoint2D.x;
      TestPoint.z = TestPoint2D.y;
View Full Code Here

  //
  // -------------------------------------------------------------------------------------://

  boolean ForcePointToCellCollumn(Vector2f TestPoint) {
    // create a motion path from the center of the cell to our point
    Line2D TestPath = new Line2D(new Vector2f(m_CenterPoint.x,
        m_CenterPoint.z), TestPoint);

    ClassifyResult result = ClassifyPathToCell(TestPath);
    // compare this path to the cell.

    if (result.result == PATH_RESULT.EXITING_CELL) {
      Vector2f PathDirection = new Vector2f(result.intersection.x
          - m_CenterPoint.x, result.intersection.y - m_CenterPoint.z);

      PathDirection = PathDirection.mult(0.9f);

      TestPoint.x = m_CenterPoint.x + PathDirection.x;
      TestPoint.y = m_CenterPoint.z + PathDirection.y;
      return (true);
    } else if (result.result == PATH_RESULT.NO_RELATIONSHIP) {
View Full Code Here

  // Force a 3D point to the interior cell by forcing it to the interior of
  // each wall
  //
  // -------------------------------------------------------------------------------------://
  boolean ForcePointToCellCollumn(Vector3f TestPoint) {
    Vector2f TestPoint2D = new Vector2f(TestPoint.x, TestPoint.z);
    boolean PointAltered = ForcePointToCellCollumn(TestPoint2D);

    if (PointAltered) {
      TestPoint.x = TestPoint2D.x;
      TestPoint.z = TestPoint2D.y;
View Full Code Here

TOP

Related Classes of com.jme3.math.Vector2f

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.