Package com.jme3.math

Examples of com.jme3.math.Vector2f


    public CursorStore (int x, int y) {
      this(0, 0, x, y, true);
    }
   
    public Vector2f getVector() {
      return new Vector2f(x, y);
    }
View Full Code Here


    public Vector2f getVector() {
      return new Vector2f(x, y);
    }
   
    public Vector2f getPreVector() {
      return new Vector2f(x+xDelta, y-yDelta);
    }
View Full Code Here

   
    PlanetarySystem system = new PlanetarySystem();
    system.setId(1);
    system.setName("Sol");
    system.setSun(sun);
    system.setPosition(new Vector2f(100, 100));
    system.setPlanets(planets);
   
    String jsonString = mapper.writeValueAsString(system);
    System.out.println(jsonString);
  }
View Full Code Here

  }
 
  public void animate(float vertical, float horizontal, float time) {
    setAnimationTime(time);
    this.start = rotationOffset;
    this.target = new Vector2f(vertical, horizontal);
  }
View Full Code Here

          material.setTexture("DiffuseMap", grass);
          Texture normal = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
          normal.setWrap(WrapMode.Repeat);
          material.setTexture("NormalMap", normal);
          material.setFloat("ScrollSpeed", 0.1f);
          material.setVector2("ScrollDirection", new Vector2f(0.1f,0.3f));

          // CREATE HEIGHTMAP
          AbstractHeightMap heightmap = null;
          try {
              //heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
View Full Code Here

//        new Vector2f(worldTranslation.x-TERRAIN_SIZE_HALF, worldTranslation.z+TERRAIN_SIZE_HALF)
//    );
//    left = new Line2D(bottom.EndPointB(),top.EndPointA());
    //l2j tiles are top left 0/0 and bottom right 256/256
    top = new Line2D(
    new Vector2f(worldTranslation.x+CENTER_OFFSET, worldTranslation.z+CENTER_OFFSET),
    new Vector2f(worldTranslation.x+TERRAIN_SIZE+CENTER_OFFSET, worldTranslation.z+CENTER_OFFSET)
    );
    right = new Line2D(top.EndPointB(),
    new Vector2f(worldTranslation.x+TERRAIN_SIZE+CENTER_OFFSET, worldTranslation.z+TERRAIN_SIZE+CENTER_OFFSET)
    );
    bottom = new Line2D(right.EndPointB(),
    new Vector2f(worldTranslation.x+CENTER_OFFSET, worldTranslation.z+TERRAIN_SIZE+CENTER_OFFSET)
    );
    left = new Line2D(bottom.EndPointB(),top.EndPointA());
    log.finest(this+" top:"+top);
    log.finest(this+" right:"+right);
    log.finest(this+" bottom:"+bottom);
View Full Code Here

  boolean buildNavigationPathToBorder(Path navPath, Cell startCell, Vector3f startPos,
      Vector3f endPos) {
//    if (hasBounds()) {
      // get intersection point of direct route and border lines of tile
      Line2D l = new Line2D(startPos.x, startPos.z, endPos.x, endPos.z);
      Vector2f cross = new Vector2f();
      //FIXME aemhm what if we do not intersect top?!?!
      LINE_CLASSIFICATION classi = top.Intersection(l, cross);
     
      //check which side we cross
      if(classi != LINE_CLASSIFICATION.SEGMENTS_INTERSECT){
        classi = right.Intersection(l, cross);
        if(classi != LINE_CLASSIFICATION.SEGMENTS_INTERSECT){
          classi = bottom.Intersection(l, cross);
          if(classi != LINE_CLASSIFICATION.SEGMENTS_INTERSECT){
            classi = left.Intersection(l, cross);
            if(classi != LINE_CLASSIFICATION.SEGMENTS_INTERSECT)
              return false;
          }
        }
      }
      //TODO new plan, we have a crossing, ok, now find the closest cell on that border on our side, the cross must be shifted to that cell
      // then go from there to the final destination
      if(cross != null){
        int where = getBoundingSide(cross.x, cross.y);
        //collect all boundig cells on that tiles
        HashSet<Cell> targets = getBorderCells(where);
        //max dist can not be more than the span of a mesh tile
        float max = (TERRAIN_SIZE*TERRAIN_SIZE) +
              (TERRAIN_SIZE*TERRAIN_SIZE) + 0.01f;
        float dist = 0f;
        Cell targetCell = null;
        Vector3f goal = null;
        //loop over them and find the closest one //what if none on that sides, why loop at some which are completely off ???
        for(Cell c : targets){
          //prefere computed cross section over midpoints
          if(c.IsPointInCellCollumn(cross)){
            targetCell = c;
            goal = new Vector3f(cross.x, 0, cross.y);
            c.MapVectorHeightToCell(goal);
            break;
          }
          //all cell midpoints
          for(Vector3f point : c.m_WallMidpoint){
            //not needed, as this will not work, midpoints will be always on the line
//            //to find the one on the border
//            if(!isPointInTile(point.x, point.z)){
              //and which is closer than the ones before the current
              dist = cross.distanceSquared(point.x, point.z);
              if(dist<max){
                max = dist;
                targetCell = c;
                goal = point;
              }
View Full Code Here

  Cell resolveMotionNewWay(Vector3f StartPos, Cell StartCell, Vector3f EndPos) {
        // create a 2D motion path from our Start and End positions, tossing out
        // their Y values to project them
        // down to the XZ plane.
        Line2D MotionPath = new Line2D(new Vector2f(StartPos.x, StartPos.z),
            new Vector2f(EndPos.x, EndPos.z));
 
        // these three will hold the results of our tests against the cell walls
        ClassifyResult Result = null;
 
        // TestCell is the cell we are currently examining.
        Cell TestCell = StartCell;
 
        Result = TestCell.ClassifyPathToCell(MotionPath);
 
        // if exiting the cell...
        if (Result.result == Cell.PATH_RESULT.EXITING_CELL) {
          // Set if we are moving to an adjacent cell or we have hit a
          // solid (unlinked) edge
          if (Result.cell != null) {
            // moving on. Set our motion origin to the point of
            // intersection with this cell
            // and continue, using the new cell as our test cell.
            MotionPath.SetEndPointA(Result.intersection);
            TestCell = Result.cell;
          } else {
            //FIXME this could also be the case of switching meshes :-< check this !!
            Cell c = FindClosestCell(EndPos, true);
            if(c!= null && c != TestCell){
  //System.out.println("Mesh switching");
                TestCell =c;
            }
            else{
              //FIXME thid should push the entity more away from a wall than it does at the moment and make it move more perpendicular to the wall
  //System.out.println("Hitting a wall!");
              // we have hit a solid wall. Resolve the collision and
              // correct our path.
              MotionPath.SetEndPointA(Result.intersection);
              TestCell.ProjectPathOnCellWall(Result.side, MotionPath);
   
              // add some friction to the new MotionPath since we are
              // scraping against a wall.
              // we do this by reducing the magnatude of our motion by 10%
              Vector2f Direction = MotionPath.EndPointB().subtract(
                  MotionPath.EndPointA()).mult(0.9f);
              // Direction.mult(0.9f);
              MotionPath.SetEndPointB(MotionPath.EndPointA().add(
                  Direction));
            }
          }
        } else if (Result.result == Cell.PATH_RESULT.NO_RELATIONSHIP) {
  //System.out.println("NO RELATION");
          //FIXME this could also be the case of optimized meshes
          Cell c = FindClosestCell(EndPos, true);
          if(c!= null && c != TestCell){
              TestCell =c;
          } else {
          // Although theoretically we should never encounter this case,
          // we do sometimes find ourselves standing directly on a vertex
          // of the cell.
          // This can be viewed by some routines as being outside the
          // cell.
          // To accomodate this rare case, we can force our starting point
          // to be within
          // the current cell by nudging it back so we may continue.
          Vector2f NewOrigin = MotionPath.EndPointA();
          TestCell.ForcePointToCellCollumn(NewOrigin);
  //          MotionPath.SetEndPointA(NewOrigin);
          //we do not want to iterate we just want them to stop at the wall and not cet out
          MotionPath.SetEndPointB(NewOrigin);
          }
View Full Code Here

    m_PointB = PointB;
    m_NormalCalculated = false;
  }
 
  public Line2D(float x1, float y1, float x2, float y2){
    m_PointA = new Vector2f(x1,y1);
    m_PointB = new Vector2f(x2,y2);
    m_NormalCalculated = false;
  }
View Full Code Here

    if (!m_NormalCalculated)
    {
      ComputeNormal();
    }

    Vector2f TestVector = new Vector2f(Point.subtract(m_PointA));
   
    return TestVector.dot(m_Normal); //.x*m_Normal.x + TestVector.y*m_Normal.y;//DotProduct(TestVector,m_Normal);

  }
 
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.