/*
================
DialogAFConstraintSpring::LoadConstraint
================
*/
void DialogAFConstraintSpring::LoadConstraint( idDeclAF_Constraint *c ) {
	int i;

	constraint = c;

	// load first anchor from the current idDeclAF_Constraint
	SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;
	if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );

	// load second anchor from the current idDeclAF_Constraint
	SetSafeComboBoxSelection( &m_comboAnchor2Joint, constraint->anchor2.joint1.c_str(), -1 );
	m_anchor2_x = constraint->anchor2.ToVec3().x;
	m_anchor2_y = constraint->anchor2.ToVec3().y;
	m_anchor2_z = constraint->anchor2.ToVec3().z;
	if ( constraint->anchor2.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR2_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR2_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR2_JOINT, IDC_RADIO_ANCHOR2_COORDINATES, i );

	// spring settings
	m_stretch = constraint->stretch;
	m_compress = constraint->compress;
	m_damping = constraint->damping;
	m_restLength = constraint->restLength;

	// spring limits
	if ( constraint->minLength > 0.0f ) {
		i = IDC_RADIO_SPRING_MIN_LENGTH;
	}
	else {
		i = IDC_RADIO_SPRING_NO_MIN_LENGTH;
	}
	CheckRadioButton( IDC_RADIO_SPRING_NO_MIN_LENGTH, IDC_RADIO_SPRING_MIN_LENGTH, i );
	m_minLength = constraint->minLength;

	if ( constraint->maxLength > 0.0f ) {
		i = IDC_RADIO_SPRING_MAX_LENGTH;
	}
	else {
		i = IDC_RADIO_SPRING_NO_MAX_LENGTH;
	}
	CheckRadioButton( IDC_RADIO_SPRING_NO_MAX_LENGTH, IDC_RADIO_SPRING_MAX_LENGTH, i );
	m_maxLength = constraint->maxLength;

	// update displayed values
	UpdateData( FALSE );
}
Exemple #2
0
/*
================
DialogAFConstraintHinge::LoadConstraint
================
*/
void DialogAFConstraintHinge::LoadConstraint( idDeclAF_Constraint *c ) {
	int i, s1, s2;
	idAngles angles;

	constraint = c;

	// load anchor from the current idDeclAF_Constraint
	SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;
	if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );

	// hinge axis
	s1 = SetSafeComboBoxSelection( &m_comboAxisJoint1, constraint->axis.joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboAxisJoint2, constraint->axis.joint2.c_str(), s1 );
	angles = constraint->axis.ToVec3().ToAngles();
	m_axisPitch = angles.pitch;
	m_axisYaw = angles.yaw;
	if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_HINGE_AXIS_BONE;
	}
	else {
		i = IDC_RADIO_HINGE_AXIS_ANGLES;
		constraint->axis.type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_HINGE_AXIS_BONE, IDC_RADIO_HINGE_AXIS_ANGLES, i );

	// hinge limit
	if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
		i = IDC_RADIO_HINGE_LIMIT_ANGLES;
	}
	else {
		i = IDC_RADIO_HINGE_LIMIT_NONE;
	}
	CheckRadioButton( IDC_RADIO_HINGE_LIMIT_NONE, IDC_RADIO_HINGE_LIMIT_ANGLES, i );
	m_limitAngle1 = constraint->limitAngles[0];
	m_limitAngle2 = constraint->limitAngles[1];
	m_limitAngle3 = constraint->limitAngles[2];

	// update displayed values
	UpdateData( FALSE );
}
/*
================
DialogAFBody::InitModifiedJointList
================
*/
void DialogAFBody::InitModifiedJointList( void ) {
	int i, j, numJoints;
	CString str;
	m_comboModifiedJoint.ResetContent();
	if( !file ) {
		return;
	}
	const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
	if( !model ) {
		return;
	}
	numJoints = model->NumJoints();
	for( i = 0; i < numJoints; i++ ) {
		const char *jointName = model->GetJointName( ( jointHandle_t ) i );
		for( j = 0; j < file->bodies.Num(); j++ ) {
			if( file->bodies[j] == body ) {
				continue;
			}
			if( file->bodies[j]->jointName.Icmp( jointName ) == 0 ) {
				break;
			}
		}
		if( j < file->bodies.Num() ) {
			continue;
		}
		m_comboModifiedJoint.AddString( jointName );
	}
	if( body ) {
		if( body->jointName.Length() == 0 ) {
			m_comboModifiedJoint.GetLBText( 0, str );
			body->jointName = str;
		}
		SetSafeComboBoxSelection( &m_comboModifiedJoint, body->jointName, -1 );
		// cannot change the body which modifies the origin joint
		if( body->jointName.Icmp( "origin" ) == 0 ) {
			// check if there is another body which modifies the "origin" joint
			for( i = 0; i < file->bodies.Num(); i++ ) {
				if( file->bodies[i] == body ) {
					continue;
				}
				if( file->bodies[i]->jointName.Icmp( "origin" ) == 0 ) {
					break;
				}
			}
			// if there is another body which modifies the "origin" joint
			if( i < file->bodies.Num() ) {
				GetDlgItem( IDC_COMBO_MODIFIEDJOINT )->EnableWindow( true );
			} else {
				GetDlgItem( IDC_COMBO_MODIFIEDJOINT )->EnableWindow( false );
			}
		} else {
			GetDlgItem( IDC_COMBO_MODIFIEDJOINT )->EnableWindow( true );
		}
	}
}
/*
================
DialogAFConstraint::LoadConstraint
================
*/
void DialogAFConstraint::LoadConstraint( const char *name ) {
	int i, s1, s2;

	if ( !file ) {
		return;
	}
	for ( i = 0; i < file->constraints.Num(); i++ ) {
		if ( file->constraints[i]->name.Icmp( name ) == 0 ) {
			break;
		}
	}
	if ( i >= file->constraints.Num() ) {
		return;
	}
	constraint = file->constraints[i];

	// load the constraint type from the current idDeclAF_Constraint
	SetSafeComboBoxSelection( &m_comboConstraintType, ConstraintTypeToString( constraint->type ), -1 );

	// load constrained bodies from the current idDeclAF_Constraint
	s1 = SetSafeComboBoxSelection( &m_comboBody1List, constraint->body1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboBody2List, constraint->body2.c_str(), s1 );

	// load friction from the current idDeclAF_Constraint
	m_friction = constraint->friction;

	// update displayed values
	UpdateData( FALSE );

	InitConstraintTypeDlg();

	if ( GetStyle() & WS_VISIBLE ) {
		// highlight the current constraint ingame
		cvarSystem->SetCVarString( "af_highlightConstraint", name );
	}
}
Exemple #5
0
/*
================
DialogDeclNew::OnInitDialog
================
*/
BOOL DialogDeclNew::OnInitDialog()  {

	CDialog::OnInitDialog();

	InitTypeList();

	SetSafeComboBoxSelection( &typeList, defaultType.c_str(), -1 );
	nameEdit.SetWindowText( defaultName.c_str() );
	fileEdit.SetWindowText( defaultFile.c_str() );

	EnableToolTips( TRUE );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
/*
================
DialogAFConstraintSlider::LoadConstraint
================
*/
void DialogAFConstraintSlider::LoadConstraint( idDeclAF_Constraint *c ) {
	int i, s1, s2;
	idAngles angles;

	constraint = c;

	// slider axis
	s1 = SetSafeComboBoxSelection( &m_comboAxisJoint1, constraint->axis.joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboAxisJoint2, constraint->axis.joint2.c_str(), s1 );
	angles = constraint->axis.ToVec3().ToAngles();
	m_axisPitch = angles.pitch;
	m_axisYaw = angles.yaw;
	if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_SLIDER_AXIS_BONE;
	}
	else {
		i = IDC_RADIO_SLIDER_AXIS_ANGLES;
		constraint->axis.type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_SLIDER_AXIS_BONE, IDC_RADIO_SLIDER_AXIS_ANGLES, i );

	// update displayed values
	UpdateData( FALSE );
}
/*
================
DialogAFConstraintUniversal::LoadConstraint
================
*/
void DialogAFConstraintUniversal::LoadConstraint( idDeclAF_Constraint *c ) {
	int i, s1, s2;
	idAngles angles;
	idMat3 mat;

	constraint = c;

	// anchor
	SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;
	if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );

	// shaft 1
	s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft1, constraint->shaft[0].joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft1, constraint->shaft[0].joint2.c_str(), s1 );
	angles = constraint->shaft[0].ToVec3().ToAngles();
	m_pitchShaft1 = angles.pitch;
	m_yawShaft1 = angles.yaw;
	if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_BONE_SHAFT1;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1;
		constraint->shaft[0].type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT1, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, i );

	// shaft 2
	s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft2, constraint->shaft[1].joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft2, constraint->shaft[1].joint2.c_str(), s1 );
	angles = constraint->shaft[1].ToVec3().ToAngles();
	m_pitchShaft2 = angles.pitch;
	m_yawShaft2 = angles.yaw;
	if ( constraint->shaft[1].type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_BONE_SHAFT2;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2;
		constraint->shaft[1].type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT2, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, i );

	// limit
	if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_CONE;
	}
	else if ( constraint->limit == idDeclAF_Constraint::LIMIT_PYRAMID ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_LIMIT_NONE;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_NONE, IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, i );

	m_coneAngle = constraint->limitAngles[0];
	m_pyramidAngle1 = constraint->limitAngles[0];
	m_pyramidAngle2 = constraint->limitAngles[1];
	m_limitRoll = constraint->limitAngles[2];
	angles = constraint->limitAxis.ToVec3().ToAngles();
	m_limitPitch = angles.pitch;
	m_limitYaw = angles.yaw;

	if ( constraint->limitAxis.type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_BONE;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_LIMIT_ANGLES;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_BONE, IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, i );
	s1 = SetSafeComboBoxSelection( &m_comboLimitJoint1, constraint->limitAxis.joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboLimitJoint2, constraint->limitAxis.joint2.c_str(), s1 );

	// update displayed values
	UpdateData( FALSE );
}
/*
================
DialogAFConstraintBallAndSocket::LoadConstraint
================
*/
void DialogAFConstraintBallAndSocket::LoadConstraint( idDeclAF_Constraint *c ) {
	int i, s1, s2;
	idAngles angles;

	constraint = c;

	// anchor
	SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;
	if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );

	// limit
	if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
		i = IDC_RADIO_BAS_LIMIT_CONE;
	}
	else if ( constraint->limit == idDeclAF_Constraint::LIMIT_PYRAMID ) {
		i = IDC_RADIO_BAS_LIMIT_PYRAMID;
	}
	else {
		i = IDC_RADIO_BAS_LIMIT_NONE;
	}
	CheckRadioButton( IDC_RADIO_BAS_LIMIT_NONE, IDC_RADIO_BAS_LIMIT_PYRAMID, i );

	m_coneAngle = constraint->limitAngles[0];
	m_pyramidAngle1 = constraint->limitAngles[0];
	m_pyramidAngle2 = constraint->limitAngles[1];
	m_limitRoll = constraint->limitAngles[2];
	angles = constraint->limitAxis.ToVec3().ToAngles();
	m_limitPitch = angles.pitch;
	m_limitYaw = angles.yaw;

	if ( constraint->limitAxis.type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_BAS_LIMIT_BONE;
	}
	else {
		i = IDC_RADIO_BAS_LIMIT_ANGLES;
	}
	CheckRadioButton( IDC_RADIO_BAS_LIMIT_BONE, IDC_RADIO_BAS_LIMIT_ANGLES, i );
	s1 = SetSafeComboBoxSelection( &m_comboLimitJoint1, constraint->limitAxis.joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboLimitJoint2, constraint->limitAxis.joint2.c_str(), s1 );

	// limit axis
	s1 = SetSafeComboBoxSelection( &m_comboLimitAxisJoint1, constraint->shaft[0].joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboLimitAxisJoint2, constraint->shaft[0].joint2.c_str(), s1 );
	angles = constraint->shaft[0].ToVec3().ToAngles();
	m_limitAxisPitch = angles.pitch;
	m_limitAxisYaw = angles.yaw;
	if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_BAS_LIMIT_AXIS_BONE;
	}
	else {
		i = IDC_RADIO_BAS_LIMIT_AXIS_ANGLES;
		constraint->shaft[0].type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_BAS_LIMIT_AXIS_BONE, IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, i );

	// update displayed values
	UpdateData( FALSE );
}
/*
================
DialogAFBody::LoadBody
================
*/
void DialogAFBody::LoadBody( const char *name ) {
	int i, s1, s2;
	idStr str;
	if( !file ) {
		return;
	}
	for( i = 0; i < file->bodies.Num(); i++ ) {
		if( file->bodies[i]->name.Icmp( name ) == 0 ) {
			break;
		}
	}
	if( i >= file->bodies.Num() ) {
		return;
	}
	body = file->bodies[i];
	// load collision model from the current idDeclAF_Body
	SetSafeComboBoxSelection( &cm_comboType, ModelTypeToString( body->modelType ), -1 );
	if( body->modelType == TRM_BONE ) {
		s1 = SetSafeComboBoxSelection( &cm_comboBoneJoint1, body->v1.joint1.c_str(), -1 );
		s2 = SetSafeComboBoxSelection( &cm_comboBoneJoint2, body->v2.joint1.c_str(), s1 );
		cm_width = body->width;
		cm_length = cm_height = 20.0f;
		s1 = SetSafeComboBoxSelection( &cm_originBoneCenterJoint1, body->v1.joint1.c_str(), -1 );
		s2 = SetSafeComboBoxSelection( &cm_originBoneCenterJoint2, body->v2.joint1.c_str(), s1 );
	} else {
		cm_length = body->v2.ToVec3().x - body->v1.ToVec3().x;
		cm_height = body->v2.ToVec3().z - body->v1.ToVec3().z;
		cm_width = body->v2.ToVec3().y - body->v1.ToVec3().y;
		cm_origin_x = body->origin.ToVec3().x;
		cm_origin_y = body->origin.ToVec3().y;
		cm_origin_z = body->origin.ToVec3().z;
		s1 = SetSafeComboBoxSelection( &cm_originBoneCenterJoint1, body->origin.joint1.c_str(), -1 );
		s2 = SetSafeComboBoxSelection( &cm_originBoneCenterJoint2, body->origin.joint2.c_str(), s1 );
		s1 = SetSafeComboBoxSelection( &cm_originJoint, body->origin.joint1.c_str(), -1 );
		cm_angles_pitch = body->angles.pitch;
		cm_angles_yaw = body->angles.yaw;
		cm_angles_roll = body->angles.roll;
		if( body->origin.type == idAFVector::VEC_BONECENTER ) {
			i = IDC_RADIO_ORIGIN_BONECENTER;
		} else if( body->origin.type == idAFVector::VEC_JOINT ) {
			i = IDC_RADIO_ORIGIN_JOINT;
		} else {
			i = IDC_RADIO_ORIGIN_COORDINATES;
		}
		CheckRadioButton( IDC_RADIO_ORIGIN_COORDINATES, IDC_RADIO_ORIGIN_JOINT, i );
	}
	cm_numSides = body->numSides;
	cm_density = body->density;
	if( body->inertiaScale == mat3_identity ) {
		cm_inertiaScale.SetWindowText( "none" );
	} else {
		cm_inertiaScale.SetWindowText( body->inertiaScale.ToString( 1 ) );
	}
	// load collision detection settings from the current idDeclAF_Body
	m_selfCollision = body->selfCollision;
	idDeclAF::ContentsToString( body->contents, str );
	m_editContents.SetWindowText( str );
	idDeclAF::ContentsToString( body->clipMask, str );
	m_editClipMask.SetWindowText( str );
	// load friction settings from the current idDeclAF_Body
	m_linearFriction = body->linearFriction;
	m_angularFriction = body->angularFriction;
	m_contactFriction = body->contactFriction;
	// friction direction and contact motor direction
	if( body->frictionDirection.ToVec3() != vec3_origin ) {
		idFile_Memory file( "frictionDirection" );
		file.WriteFloatString( "%f %f %f", body->frictionDirection.ToVec3().x, body->frictionDirection.ToVec3().y, body->frictionDirection.ToVec3().z );
		m_frictionDirection.SetWindowText( file.GetDataPtr() );
	} else {
		m_frictionDirection.SetWindowText( "" );
	}
	if( body->contactMotorDirection.ToVec3() != vec3_origin ) {
		idFile_Memory file( "contactMotorDirection" );
		file.WriteFloatString( "%f %f %f", body->contactMotorDirection.ToVec3().x, body->contactMotorDirection.ToVec3().y, body->contactMotorDirection.ToVec3().z );
		m_contactMotorDirection.SetWindowText( file.GetDataPtr() );
	} else {
		m_contactMotorDirection.SetWindowText( "" );
	}
	// load joint settings from the current idDeclAF_Body
	InitModifiedJointList();
	if( body->jointMod == DECLAF_JOINTMOD_AXIS ) {
		i = IDC_RADIO_MODIFY_ORIENTATION;
	} else if( body->jointMod == DECLAF_JOINTMOD_ORIGIN ) {
		i = IDC_RADIO_MODIFY_POSITION;
	} else if( body->jointMod == DECLAF_JOINTMOD_BOTH ) {
		i = IDC_RADIO_MODIFY_BOTH;
	} else {
		i = IDC_RADIO_MODIFY_ORIENTATION;
	}
	CheckRadioButton( IDC_RADIO_MODIFY_ORIENTATION, IDC_RADIO_MODIFY_BOTH, i );
	m_editContainedJoints.SetWindowText( body->containedJoints.c_str() );
	// update displayed values
	UpdateData( FALSE );
	InitCollisionModelType();	// CComboBox::SetCurSel doesn't call this
	if( GetStyle() & WS_VISIBLE ) {
		// highlight the current body ingame
		cvarSystem->SetCVarString( "af_highlightBody", name );
	}
}