Examples of Vector4f


Examples of javax.vecmath.Vector4f

/*     */   }
/*     */
/*     */   final void setPlaneR(Vector4f planeR)
/*     */   {
/* 182 */     initPlaneR(planeR);
/* 183 */     sendMessage(8, new Vector4f(planeR));
/*     */   }
View Full Code Here

Examples of javax.vecmath.Vector4f

/*     */   }
/*     */
/*     */   final void setPlaneQ(Vector4f planeQ)
/*     */   {
/* 212 */     initPlaneQ(planeQ);
/* 213 */     sendMessage(16, new Vector4f(planeQ));
/*     */   }
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

        Quaternion orientation   = new Quaternion(cont1OrientationQuat_xyzw[0],
                cont1OrientationQuat_xyzw[1], cont1OrientationQuat_xyzw[2], cont1OrientationQuat_xyzw[3]);

        // Apply yaw offset
        Quaternion yaw           = new Quaternion();
        Vector4f vecAxisYawAngle = new Vector4f(0f, 1f, 0f, -yawOffset * PIOVER180);
        yaw.setFromAxisAngle(vecAxisYawAngle);
        Quaternion.mul(yaw, orientation, orientation);
        return orientation;
    }
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

                headPitch  = rawYawPitchRoll[1];
                headRoll   = rawYawPitchRoll[2];

                // Apply pitch offset
                Quaternion pitchCorrection = new Quaternion();
                Vector4f vecAxisPitchAngle = new Vector4f(1f, 0f, 0f, -lookPitchOffset * PIOVER180);
                pitchCorrection.setFromAxisAngle(vecAxisPitchAngle);
                Quaternion.mul(pitchCorrection, orientation, orientation);

                // Apply yaw offset
                Quaternion yawCorrection   = new Quaternion();
                Vector4f vecAxisYawAngle   = new Vector4f(0f, 1f, 0f, (-lookYawOffset * PIOVER180));
                yawCorrection.setFromAxisAngle(vecAxisYawAngle);
                Quaternion.mul(yawCorrection, orientation, orientation);

                // Get camera orientation:
                // Matrix
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

    this.e = e;
    time = 0.0f;
    this.period = period;

    rotation = new Quaternion();
    rotation.setFromAxisAngle(new Vector4f(rotX, rotY, rotZ, angle));
    position = new Vector3f();

    light = Lighting.addLight(position, 0.1f * red, 0.1f * green, 0.1f * blue, red, green, blue, red, green, blue);

    // create display list
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

    applyRotation();
  }

  private void applyRotation() {
    // rotate head
    Vector4f v1 = new Vector4f(pos2d.x, pos2d.y, pos2d.z, 1.0f);
    Vector4f v2 = Matrix4f.transform(rotationMatrix, v1, null);

    position.x = v2.x;
    position.y = v2.y;
    position.z = v2.z;

    // rotate tail
    Vector3f.add(pos2d, tailDistance, tailPosition);
    v1 = new Vector4f(tailPosition.x, tailPosition.y, tailPosition.z, 1.0f);

    Matrix4f.transform(rotationMatrix, v1, v2);

    tailPosition.x = v2.x;
    tailPosition.y = v2.y;
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

  /**
   * @return position of cursor projected on text plane
   */
  public Vector3f getTextPosition() {
    Vector4f v1 = new Vector4f(pos2d.x, pos2d.y, pos2d.z - textDist, 1.0f);
    Vector4f v2 = Matrix4f.transform(rotationMatrix, v1, null);

    return new Vector3f(v2.x, v2.y, v2.z);
  }
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

    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){
              msh.add(objMeshes.get("res/mesh/cactus_branch2.obj"));
            }
            if(rand.nextFloat() > 0.15f){
              msh.add(objMeshes.get("res/mesh/cactus_branch3.obj"));
            }
           
            break;
          default:
            //msh.add(trackStraight);
            msh.add(objMeshes.get("res/mesh/track.obj"));
        }
       
        /* Stitch together the meshes of current grid */
        for(int i=0; i<msh.size(); i++){
          FloatBuffer data = msh.get(i).getData();
          int indices = msh.get(i).getIndiceCount();
          int keyframes = msh.get(i).getKeyframeCount();
          int[] offsets = new int[4];
         
          offsets[0] = 0// always only the first keyframe
          offsets[1] = 3*indices*keyframes;
          offsets[2] = 2*indices+offsets[1];
          offsets[3] = 3*indices*keyframes+offsets[2];
         
          data.rewind();

          for(int n=0;n<indices;n++){
            data.position(offsets[0]);
            data.get(temp, 0, 3);
            data.position(offsets[1]);
            data.get(temp, 3, 2);
            data.position(offsets[2]);
            data.get(temp, 5, 3);
            data.position(offsets[3]);
            data.get(temp, 8, 1);
           
            offsets[0] += 3;
            offsets[1] += 2;
            offsets[2] += 3;
            offsets[3]++;
           
            /* XYZ */
            Matrix4f.transform(rotMat, new Vector4f(temp[0], temp[1], temp[2], 1), translatedVertex);
            Matrix4f.transform(transMat, translatedVertex, translatedVertex);
            posBuffer.add(translatedVertex.x);
            posBuffer.add(translatedVertex.y);
            posBuffer.add(translatedVertex.z);
           
            /* UV */
            uvBuffer.add(temp[3]);
            uvBuffer.add(temp[4]);
           
            /* Normals */
            Matrix4f.transform(rotMat, new Vector4f(temp[5], temp[6], temp[7], 0), rotatedNormal);
            norBuffer.add(rotatedNormal.x);
            norBuffer.add(rotatedNormal.y);
            norBuffer.add(rotatedNormal.z);
           
           
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

   
  }
 
  public Vector3f up() {
   
    Vector4f up = MatrixMath.multiply((Matrix4f) orientation().invert(), new Vector4f(0, 1, 0, 1));
   
    return new Vector3f(up.x, up.y, up.z);
   
  }
View Full Code Here

Examples of org.lwjgl.util.vector.Vector4f

   
  }
 
  public Vector3f forward() {
   
    Vector4f forward = MatrixMath.multiply((Matrix4f) orientation().invert(), new Vector4f(0, 0, -1, 1));
   
    return new Vector3f(forward.x, forward.y, forward.z);
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.