コード例 #1
0
ファイル: R4Matrix.cpp プロジェクト: cricklet/Path-Tracer
void R4Matrix:: 
Scale(const R3Vector& scale)
{
    // Scale matrix
    XScale(scale.X());
    YScale(scale.Y());
    ZScale(scale.Z());
}
コード例 #2
0
ファイル: R4Matrix.cpp プロジェクト: cricklet/Path-Tracer
void R4Matrix:: 
Translate(const R3Vector& offset)
{
    // Translate matrix
    XTranslate(offset.X());
    YTranslate(offset.Y());
    ZTranslate(offset.Z());
}
コード例 #3
0
ファイル: R3Point.cpp プロジェクト: cricklet/Path-Tracer
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());
}
コード例 #4
0
ファイル: Bearpaw.cpp プロジェクト: menewman/gfx_game
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;
    }
    */
    
    
} }
コード例 #5
0
ファイル: R3Matrix.cpp プロジェクト: dmrd/startiger
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);
}
コード例 #6
0
ファイル: R4Matrix.cpp プロジェクト: cricklet/Path-Tracer
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;
}
コード例 #7
0
ファイル: R4Matrix.cpp プロジェクト: cricklet/Path-Tracer
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
}
コード例 #8
0
ファイル: R3Matrix.cpp プロジェクト: dmrd/startiger
void R3Matrix::Rotate(const R3Vector& radians)
{
    XRotate(radians.X());
    YRotate(radians.Y());
    ZRotate(radians.Z());
}