Package org.lwjgl.util.vector

Examples of org.lwjgl.util.vector.Matrix4f


    glMultMatrix(m);
  }

  public static void glFrustum(final float l, final float r, final float b, final float t, final float n, final float f) {
    final Matrix4f m = m4f;
    m.setIdentity();

    m.m00 = 2.0f * n / (r - l);
    m.m20 = (r + l) / (r - l);

    m.m11 = 2.0f * n / (t - b);
View Full Code Here


      return;
    }

    final float cotangent = (float)cos(radians) / sine;

    final Matrix4f m = m4f;
    m.setIdentity();

    m.m00 = cotangent / aspect;
    m.m11 = cotangent;
    m.m22 = -(zFar + zNear) / deltaZ;
    m.m23 = -1.0f;
View Full Code Here

      GL11.glRotatef(-rotZ, 0.0f, 0.0f, 1.0f);
    }
  }

  public static Matrix4f getTransformation() {
    Matrix4f matrix = new Matrix4f();

    matrix.translate(new Vector3f(-position.x, -position.y, -position.z));

    // convert angles from degrees to radians
    matrix.rotate((float) ((-rotX) * Math.PI / 180.0), new Vector3f(1.0f, 0.0f, 0.0f));
    matrix.rotate((float) ((-rotY) * Math.PI / 180.0), new Vector3f(0.0f, 1.0f, 0.0f));
    matrix.rotate((float) ((-rotZ) * Math.PI / 180.0), new Vector3f(0.0f, 0.0f, 1.0f));

    return matrix;
  }
View Full Code Here

  /**
   * Calculates Z-position in eye coordinates. Call getZDepth to get result.
   */
  public void updateZDepth() {
    Matrix4f transformation = Camera.getTransformation();
    transformation.translate(getPosition());

    zDepth = transformation.m32;
  }
View Full Code Here

    pos2d = new Vector3f(x, y, z);
    position = new Vector3f(x, y, z);
    this.textDist = textDist;
    tailDistance = new Vector3f(0.0f, 0.0f, 2.0f);
    rotationMatrix = new Matrix4f();

    state = State.NORMAL;
    normalColor = new Color(1.0f, 0.9f, 0.7f);
    this.hoverColor = hoverColor;
    applyColor = new Color(0.3f, 1.0f, 0.0f);
View Full Code Here

    ArrayList<Float> posBuffer = new ArrayList<>();
    ArrayList<Float> uvBuffer = new ArrayList<>();
    ArrayList<Float> norBuffer = new ArrayList<>();
    ArrayList<Float> idBuffer = new ArrayList<>();
 
    Matrix4f transMat = new Matrix4f();
    Matrix4f rotMat = new Matrix4f();
   
    Vector4f translatedVertex = new Vector4f();
    Vector4f rotatedNormal = new Vector4f();
   
    float[] temp = new float[9];
   
    for(int row = 0; row < Map.chunkSize; row++) {
      for(int col = 0; col < Map.chunkSize; col++) {
        int x = xStart+col;
        int y = yStart+row;
       
        if(map.get(y, x) == Map.EMPTY){
          /* Nothing to be added*/
          continue;
        }
       
        ArrayList<Mesh> msh = new ArrayList<>();
        int scan[] = map.scan(y, x);
        float mRotation = 0f;

        /* Set transform matrix for this piece of track */
        transMat.setIdentity();
        rotMat.setIdentity();
        /* Translate by x,z coordinates */
        transMat.translate(new Vector3f(y, 0, x));
       
        int trackType = getTrackType(map.get(y, x), scan, map.scanRideable(y, x));
       
        /* Populate msh list with right .obj meshes */
        switch(trackType){
          case EW_STRAIGHT:
            mRotation -= 90f;
            rotMat.rotate((float) Math.toRadians(mRotation), new Vector3f(0, 1, 0));
          case NS_STRAIGHT:
            //msh.add(trackStraight);
            msh.add(objMeshes.get("res/mesh/track.obj"));
            break;

          case NSEW_CROSS:
            //msh.add(trackXCrossing);
            msh.add(objMeshes.get("res/mesh/track_x_cross.obj"));
            break;

          case NE_CURVE:
            mRotation -= 90f;
          case NW_CURVE:
            mRotation -= 90f;
          case SW_CURVE:
            mRotation -= 90f;
            rotMat.rotate((float) Math.toRadians(mRotation), new Vector3f(0, 1, 0));
          case SE_CURVE:
            //msh.add(track90Corner);
            msh.add(objMeshes.get("res/mesh/track_90_corner.obj"));
            break;

          case WNE_CROSS:
            mRotation -= 90f;
          case SWN_CROSS:
            mRotation -= 90f;
          case ESW_CROSS:
            mRotation -= 90f;
            rotMat.rotate((float) Math.toRadians(mRotation), new Vector3f(0, 1, 0));
          case NES_CROSS:
            //msh.add(trackTCrossing);
            msh.add(objMeshes.get("res/mesh/track_t_cross.obj"));
            break;

          case EW_STATION:
            mRotation -= 90f;
            rotMat.rotate((float) Math.toRadians(mRotation), new Vector3f(0, 1, 0));
          case NS_STATION:
            //msh.add(trackStraight);
            //msh.add(station);
            msh.add(objMeshes.get("res/mesh/track.obj"));
            msh.add(objMeshes.get("res/mesh/station2.obj"));

            if(rand.nextFloat() > 0.5f){
              //msh.add(station_bin);
              msh.add(objMeshes.get("res/mesh/station2_bin.obj"));
            }
            if(rand.nextFloat() > 0.5f){
              //msh.add(station_bench);
              msh.add(objMeshes.get("res/mesh/station2_bench.obj"));
            }
            if(rand.nextFloat() > 0.75f){
              //msh.add(station_map);
              msh.add(objMeshes.get("res/mesh/station2_map.obj"));
            }
            break;

          case WNE_STATION:
            mRotation -= 90f;
          case SWN_STATION:
            mRotation -= 90f;
          case ESW_STATION:
            mRotation -= 90f;
            rotMat.rotate((float) Math.toRadians(mRotation), new Vector3f(0, 1, 0));
          case NES_STATION:
            //msh.add(trackTCrossing);
            //msh.add(station);
            msh.add(objMeshes.get("res/mesh/track_t_cross.obj"));
            msh.add(objMeshes.get("res/mesh/station2.obj"));

            if(rand.nextFloat() > 0.5f){
              //msh.add(station_bin);
              msh.add(objMeshes.get("res/mesh/station2_bin.obj"));
            }
            if(rand.nextFloat() > 0.5f){
              //msh.add(station_bench);
              msh.add(objMeshes.get("res/mesh/station2_bench.obj"));
            }
            if(rand.nextFloat() > 0.75f){
              //msh.add(station_map);
              msh.add(objMeshes.get("res/mesh/station2_map.obj"));
            }
            break;
           
          case TREE:
            transMat.translate(new Vector3f(((float)Math.random()-0.5f)*0.8f, 0, ((float)Math.random()-0.5f)*0.8f));
            rotMat.rotate((float) Math.toRadians(Math.random()*360.0), new Vector3f(0, 1, 0));
            msh.add(objMeshes.get("res/mesh/cactus_trunk.obj"));
            if(rand.nextFloat() > 0.15f){
              msh.add(objMeshes.get("res/mesh/cactus_branch1.obj"));
            }
            if(rand.nextFloat() > 0.15f){
View Full Code Here

  private static Vector3f clearColor;
  private static Camera camera;
 
  public static void create() throws LWJGLException {
    viewMatrixBuffer = BufferUtils.createFloatBuffer(16);
    viewMatrix = new Matrix4f();
    projectionMatrixBuffer = BufferUtils.createFloatBuffer(16);
    projectionMatrix = new Matrix4f();
   
    frustum = new float[6][4];
    clearColor = new Vector3f(1,1,1);
    camera = new Camera();
   
View Full Code Here

    material = new Material();
    position = new Vector3f();
    rotation = new Vector3f();
    scale = new Vector3f(1f,1f,1f);
   
    modelMatrix = new Matrix4f();
    modelMatrixDirty = true;
   
    keyframe1 = 0;
    keyframe2 = -1;
    keyframeBlend = 0.0f;
View Full Code Here

   
  }
 
  private Matrix4f orientation() {

    Matrix4f orientation = new Matrix4f();
   
    orientation.rotate(verticalAngle, new Vector3f(1, 0, 0));
    orientation.rotate(horizontalAngle, new Vector3f(0, 1, 0));
   
    return orientation;
   
  }
View Full Code Here

   
  }
 
  public Matrix4f viewMatrix() {
   
    Matrix4f camera = projection();
    Matrix4f.mul(camera, orientation(), camera);
   
    Vector3f negPosition = new Vector3f();
    position.negate(negPosition);
   
    camera.translate(negPosition);
   
    return camera;
   
  }
View Full Code Here

TOP

Related Classes of org.lwjgl.util.vector.Matrix4f

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.