Exemple #1
0
 /**
  * Rotates the animal around the y axis
  *
  * @param angle The amount to rotate (In Radians)
  */
 protected void rotate(double angle) {
   if (!mMoving) {
     mRotY += angle;
     mat4 m = axisRotation(new vec4(0, 1, 0, 0), mRotY);
     mForward = mul(new vec4(0, 0, -1, 0), m);
     mRight = mul(new vec4(1, 0, 0, 0), m);
     mUp = mul(new vec4(0, 1, 0, 0), m);
     vec4 u = mRight.mul(mWidth);
     vec4 v = mUp.mul(mHeight);
     vec4 w = mForward.mul(mDepth);
     mBox = new OrientedBoundingBox(mPos.sub(u.mul(0.5).sub(v.mul(0.5).sub(w.mul(0.5)))), u, v, w);
   }
 }
Exemple #2
0
 /**
  * Creates a simple animal
  *
  * @param mesh The mesh this animal will use
  * @param position The initial position of this animal
  * @param yOffset A translation along the y axis to put the animal on its feet
  */
 public Animal(Mesh mesh, vec4 position, float yOffset) {
   mMesh = mesh;
   mPos = position;
   mYOffset = yOffset;
   mRad = 1.5f;
   this.ot = ObjectType.ANIMAL;
   mat4 m = axisRotation(new vec4(0, 1, 0, 0), mRotY);
   mForward = mul(new vec4(0, 0, -1, 0), m);
   mRight = mul(new vec4(1, 0, 0, 0), m);
   mUp = mul(new vec4(0, 1, 0, 0), m);
   vec4 u = mRight.mul(mWidth);
   vec4 v = mUp.mul(mHeight);
   vec4 w = mForward.mul(mDepth);
   mBox = new OrientedBoundingBox(mPos.sub(u.mul(0.5).sub(v.mul(0.5).sub(w.mul(0.5)))), u, v, w);
 }