Package com.jme3.math

Examples of com.jme3.math.Vector2f


    float rw = radius/width;
    float rbw = (width-radius)/width;
   
    //left center
    vertices[0] = ref.clone();
    texCoord[0] = new Vector2f(rbw, 0.5f);
   
    // draw left half circle
    int lastPoint = 0;
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+1;
      int indicesBase = (i-1)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f(1-rw+(z * rw), (x * 0.5f) + 0.5f);
      if (lastPoint > 0) {
        indices[indicesBase] = 0;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
      }
      lastPoint = verticesBase;
      angle += rate;
    }
   
    // right center
    ref.z = radius-width/2f;
    int base2 = samples+2;
    vertices[base2] = ref.clone();
   
   
    texCoord[base2] = new Vector2f(rw, 0.5f);
    angle = FastMath.PI;
    lastPoint = 0;
   
    // draw right half circle
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+samples+3;
      int indicesBase = (i+samples)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f(rw + (z * rw), (x * 0.5f) + 0.5f);
      System.out.println(texCoord[verticesBase]);
      if (lastPoint > 0) {
        indices[indicesBase] = base2;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
View Full Code Here


    } else {
      cam.setCanZoom(false);
      cam.setZoomDistance(distanceAnimation.getDistance());
    }
    if (!rotationOffsetAnimation.isFinished()) {
      Vector2f rotationOffset = rotationOffsetAnimation.getRotationOffset();
      cam.setRotationOffset(rotationOffset.x, rotationOffset.y);
    }
    if (positionAnimation.isFinished() && target != null) {
      cam.setSpatial(target);
    }
View Full Code Here

        return flame;
  }

  public void onMove(int cursorId, int delta, int delta2, int newX, int newY) {
    if (cursorId == 0) {
      flame1.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(newX, newY), zPos));
    } else if(cursorId == 1) {
      flame2.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(newX, newY), zPos));
    }
  }
View Full Code Here

    }
  }

  public void onNew(int cursorId, int x, int y) {
    if (cursorId == 0) {
      flame1.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(x, y), zPos));
      flame1.setParticlesPerSec(100);
    } else if(cursorId == 1) {
      flame2.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(x, y), zPos));
      flame2.setParticlesPerSec(100);
    }
  }
View Full Code Here

    private Vector2f initialFoodHUDPosition;

    public UIManager() {
        myApp = GameNameGoesHere.getApp();
        WIDTH = myApp.getSettings().getWidth() * 0.15f;
        initialFoodHUDPosition = new Vector2f(
            myApp.getSettings().getWidth() * 0.2f, myApp.getSettings().getHeight() * 0.05f);

        initialiseNifty();
        stateManager = myApp.getStateManager();
    }
View Full Code Here

       // String[] fileNames = {"appleImg.png", "appleImg.png", "appleImg.png"};
       // ColorRGBA[] colors = {ColorRGBA.Pink, ColorRGBA.Green, ColorRGBA.Red};

        for (int i = 0, length = 3; i < length; i++) {

            Vector2f position = initialFoodHUDPosition.clone();
            position.setX(position.getX() + (WIDTH * i) + (myApp.getSettings().getWidth() * 0.08f * i));
            createBorder(position);
        }

        myApp.getGuiNode().attachChild(products);
    }
View Full Code Here

        p.setWidth(WIDTH);
        p.setHeight(WIDTH);

        p.getMaterial().setColor("Color", color);

        Vector2f position = initialFoodHUDPosition.clone();
        position.setX(position.getX() + (WIDTH * index) + (myApp.getSettings().getWidth() * 0.08f * index));
        p.setPosition(position.getX(), position.getY());
        createBorder(position);

        products.attachChild(p);
        myApp.getGuiNode().attachChild(products);
    }
View Full Code Here

        // delte the availableCursorsToDelete from availableCursors
        availableCursors.removeAll(availableCursorsToDelete);
      }
    // mouse to TUIO bridge
    } else {
      Vector2f mousePos = inputManager.getCursorPosition();
     
      if (mouseButton == MouseInput.BUTTON_LEFT) {
        if (mouseActive && mouseReleased) {
          for (int i = 0; i < listeners.size(); i++) {
            mouseReleased = false;
            lastMousePos = mousePos;
            TuioInputListener listener = listeners.get(i);
            listener.onNew(0, (int) mousePos.x, (int) mousePos.y);
          }
        } else if (mouseActive && !mouseReleased) {
          for (int i = 0; i < listeners.size(); i++) {
            TuioInputListener listener = listeners.get(i);
            listener.onMove(0, (int) (mousePos.x - lastMousePos.x), (int) (mousePos.y - lastMousePos.y), (int) mousePos.x, (int) mousePos.y);
          }
        } else if (!mouseActive && !mouseReleased) {
          for (int i = 0; i < listeners.size(); i++) {
            mouseReleased = true;
            lastMousePos = new Vector2f(0,0);
            TuioInputListener listener = listeners.get(i);
            listener.onRelease(0);
          }
        }
      }
     
      if (mouseButton == MouseInput.BUTTON_RIGHT) {
        mouseReleased = false;
        if(mouseActive && !mouseReleased){
          Vector2f delta = mousePos.subtract(lastRightMousePos);
          if (delta.length() > 0) {
            GestureSystem.get().move(delta);
         
        }
      }
     
View Full Code Here

    // if we have an cursor and the timer expired
    if (cursor != null && !twoCursors) {
      // if time is expired reset timer and trigger event
      if (isTimerExpired()) {
        resetTimer();
        Vector2f longClick = cursor.getVector();
        for (int i = 0; i < listeners.size(); i++) {
          GestureListener listener = listeners.get(i);
          listener.longClick(longClick);
        }
      } else {
        // if the cursor has move over the longClickMaxDelta reset the Timer
        if (FastMath.abs(cursor.xDelta) > longClickMaxDelta ||
          FastMath.abs(cursor.yDelta) > longClickMaxDelta ) {
          resetTimer();
        }
      }
    }
   
   
    // get the last cursor for up and click event
    CursorStore lastCursor = null;
    if (lastCursor1 != null && lastCursor2 == null) {
      lastCursor = lastCursor1;
      lastCursor1 = null;
    } else if (lastCursor2 != null && lastCursor1 == null){
      lastCursor = lastCursor2;
      lastCursor2 = null;
    } else {
      // no last cursor or multitouch event ended
      return;
    }
    // we know we have an up event -> reset long click timer
    resetTimer();
   
    Vector2f up = lastCursor.getVector();
    // loop through listeners and trigger up and click events
    for (int i = 0; i < listeners.size(); i++) {
      GestureListener listener = listeners.get(i);
      listener.up(up);
      if (cursor1 == null && cursor2 == null && !twoCursors) {
View Full Code Here

    float distancePre = FastMath.abs(cursor1.getPreVector().distance(cursor2.getPreVector()));
    float distanceNow = FastMath.abs(cursor1.getVector().distance(cursor2.getVector()));
   
    float zoom = distanceNow - distancePre;
 
    Vector2f nPre = cursor1.getPreVector().subtract(cursor2.getPreVector()).normalize();
    Vector2f nNow = cursor1.getVector().subtract(cursor2.getVector()).normalize();
   
    // scalar product  -> angle
    float angle = FastMath.acos(nPre.x * nNow.x + nPre.y * nNow.y);
   
    //TODO: Find a better calculation
    if (!isPosRotation(nPre, nNow, angle)) angle = -angle;
 
    Vector2f pre = cursor1.getVector().subtract(cursor1.getPreVector());
    Vector2f now = cursor2.getVector().subtract(cursor2.getPreVector());
   
    Vector2f move = pre.add(now).divide(2f);
   
    for (int i = 0; i < listeners.size(); i++) {
      GestureListener listener = listeners.get(i);
      listener.zoom(zoom);
      listener.rotate(angle);
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.