コード例 #1
0
void CCharShape::AdjustJoints (ETR_DOUBLE turnFact, bool isBraking,
                               ETR_DOUBLE paddling_factor, ETR_DOUBLE speed,
                               const TVector3d& net_force, ETR_DOUBLE flap_factor) {
	ETR_DOUBLE turning_angle[2];
	ETR_DOUBLE paddling_angle = 0;
	ETR_DOUBLE ext_paddling_angle = 0;
	ETR_DOUBLE kick_paddling_angle = 0;
	ETR_DOUBLE braking_angle = 0;
	ETR_DOUBLE force_angle = 0;
	ETR_DOUBLE turn_leg_angle = 0;
	ETR_DOUBLE flap_angle = 0;

	if (isBraking) braking_angle = MAX_ARM_ANGLE2;

	paddling_angle = MAX_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
	ext_paddling_angle = MAX_EXT_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
	kick_paddling_angle = MAX_KICK_PADDLING_ANGLE2 * sin(paddling_factor * M_PI * 2.0);

	turning_angle[0] = max(-turnFact,0.0) * MAX_ARM_ANGLE2;
	turning_angle[1] = max(turnFact,0.0) * MAX_ARM_ANGLE2;
	flap_angle = MAX_ARM_ANGLE2 * (0.5 + 0.5 * sin (M_PI * flap_factor * 6 - M_PI / 2));
	force_angle = clamp (-20.0, -net_force.z / 300.0, 20.0);
	turn_leg_angle = turnFact * 10;

	ResetJoints ();

	RotateNode ("left_shldr", 3,
	            min (braking_angle + paddling_angle + turning_angle[0], MAX_ARM_ANGLE2) + flap_angle);
	RotateNode ("right_shldr", 3,
	            min (braking_angle + paddling_angle + turning_angle[1], MAX_ARM_ANGLE2) + flap_angle);

	RotateNode ("left_shldr", 2, -ext_paddling_angle);
	RotateNode ("right_shldr", 2, ext_paddling_angle);
	RotateNode ("left_hip", 3, -20 + turn_leg_angle + force_angle);
	RotateNode ("right_hip", 3, -20 - turn_leg_angle + force_angle);

	RotateNode ("left_knee", 3,
	            -10 + turn_leg_angle - min (35.0f, speed) + kick_paddling_angle + force_angle);
	RotateNode ("right_knee", 3,
	            -10 - turn_leg_angle - min (35.0f, speed) - kick_paddling_angle + force_angle);

	RotateNode ("left_ankle", 3, -20 + min (50.0f, speed));
	RotateNode ("right_ankle", 3, -20 + min (50.0f, speed));
	RotateNode ("tail", 3, turnFact * 20);
	RotateNode ("neck", 3, -50);
	RotateNode ("head", 3, -30);
	RotateNode ("head", 2, -turnFact * 70);
}
コード例 #2
0
ファイル: tux.cpp プロジェクト: RKSimon/extremetuxracer
void CCharShape::AdjustJoints (double turnFact, bool isBraking, 
			double paddling_factor, double speed,
			TVector3 net_force, double flap_factor) {
    double turning_angle[2] = {0, 0};
    double paddling_angle = 0;
    double ext_paddling_angle = 0; 
    double kick_paddling_angle = 0;
    double braking_angle = 0;
    double force_angle = 0;
    double turn_leg_angle = 0;
    double flap_angle = 0;

    if (isBraking) braking_angle = MAX_ARM_ANGLE2;

    paddling_angle = MAX_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
    ext_paddling_angle = MAX_EXT_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
    kick_paddling_angle = MAX_KICK_PADDLING_ANGLE2 * sin(paddling_factor * M_PI * 2.0);

    turning_angle[0] = MAX(-turnFact,0.0) * MAX_ARM_ANGLE2;
    turning_angle[1] = MAX(turnFact,0.0) * MAX_ARM_ANGLE2;
    flap_angle = MAX_ARM_ANGLE2 * (0.5 + 0.5 * sin (M_PI * flap_factor * 6 - M_PI / 2));
    force_angle = max (-20.0, min (20.0, -net_force.z / 300.0));
    turn_leg_angle = turnFact * 10;
    
	ResetJoints ();

    RotateNode ("left_shldr", 3, 
		    MIN (braking_angle + paddling_angle + turning_angle[0], MAX_ARM_ANGLE2) + flap_angle);
    RotateNode ("right_shldr", 3,
		    MIN (braking_angle + paddling_angle + turning_angle[1], MAX_ARM_ANGLE2) + flap_angle);

    RotateNode ("left_shldr", 2, -ext_paddling_angle);
    RotateNode ("right_shldr", 2, ext_paddling_angle);
    RotateNode ("left_hip", 3, -20 + turn_leg_angle + force_angle);
    RotateNode ("right_hip", 3, -20 - turn_leg_angle + force_angle);
	
    RotateNode ("left_knee", 3, 
		-10 + turn_leg_angle - MIN (35, speed) + kick_paddling_angle + force_angle);
    RotateNode ("right_knee", 3, 
		-10 - turn_leg_angle - MIN (35, speed) - kick_paddling_angle + force_angle);

    RotateNode ("left_ankle", 3, -20 + MIN (50, speed));
    RotateNode ("right_ankle", 3, -20 + MIN (50, speed));
    RotateNode ("tail", 3, turnFact * 20);
    RotateNode ("neck", 3, -50);
    RotateNode ("head", 3, -30);
    RotateNode ("head", 2, -turnFact * 70);
}