void DialogAFConstraint::OnBnClickedButtonRenameconstraint() {
	int i;
	CString name, newName;
	DialogAFName nameDlg;

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

	i = m_comboConstraintList.GetCurSel();
	if ( i != CB_ERR ) {
		m_comboConstraintList.GetLBText( i, name );
		nameDlg.SetName( name );
		nameDlg.SetComboBox( &m_comboConstraintList );
		if ( nameDlg.DoModal() == IDOK ) {
			nameDlg.GetName( newName );
			// rename constraint;
			file->RenameConstraint( name, newName );
			m_comboConstraintList.DeleteString( i );
			m_comboConstraintList.SetCurSel( m_comboConstraintList.AddString( newName ) );
			LoadConstraint( newName );
			gameEdit->AF_UpdateEntities( file->GetName() );
			AFDialogSetFileModified();
		}
	}
}
/*
================
DialogAFConstraintUniversal::SaveConstraint
================
*/
void DialogAFConstraintUniversal::SaveConstraint( void ) {
	int s1, s2;
	CString str;
	idAngles angles;
	idMat3 mat;

	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;

	// shaft 1
	if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
		s1 = GetSafeComboBoxSelection( &m_comboJoint1Shaft1, str, -1 );
		constraint->shaft[0].joint1 = str;
		s2 = GetSafeComboBoxSelection( &m_comboJoint2Shaft1, str, s1 );
		constraint->shaft[0].joint2 = str;
	}
	else {
		constraint->shaft[0].ToVec3() = idAngles( m_pitchShaft1, m_yawShaft1, 0.0f ).ToForward();
	}

	// shaft 2
	if ( constraint->shaft[1].type == idAFVector::VEC_BONEDIR ) {
		s1 = GetSafeComboBoxSelection( &m_comboJoint1Shaft2, str, -1 );
		constraint->shaft[1].joint1 = str;
		s2 = GetSafeComboBoxSelection( &m_comboJoint2Shaft2, str, s1 );
		constraint->shaft[1].joint2 = str;
	}
	else {
		constraint->shaft[1].ToVec3() = idAngles( m_pitchShaft2, m_yawShaft2, 0.0f ).ToForward();
	}

	// 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;

	AFDialogSetFileModified();
}
/*
================
DialogAFProperties::SetFile
================
*/
void DialogAFProperties::SaveFile( void )
{
    CString str;

    if ( !file )
    {
        return;
    }
    UpdateData( TRUE );
    m_editModel.GetWindowText( str );
    file->model = str;
    m_editSkin.GetWindowText( str );
    file->skin = str;
    file->selfCollision = ( m_selfCollision != FALSE );
    m_editContents.GetWindowText( str );
    file->contents = idDeclAF::ContentsFromString( str );
    m_editClipMask.GetWindowText( str );
    file->clipMask = idDeclAF::ContentsFromString( str );
    file->defaultLinearFriction = m_linearFriction;
    file->defaultAngularFriction = m_angularFriction;
    file->defaultContactFriction = m_contactFriction;
    file->defaultConstraintFriction = m_constraintFriction;
    file->totalMass = m_totalMass;
    file->suspendVelocity[0] = m_suspendLinearVelocity;
    file->suspendVelocity[1] = m_suspendAngularVelocity;
    file->suspendAcceleration[0] = m_suspendLinearAcceleration;
    file->suspendAcceleration[1] = m_suspendAngularAcceleration;
    file->noMoveTime = m_noMoveTime;
    file->minMoveTime = m_minMoveTime;
    file->maxMoveTime = m_maxMoveTime;
    file->noMoveTranslation = m_linearTolerance;
    file->noMoveRotation = m_angularTolerance;

    AFDialogSetFileModified();
}
예제 #4
0
void DialogAFBody::OnBnClickedButtonRenamebody() {
	int i;
	CString name, newName;
	DialogAFName nameDlg;
	if( !file || !body ) {
		return;
	}
	i = bodyList.GetCurSel();
	if( i != CB_ERR ) {
		bodyList.GetLBText( i, name );
		nameDlg.SetName( name );
		nameDlg.SetComboBox( &bodyList );
		if( nameDlg.DoModal() == IDOK ) {
			nameDlg.GetName( newName );
			// rename body
			file->RenameBody( name, newName );
			bodyList.DeleteString( i );
			bodyList.SetCurSel( bodyList.AddString( newName ) );
			LoadBody( newName );
			constraintDlg->LoadFile( file );
			gameEdit->AF_UpdateEntities( file->GetName() );
			AFDialogSetFileModified();
		}
	}
}
예제 #5
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();
}
예제 #6
0
void DialogAFBody::OnBnClickedButtonNewbody() {
	DialogAFName nameDlg;
	CString str;
	INT_PTR res;

	// the names 'origin' and 'world' are reserved for constraints bound to the world
	bodyList.AddString( "origin" );
	bodyList.AddString( "world" );

	nameDlg.SetComboBox( &bodyList );
	res = nameDlg.DoModal();

	bodyList.DeleteString( bodyList.FindString( -1, "origin" ) );
	bodyList.DeleteString( bodyList.FindString( -1, "world" ) );

	if ( res == IDOK ) {
		nameDlg.GetName( str );
		// create new body
		file->NewBody( str );
		bodyList.SetCurSel( bodyList.AddString( str ) );
		LoadBody( str );
		constraintDlg->LoadFile( file );
		gameEdit->AF_UpdateEntities( file->GetName() );
		AFDialogSetFileModified();
	}
	InitNewRenameDeleteButtons();
}
/*
================
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();
}
예제 #8
0
/*
================
DialogAFConstraintFixed::SaveConstraint
================
*/
void DialogAFConstraintFixed::SaveConstraint( void ) {

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

	AFDialogSetFileModified();
}
void DialogAFConstraint::OnBnClickedButtonNewconstraint() {
	DialogAFName nameDlg;
	CString str;

	nameDlg.SetComboBox( &m_comboConstraintList );
	if ( nameDlg.DoModal() == IDOK ) {
		nameDlg.GetName( str );
		// create new constraint
		file->NewConstraint( str );
		m_comboConstraintList.SetCurSel( m_comboConstraintList.AddString( str ) );
		LoadConstraint( str );
		gameEdit->AF_UpdateEntities( file->GetName() );
		AFDialogSetFileModified();
	}
	InitNewRenameDeleteButtons();
}
예제 #10
0
/*
================
DialogAF::OnBnClickedButtonAfNew
================
*/
void DialogAF::OnBnClickedButtonAfNew() {
	DialogAFName nameDlg;
	CString name;
	idStr fileName;
	nameDlg.SetComboBox( &AFList );
	if( nameDlg.DoModal() != IDOK ) {
		return;
	}
	nameDlg.GetName( name );
	CFileDialog dlgSave( FALSE, "map", NULL, OFN_OVERWRITEPROMPT, "AF Files (*.af)|*.af|All Files (*.*)|*.*||", AfxGetMainWnd() );
	if( dlgSave.DoModal() != IDOK ) {
		return;
	}
	fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile );
	// create a new .af file
	AFList.AddString( name );
	AFList.SetCurSel( AFList.FindString( -1, name ) );
	idDeclAF *decl = static_cast<idDeclAF *>( declManager->CreateNewDecl( DECL_AF, name, fileName ) );
	LoadFile( decl );
	AFDialogSetFileModified();
}
예제 #11
0
void DialogAFBody::OnBnClickedButtonDeletebody() {
	int i;
	CString str;
	if( !file || !body ) {
		return;
	}
	i = bodyList.GetCurSel();
	if( i != CB_ERR ) {
		if( MessageBox( "Are you sure you want to delete this body and all attached constraints ?", "Delete Body", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
			bodyList.GetLBText( i, str );
			// delete currently selected body
			file->DeleteBody( str );
			bodyList.DeleteString( i );
			body = NULL;
			OnCbnSelchangeComboBodies();
			constraintDlg->LoadFile( file );
			gameEdit->AF_UpdateEntities( file->GetName() );
			AFDialogSetFileModified();
		}
	}
	InitNewRenameDeleteButtons();
}
/*
================
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();
}
void DialogAFConstraint::OnBnClickedButtonDeleteconstraint() {
	int i;
	CString str;

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

	i = m_comboConstraintList.GetCurSel();
	if ( i != CB_ERR ) {
		if ( MessageBox( "Are you sure you want to delete this constraint ?", "Delete Constraint", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
			m_comboConstraintList.GetLBText( i, str );
			// delete current constraint
			file->DeleteConstraint( str );
			constraint = NULL;
			m_comboConstraintList.DeleteString( i );
			OnCbnSelchangeComboConstraints();
			gameEdit->AF_UpdateEntities( file->GetName() );
			AFDialogSetFileModified();
		}
	}
	InitNewRenameDeleteButtons();
}
/*
================
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();
}
예제 #15
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();
}