Package com.badlogic.gdx.math

Examples of com.badlogic.gdx.math.Vector3


    if (offset < 0 || dimensions < 1 || (offset + dimensions) > vertexSize) throw new IndexOutOfBoundsException();
    if (start < 0 || count < 1 || ((start + count) * vertexSize) > vertices.length)
      throw new IndexOutOfBoundsException("start = " + start + ", count = " + count + ", vertexSize = " + vertexSize
        + ", length = " + vertices.length);

    final Vector3 tmp = new Vector3();

    int idx = offset + (start * vertexSize);
    switch (dimensions) {
    case 1:
      for (int i = 0; i < count; i++) {
        tmp.set(vertices[idx], 0, 0).mul(matrix);
        vertices[idx] = tmp.x;
        idx += vertexSize;
      }
      break;
    case 2:
      for (int i = 0; i < count; i++) {
        tmp.set(vertices[idx], vertices[idx + 1], 0).mul(matrix);
        vertices[idx] = tmp.x;
        vertices[idx + 1] = tmp.y;
        idx += vertexSize;
      }
      break;
    case 3:
      for (int i = 0; i < count; i++) {
        tmp.set(vertices[idx], vertices[idx + 1], vertices[idx + 2]).mul(matrix);
        vertices[idx] = tmp.x;
        vertices[idx + 1] = tmp.y;
        vertices[idx + 2] = tmp.z;
        idx += vertexSize;
      }
View Full Code Here


    lookAt(0, 0, 0);
    normalizeUp();
  }

  private float calculateAngle (float a) {
    Vector3 camPos = calculateDirection(a);
    position.set(camPos.mul(30));
    lookAt(0, 0, 0);
    normalizeUp();
    update();

    Vector3 orig = new Vector3(0, 0, 0);
    Vector3 vec = new Vector3(1, 0, 0);
    project(orig);
    project(vec);
    Vector2 d = new Vector2(vec.x - orig.x, -(vec.y - orig.y));
    return d.angle();
  }
View Full Code Here

    return d.angle();
  }

  private Vector3 calculateDirection (float angle) {
    Matrix4 transform = new Matrix4();
    Vector3 dir = new Vector3(-1, 0, 1).nor();
    float rotAngle = (float)Math.toDegrees(Math.asin(Math.tan(Math.toRadians(angle))));
    transform.setToRotation(new Vector3(1, 0, 1).nor(), angle);
    dir.mul(transform).nor();
    return dir;
  }
View Full Code Here

    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
  }

  public void resize(int width, int height) {
    super.resize(width, height);
    Vector3 oldPosition = new Vector3();
    Vector3 oldDirection = new Vector3();
    if (cam != null) {
      oldPosition.set(cam.position);
      oldDirection.set(cam.direction);
      cam = new PerspectiveCamera(28, Gdx.graphics.getWidth(),
          Gdx.graphics.getHeight());
      cam.position.set(oldPosition);
      cam.direction.set(oldDirection);
    } else {
View Full Code Here

      ship.update(delta);
    }
   
    for (int e = 0; e < bullets.size; e++) {
      if (bullets.get(e).body.getLinearVelocity().len2()<5) {
        deadBullets.add(new DeadCannonBall(new Vector3(bullets.get(e).body.getWorldCenter().x,bullets.get(e).body.getWorldCenter().y,0), bullets.get(e).body.getAngle()));
       
        world.destroyBody(bullets.get(e).body);
        bullets.removeIndex(e);
       
      }
    }   
   
    while(deadBullets.size>100) {
      deadBullets.removeIndex(0);       
    }
   
    while(deadEnemies.size>20) {
      deadEnemies.removeIndex(0);       
    }   
   
    for (int e = 0; e < enemies.size; e++) {
      if (enemies.get(e).life <= 0 && enemies.get(e).body.getLinearVelocity().len2()<5) {
        deadEnemies.add(new DeadEnemyShip(new Vector3(enemies.get(e).body.getWorldCenter().x,enemies.get(e).body.getWorldCenter().y,0), enemies.get(e).body.getAngle()));
       
        world.destroyBody(enemies.get(e).body);
        enemies.removeIndex(e);
       
      }
View Full Code Here

   
   
    diffuseShader.end();
   
    //update cam
    Vector3 position3 = new Vector3();
    model.getTranslation(position3);
    cam.position.set(position3.x, (-position3.z/4.0f)+10, position3.y-20);
    cam.lookAt(0, (position3.y/1.5f)-2, position3.y);
   
   
View Full Code Here

    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
  }

  public void resize(int width, int height) {
    super.resize(width, height);
    Vector3 oldPosition = new Vector3();
    Vector3 oldDirection = new Vector3();
    if (cam != null) {
      oldPosition.set(cam.position);
      oldDirection.set(cam.direction);
      cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(),
          Gdx.graphics.getHeight());
      cam.position.set(oldPosition);
      cam.direction.set(oldDirection);
    } else {
View Full Code Here

//    Gdx.gl.glEnable(GL20.GL_CULL_FACE);
    Gdx.gl.glCullFace(GL20.GL_BACK);
  }

  private void initLevel() {
    Vector3 position = new Vector3();
    position = new Vector3(0, 8, 0);

    calculateModelMatrix();
  }
View Full Code Here

   
   
    diffuseShader.end();
   
    //update cam
    Vector3 position3 = new Vector3();
    model.getTranslation(position3);
    cam.position.set(position3.x+1, (-position3.z)+2.2f+scale, position3.z+2);
    cam.lookAt(0, (position3.y/1.5f), position3.y);
   
   
View Full Code Here

  this(allowZoom, null);
  }

  @Override
  public boolean touchDown(int x, int y, int pointer, int button) {
  Vector3 tmp = new Vector3(x * sclx, y * scly, 0);
  camera.unproject(tmp);
  return false;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.math.Vector3

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.