コード例 #1
0
void CRRCControlSurfaceAnimation::transformPoint(CRRCMath::Vector3& point)
{
  sgVec3 pnt_sg;

  sgSetVec3(pnt_sg, (float)point.r[0], (float)point.r[1], (float)point.r[2]);
  sgXformVec3(pnt_sg, current_transformation);

  point.r[0] = pnt_sg[SG_X];
  point.r[1] = pnt_sg[SG_Y];
  point.r[2] = pnt_sg[SG_Z];
}
コード例 #2
0
void TransIcelandicExpress::mouseMotion( int xrel, int yrel ) {
	// rotate the camera
	sgVec3 axis, oldCamPos;
	sgMat4 m;
	float rot_factor = 0.5;

	// change heading
	sgSetVec3( axis, 0.0, 1.0, 0.0 );
	sgMakeRotMat4( m, (float)xrel * rot_factor, axis ) ;

	sgXformVec3( cameraPos, m ) ;

	// change pitch
	sgSetVec3( axis, 1.0, 0.0, 0.0 );
	sgMakeRotMat4( m, (float)yrel * rot_factor, axis ) ;

	sgCopyVec3( oldCamPos, cameraPos );
	sgXformVec3( cameraPos, m ) ;

	// don't let the camera go below player
	if (cameraPos[1] < 0.0 ) {
		sgCopyVec3( cameraPos, oldCamPos );		
	}
}