Beispiel #1
0
/*
================
DialogAFConstraintHinge::SaveConstraint
================
*/
void DialogAFConstraintHinge::SaveConstraint( void ) {
	int s1, s2;
	CString str;

	if ( !file || !constraint ) {
		return;
	}
	UpdateData( TRUE );

	// save anchor to the current idDeclAF_Constraint
	GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
	constraint->anchor.joint1 = str;
	constraint->anchor.ToVec3().x = m_anchor_x;
	constraint->anchor.ToVec3().y = m_anchor_y;
	constraint->anchor.ToVec3().z = m_anchor_z;

	// hinge axis
	if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
		s1 = GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
		constraint->axis.joint1 = str;
		s2 = GetSafeComboBoxSelection( &m_comboAxisJoint2, str, s1 );
		constraint->axis.joint2 = str;
	}
	else {
		constraint->axis.ToVec3() = idAngles( m_axisPitch, m_axisYaw, 0.0f ).ToForward();
	}

	// hinge limit
	constraint->limitAngles[0] = m_limitAngle1;
	constraint->limitAngles[1] = m_limitAngle2;
	constraint->limitAngles[2] = m_limitAngle3;

	AFDialogSetFileModified();
}
/*
================
DialogAFConstraintSpring::SaveConstraint
================
*/
void DialogAFConstraintSpring::SaveConstraint( void ) {
	CString str;

	if ( !file || !constraint ) {
		return;
	}
	UpdateData( TRUE );

	// save first anchor to the current idDeclAF_Constraint
	GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
	constraint->anchor.joint1 = str;
	constraint->anchor.ToVec3().x = m_anchor_x;
	constraint->anchor.ToVec3().y = m_anchor_y;
	constraint->anchor.ToVec3().z = m_anchor_z;

	// save second anchor to the current idDeclAF_Constraint
	GetSafeComboBoxSelection( &m_comboAnchor2Joint, str, -1 );
	constraint->anchor2.joint1 = str;
	constraint->anchor2.ToVec3().x = m_anchor2_x;
	constraint->anchor2.ToVec3().y = m_anchor2_y;
	constraint->anchor2.ToVec3().z = m_anchor2_z;

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

	// spring limits
	constraint->minLength = m_minLength;
	constraint->maxLength = m_maxLength;

	AFDialogSetFileModified();
}
/*
================
DialogAFConstraintBallAndSocket::SaveConstraint
================
*/
void DialogAFConstraintBallAndSocket::SaveConstraint( void ) {
	int s1, s2;
	CString str;
	idAngles angles;

	if ( !file || !constraint ) {
		return;
	}
	UpdateData( TRUE );

	// anchor
	GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
	constraint->anchor.joint1 = str;
	constraint->anchor.ToVec3().x = m_anchor_x;
	constraint->anchor.ToVec3().y = m_anchor_y;
	constraint->anchor.ToVec3().z = m_anchor_z;

	// limit
	if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
		constraint->limitAngles[0] = m_coneAngle;
	}
	else {
		constraint->limitAngles[0] = m_pyramidAngle1;
	}
	constraint->limitAngles[1] = m_pyramidAngle2;
	constraint->limitAngles[2] = m_limitRoll;
	angles.pitch = m_limitPitch;
	angles.yaw = m_limitYaw;
	angles.roll = 0.0f;
	constraint->limitAxis.ToVec3() = angles.ToForward();
	s1 = GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
	constraint->limitAxis.joint1 = str;
	s2 = GetSafeComboBoxSelection( &m_comboLimitJoint2, str, s1 );
	constraint->limitAxis.joint2 = str;

	// limit axis
	if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
		s1 = GetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str, -1 );
		constraint->shaft[0].joint1 = str;
		s2 = GetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str, s1 );
		constraint->shaft[0].joint2 = str;
	}
	else {
		constraint->shaft[0].ToVec3() = idAngles( m_limitAxisPitch, m_limitAxisYaw, 0.0f ).ToForward();
	}

	AFDialogSetFileModified();
}
/*
================
DialogAFConstraintSlider::SaveConstraint
================
*/
void DialogAFConstraintSlider::SaveConstraint( void ) {
	int s1, s2;
	CString str;

	if ( !file || !constraint ) {
		return;
	}
	UpdateData( TRUE );

	// slider axis
	if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
		s1 = GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
		constraint->axis.joint1 = str;
		s2 = GetSafeComboBoxSelection( &m_comboAxisJoint2, str, s1 );
		constraint->axis.joint2 = str;
	}
	else {
		constraint->axis.ToVec3() = idAngles( m_axisPitch, m_axisYaw, 0.0f ).ToForward();
	}

	AFDialogSetFileModified();
}
/*
================
DialogAFConstraint::SaveConstraint
================
*/
void DialogAFConstraint::SaveConstraint( void ) {
	int s1, s2;
	CString str;

	if ( !file || !constraint ) {
		return;
	}
	UpdateData( TRUE );

	// save constraint type to the current idDeclAF_Constraint
	GetSafeComboBoxSelection( &m_comboConstraintType, str, -1 );
	constraint->type = StringToConstraintType( str );

	// save constrained bodies to the current idDeclAF_Constraint
	s1 = GetSafeComboBoxSelection( &m_comboBody1List, str, -1 );
	constraint->body1 = str;
	s2 = GetSafeComboBoxSelection( &m_comboBody2List, str, s1 );
	constraint->body2 = str;

	// save friction to the current idDeclAF_Constraint
	constraint->friction = m_friction;

	AFDialogSetFileModified();
}
/*
================
DialogAFConstraint::InitConstraintTypeDlg
================
*/
void DialogAFConstraint::InitConstraintTypeDlg( void ) {
	CString str;
	RECT rect;

	if ( !file || !constraint ) {
		return;
	}

	UpdateData( TRUE );

	if ( constraintDlg ) {
		constraintDlg->ShowWindow( SW_HIDE );
	}

	GetSafeComboBoxSelection( &m_comboConstraintType, str, -1 );
	switch( StringToConstraintType( str ) ) {
		case DECLAF_CONSTRAINT_FIXED:
			fixedDlg->LoadConstraint( constraint );
			constraintDlg = fixedDlg;
			break;
		case DECLAF_CONSTRAINT_BALLANDSOCKETJOINT:
			ballAndSocketDlg->LoadConstraint( constraint );
			constraintDlg = ballAndSocketDlg;
			break;
		case DECLAF_CONSTRAINT_UNIVERSALJOINT:
			universalDlg->LoadConstraint( constraint );
			constraintDlg = universalDlg;
			break;
		case DECLAF_CONSTRAINT_HINGE:
			hingeDlg->LoadConstraint( constraint );
			constraintDlg = hingeDlg;
			break;
		case DECLAF_CONSTRAINT_SLIDER:
			sliderDlg->LoadConstraint( constraint );
			constraintDlg = sliderDlg;
			break;
		case DECLAF_CONSTRAINT_SPRING:
			springDlg->LoadConstraint( constraint );
			constraintDlg = springDlg;
			break;
	}

	if ( constraintDlg ) {
		constraintDlg->ShowWindow( SW_SHOW );
		constraintDlg->GetWindowRect( &rect );
		constraintDlg->MoveWindow( 0, 117, rect.right - rect.left, rect.bottom - rect.top );
	}
}
Beispiel #7
0
/*
================
DialogDeclNew::OnBnClickedOk
================
*/
void DialogDeclNew::OnBnClickedOk() {
	CString typeName, declName, fileName;
	const char *errorTitle = "Error creating declaration.";

	if ( !declTree ) {
		MessageBox( "No declaration tree available.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	if ( GetSafeComboBoxSelection( &typeList, typeName, -1 ) == -1 ) {
		MessageBox( "No declaration type selected.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	nameEdit.GetWindowText( declName );
	if ( declName.GetLength() == 0 ) {
		MessageBox( "No declaration name specified.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	fileEdit.GetWindowText( fileName );
	if ( fileName.GetLength() == 0 ) {
		MessageBox( "No file name specified.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	if ( declTree->FindItem( idStr( typeName + "/" + declName ) ) ) {
		MessageBox( "Declaration already exists.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	declType_t type = declManager->GetDeclTypeFromName( typeName );
	if ( type >= declManager->GetNumDeclTypes() ) {
		MessageBox( "Unknown declaration type.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	newDecl = declManager->CreateNewDecl( type, declName, fileName );

	OnOK();
}
Beispiel #8
0
/*
================
DialogDeclNew::OnBnClickedFile
================
*/
void DialogDeclNew::OnBnClickedFile() {
	CString typeName, folder, ext;
	idStr path;
	const char *errorTitle = "Error selecting file.";

	if ( GetSafeComboBoxSelection( &typeList, typeName, -1 ) == -1 ) {
		MessageBox( "Select a declaration type first.", errorTitle, MB_OK );
		return;
	}

	declType_t type = declManager->GetDeclTypeFromName( typeName );
	if ( type >= declManager->GetNumDeclTypes() ) {
		MessageBox( "Unknown declaration type.", errorTitle, MB_OK | MB_ICONERROR );
		return;
	}

	switch( type ) {
		case DECL_TABLE:		folder = "materials";	ext = "(*.mtr)|*.mtr|(*.*)|*.*||";					break;
		case DECL_MATERIAL:		folder = "materials";	ext = "(*.mtr)|*.mtr|(*.*)|*.*||";					break;
		case DECL_SKIN:			folder = "skins";		ext = "(*.skin)|*.skin|(*.*)|*.*||";				break;
		case DECL_SOUND:		folder = "sound";		ext = "(*.sndshd|*.sndshd|(*.*)|*.*||";				break;
		case DECL_ENTITYDEF:	folder = "def";			ext = "(*.def)|*.def|(*.decl)|*.decl|(*.*)|*.*||";	break;
		case DECL_MODELDEF:		folder = "def";			ext = "(*.def)|*.def|(*.*)|*.*||";					break;
		case DECL_FX:			folder = "fx";			ext = "(*.fx)|*.fx|(*.*)|*.*||";					break;
		case DECL_PARTICLE:		folder = "particles";	ext = "(*.prt)|*.prt|(*.*)|*.*||";					break;
		case DECL_AF:			folder = "af";			ext = "(*.af)|*.af|(*.*)|*.*||";					break;
		default:				folder = "def";			ext = "(*.decl)|*.decl|(*.*)|*.*||";				break;
	}

	path = fileSystem->RelativePathToOSPath( folder );
	path += "\\*";

	CFileDialog dlgFile( TRUE, "decl", path, 0, ext, this );
	if ( dlgFile.DoModal() == IDOK ) {
		path = fileSystem->OSPathToRelativePath( dlgFile.m_ofn.lpstrFile );
		fileEdit.SetWindowText( path );
	}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalLimitJoint2() {
	CString str;
	GetSafeComboBoxSelection( &m_comboLimitJoint2, str, -1 );
	UnsetSafeComboBoxSelection( &m_comboLimitJoint1, str );
	UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitAxisJoint2() {
	CString str;
	GetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str, -1 );
	UnsetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str );
	UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintBody2() {
	CString str;
	GetSafeComboBoxSelection( &m_comboBody2List, str, -1 );
	UnsetSafeComboBoxSelection( &m_comboBody1List, str );
	UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraints() {
	CString str;

	GetSafeComboBoxSelection( &m_comboConstraintList, str, -1 );
	LoadConstraint( str );
}
Beispiel #13
0
void DialogAFConstraintHinge::OnCbnSelchangeComboHingeAxisJoint2() {
	CString str;
	GetSafeComboBoxSelection( &m_comboAxisJoint2, str, -1 );
	UnsetSafeComboBoxSelection( &m_comboAxisJoint1, str );
	UpdateFile();
}
Beispiel #14
0
void DialogAFBody::OnCbnSelchangeComboBoneJoint2() {
	CString str;
	GetSafeComboBoxSelection( &cm_comboBoneJoint2, str, -1 );
	UnsetSafeComboBoxSelection( &cm_comboBoneJoint1, str );
	UpdateFile();
}
Beispiel #15
0
void DialogAFBody::OnCbnSelchangeComboBodies() {
	CString str;
	GetSafeComboBoxSelection( &bodyList, str, -1 );
	LoadBody( str );
}
Beispiel #16
0
/*
================
DialogAFBody::SaveBody
================
*/
void DialogAFBody::SaveBody( void ) {
	int s1, s2;
	CString str;
	if( !file || !body ) {
		return;
	}
	UpdateData( TRUE );
	// save the collision model to the current idDeclAF_Body
	cm_comboType.GetLBText( cm_comboType.GetCurSel(), str );
	body->modelType = StringToModelType( str );
	if( body->modelType == TRM_BONE ) {
		body->origin.type = idAFVector::VEC_BONECENTER;
		s1 = GetSafeComboBoxSelection( &cm_comboBoneJoint1, str, -1 );
		body->v1.type = idAFVector::VEC_JOINT;
		body->v1.joint1 = str;
		body->origin.joint1 = str;
		s2 = GetSafeComboBoxSelection( &cm_comboBoneJoint2, str, s1 );
		body->v2.type = idAFVector::VEC_JOINT;
		body->v2.joint1 = str;
		body->origin.joint2 = str;
		body->width = cm_width;
		body->angles.Zero();
	} else {
		body->v1.type = idAFVector::VEC_COORDS;
		body->v1.ToVec3().x = -0.5f * cm_length;
		body->v1.ToVec3().y = -0.5f * cm_width;
		body->v1.ToVec3().z = -0.5f * cm_height;
		body->v2.type = idAFVector::VEC_COORDS;
		body->v2.ToVec3().x = 0.5f * cm_length;
		body->v2.ToVec3().y = 0.5f * cm_width;
		body->v2.ToVec3().z = 0.5f * cm_height;
		body->origin.ToVec3().x = cm_origin_x;
		body->origin.ToVec3().y = cm_origin_y;
		body->origin.ToVec3().z = cm_origin_z;
		body->angles.pitch = cm_angles_pitch;
		body->angles.yaw = cm_angles_yaw;
		body->angles.roll = cm_angles_roll;
		if( body->origin.type == idAFVector::VEC_JOINT ) {
			s1 = GetSafeComboBoxSelection( &cm_originJoint, str, -1 );
			body->origin.joint1 = str;
		} else {
			s1 = GetSafeComboBoxSelection( &cm_originBoneCenterJoint1, str, -1 );
			body->origin.joint1 = str;
		}
		s2 = GetSafeComboBoxSelection( &cm_originBoneCenterJoint2, str, s1 );
		body->origin.joint2 = str;
	}
	body->numSides = cm_numSides;
	body->density = cm_density;
	cm_inertiaScale.GetWindowText( str );
	if( idStr::Icmp( str, "none" ) == 0 ) {
		body->inertiaScale.Identity();
	} else {
		idLexer src( str, str.GetLength(), "inertiaScale" );
		src.SetFlags( LEXFL_NOERRORS | LEXFL_NOWARNINGS );
		for( int i = 0; i < 3; i++ ) {
			for( int j = 0; j < 3; j++ ) {
				body->inertiaScale[i][j] = src.ParseFloat();
			}
		}
	}
	// save the collision detection settings to the current idDeclAF_Body
	body->selfCollision = ( m_selfCollision != FALSE );
	m_editContents.GetWindowText( str );
	body->contents = idDeclAF::ContentsFromString( str );
	m_editClipMask.GetWindowText( str );
	body->clipMask = idDeclAF::ContentsFromString( str );
	// save friction settings to the current idDeclAF_Body
	body->linearFriction = m_linearFriction;
	body->angularFriction = m_angularFriction;
	body->contactFriction = m_contactFriction;
	// friction direction and contact motor direction
	m_frictionDirection.GetWindowText( str );
	if( str.GetLength() != 0 ) {
		body->frictionDirection.ToVec3().Zero();
		sscanf( str, "%f %f %f", &body->frictionDirection.ToVec3().x, &body->frictionDirection.ToVec3().y, &body->frictionDirection.ToVec3().z );
	}
	m_contactMotorDirection.GetWindowText( str );
	if( str.GetLength() != 0 ) {
		body->contactMotorDirection.ToVec3().Zero();
		sscanf( str, "%f %f %f", &body->contactMotorDirection.ToVec3().x, &body->contactMotorDirection.ToVec3().y, &body->contactMotorDirection.ToVec3().z );
	}
	// save joint settings to the current idDeclAF_Body
	GetSafeComboBoxSelection( &m_comboModifiedJoint, str, -1 );
	body->jointName = str;
	m_editContainedJoints.GetWindowText( str );
	body->containedJoints = str;
	AFDialogSetFileModified();
}
Beispiel #17
0
void DialogAFBody::OnOnCbnSelchangeComboOriginBoneCenterJoint1() {
	CString str;
	GetSafeComboBoxSelection( &cm_originBoneCenterJoint1, str, -1 );
	UnsetSafeComboBoxSelection( &cm_originBoneCenterJoint2, str );
	UpdateFile();
}