Exemplo n.º 1
0
void R4Matrix:: 
Scale(const R3Vector& scale)
{
    // Scale matrix
    XScale(scale.X());
    YScale(scale.Y());
    ZScale(scale.Z());
}
Exemplo n.º 2
0
void R4Matrix:: 
Translate(const R3Vector& offset)
{
    // Translate matrix
    XTranslate(offset.X());
    YTranslate(offset.Y());
    ZTranslate(offset.Z());
}
Exemplo n.º 3
0
void R3Point:: 
Rotate(const R3Vector& radians)
{
    // Rotate first around X, then around Y, and finally around Z
    ZRotate(radians.Z());
    YRotate(radians.Y());
    XRotate(radians.X());
}
Exemplo n.º 4
0
void Bearpaw::
updatePosition(double delta_time, R3Point playerPos) { //, double bound, R3Scene *scene, vector<Bearpaw>& Bearpaw_list, vector<Hunter>& hunter_list, R3Box bearBBox)
{
    fprintf(stderr, "center at {%f, %f, %f}\n",shape.mesh->Center().X(), shape.mesh->Center().Y(), shape.mesh->Center().Z());
    position = playerPos + playeroffset;
    
    R3Vector toNew = position - shape.mesh->Center();
    fprintf(stderr, "moving by {%f, %f, %f}\n",toNew.X(), toNew.Y(), toNew.Z());
	shape.mesh->Translate(toNew.X(), toNew.Y(), toNew.Z());
	bbox = shape.mesh->bbox;
    
    /*
    R3Vector 
    fromPlayer.SetY(0);

    fromPlayer.Normalize();
    
    position += fromPlayer*delta_time*speed;
    
    // update the y-position
    R3Vector grav = R3Vector(0,-15,0);
    R3Vector f_grav = mass * grav;
    R3Vector accel = f_grav / mass;
    position.Translate(delta_time * velocity);
    velocity += delta_time * accel;
    if (position.Y() <= 4.0) { // currently a magic number
        position.SetY(4.0);
        velocity += R3Vector(0,10,0);
    }
    

    if (shape.type == R3_MESH_SHAPE) {    // only going to use a mesh for the bear paw
        R3Vector toNew = position - shape.mesh->Center();
		shape.mesh->Translate(toNew.X(), toNew.Y(), toNew.Z());
		bbox = shape.mesh->bbox;
    }
    */
    
    
} }
Exemplo n.º 5
0
R3Matrix R3Matrix::Rotation(const R3Vector& axis, double radians)
{
    // rotate matrix for arbitrary axis counterclockwise
    // From Graphics Gems I, p. 466
    double x = axis.X();
    double y = axis.Y();
    double z = axis.Z();
    double c = cos(radians);
    double s = sin(radians);
    double t = 1.0 - c;
    return R3Matrix(t*x*x + c, t*x*y - s*z, t*x*z + s*y, 0.0,
            t*x*y + s*z, t*y*y + c, t*y*z - s*x, 0.0,
            t*x*z - s*y, t*y*z + s*x, t*z*z + c, 0.0,
            0.0, 0.0, 0.0, 1.0);
}
Exemplo n.º 6
0
void R4Matrix:: 
Rotate(const R3Vector& axis, RNAngle radians)
{
    // rotate matrix for arbitrary axis counterclockwise
    // From Graphics Gems I, p. 466
    RNCoord x = axis.X();
    RNCoord y = axis.Y();
    RNCoord z = axis.Z();
    RNScalar c = cos(radians);
    RNScalar s = sin(radians);
    RNScalar t = 1.0 - c;
    R4Matrix rotation(
        t*x*x + c, t*x*y - s*z, t*x*z + s*y, 0.0,
        t*x*y + s*z, t*y*y + c, t*y*z - s*x, 0.0,
        t*x*z - s*y, t*y*z + s*x, t*z*z + c, 0.0,
        0.0, 0.0, 0.0, 1.0);
    *this *= rotation;
}
Exemplo n.º 7
0
void R4Matrix:: 
Rotate(const R3Vector& radians)
{
#if 1
    // Rotate first around X, then around Y, and finally around Z
    ZRotate(radians.Z());
    YRotate(radians.Y());
    XRotate(radians.X());
#else
    // This is faster way to do same thing (not tested)
    R4Matrix rotation(
      cos(radians.Y())*cos(radians.Z()),  
      sin(radians.X())*sin(radians.Y())*cos(radians.Z()) - cos(radians.X())*sin(radians.Z()), 
      cos(radians.X())*sin(radians.Y())*cos(radians.Z()) + sin(radians.X())*sin(radians.Z()), 0,
      cos(radians.Y())*sin(radians.Z()),
      sin(radians.X())*sin(radians.Y())*sin(radians.Z()) + cos(radians.X())*cos(radians.Z()),
      cos(radians.X())*sin(radians.Y())*sin(radians.Z()) - sin(radians.X())*cos(radians.Z()), 0,
      -sin(radians.Y()), 
      cos(radians.Y())*sin(radians.X()),
      cos(radians.X())*cos(radians.Y()), 0,
      0, 0, 0, 1);
    *this = rotation * (*this);
#endif
}
Exemplo n.º 8
0
void R3Matrix::Rotate(const R3Vector& radians)
{
    XRotate(radians.X());
    YRotate(radians.Y());
    ZRotate(radians.Z());
}