hello world

This commit is contained in:
Timothee 'TTimo' Besset
2011-11-22 15:28:15 -06:00
commit fb1609f554
2155 changed files with 1017022 additions and 0 deletions

628
neo/tools/af/DialogAF.cpp Normal file
View File

@@ -0,0 +1,628 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
#include "DialogAFView.h"
#include "DialogAFProperties.h"
#include "DialogAFBody.h"
#include "DialogAFConstraint.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
// DialogAF
#define AFTAB_VIEW 0x01
#define AFTAB_PROPERTIES 0x02
#define AFTAB_BODIES 0x03
#define AFTAB_CONSTRAINTS 0x04
toolTip_t DialogAF::toolTips[] = {
{ IDC_COMBO_AF, "select an articulated figure for editing" },
{ IDC_BUTTON_AF_NEW, "create a new articulated figure" },
{ IDC_BUTTON_AF_DELETE, "delete the selected articulated figure" },
{ IDC_BUTTON_AF_SPAWN, "spawn ingame entity using the selected articulated figure" },
{ IDC_BUTTON_AF_TPOSE, "set ingame entity using the selected articulated figure back into T-Pose" },
{ IDC_BUTTON_AF_KILL, "kill ingame entity using the selected articulated figure" },
{ IDC_BUTTON_AF_SAVE, "save the selected articulated figure" },
{ IDCANCEL, "cancel all changes to all articulated figures" },
{ 0, NULL }
};
DialogAF *g_AFDialog = NULL;
IMPLEMENT_DYNAMIC(DialogAF, CDialog)
/*
================
DialogAF::DialogAF
================
*/
DialogAF::DialogAF( CWnd* pParent /*=NULL*/ )
: CDialog(DialogAF::IDD, pParent)
, file(NULL)
{
wndTabs = NULL;
wndTabDisplay = NULL;
}
/*
================
DialogAF::~DialogAF
================
*/
DialogAF::~DialogAF() {
}
/*
================
DialogAF::DoDataExchange
================
*/
void DialogAF::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAF)
DDX_Control(pDX, IDC_COMBO_AF, AFList);
//}}AFX_DATA_MAP
}
/*
================
DialogAF::LoadFile
================
*/
void DialogAF::LoadFile( idDeclAF *af ) {
file = af;
propertiesDlg->LoadFile( af );
bodyDlg->LoadFile( af );
constraintDlg->LoadFile( af );
if ( file ) {
// select file in AFList
int i = AFList.FindString( -1, file->GetName() );
if ( i != AFList.GetCurSel() ) {
AFList.SetCurSel( i );
}
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( file->modified );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( true );
}
else {
AFList.SetCurSel( -1 );
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( false );
}
}
/*
================
DialogAF::LoadFile
================
*/
void DialogAF::SaveFile( void ) {
if ( !file ) {
return;
}
propertiesDlg->SaveFile();
bodyDlg->SaveFile();
constraintDlg->SaveFile();
gameEdit->AF_UpdateEntities( file->GetName() );
}
/*
================
DialogAF::SetFileModified
================
*/
void DialogAF::SetFileModified( void ) {
if ( file ) {
file->modified = true;
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( true );
}
}
/*
================
DialogAF::ReloadFile
================
*/
void DialogAF::ReloadFile( void ) {
LoadFile( file );
}
/*
================
DialogAF::InitAFList
================
*/
void DialogAF::InitAFList( void ) {
int i, c;
AFList.ResetContent();
c = declManager->GetNumDecls( DECL_AF );
for ( i = 0; i < c; i++ ) {
AFList.AddString( static_cast<const idDeclAF *>( declManager->DeclByIndex( DECL_AF, i, false ) )->GetName() );
}
}
/*
================
DialogAF::AddTabItem
================
*/
void DialogAF::AddTabItem( int id, const char *name ) {
TCITEM item;
item.mask = TCIF_PARAM;
item.lParam = id;
int tab = wndTabs->InsertItem( wndTabs->GetItemCount(), name );
wndTabs->SetItem( tab, &item );
}
/*
================
DialogAF::SetTab
================
*/
void DialogAF::SetTab( int id ) {
int c = wndTabs->GetItemCount();
for ( int i = 0; i < c; i++ ) {
TCITEM item;
item.mask = TCIF_PARAM;
wndTabs->GetItem( i, &item );
if ( item.lParam == id ) {
wndTabs->SetCurSel(i);
return;
}
}
wndTabs->SetCurSel(0);
}
/*
================
DialogAF::SetTabChildPos
position the child dialog box
================
*/
void DialogAF::SetTabChildPos( void ) {
if ( wndTabDisplay ) {
wndTabDisplay->ShowWindow( SW_SHOW );
wndTabDisplay->SetWindowPos( wndTabs, 12, 60, 0, 0, SWP_NOSIZE );
}
}
/*
================
DialogAF::OnInitDialog
================
*/
BOOL DialogAF::OnInitDialog() {
CDialog::OnInitDialog();
com_editors |= EDITOR_AF;
// initialize list with articulated figure files
InitAFList();
// initialize tabs
wndTabs = (CTabCtrl *) GetDlgItem( IDC_DIALOG_AF_TAB_MODE );
AddTabItem( AFTAB_VIEW, "View" );
AddTabItem( AFTAB_PROPERTIES, "Properties" );
AddTabItem( AFTAB_BODIES, "Bodies" );
AddTabItem( AFTAB_CONSTRAINTS, "Constraints" );
SetTab( AFTAB_VIEW );
// create child dialog windows
viewDlg = new DialogAFView( this );
propertiesDlg = new DialogAFProperties( this );
bodyDlg = new DialogAFBody( this );
constraintDlg = new DialogAFConstraint( this );
// the body dialog may force the constraint dialog to reload the file
bodyDlg->constraintDlg = constraintDlg;
// the properties dialog may force the body or constraint dialog to reload the file
propertiesDlg->bodyDlg = bodyDlg;
propertiesDlg->constraintDlg = constraintDlg;
// set active child dialog
wndTabDisplay = viewDlg;
SetTabChildPos();
EnableToolTips( TRUE );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(DialogAF, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY(TCN_SELCHANGE, IDC_DIALOG_AF_TAB_MODE, OnTcnSelchangeTabMode)
ON_WM_DESTROY()
ON_WM_ACTIVATE()
ON_WM_MOVE()
ON_WM_SETFOCUS()
ON_CBN_SELCHANGE(IDC_COMBO_AF, OnCbnSelchangeComboAf)
ON_BN_CLICKED(IDC_BUTTON_AF_NEW, OnBnClickedButtonAfNew)
ON_BN_CLICKED(IDC_BUTTON_AF_DELETE, OnBnClickedButtonAfDelete)
ON_BN_CLICKED(IDC_BUTTON_AF_SAVE, OnBnClickedButtonAfSave)
ON_BN_CLICKED(IDC_BUTTON_AF_SPAWN, OnBnClickedButtonAfSpawn)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON_AF_KILL, OnBnClickedButtonAfKill)
ON_BN_CLICKED(IDC_BUTTON_AF_TPOSE, OnBnClickedButtonAfTpose)
END_MESSAGE_MAP()
/*
================
AFEditorInit
================
*/
void AFEditorInit( const idDict *spawnArgs ) {
if ( renderSystem->IsFullScreen() ) {
common->Printf( "Cannot run the articulated figure editor in fullscreen mode.\n"
"Set r_fullscreen to 0 and vid_restart.\n" );
return;
}
if ( g_AFDialog == NULL ) {
InitAfx();
g_AFDialog = new DialogAF();
}
if ( g_AFDialog->GetSafeHwnd() == NULL) {
g_AFDialog->Create( IDD_DIALOG_AF );
/*
// FIXME: restore position
CRect rct;
g_AFDialog->SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE );
*/
}
idKeyInput::ClearStates();
g_AFDialog->ShowWindow( SW_SHOW );
g_AFDialog->SetFocus();
if ( spawnArgs ) {
// select AF based on spawn args
const char *name = spawnArgs->GetString( "articulatedFigure" );
if ( name[0] == '\0' ) {
name = spawnArgs->GetString( "ragdoll" );
}
idDeclAF *decl = static_cast<idDeclAF *>( const_cast<idDecl *>( declManager->FindType( DECL_AF, name ) ) );
if ( decl ) {
g_AFDialog->LoadFile( decl );
}
}
}
/*
================
AFEditorRun
================
*/
void AFEditorRun( void ) {
#if _MSC_VER >= 1300
MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
#else
MSG *msg = &m_msgCur;
#endif
while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
// pump message
if ( !AfxGetApp()->PumpMessage() ) {
}
}
}
/*
================
AFEditorShutdown
================
*/
void AFEditorShutdown( void ) {
delete g_AFDialog;
g_AFDialog = NULL;
}
// DialogAF message handlers
/*
================
DialogAF::OnActivate
================
*/
void DialogAF::OnActivate( UINT nState, CWnd *pWndOther, BOOL bMinimized ) {
CDialog::OnActivate( nState, pWndOther, bMinimized );
}
/*
================
DialogAF::OnToolTipNotify
================
*/
BOOL DialogAF::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
/*
================
DialogAF::OnSetFocus
================
*/
void DialogAF::OnSetFocus( CWnd *pOldWnd ) {
//SetActiveWindow();
CDialog::OnSetFocus( pOldWnd );
}
/*
================
DialogAF::OnDestroy
================
*/
void DialogAF::OnDestroy() {
com_editors &= ~EDITOR_AF;
return CDialog::OnDestroy();
}
/*
================
DialogAF::OnMove
================
*/
void DialogAF::OnMove( int x, int y ) {
if ( GetSafeHwnd() ) {
CRect rct;
GetWindowRect( rct );
// FIXME: save position
}
CDialog::OnMove( x, y );
}
/*
================
DialogAF::OnTcnSelchangeTabMode
tab control notification handler
================
*/
void DialogAF::OnTcnSelchangeTabMode( NMHDR *pNMHDR, LRESULT *pResult ) {
*pResult = 0;
// hide the current tab child dialog box, if any.
if ( wndTabDisplay != NULL ) {
wndTabDisplay->ShowWindow( SW_HIDE );
}
TCITEM item;
item.mask = TCIF_PARAM;
wndTabs->GetItem( wndTabs->GetCurSel(), &item );
// show the new tab child dialog box.
switch ( item.lParam ) {
case AFTAB_VIEW:
wndTabDisplay = viewDlg;
break;
case AFTAB_PROPERTIES:
wndTabDisplay = propertiesDlg;
break;
case AFTAB_BODIES:
wndTabDisplay = bodyDlg;
break;
case AFTAB_CONSTRAINTS:
wndTabDisplay = constraintDlg;
break;
}
SetTabChildPos();
}
/*
================
DialogAF::OnCbnSelchangeComboAf
================
*/
void DialogAF::OnCbnSelchangeComboAf() {
int index = AFList.GetCurSel();
if ( index < 0 || index >= declManager->GetNumDecls( DECL_AF ) ) {
InitAFList();
return;
}
if ( index != CB_ERR ) {
CString str;
AFList.GetLBText( index, str );
LoadFile( static_cast<idDeclAF *>( const_cast<idDecl *>( declManager->FindType( DECL_AF, str ) ) ) );
}
}
/*
================
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();
}
/*
================
DialogAF::OnBnClickedButtonAfDelete
================
*/
void DialogAF::OnBnClickedButtonAfDelete() {
int i;
i = AFList.GetCurSel();
if ( i != CB_ERR ) {
if ( MessageBox( "Are you sure you want to delete the articulated figure file ?", "Delete Articulated Figure", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
// FIXME: delete the currently selected .af file
}
}
}
/*
================
DialogAF::OnBnClickedButtonAfSpawn
================
*/
void DialogAF::OnBnClickedButtonAfSpawn() {
int index = AFList.GetCurSel();
if ( index != CB_ERR ) {
CString str;
AFList.GetLBText( index, str );
gameEdit->AF_SpawnEntity( str );
}
}
/*
================
DialogAF::OnBnClickedButtonAfTpose
================
*/
void DialogAF::OnBnClickedButtonAfTpose() {
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAF::OnBnClickedButtonAfKill
================
*/
void DialogAF::OnBnClickedButtonAfKill() {
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "deleteSelected\n" );
}
/*
================
DialogAF::OnBnClickedButtonAfSave
================
*/
void DialogAF::OnBnClickedButtonAfSave() {
// save the selected .af file
if ( file ) {
if ( file->Save() ) {
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
}
else {
MessageBox( "Saving the file failed. Make sure the file is not read-only.", "Delete Articulated Figure", MB_OK );
}
}
}
/*
================
DialogAF::OnBnClickedCancel
================
*/
void DialogAF::OnBnClickedCancel() {
int i, c;
// check if there are modified .af files and come up with a warning if so
c = declManager->GetNumDecls( DECL_AF );
for ( i = 0; i < c; i++ ) {
if ( static_cast<const idDeclAF *>( declManager->DeclByIndex( DECL_AF, i ) )->modified ) {
if ( MessageBox( "Some articulated figures have been modified.\nCancel all changes ?", "Cancel", MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
return;
}
break;
}
}
// reload all modified .af files
LoadFile( NULL );
gameEdit->AF_UndoChanges();
InitAFList();
OnCancel();
}
// General convenience routines
/*
================
AFDialogSetFileModified
================
*/
void AFDialogSetFileModified( void ) {
if ( g_AFDialog ) {
g_AFDialog->SetFileModified();
}
}
/*
================
AFDialogReloadFile
================
*/
void AFDialogReloadFile( void ) {
if ( g_AFDialog ) {
g_AFDialog->ReloadFile();
}
}

98
neo/tools/af/DialogAF.h Normal file
View File

@@ -0,0 +1,98 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
class idDeclAF;
class DialogAFView;
class DialogAFProperties;
class DialogAFBody;
class DialogAFConstraint;
// DialogAF dialog
class DialogAF : public CDialog {
DECLARE_DYNAMIC(DialogAF)
public:
DialogAF( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAF();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void ReloadFile( void );
void SetFileModified( void );
enum { IDD = IDD_DIALOG_AF };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnSetFocus( CWnd *pOldWnd );
afx_msg void OnDestroy();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnMove( int x, int y );
afx_msg void OnTcnSelchangeTabMode( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnCbnSelchangeComboAf();
afx_msg void OnBnClickedButtonAfNew();
afx_msg void OnBnClickedButtonAfDelete();
afx_msg void OnBnClickedButtonAfSpawn();
afx_msg void OnBnClickedButtonAfTpose();
afx_msg void OnBnClickedButtonAfKill();
afx_msg void OnBnClickedButtonAfSave();
afx_msg void OnBnClickedCancel();
DECLARE_MESSAGE_MAP()
private:
CTabCtrl * wndTabs;
CWnd * wndTabDisplay;
DialogAFView * viewDlg;
DialogAFProperties *propertiesDlg;
DialogAFBody * bodyDlg;
DialogAFConstraint *constraintDlg;
idDeclAF * file; // file being edited
//{{AFX_DATA(DialogAF)
CComboBox AFList; // list with .af files
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitAFList( void );
void AddTabItem( int id, const char *name );
void SetTab( int id );
void SetTabChildPos( void );
};
void AFDialogSetFileModified( void );
void AFDialogReloadFile( void );

File diff suppressed because it is too large Load Diff

160
neo/tools/af/DialogAFBody.h Normal file
View File

@@ -0,0 +1,160 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFBody dialog
class DialogAFBody : public CDialog {
DECLARE_DYNAMIC(DialogAFBody)
public:
DialogAFBody( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFBody();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadBody( const char *name );
void SaveBody( void );
void UpdateFile( void );
DialogAFConstraint *constraintDlg;
enum { IDD = IDD_DIALOG_AF_BODY };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg void OnCbnSelchangeComboBodies();
afx_msg void OnBnClickedButtonNewbody();
afx_msg void OnBnClickedButtonRenamebody();
afx_msg void OnBnClickedButtonDeletebody();
afx_msg void OnCbnSelchangeComboCmType();
afx_msg void OnEnChangeEditCmLength();
afx_msg void OnDeltaposSpinCmLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmHeight();
afx_msg void OnDeltaposSpinCmHeight(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmWidth();
afx_msg void OnDeltaposSpinCmWidth(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmNumsides();
afx_msg void OnDeltaposSpinCmNumsides(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnCbnSelchangeComboBoneJoint1();
afx_msg void OnCbnSelchangeComboBoneJoint2();
afx_msg void OnEnChangeEditCmDensity();
afx_msg void OnDeltaposSpinCmDensity(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmInertiascale();
afx_msg void OnBnClickedRadioOriginCoordinates();
afx_msg void OnBnClickedRadioOriginBonecenter();
afx_msg void OnBnClickedRadioOriginJoint();
afx_msg void OnEnChangeEditAfVectorX();
afx_msg void OnDeltaposSpinAfVectorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAfVectorY();
afx_msg void OnDeltaposSpinAfVectorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAfVectorZ();
afx_msg void OnDeltaposSpinAfVectorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnOnCbnSelchangeComboOriginBoneCenterJoint1();
afx_msg void OnOnCbnSelchangeComboOriginBoneCenterJoint2();
afx_msg void OnOnCbnSelchangeComboOriginJoint();
afx_msg void OnEnChangeEditAnglesPitch();
afx_msg void OnDeltaposSpinAnglesPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAnglesYaw();
afx_msg void OnDeltaposSpinAnglesYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAnglesRoll();
afx_msg void OnDeltaposSpinAnglesRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedCheckSelfcollision();
afx_msg void OnEnChangeEditContents();
afx_msg void OnEnChangeEditClipmask();
afx_msg void OnEnChangeEditLinearfriction();
afx_msg void OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAngularfriction();
afx_msg void OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditContactfriction();
afx_msg void OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditFrictionDirection();
afx_msg void OnEnChangeEditContactMotorDirection();
afx_msg void OnCbnSelchangeComboModifiedjoint();
afx_msg void OnBnClickedRadioModifyOrientation();
afx_msg void OnBnClickedRadioModifyPosition();
afx_msg void OnBnClickedRadioModifyBoth();
afx_msg void OnEnChangeEditContainedjoints();
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Body * body;
int numJoints;
//{{AFX_DATA(DialogAFBody)
CComboBox bodyList; // list with bodies
CComboBox cm_comboType;
float cm_length;
float cm_height;
float cm_width;
CComboBox cm_comboBoneJoint1;
CComboBox cm_comboBoneJoint2;
float cm_numSides;
float cm_density;
CEdit cm_inertiaScale;
float cm_origin_x;
float cm_origin_y;
float cm_origin_z;
CComboBox cm_originBoneCenterJoint1;
CComboBox cm_originBoneCenterJoint2;
CComboBox cm_originJoint;
float cm_angles_pitch;
float cm_angles_yaw;
float cm_angles_roll;
BOOL m_selfCollision;
CEdit m_editContents;
CEdit m_editClipMask;
float m_linearFriction;
float m_angularFriction;
float m_contactFriction;
CEdit m_frictionDirection;
CEdit m_contactMotorDirection;
CComboBox m_comboModifiedJoint;
CEdit m_editContainedJoints;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitBodyList( void );
void InitJointLists( void );
void InitCollisionModelType( void );
void InitModifiedJointList( void );
void InitNewRenameDeleteButtons( void );
void ValidateCollisionModelLength( bool update );
void ValidateCollisionModelHeight( bool update );
void ValidateCollisionModelWidth( bool update );
void ValidateCollisionModelNumSides( bool update );
void ValidateCollisionModelDensity( bool update );
};

View File

@@ -0,0 +1,561 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintFixed.h"
#include "DialogAFConstraintBallAndSocket.h"
#include "DialogAFConstraintUniversal.h"
#include "DialogAFConstraintHinge.h"
#include "DialogAFConstraintSlider.h"
#include "DialogAFConstraintSpring.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
typedef struct {
declAFConstraintType_t type;
const char *name;
} c_type_t;
c_type_t constraintTypes[] = {
{ DECLAF_CONSTRAINT_FIXED, "fixed" },
{ DECLAF_CONSTRAINT_BALLANDSOCKETJOINT, "ball and socket" },
{ DECLAF_CONSTRAINT_UNIVERSALJOINT, "universal" },
{ DECLAF_CONSTRAINT_HINGE, "hinge" },
{ DECLAF_CONSTRAINT_SLIDER, "slider" },
{ DECLAF_CONSTRAINT_SPRING, "spring" },
{ DECLAF_CONSTRAINT_INVALID, NULL }
};
const char *ConstraintTypeToString( declAFConstraintType_t type ) {
for ( int i = 0; constraintTypes[i].name; i++ ) {
if ( constraintTypes[i].type == type ) {
return constraintTypes[i].name;
}
}
return "";
}
declAFConstraintType_t StringToConstraintType( const char *str ) {
for ( int i = 0; constraintTypes[i].name; i++ ) {
if ( idStr::Icmp( constraintTypes[i].name, str ) == 0 ) {
return constraintTypes[i].type;
}
}
return DECLAF_CONSTRAINT_INVALID;
}
// DialogAFConstraint dialog
toolTip_t DialogAFConstraint::toolTips[] = {
{ IDC_COMBO_CONSTRAINTS, "select contraint for editing" },
{ IDC_BUTTON_NEWCONSTRAINT, "create a new constraint" },
{ IDC_BUTTON_RENAMECONSTRAINT, "rename the selected constraint" },
{ IDC_BUTTON_DELETECONSTRAINT, "delete the selected constraint" },
{ IDC_COMBO_CONSTRAINT_TYPE, "constraint type" },
{ IDC_COMBO_CONSTRAINT_BODY1, "first constrained body" },
{ IDC_COMBO_CONSTRAINT_BODY2, "second constrained body" },
{ IDC_EDIT_CONSTRAINT_FRICTION, "constraint friction" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraint, CDialog)
/*
================
DialogAFConstraint::DialogAFConstraint
================
*/
DialogAFConstraint::DialogAFConstraint( CWnd* pParent /*=NULL*/ )
: CDialog(DialogAFConstraint::IDD, pParent)
, m_friction(0)
, constraint(NULL)
, file(NULL)
, constraintDlg(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraint::~DialogAFConstraint
================
*/
DialogAFConstraint::~DialogAFConstraint() {
}
/*
================
DialogAFConstraint::DoDataExchange
================
*/
void DialogAFConstraint::DoDataExchange( CDataExchange* pDX ) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraint)
DDX_Control(pDX, IDC_COMBO_CONSTRAINTS, m_comboConstraintList);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_TYPE, m_comboConstraintType);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_BODY1, m_comboBody1List);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_BODY2, m_comboBody2List);
DDX_Text(pDX, IDC_EDIT_CONSTRAINT_FRICTION, m_friction);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraint::InitConstraintList
================
*/
void DialogAFConstraint::InitConstraintList( void ) {
CString str;
m_comboConstraintList.ResetContent();
if ( !file ) {
return;
}
for ( int i = 0; i < file->constraints.Num(); i++ ) {
m_comboConstraintList.AddString( file->constraints[i]->name.c_str() );
}
if ( m_comboConstraintList.GetCount() != 0 ) {
m_comboConstraintList.SetCurSel( 0 );
m_comboConstraintList.GetLBText( 0, str );
LoadConstraint( str );
}
}
/*
================
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 );
}
}
/*
================
DialogAFConstraint::InitBodyLists
================
*/
void DialogAFConstraint::InitBodyLists( void ) {
m_comboBody1List.ResetContent();
m_comboBody2List.ResetContent();
if ( !file ) {
return;
}
for ( int i = 0; i < file->bodies.Num(); i++ ) {
m_comboBody1List.AddString( file->bodies[i]->name );
m_comboBody2List.AddString( file->bodies[i]->name );
}
// the second body may also be the world
m_comboBody2List.AddString( "world" ); // FIXME: we currently assume this is the last body in the list
}
/*
================
DialogAFConstraint::InitNewRenameDeleteButtons
================
*/
void DialogAFConstraint::InitNewRenameDeleteButtons( void ) {
if ( file && file->bodies.Num() >= 1 ) {
GetDlgItem( IDC_BUTTON_NEWCONSTRAINT )->EnableWindow( true );
}
else {
GetDlgItem( IDC_BUTTON_NEWCONSTRAINT )->EnableWindow( false );
}
if ( file && m_comboConstraintList.GetCount() >= 1 ) {
GetDlgItem( IDC_BUTTON_RENAMECONSTRAINT )->EnableWindow( true );
GetDlgItem( IDC_BUTTON_DELETECONSTRAINT )->EnableWindow( true );
}
else {
GetDlgItem( IDC_BUTTON_RENAMECONSTRAINT )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_DELETECONSTRAINT )->EnableWindow( false );
}
}
/*
================
DialogAFConstraint::LoadFile
================
*/
void DialogAFConstraint::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
ballAndSocketDlg->LoadFile( af );
universalDlg->LoadFile( af );
hingeDlg->LoadFile( af );
sliderDlg->LoadFile( af );
springDlg->LoadFile( af );
InitBodyLists();
InitConstraintList();
InitNewRenameDeleteButtons();
}
/*
================
DialogAFConstraint::SaveFile
================
*/
void DialogAFConstraint::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
}
/*
================
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::UpdateFile
================
*/
void DialogAFConstraint::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraint::OnInitDialog
================
*/
BOOL DialogAFConstraint::OnInitDialog() {
CDialog::OnInitDialog();
// initialize the constraint types
m_comboConstraintType.ResetContent();
for ( int i = 0; constraintTypes[i].name; i++ ) {
m_comboConstraintType.AddString( constraintTypes[i].name );
}
fixedDlg = new DialogAFConstraintFixed( this );
fixedDlg->ShowWindow( SW_HIDE );
ballAndSocketDlg = new DialogAFConstraintBallAndSocket( this );
ballAndSocketDlg->ShowWindow( SW_HIDE );
universalDlg = new DialogAFConstraintUniversal( this );
universalDlg->ShowWindow( SW_HIDE );
hingeDlg = new DialogAFConstraintHinge( this );
hingeDlg->ShowWindow( SW_HIDE );
sliderDlg = new DialogAFConstraintSlider( this );
sliderDlg->ShowWindow( SW_HIDE );
springDlg = new DialogAFConstraintSpring( this );
springDlg->ShowWindow( SW_HIDE );
constraintDlg = NULL;
InitNewRenameDeleteButtons();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/*
================
DialogAFConstraint::OnToolHitTest
================
*/
int DialogAFConstraint::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraint, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_WM_SHOWWINDOW()
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINTS, OnCbnSelchangeComboConstraints)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_TYPE, OnCbnSelchangeComboConstraintType)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_BODY1, OnCbnSelchangeComboConstraintBody1)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_BODY2, OnCbnSelchangeComboConstraintBody2)
ON_EN_CHANGE(IDC_EDIT_CONSTRAINT_FRICTION, OnEnChangeEditConstraintFriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONSTRAINT_FRICTION, OnDeltaposSpinConstraintFriction)
ON_BN_CLICKED(IDC_BUTTON_NEWCONSTRAINT, OnBnClickedButtonNewconstraint)
ON_BN_CLICKED(IDC_BUTTON_RENAMECONSTRAINT, OnBnClickedButtonRenameconstraint)
ON_BN_CLICKED(IDC_BUTTON_DELETECONSTRAINT, OnBnClickedButtonDeleteconstraint)
END_MESSAGE_MAP()
// DialogAFConstraint message handlers
BOOL DialogAFConstraint::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraint::OnShowWindow( BOOL bShow, UINT nStatus ) {
if ( bShow && constraint ) {
cvarSystem->SetCVarString( "af_highlightConstraint", constraint->name.c_str() );
} else {
cvarSystem->SetCVarString( "af_highlightConstraint", "" );
}
CDialog::OnShowWindow( bShow, nStatus );
}
void DialogAFConstraint::OnCbnSelchangeComboConstraints() {
CString str;
GetSafeComboBoxSelection( &m_comboConstraintList, str, -1 );
LoadConstraint( str );
}
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();
}
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();
}
}
}
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();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintType() {
InitConstraintTypeDlg();
UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintBody1() {
CString str;
GetSafeComboBoxSelection( &m_comboBody1List, str, -1 );
UnsetSafeComboBoxSelection( &m_comboBody2List, str );
UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintBody2() {
CString str;
GetSafeComboBoxSelection( &m_comboBody2List, str, -1 );
UnsetSafeComboBoxSelection( &m_comboBody1List, str );
UpdateFile();
}
void DialogAFConstraint::OnEnChangeEditConstraintFriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ), false );
}
}
void DialogAFConstraint::OnDeltaposSpinConstraintFriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_friction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,98 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
class DialogAFConstraintFixed;
class DialogAFConstraintBallAndSocket;
class DialogAFConstraintUniversal;
class DialogAFConstraintHinge;
class DialogAFConstraintSlider;
class DialogAFConstraintSpring;
// DialogAFConstraint dialog
class DialogAFConstraint : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraint)
public:
DialogAFConstraint( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFConstraint();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( const char *name );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg void OnCbnSelchangeComboConstraints();
afx_msg void OnBnClickedButtonNewconstraint();
afx_msg void OnBnClickedButtonRenameconstraint();
afx_msg void OnBnClickedButtonDeleteconstraint();
afx_msg void OnCbnSelchangeComboConstraintType();
afx_msg void OnCbnSelchangeComboConstraintBody1();
afx_msg void OnCbnSelchangeComboConstraintBody2();
afx_msg void OnEnChangeEditConstraintFriction();
afx_msg void OnDeltaposSpinConstraintFriction(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
CDialog * constraintDlg;
DialogAFConstraintFixed *fixedDlg;
DialogAFConstraintBallAndSocket *ballAndSocketDlg;
DialogAFConstraintUniversal *universalDlg;
DialogAFConstraintHinge *hingeDlg;
DialogAFConstraintSlider *sliderDlg;
DialogAFConstraintSpring *springDlg;
//{{AFX_DATA(DialogAFConstraint)
CComboBox m_comboConstraintList; // list with constraints
CComboBox m_comboConstraintType;
CComboBox m_comboBody1List;
CComboBox m_comboBody2List;
float m_friction;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitConstraintList( void );
void InitConstraintTypeDlg( void );
void InitBodyLists( void );
void InitNewRenameDeleteButtons( void );
};

View File

@@ -0,0 +1,735 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintBallAndSocket.h"
// DialogAFConstraintBallAndSocket dialog
toolTip_t DialogAFConstraintBallAndSocket::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_BAS_LIMIT_NONE, "no joint limit" },
{ IDC_RADIO_BAS_LIMIT_CONE, "cone shaped joint limit" },
{ IDC_RADIO_BAS_LIMIT_PYRAMID, "pyramid shaped joint limit" },
{ IDC_EDIT_BAS_LIMIT_CONE_ANGLE, "cone angle" },
{ IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, "first pyramid angle" },
{ IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, "second pyramid angle" },
{ IDC_EDIT_BAS_LIMIT_ROLL, "roll angle" },
{ IDC_RADIO_BAS_LIMIT_BONE, "use a bone for the orientation of the limit" },
{ IDC_RADIO_BAS_LIMIT_ANGLES, "use angles to set the orientation of the limit" },
{ IDC_COMBO_BAS_LIMIT_JOINT1, "bone start joint" },
{ IDC_COMBO_BAS_LIMIT_JOINT2, "bone end joint" },
{ IDC_EDIT_BAS_LIMIT_PITCH, "pitch angle" },
{ IDC_EDIT_BAS_LIMIT_YAW, "yaw angle" },
{ IDC_RADIO_BAS_LIMIT_AXIS_BONE, "use a bone for the limit axis" },
{ IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, "use angles to set the orientation of the limit axis" },
{ IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_BAS_LIMIT_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_BAS_LIMIT_AXIS_YAW, "yaw angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintBallAndSocket, CDialog)
/*
================
DialogAFConstraintBallAndSocket::DialogAFConstraintBallAndSocket
================
*/
DialogAFConstraintBallAndSocket::DialogAFConstraintBallAndSocket(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintBallAndSocket::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_coneAngle(30.0f)
, m_pyramidAngle1(30.0f)
, m_pyramidAngle2(30.0f)
, m_limitPitch(0)
, m_limitYaw(0)
, m_limitRoll(0)
, m_limitAxisPitch(0)
, m_limitAxisYaw(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_BALLANDSOCKET, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintBallAndSocket::~DialogAFConstraintBallAndSocket
================
*/
DialogAFConstraintBallAndSocket::~DialogAFConstraintBallAndSocket() {
}
/*
================
DialogAFConstraintBallAndSocket::DoDataExchange
================
*/
void DialogAFConstraintBallAndSocket::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintBallAndSocket)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_CONE_ANGLE, m_coneAngle);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, m_pyramidAngle1);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, m_pyramidAngle2);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_JOINT1, m_comboLimitJoint1);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_JOINT2, m_comboLimitJoint2);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PITCH, m_limitPitch);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_YAW, m_limitYaw);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_ROLL, m_limitRoll);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, m_comboLimitAxisJoint1);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, m_comboLimitAxisJoint2);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_AXIS_PITCH, m_limitAxisPitch);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_AXIS_YAW, m_limitAxisYaw);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintBallAndSocket::InitJointLists
================
*/
void DialogAFConstraintBallAndSocket::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboLimitJoint1.ResetContent();
m_comboLimitJoint2.ResetContent();
m_comboLimitAxisJoint1.ResetContent();
m_comboLimitAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboLimitJoint1.AddString( jointName );
m_comboLimitJoint2.AddString( jointName );
m_comboLimitAxisJoint1.AddString( jointName );
m_comboLimitAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintBallAndSocket::LoadFile
================
*/
void DialogAFConstraintBallAndSocket::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintBallAndSocket::SaveFile
================
*/
void DialogAFConstraintBallAndSocket::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
/*
================
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();
}
/*
================
DialogAFConstraintBallAndSocket::UpdateFile
================
*/
void DialogAFConstraintBallAndSocket::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintBallAndSocket::OnToolHitTest
================
*/
int DialogAFConstraintBallAndSocket::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintBallAndSocket, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_NONE, OnBnClickedRadioBasLimitNone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_CONE, OnBnClickedRadioBasLimitCone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_PYRAMID, OnBnClickedRadioBasLimitPyramid)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_CONE_ANGLE, OnEnChangeEditBasLimitConeAngle)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_CONE_ANGLE, OnDeltaposSpinBasLimitConeAngle)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, OnEnChangeEditBasLimitPyramidAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PYRAMID_ANGLE1, OnDeltaposSpinBasLimitPyramidAngle1)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, OnEnChangeEditBasLimitPyramidAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PYRAMID_ANGLE2, OnDeltaposSpinBasLimitPyramidAngle2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_ROLL, OnEnChangeEditBasLimitRoll)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_ROLL, OnDeltaposSpinBasLimitRoll)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_BONE, OnBnClickedRadioBasLimitBone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_ANGLES, OnBnClickedRadioBasLimitAngles)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_JOINT1, OnCbnSelchangeComboBasLimitJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_JOINT2, OnCbnSelchangeComboBasLimitJoint2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PITCH, OnEnChangeEditBasLimitPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PITCH, OnDeltaposSpinBasLimitPitch)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_YAW, OnEnChangeEditBasLimitYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_YAW, OnDeltaposSpinBasLimitYaw)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_AXIS_BONE, OnBnClickedRadioBasLimitAxisBone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, OnBnClickedRadioBasLimitAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, OnCbnSelchangeComboBasLimitAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, OnCbnSelchangeComboBasLimitAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_AXIS_PITCH, OnEnChangeEditBasLimitAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_AXIS_PITCH, OnDeltaposSpinBasLimitAxisPitch)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_AXIS_YAW, OnEnChangeEditBasLimitAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_AXIS_YAW, OnDeltaposSpinBasLimitAxisYaw)
END_MESSAGE_MAP()
// DialogAFConstraintBallAndSocket message handlers
BOOL DialogAFConstraintBallAndSocket::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitCone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_CONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitPyramid() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_PYRAMID ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_PYRAMID;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitConeAngle() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_CONE_ANGLE ) ) ) {
UpdateFile();
}
else {
m_coneAngle = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_CONE_ANGLE ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_coneAngle += 1.0f;
}
else if ( m_coneAngle > 0.0f ) {
m_coneAngle -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPyramidAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1 ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle1 += 1.0f;
}
else if ( m_pyramidAngle1 > 0.0f ) {
m_pyramidAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPyramidAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2 ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle2 += 1.0f;
}
else if ( m_pyramidAngle2 > 0.0f ) {
m_pyramidAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitRoll() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_ROLL ) ) ) {
UpdateFile();
}
else {
m_limitRoll = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_ROLL ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitRoll(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitRoll += 1.0f;
}
else {
m_limitRoll -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitBone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_BONE ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint2, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint1, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PITCH ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitPitch += 1.0f;
}
else {
m_limitPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_YAW ) ) ) {
UpdateFile();
}
else {
m_limitYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_YAW ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitYaw += 1.0f;
}
else {
m_limitYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_AXIS_BONE ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitAxisPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_PITCH ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAxisPitch += 1.0f;
}
else {
m_limitAxisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
m_limitAxisYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_YAW ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAxisYaw += 1.0f;
}
else {
m_limitAxisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,117 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintBallAndSocket dialog
class DialogAFConstraintBallAndSocket : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintBallAndSocket)
public:
DialogAFConstraintBallAndSocket(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintBallAndSocket();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_BALLANDSOCKET };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitNone();
afx_msg void OnBnClickedRadioBasLimitCone();
afx_msg void OnBnClickedRadioBasLimitPyramid();
afx_msg void OnEnChangeEditBasLimitConeAngle();
afx_msg void OnDeltaposSpinBasLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitPyramidAngle1();
afx_msg void OnDeltaposSpinBasLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitPyramidAngle2();
afx_msg void OnDeltaposSpinBasLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitRoll();
afx_msg void OnDeltaposSpinBasLimitRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitBone();
afx_msg void OnBnClickedRadioBasLimitAngles();
afx_msg void OnCbnSelchangeComboBasLimitJoint1();
afx_msg void OnCbnSelchangeComboBasLimitJoint2();
afx_msg void OnEnChangeEditBasLimitPitch();
afx_msg void OnDeltaposSpinBasLimitPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitYaw();
afx_msg void OnDeltaposSpinBasLimitYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitAxisBone();
afx_msg void OnBnClickedRadioBasLimitAxisAngles();
afx_msg void OnCbnSelchangeComboBasLimitAxisJoint1();
afx_msg void OnCbnSelchangeComboBasLimitAxisJoint2();
afx_msg void OnEnChangeEditBasLimitAxisPitch();
afx_msg void OnDeltaposSpinBasLimitAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitAxisYaw();
afx_msg void OnDeltaposSpinBasLimitAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintBallAndSocket)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
float m_coneAngle;
float m_pyramidAngle1;
float m_pyramidAngle2;
CComboBox m_comboLimitJoint1;
CComboBox m_comboLimitJoint2;
float m_limitPitch;
float m_limitYaw;
float m_limitRoll;
CComboBox m_comboLimitAxisJoint1;
CComboBox m_comboLimitAxisJoint2;
float m_limitAxisPitch;
float m_limitAxisYaw;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,169 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintFixed.h"
// DialogAFConstraintFixed dialog
toolTip_t DialogAFConstraintFixed::toolTips[] = {
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintFixed, CDialog)
/*
================
DialogAFConstraintFixed::DialogAFConstraintFixed
================
*/
DialogAFConstraintFixed::DialogAFConstraintFixed(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintFixed::IDD, pParent)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_FIXED, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintFixed::~DialogAFConstraintFixed
================
*/
DialogAFConstraintFixed::~DialogAFConstraintFixed() {
}
/*
================
DialogAFConstraintFixed::DoDataExchange
================
*/
void DialogAFConstraintFixed::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintHinge)
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintFixed::InitJointLists
================
*/
void DialogAFConstraintFixed::InitJointLists( void ) {
}
/*
================
DialogAFConstraintFixed::LoadFile
================
*/
void DialogAFConstraintFixed::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintFixed::SaveFile
================
*/
void DialogAFConstraintFixed::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintFixed::LoadConstraint
================
*/
void DialogAFConstraintFixed::LoadConstraint( idDeclAF_Constraint *c ) {
constraint = c;
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintFixed::SaveConstraint
================
*/
void DialogAFConstraintFixed::SaveConstraint( void ) {
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintFixed::UpdateFile
================
*/
void DialogAFConstraintFixed::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintFixed::OnToolHitTest
================
*/
int DialogAFConstraintFixed::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintFixed, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
// DialogAFConstraintFixed message handlers
BOOL DialogAFConstraintFixed::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}

View File

@@ -0,0 +1,65 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintFixed dialog
class DialogAFConstraintFixed : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintFixed)
public:
DialogAFConstraintFixed(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintFixed();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_FIXED };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintHinge)
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,565 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintHinge.h"
// DialogAFConstraintHinge dialog
toolTip_t DialogAFConstraintHinge::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_HINGE_AXIS_BONE, "use a bone for the hinge axis" },
{ IDC_RADIO_HINGE_AXIS_ANGLES, "use angles to set the orientation of the hinge axis" },
{ IDC_COMBO_HINGE_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_HINGE_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_HINGE_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_HINGE_AXIS_YAW, "yaw angle" },
{ IDC_RADIO_HINGE_LIMIT_NONE, "no limit" },
{ IDC_RADIO_HINGE_LIMIT_ANGLES, "angle limit" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE1, "limit orientation" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE2, "limit width" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE3, "limit angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintHinge, CDialog)
/*
================
DialogAFConstraintHinge::DialogAFConstraintHinge
================
*/
DialogAFConstraintHinge::DialogAFConstraintHinge(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintHinge::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_axisPitch(0)
, m_axisYaw(0)
, m_limitAngle1(0)
, m_limitAngle2(30.0f)
, m_limitAngle3(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_HINGE, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintHinge::~DialogAFConstraintHinge
================
*/
DialogAFConstraintHinge::~DialogAFConstraintHinge() {
}
/*
================
DialogAFConstraintHinge::DoDataExchange
================
*/
void DialogAFConstraintHinge::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintHinge)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Control(pDX, IDC_COMBO_HINGE_AXIS_JOINT1, m_comboAxisJoint1);
DDX_Control(pDX, IDC_COMBO_HINGE_AXIS_JOINT2, m_comboAxisJoint2);
DDX_Text(pDX, IDC_EDIT_HINGE_AXIS_PITCH, m_axisPitch);
DDX_Text(pDX, IDC_EDIT_HINGE_AXIS_YAW, m_axisYaw);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE1, m_limitAngle1);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE2, m_limitAngle2);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE3, m_limitAngle3);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintHinge::InitJointLists
================
*/
void DialogAFConstraintHinge::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboAxisJoint1.ResetContent();
m_comboAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboAxisJoint1.AddString( jointName );
m_comboAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintHinge::LoadFile
================
*/
void DialogAFConstraintHinge::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintHinge::SaveFile
================
*/
void DialogAFConstraintHinge::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
/*
================
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();
}
/*
================
DialogAFConstraintHinge::UpdateFile
================
*/
void DialogAFConstraintHinge::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintHinge::OnToolHitTest
================
*/
int DialogAFConstraintHinge::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintHinge, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_HINGE_AXIS_BONE, OnBnClickedRadioHingeAxisBone)
ON_BN_CLICKED(IDC_RADIO_HINGE_AXIS_ANGLES, OnBnClickedRadioHingeAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_HINGE_AXIS_JOINT1, OnCbnSelchangeComboHingeAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_HINGE_AXIS_JOINT2, OnCbnSelchangeComboHingeAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_HINGE_AXIS_PITCH, OnEnChangeEditHingeAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_AXIS_PITCH, OnDeltaposSpinHingeAxisPitch)
ON_EN_CHANGE(IDC_EDIT_HINGE_AXIS_YAW, OnEnChangeEditHingeAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_AXIS_YAW, OnDeltaposSpinHingeAxisYaw)
ON_BN_CLICKED(IDC_RADIO_HINGE_LIMIT_NONE, OnBnClickedRadioHingeLimitNone)
ON_BN_CLICKED(IDC_RADIO_HINGE_LIMIT_ANGLES, OnBnClickedRadioHingeLimitAngles)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE1, OnEnChangeEditHingeLimitAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE1, OnDeltaposSpinHingeLimitAngle1)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE2, OnEnChangeEditHingeLimitAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE2, OnDeltaposSpinHingeLimitAngle2)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE3, OnEnChangeEditHingeLimitAngle3)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE3, OnDeltaposSpinHingeLimitAngle3)
END_MESSAGE_MAP()
// DialogAFConstraintHinge message handlers
BOOL DialogAFConstraintHinge::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintHinge::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_AXIS_BONE ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnCbnSelchangeComboHingeAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintHinge::OnCbnSelchangeComboHingeAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintHinge::OnEnChangeEditHingeAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
m_axisPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_PITCH ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisPitch += 1.0f;
}
else {
m_axisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
m_axisYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_YAW ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisYaw += 1.0f;
}
else {
m_axisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_limitAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE1 ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle1 += 1.0f;
}
else {
m_limitAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_limitAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE2 ), false );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle2 += 1.0f;
}
else if ( m_limitAngle2 > 0.0f ) {
m_limitAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle3() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE3 ) ) ) {
UpdateFile();
}
else {
m_limitAngle3 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE3 ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle3(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle3 += 1.0f;
}
else {
m_limitAngle3 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,101 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintHinge dialog
class DialogAFConstraintHinge : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintHinge)
public:
DialogAFConstraintHinge(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintHinge();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioHingeAxisBone();
afx_msg void OnBnClickedRadioHingeAxisAngles();
afx_msg void OnCbnSelchangeComboHingeAxisJoint1();
afx_msg void OnCbnSelchangeComboHingeAxisJoint2();
afx_msg void OnEnChangeEditHingeAxisPitch();
afx_msg void OnDeltaposSpinHingeAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeAxisYaw();
afx_msg void OnDeltaposSpinHingeAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioHingeLimitNone();
afx_msg void OnBnClickedRadioHingeLimitAngles();
afx_msg void OnEnChangeEditHingeLimitAngle1();
afx_msg void OnDeltaposSpinHingeLimitAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeLimitAngle2();
afx_msg void OnDeltaposSpinHingeLimitAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeLimitAngle3();
afx_msg void OnDeltaposSpinHingeLimitAngle3(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintHinge)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboAxisJoint1;
CComboBox m_comboAxisJoint2;
float m_axisPitch;
float m_axisYaw;
float m_limitAngle1;
float m_limitAngle2;
float m_limitAngle3;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,313 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintSlider.h"
// DialogAFConstraintSlider dialog
toolTip_t DialogAFConstraintSlider::toolTips[] = {
{ IDC_RADIO_SLIDER_AXIS_BONE, "use a bone for the slider axis" },
{ IDC_RADIO_SLIDER_AXIS_ANGLES, "use angles to set the orientation of the slider axis" },
{ IDC_COMBO_SLIDER_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_SLIDER_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_SLIDER_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_SLIDER_AXIS_YAW, "yaw angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintSlider, CDialog)
/*
================
DialogAFConstraintSlider::DialogAFConstraintSlider
================
*/
DialogAFConstraintSlider::DialogAFConstraintSlider(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintSlider::IDD, pParent)
, m_axisPitch(0)
, m_axisYaw(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_SLIDER, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintSlider::~DialogAFConstraintSlider
================
*/
DialogAFConstraintSlider::~DialogAFConstraintSlider() {
}
/*
================
DialogAFConstraintSlider::DoDataExchange
================
*/
void DialogAFConstraintSlider::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintSlider)
DDX_Control(pDX, IDC_COMBO_SLIDER_AXIS_JOINT1, m_comboAxisJoint1);
DDX_Control(pDX, IDC_COMBO_SLIDER_AXIS_JOINT2, m_comboAxisJoint2);
DDX_Text(pDX, IDC_EDIT_SLIDER_AXIS_PITCH, m_axisPitch);
DDX_Text(pDX, IDC_EDIT_SLIDER_AXIS_YAW, m_axisYaw);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintSlider::InitJointLists
================
*/
void DialogAFConstraintSlider::InitJointLists( void ) {
m_comboAxisJoint1.ResetContent();
m_comboAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAxisJoint1.AddString( jointName );
m_comboAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintSlider::LoadFile
================
*/
void DialogAFConstraintSlider::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintSlider::SaveFile
================
*/
void DialogAFConstraintSlider::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
/*
================
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();
}
/*
================
DialogAFConstraintSlider::UpdateFile
================
*/
void DialogAFConstraintSlider::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintSlider::OnToolHitTest
================
*/
int DialogAFConstraintSlider::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintSlider, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_BONE, OnBnClickedRadioSliderAxisBone)
ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_ANGLES, OnBnClickedRadioSliderAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT1, OnCbnSelchangeComboSliderAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT2, OnCbnSelchangeComboSliderAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_PITCH, OnEnChangeEditSliderAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_PITCH, OnDeltaposSpinSliderAxisPitch)
ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_YAW, OnEnChangeEditSliderAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_YAW, OnDeltaposSpinSliderAxisYaw)
END_MESSAGE_MAP()
// DialogAFConstraintSlider message handlers
BOOL DialogAFConstraintSlider::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintSlider::OnBnClickedRadioSliderAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_BONE ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintSlider::OnBnClickedRadioSliderAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSlider::OnCbnSelchangeComboSliderAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintSlider::OnCbnSelchangeComboSliderAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintSlider::OnEnChangeEditSliderAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) );
}
}
void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisPitch += 1.0f;
}
else {
m_axisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSlider::OnEnChangeEditSliderAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) );
}
}
void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisYaw += 1.0f;
}
else {
m_axisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintSlider dialog
class DialogAFConstraintSlider : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintSlider)
public:
DialogAFConstraintSlider(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintSlider();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioSliderAxisBone();
afx_msg void OnBnClickedRadioSliderAxisAngles();
afx_msg void OnCbnSelchangeComboSliderAxisJoint1();
afx_msg void OnCbnSelchangeComboSliderAxisJoint2();
afx_msg void OnEnChangeEditSliderAxisPitch();
afx_msg void OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSliderAxisYaw();
afx_msg void OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintSlider)
CComboBox m_comboAxisJoint1;
CComboBox m_comboAxisJoint2;
float m_axisPitch;
float m_axisYaw;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,662 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintSpring.h"
// DialogAFConstraintSpring dialog
toolTip_t DialogAFConstraintSpring::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the first anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "first anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the first anchor" },
{ IDC_EDIT_ANCHOR_X, "first anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "first anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "first anchor z-coordinate" },
{ IDC_RADIO_ANCHOR2_JOINT, "use the position of a joint for the second anchor" },
{ IDC_COMBO_ANCHOR2_JOINT, "second anchor joint name" },
{ IDC_RADIO_ANCHOR2_COORDINATES, "use absolute coordinates for the second anchor" },
{ IDC_EDIT_ANCHOR2_X, "second anchor x-coordinate" },
{ IDC_EDIT_ANCHOR2_Y, "second anchor y-coordinate" },
{ IDC_EDIT_ANCHOR2_Z, "second anchor z-coordinate" },
{ IDC_EDIT_SPRING_STRETCH, "spring constant when stretched" },
{ IDC_EDIT_SPRING_COMPRESS, "spring constant when compressed" },
{ IDC_EDIT_SPRING_DAMPING, "spring damping" },
{ IDC_EDIT_SPRING_REST_LENGTH, "rest length" },
{ IDC_RADIO_SPRING_NO_MIN_LENGTH, "no minimum length" },
{ IDC_RADIO_SPRING_MIN_LENGTH, "minimum length" },
{ IDC_EDIT_SPRING_MIN_LENGTH, "minimum length" },
{ IDC_RADIO_SPRING_NO_MAX_LENGTH, "no maximum length" },
{ IDC_RADIO_SPRING_MAX_LENGTH, "maximum length" },
{ IDC_EDIT_SPRING_MAX_LENGTH, "maximum length" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintSpring, CDialog)
/*
================
DialogAFConstraintSpring::DialogAFConstraintSpring
================
*/
DialogAFConstraintSpring::DialogAFConstraintSpring(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintSpring::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_anchor2_x(0)
, m_anchor2_y(0)
, m_anchor2_z(0)
, m_stretch(0)
, m_compress(0)
, m_damping(0)
, m_restLength(0)
, m_minLength(0)
, m_maxLength(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_SPRING, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintSpring::~DialogAFConstraintSpring
================
*/
DialogAFConstraintSpring::~DialogAFConstraintSpring() {
}
/*
================
DialogAFConstraintSpring::DoDataExchange
================
*/
void DialogAFConstraintSpring::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintSpring)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Control(pDX, IDC_COMBO_ANCHOR2_JOINT, m_comboAnchor2Joint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_X, m_anchor2_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_Y, m_anchor2_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_Z, m_anchor2_z);
DDX_Text(pDX, IDC_EDIT_SPRING_STRETCH, m_stretch);
DDX_Text(pDX, IDC_EDIT_SPRING_COMPRESS, m_compress);
DDX_Text(pDX, IDC_EDIT_SPRING_DAMPING, m_damping);
DDX_Text(pDX, IDC_EDIT_SPRING_REST_LENGTH, m_restLength);
DDX_Text(pDX, IDC_EDIT_SPRING_MIN_LENGTH, m_minLength);
DDX_Text(pDX, IDC_EDIT_SPRING_MAX_LENGTH, m_maxLength);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintSpring::InitJointLists
================
*/
void DialogAFConstraintSpring::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboAnchor2Joint.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboAnchor2Joint.AddString( jointName );
}
}
/*
================
DialogAFConstraintSpring::LoadFile
================
*/
void DialogAFConstraintSpring::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintSpring::SaveFile
================
*/
void DialogAFConstraintSpring::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
/*
================
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();
}
/*
================
DialogAFConstraintSpring::UpdateFile
================
*/
void DialogAFConstraintSpring::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintSpring::OnToolHitTest
================
*/
int DialogAFConstraintSpring::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintSpring, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_ANCHOR2_JOINT, OnBnClickedRadioAnchor2Joint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR2_COORDINATES, OnBnClickedRadioAnchor2Coordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR2_JOINT, OnCbnSelchangeComboAnchor2Joint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_X, OnEnChangeEditAnchor2X)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_Y, OnEnChangeEditAnchor2Y)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_Z, OnEnChangeEditAnchor2Z)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_X, OnDeltaposSpinAnchor2X)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_Y, OnDeltaposSpinAnchor2Y)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_Z, OnDeltaposSpinAnchor2Z)
ON_EN_CHANGE(IDC_EDIT_SPRING_STRETCH, OnEnChangeEditSpringStretch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_STRETCH, OnDeltaposSpinSpringStretch)
ON_EN_CHANGE(IDC_EDIT_SPRING_COMPRESS, OnEnChangeEditSpringCompress)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_COMPRESS, OnDeltaposSpinSpringCompress)
ON_EN_CHANGE(IDC_EDIT_SPRING_DAMPING, OnEnChangeEditSpringDamping)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_DAMPING, OnDeltaposSpinSpringDamping)
ON_EN_CHANGE(IDC_EDIT_SPRING_REST_LENGTH, OnEnChangeEditSpringRestLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_REST_LENGTH, OnDeltaposSpinSpringRestLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_NO_MIN_LENGTH, OnBnClickedRadioLimitNoMinLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_MIN_LENGTH, OnBnClickedRadioLimitMinLength)
ON_EN_CHANGE(IDC_EDIT_SPRING_MIN_LENGTH, OnEnChangeEditLimitMinLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_MIN_LENGTH, OnDeltaposSpinLimitMinLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_NO_MAX_LENGTH, OnBnClickedRadioLimitNoMaxLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_MAX_LENGTH, OnBnClickedRadioLimitMaxLength)
ON_EN_CHANGE(IDC_EDIT_SPRING_MAX_LENGTH, OnEnChangeEditLimitMaxLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_MAX_LENGTH, OnDeltaposSpinLimitMaxLength)
END_MESSAGE_MAP()
// DialogAFConstraintSpring message handlers
BOOL DialogAFConstraintSpring::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchor2Joint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR2_JOINT ) ) {
if ( constraint ) {
constraint->anchor2.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchor2Coordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR2_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor2.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnCbnSelchangeComboAnchor2Joint() {
UpdateFile();
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2X() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_X ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_X ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2Y() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Y ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Y ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2Z() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Z ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Z ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2X(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_x += 1.0f;
}
else {
m_anchor2_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2Y(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_y += 1.0f;
}
else {
m_anchor2_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2Z(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_z += 1.0f;
}
else {
m_anchor2_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringStretch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_STRETCH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_STRETCH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringStretch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_stretch = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_STRETCH ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringCompress() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_COMPRESS ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_COMPRESS ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringCompress(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_compress = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_COMPRESS ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringDamping() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_DAMPING ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_DAMPING ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringDamping(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_damping = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_DAMPING ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringRestLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_REST_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_REST_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringRestLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_restLength += 1.0f;
}
else {
m_restLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitNoMinLength() {
if ( IsDlgButtonChecked( IDC_RADIO_SPRING_NO_MIN_LENGTH ) ) {
if ( constraint ) {
constraint->minLength = 0.0f;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitMinLength() {
// do nothing
}
void DialogAFConstraintSpring::OnEnChangeEditLimitMinLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MIN_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MIN_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinLimitMinLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_minLength += 1.0f;
}
else {
m_minLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitNoMaxLength() {
if ( IsDlgButtonChecked( IDC_RADIO_SPRING_NO_MAX_LENGTH ) ) {
if ( constraint ) {
constraint->maxLength = 0.0f;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitMaxLength() {
// do nothing
}
void DialogAFConstraintSpring::OnEnChangeEditLimitMaxLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MAX_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MAX_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinLimitMaxLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_maxLength += 1.0f;
}
else {
m_maxLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,113 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintSpring dialog
class DialogAFConstraintSpring : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintSpring)
public:
DialogAFConstraintSpring(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintSpring();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioAnchor2Joint();
afx_msg void OnBnClickedRadioAnchor2Coordinates();
afx_msg void OnCbnSelchangeComboAnchor2Joint();
afx_msg void OnEnChangeEditAnchor2X();
afx_msg void OnEnChangeEditAnchor2Y();
afx_msg void OnEnChangeEditAnchor2Z();
afx_msg void OnDeltaposSpinAnchor2X(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchor2Y(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchor2Z(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringStretch();
afx_msg void OnDeltaposSpinSpringStretch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringCompress();
afx_msg void OnDeltaposSpinSpringCompress(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringDamping();
afx_msg void OnDeltaposSpinSpringDamping(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringRestLength();
afx_msg void OnDeltaposSpinSpringRestLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioLimitNoMinLength();
afx_msg void OnBnClickedRadioLimitMinLength();
afx_msg void OnEnChangeEditLimitMinLength();
afx_msg void OnDeltaposSpinLimitMinLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioLimitNoMaxLength();
afx_msg void OnBnClickedRadioLimitMaxLength();
afx_msg void OnEnChangeEditLimitMaxLength();
afx_msg void OnDeltaposSpinLimitMaxLength(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintSpring)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboAnchor2Joint;
float m_anchor2_x;
float m_anchor2_y;
float m_anchor2_z;
float m_stretch;
float m_compress;
float m_damping;
float m_restLength;
float m_minLength;
float m_maxLength;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,863 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintUniversal.h"
// DialogAFConstraintUniversal dialog
toolTip_t DialogAFConstraintUniversal::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_UNIVERSAL_BONE_SHAFT1, "use a bone for the first shaft" },
{ IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, "use angles to set the orientation of the first shaft" },
{ IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_YAW_SHAFT1, "yaw angle" },
{ IDC_RADIO_UNIVERSAL_BONE_SHAFT2, "use a bone for the second shaft" },
{ IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, "use angles to set the orientation of the second shaft" },
{ IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_YAW_SHAFT2, "yaw angle" },
{ IDC_RADIO_UNIVERSAL_LIMIT_NONE, "no joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_CONE, "cone shaped joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, "pyramid shaped joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_BONE, "use a bone for the limit orientation" },
{ IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, "use angles for the limit orientation" },
{ IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PITCH, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_YAW, "yaw angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_ROLL, "roll angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, "cone angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, "first pyramid angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, "second pyramid angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintUniversal, CDialog)
/*
================
DialogAFConstraintUniversal::DialogAFConstraintUniversal
================
*/
DialogAFConstraintUniversal::DialogAFConstraintUniversal(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintUniversal::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_pitchShaft1(0)
, m_yawShaft1(0)
, m_pitchShaft2(0)
, m_yawShaft2(0)
, m_coneAngle(30.0f)
, m_pyramidAngle1(30.0f)
, m_pyramidAngle2(30.0f)
, m_limitPitch(0)
, m_limitYaw(0)
, m_limitRoll(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_UNIVERSAL, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintUniversal::~DialogAFConstraintUniversal
================
*/
DialogAFConstraintUniversal::~DialogAFConstraintUniversal() {
}
/*
================
DialogAFConstraintUniversal::DoDataExchange
================
*/
void DialogAFConstraintUniversal::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintUniversal)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, m_comboJoint1Shaft1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, m_comboJoint2Shaft1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, m_pitchShaft1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_YAW_SHAFT1, m_yawShaft1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, m_comboJoint1Shaft2);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, m_comboJoint2Shaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, m_pitchShaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_YAW_SHAFT2, m_yawShaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, m_coneAngle);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, m_pyramidAngle1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, m_pyramidAngle2);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, m_comboLimitJoint1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, m_comboLimitJoint2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PITCH, m_limitPitch);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_YAW, m_limitYaw);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_ROLL, m_limitRoll);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintUniversal::InitJointLists
================
*/
void DialogAFConstraintUniversal::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboJoint1Shaft1.ResetContent();
m_comboJoint2Shaft1.ResetContent();
m_comboJoint1Shaft2.ResetContent();
m_comboJoint2Shaft2.ResetContent();
m_comboLimitJoint1.ResetContent();
m_comboLimitJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboJoint1Shaft1.AddString( jointName );
m_comboJoint2Shaft1.AddString( jointName );
m_comboJoint1Shaft2.AddString( jointName );
m_comboJoint2Shaft2.AddString( jointName );
m_comboLimitJoint1.AddString( jointName );
m_comboLimitJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintUniversal::LoadFile
================
*/
void DialogAFConstraintUniversal::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintUniversal::SaveFile
================
*/
void DialogAFConstraintUniversal::SaveFile( void ) {
SaveConstraint();
}
/*
================
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 );
}
/*
================
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();
}
/*
================
DialogAFConstraintUniversal::UpdateFile
================
*/
void DialogAFConstraintUniversal::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintUniversal::OnToolHitTest
================
*/
int DialogAFConstraintUniversal::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintUniversal, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_BONE_SHAFT1, OnBnClickedRadioUniversalBoneShaft1)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, OnBnClickedRadioUniversalAnglesShaft1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, OnCbnSelchangeComboUniversalJoint1Shaft1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, OnCbnSelchangeComboUniversalJoint2Shaft1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, OnEnChangeEditUniversalPitchShaft1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_PITCH_SHAFT1, OnDeltaposSpinUniversalPitchShaft1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_YAW_SHAFT1, OnEnChangeEditUniversalYawShaft1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_YAW_SHAFT1, OnDeltaposSpinUniversalYawShaft1)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_BONE_SHAFT2, OnBnClickedRadioUniversalBoneShaft2)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, OnBnClickedRadioUniversalAnglesShaft2)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, OnCbnSelchangeComboUniversalJoint1Shaft2)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, OnCbnSelchangeComboUniversalJoint2Shaft2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, OnEnChangeEditUniversalPitchShaft2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_PITCH_SHAFT2, OnDeltaposSpinUniversalPitchShaft2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_YAW_SHAFT2, OnEnChangeEditUniversalYawShaft2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_YAW_SHAFT2, OnDeltaposSpinUniversalYawShaft2)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_NONE, OnBnClickedRadioUniversalLimitNone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_CONE, OnBnClickedRadioUniversalLimitCone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, OnBnClickedRadioUniversalLimitPyramid)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, OnEnChangeEditUniversalLimitConeAngle)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_CONE_ANGLE, OnDeltaposSpinUniversalLimitConeAngle)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, OnEnChangeEditUniversalLimitPyramidAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, OnDeltaposSpinUniversalLimitPyramidAngle1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, OnEnChangeEditUniversalLimitPyramidAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, OnDeltaposSpinUniversalLimitPyramidAngle2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_ROLL, OnEnChangeEditUniversalLimitRoll)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_ROLL, OnDeltaposSpinUniversalLimitRoll)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_BONE, OnBnClickedRadioUniversalLimitBone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, OnBnClickedRadioUniversalLimitAngles)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, OnCbnSelchangeComboUniversalLimitJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, OnCbnSelchangeComboUniversalLimitJoint2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PITCH, OnEnChangeEditUniversalLimitPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PITCH, OnDeltaposSpinUniversalLimitPitch)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_YAW, OnEnChangeEditUniversalLimitYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_YAW, OnDeltaposSpinUniversalLimitYaw)
END_MESSAGE_MAP()
// DialogAFConstraintUniversal message handlers
BOOL DialogAFConstraintUniversal::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintUniversal::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalBoneShaft1() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_BONE_SHAFT1 ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalAnglesShaft1() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1 ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint1Shaft1() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint1Shaft1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint2Shaft1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint2Shaft1() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint2Shaft1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint1Shaft1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalPitchShaft1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT1 ) ) ) {
UpdateFile();
}
else {
m_pitchShaft1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT1 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalPitchShaft1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pitchShaft1 += 1.0f;
}
else {
m_pitchShaft1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalYawShaft1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT1 ) ) ) {
UpdateFile();
}
else {
m_yawShaft1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT1 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalYawShaft1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_yawShaft1 += 1.0f;
}
else {
m_yawShaft1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalBoneShaft2() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_BONE_SHAFT2 ) ) {
if ( constraint ) {
constraint->shaft[1].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalAnglesShaft2() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2 ) ) {
if ( constraint ) {
constraint->shaft[1].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint1Shaft2() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint1Shaft2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint2Shaft2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint2Shaft2() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint2Shaft2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint1Shaft2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalPitchShaft2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT2 ) ) ) {
UpdateFile();
}
else {
m_pitchShaft2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT2 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalPitchShaft2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pitchShaft2 += 1.0f;
}
else {
m_pitchShaft2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalYawShaft2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT2 ) ) ) {
UpdateFile();
}
else {
m_yawShaft2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT2 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalYawShaft2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_yawShaft2 += 1.0f;
}
else {
m_yawShaft2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitCone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_CONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitPyramid() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_PYRAMID;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitConeAngle() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE ) ) ) {
UpdateFile();
}
else {
m_coneAngle = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_coneAngle += 1.0f;
}
else if ( m_coneAngle > 0.0f ) {
m_coneAngle -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPyramidAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1 ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle1 += 1.0f;
}
else if ( m_pyramidAngle1 > 0.0f ) {
m_pyramidAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPyramidAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2 ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle2 += 1.0f;
}
else if ( m_pyramidAngle2 > 0.0f ) {
m_pyramidAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitRoll() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_ROLL ) ) ) {
UpdateFile();
}
else {
m_limitRoll = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_ROLL ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitRoll(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitRoll += 1.0f;
}
else {
m_limitRoll -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitBone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_BONE ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalLimitJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalLimitJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PITCH ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitPitch += 1.0f;
}
else {
m_limitPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_YAW ) ) ) {
UpdateFile();
}
else {
m_limitYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_YAW ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitYaw += 1.0f;
}
else {
m_limitYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,129 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintUniversal dialog
class DialogAFConstraintUniversal : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintUniversal)
public:
DialogAFConstraintUniversal(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintUniversal();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_UNIVERSAL };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalBoneShaft1();
afx_msg void OnBnClickedRadioUniversalAnglesShaft1();
afx_msg void OnCbnSelchangeComboUniversalJoint1Shaft1();
afx_msg void OnCbnSelchangeComboUniversalJoint2Shaft1();
afx_msg void OnEnChangeEditUniversalPitchShaft1();
afx_msg void OnDeltaposSpinUniversalPitchShaft1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalYawShaft1();
afx_msg void OnDeltaposSpinUniversalYawShaft1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalBoneShaft2();
afx_msg void OnBnClickedRadioUniversalAnglesShaft2();
afx_msg void OnCbnSelchangeComboUniversalJoint1Shaft2();
afx_msg void OnCbnSelchangeComboUniversalJoint2Shaft2();
afx_msg void OnEnChangeEditUniversalPitchShaft2();
afx_msg void OnDeltaposSpinUniversalPitchShaft2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalYawShaft2();
afx_msg void OnDeltaposSpinUniversalYawShaft2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalLimitNone();
afx_msg void OnBnClickedRadioUniversalLimitCone();
afx_msg void OnBnClickedRadioUniversalLimitPyramid();
afx_msg void OnEnChangeEditUniversalLimitConeAngle();
afx_msg void OnDeltaposSpinUniversalLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitPyramidAngle1();
afx_msg void OnDeltaposSpinUniversalLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitPyramidAngle2();
afx_msg void OnDeltaposSpinUniversalLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitRoll();
afx_msg void OnDeltaposSpinUniversalLimitRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalLimitBone();
afx_msg void OnBnClickedRadioUniversalLimitAngles();
afx_msg void OnCbnSelchangeComboUniversalLimitJoint1();
afx_msg void OnCbnSelchangeComboUniversalLimitJoint2();
afx_msg void OnEnChangeEditUniversalLimitPitch();
afx_msg void OnDeltaposSpinUniversalLimitPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitYaw();
afx_msg void OnDeltaposSpinUniversalLimitYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintUniversal)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboJoint1Shaft1;
CComboBox m_comboJoint2Shaft1;
float m_pitchShaft1;
float m_yawShaft1;
CComboBox m_comboJoint1Shaft2;
CComboBox m_comboJoint2Shaft2;
float m_pitchShaft2;
float m_yawShaft2;
float m_coneAngle;
float m_pyramidAngle1;
float m_pyramidAngle2;
CComboBox m_comboLimitJoint1;
CComboBox m_comboLimitJoint2;
float m_limitPitch;
float m_limitYaw;
float m_limitRoll;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,168 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
// DialogAFName dialog
IMPLEMENT_DYNAMIC(DialogAFName, CDialog)
/*
================
DialogAFName::DialogAFName
================
*/
DialogAFName::DialogAFName(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFName::IDD, pParent)
, m_combo(NULL)
{
}
/*
================
DialogAFName::~DialogAFName
================
*/
DialogAFName::~DialogAFName() {
}
/*
================
DialogAFName::DoDataExchange
================
*/
void DialogAFName::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_AF_NAME, m_editName);
}
/*
================
DialogAFName::SetName
================
*/
void DialogAFName::SetName( CString &str ) {
m_editName = str;
}
/*
================
DialogAFName::GetName
================
*/
void DialogAFName::GetName( CString &str ) {
str = m_editName;
}
/*
================
DialogAFName::SetComboBox
================
*/
void DialogAFName::SetComboBox( CComboBox *combo ) {
m_combo = combo;
}
/*
================
DialogAFName::OnInitDialog
================
*/
BOOL DialogAFName::OnInitDialog() {
CEdit *edit;
CString str;
CDialog::OnInitDialog();
edit = (CEdit *)GetDlgItem( IDC_EDIT_AF_NAME );
edit->SetFocus();
edit->GetWindowText( str );
edit->SetSel( 0, str.GetLength() );
return FALSE;
}
/*
================
EditVerifyName
================
*/
void EditVerifyName( CEdit *edit ) {
CString strIn, strOut;
int start, end;
static bool entered = false;
if ( entered ) {
return;
}
entered = true;
edit->GetSel( start, end );
edit->GetWindowText( strIn );
for ( int i = 0; i < strIn.GetLength(); i++ ) {
if ( ( strIn[i] >= 'a' && strIn[i] <= 'z' ) ||
( strIn[i] >= 'A' && strIn[i] <= 'Z' ) ||
( strIn[i] == '_' ) || ( strIn[i] >= '0' && strIn[i] <= '9' ) ) {
strOut.AppendChar( strIn[i] );
}
}
edit->SetWindowText( strOut );
edit->SetSel( start, end );
entered = false;
}
BEGIN_MESSAGE_MAP(DialogAFName, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_EN_CHANGE(IDC_EDIT_AF_NAME, OnEnChangeEditAfName)
END_MESSAGE_MAP()
// DialogAFName message handlers
void DialogAFName::OnBnClickedOk() {
UpdateData( TRUE );
if ( m_combo && m_combo->FindStringExact( -1, m_editName ) != -1 ) {
MessageBox( va( "The name %s is already used.", m_editName.GetBuffer() ), "Name", MB_OK );
}
else {
OnOK();
}
}
void DialogAFName::OnEnChangeEditAfName() {
EditVerifyName( (CEdit *) GetDlgItem( IDC_EDIT_AF_NAME ) );
}

View File

@@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFName dialog
class DialogAFName : public CDialog {
DECLARE_DYNAMIC(DialogAFName)
public:
DialogAFName(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFName();
void SetName( CString &str );
void GetName( CString &str );
void SetComboBox( CComboBox *combo );
enum { IDD = IDD_DIALOG_AF_NAME };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg void OnBnClickedOk();
afx_msg void OnEnChangeEditAfName();
DECLARE_MESSAGE_MAP()
private:
CString m_editName;
CComboBox * m_combo;
};

View File

@@ -0,0 +1,512 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFProperties.h"
#include "DialogAFBody.h"
#include "DialogAFConstraint.h"
// DialogAFProperties dialog
toolTip_t DialogAFProperties::toolTips[] = {
{ IDC_EDIT_MODEL, "model def" },
{ IDC_BUTTON_BROWSE_MODEL, "browse model def" },
{ IDC_EDIT_SKIN, "skin" },
{ IDC_BUTTON_BROWSE_SKIN, "browse skin" },
{ IDC_EDIT_LINEARFRICTION, "translational friction" },
{ IDC_EDIT_ANGULARFRICTION, "rotational friction" },
{ IDC_EDIT_CONTACTFRICTION, "friction with contact surfaces" },
{ IDC_EDIT_CONSTRAINTFRICTION, "constraint friction" },
{ IDC_CHECK_SELFCOLLISION, "allow bodies to collide with other bodies of this articulated figure" },
{ IDC_EDIT_CONTENTS, "content of bodies" },
{ IDC_EDIT_CLIPMASK, "collide with these content types" },
{ IDC_EDIT_TOTALMASS, "scale the mass of each body to get this total mass" },
{ IDC_EDIT_LINEARVELOCITY, "do not suspend simulation if the linear velocity is higher than this value" },
{ IDC_EDIT_ANGULARVELOCITY, "do not suspend simulation if the angular velocity is higher than this value" },
{ IDC_EDIT_LINEARACCELERATION, "do not suspend simulation if the linear acceleration is higher than this value" },
{ IDC_EDIT_ANGULARACCELERATION, "do not suspend simulation if the angular acceleration is higher than this value" },
{ IDC_EDIT_NO_MOVE_TIME, "suspend simulation if hardly any movement for this many seconds" },
{ IDC_EDIT_MAXIMUM_MOVE_TIME, "always suspend simulation after running for this many seconds" },
{ IDC_EDIT_LINEAR_TOLERANCE, "maximum translation considered no movement" },
{ IDC_EDIT_ANGULAR_TOLERANCE, "maximum rotation considered no movement" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFProperties, CDialog)
/*
================
DialogAFProperties::DialogAFProperties
================
*/
DialogAFProperties::DialogAFProperties(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFProperties::IDD, pParent)
, m_selfCollision(false)
, m_linearFriction(0)
, m_angularFriction(0)
, m_contactFriction(0)
, m_constraintFriction(0)
, m_totalMass(0)
, m_suspendLinearVelocity(0)
, m_suspendAngularVelocity(0)
, m_suspendLinearAcceleration(0)
, m_suspendAngularAcceleration(0)
, m_noMoveTime(0)
, m_minMoveTime(0)
, m_maxMoveTime(0)
, m_linearTolerance(0)
, m_angularTolerance(0)
, file(NULL)
{
Create( IDD_DIALOG_AF_PROPERTIES, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFProperties::~DialogAFProperties
================
*/
DialogAFProperties::~DialogAFProperties() {
}
/*
================
DialogAFProperties::DoDataExchange
================
*/
void DialogAFProperties::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFProperties)
DDX_Control(pDX, IDC_EDIT_MODEL, m_editModel);
DDX_Control(pDX, IDC_EDIT_SKIN, m_editSkin);
DDX_Check(pDX, IDC_CHECK_SELFCOLLISION, m_selfCollision);
DDX_Control(pDX, IDC_EDIT_CONTENTS, m_editContents);
DDX_Control(pDX, IDC_EDIT_CLIPMASK, m_editClipMask);
DDX_Text(pDX, IDC_EDIT_LINEARFRICTION, m_linearFriction);
DDX_Text(pDX, IDC_EDIT_ANGULARFRICTION, m_angularFriction);
DDX_Text(pDX, IDC_EDIT_CONTACTFRICTION, m_contactFriction);
DDX_Text(pDX, IDC_EDIT_CONSTRAINTFRICTION, m_constraintFriction);
DDX_Text(pDX, IDC_EDIT_TOTALMASS, m_totalMass);
DDX_Text(pDX, IDC_EDIT_LINEARVELOCITY, m_suspendLinearVelocity);
DDX_Text(pDX, IDC_EDIT_ANGULARVELOCITY, m_suspendAngularVelocity);
DDX_Text(pDX, IDC_EDIT_LINEARACCELERATION, m_suspendLinearAcceleration);
DDX_Text(pDX, IDC_EDIT_ANGULARACCELERATION, m_suspendAngularAcceleration);
DDX_Text(pDX, IDC_EDIT_NO_MOVE_TIME, m_noMoveTime);
DDX_Text(pDX, IDC_EDIT_MINIMUM_MOVE_TIME, m_minMoveTime);
DDX_Text(pDX, IDC_EDIT_MAXIMUM_MOVE_TIME, m_maxMoveTime);
DDX_Text(pDX, IDC_EDIT_LINEAR_TOLERANCE, m_linearTolerance);
DDX_Text(pDX, IDC_EDIT_ANGULAR_TOLERANCE, m_angularTolerance);
//}}AFX_DATA_MAP
}
/*
================
DialogAFProperties::LoadFile
================
*/
void DialogAFProperties::LoadFile( idDeclAF *af ) {
idStr str;
file = af;
if ( !file ) {
ClearFile();
return;
}
m_editModel.SetWindowText( file->model.c_str() );
m_editSkin.SetWindowText( file->skin.c_str() );
m_selfCollision = file->selfCollision;
idDeclAF::ContentsToString( file->contents, str );
m_editContents.SetWindowText( str );
idDeclAF::ContentsToString( file->clipMask, str );
m_editClipMask.SetWindowText( str );
m_linearFriction = file->defaultLinearFriction;
m_angularFriction = file->defaultAngularFriction;
m_contactFriction = file->defaultContactFriction;
m_constraintFriction = file->defaultConstraintFriction;
m_totalMass = file->totalMass;
m_suspendLinearVelocity = file->suspendVelocity[0];
m_suspendAngularVelocity = file->suspendVelocity[1];
m_suspendLinearAcceleration = file->suspendAcceleration[0];
m_suspendAngularAcceleration = file->suspendAcceleration[1];
m_noMoveTime = file->noMoveTime;
m_minMoveTime = file->minMoveTime;
m_maxMoveTime = file->maxMoveTime;
m_linearTolerance = file->noMoveTranslation;
m_angularTolerance = file->noMoveRotation;
UpdateData( FALSE );
}
/*
================
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();
}
/*
================
DialogAFProperties::UpdateFile
================
*/
void DialogAFProperties::UpdateFile( void ) {
SaveFile();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFProperties::ClearFile
================
*/
void DialogAFProperties::ClearFile( void ) {
m_editModel.SetWindowText( "" );
m_editSkin.SetWindowText( "" );
m_selfCollision = false;
m_editContents.SetWindowText( "" );
m_editClipMask.SetWindowText( "" );
m_linearFriction = 0.0f;
m_angularFriction = 0.0f;
m_contactFriction = 0.0f;
m_constraintFriction = 0.0f;
m_totalMass = -1.0f;
m_suspendLinearVelocity = 0.0f;
m_suspendAngularVelocity = 0.0f;
m_suspendLinearAcceleration = 0.0f;
m_suspendAngularAcceleration = 0.0f;
m_noMoveTime = 0.0f;
m_minMoveTime = 0.0f;
m_maxMoveTime = 0.0f;
m_linearTolerance = 0.0f;
m_angularTolerance = 0.0f;
UpdateData( FALSE );
}
/*
================
DialogAFProperties::OnToolHitTest
================
*/
int DialogAFProperties::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFProperties, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_EN_CHANGE(IDC_EDIT_MODEL, OnEnChangeEditModel)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_MODEL, OnBnClickedButtonBrowseModel)
ON_EN_CHANGE(IDC_EDIT_SKIN, OnEnChangeEditSkin)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_SKIN, OnBnClickedButtonBrowseSkin)
ON_EN_CHANGE(IDC_EDIT_LINEARFRICTION, OnEnChangeEditLinearfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_LINEARFRICTION, OnDeltaposSpinLinearfriction)
ON_EN_CHANGE(IDC_EDIT_ANGULARFRICTION, OnEnChangeEditAngularfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANGULARFRICTION, OnDeltaposSpinAngularfriction)
ON_EN_CHANGE(IDC_EDIT_CONTACTFRICTION, OnEnChangeEditContactfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONTACTFRICTION, OnDeltaposSpinContactfriction)
ON_EN_CHANGE(IDC_EDIT_CONSTRAINTFRICTION, OnEnChangeEditConstraintfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONSTRAINTFRICTION, OnDeltaposSpinConstraintfriction)
ON_BN_CLICKED(IDC_CHECK_SELFCOLLISION, OnBnClickedCheckSelfcollision)
ON_EN_CHANGE(IDC_EDIT_CONTENTS, OnEnChangeEditContents)
ON_EN_CHANGE(IDC_EDIT_CLIPMASK, OnEnChangeEditClipmask)
ON_EN_CHANGE(IDC_EDIT_TOTALMASS, OnEnChangeEditTotalmass)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_TOTALMASS, OnDeltaposSpinTotalmass)
ON_EN_CHANGE(IDC_EDIT_LINEARVELOCITY, OnEnChangeEditLinearvelocity)
ON_EN_CHANGE(IDC_EDIT_ANGULARVELOCITY, OnEnChangeEditAngularvelocity)
ON_EN_CHANGE(IDC_EDIT_LINEARACCELERATION, OnEnChangeEditLinearacceleration)
ON_EN_CHANGE(IDC_EDIT_ANGULARACCELERATION, OnEnChangeEditAngularacceleration)
ON_EN_CHANGE(IDC_EDIT_NO_MOVE_TIME, OnEnChangeEditNomovetime)
ON_EN_CHANGE(IDC_EDIT_MINIMUM_MOVE_TIME, OnEnChangeEditMinimummovetime)
ON_EN_CHANGE(IDC_EDIT_MAXIMUM_MOVE_TIME, OnEnChangeEditMaximummovetime)
ON_EN_CHANGE(IDC_EDIT_LINEAR_TOLERANCE, OnEnChangeEditLineartolerance)
ON_EN_CHANGE(IDC_EDIT_ANGULAR_TOLERANCE, OnEnChangeEditAngulartolerance)
END_MESSAGE_MAP()
// DialogAFProperties message handlers
BOOL DialogAFProperties::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFProperties::OnEnChangeEditModel() {
if ( EditControlEnterHit( &m_editModel ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditSkin() {
if ( EditControlEnterHit( &m_editSkin ) ) {
UpdateFile();
// reload the .af file
AFDialogReloadFile();
}
}
void DialogAFProperties::OnBnClickedCheckSelfcollision() {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Self Collision", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->selfCollision = file->selfCollision;
}
bodyDlg->LoadFile( file );
}
}
void DialogAFProperties::OnEnChangeEditContents() {
if ( EditControlEnterHit( &m_editContents ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contents", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->contents = file->contents;
}
bodyDlg->LoadFile( file );
}
}
}
void DialogAFProperties::OnEnChangeEditClipmask() {
if ( EditControlEnterHit( &m_editClipMask ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Clip Mask", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->clipMask = file->clipMask;
}
bodyDlg->LoadFile( file );
}
}
}
void DialogAFProperties::OnEnChangeEditLinearfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Linear Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->linearFriction = file->defaultLinearFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_linearFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_linearFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_LINEARFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditAngularfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Angular Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->angularFriction = file->defaultAngularFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_angularFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_angularFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_ANGULARFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditContactfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contact Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->contactFriction = file->defaultContactFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_contactFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_contactFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONTACTFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditConstraintfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ) ) ) {
UpdateFile();
if ( file && file->constraints.Num() && MessageBox( "Apply to all constraints ?", "Constraint Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->constraints.Num(); i++ ) {
file->constraints[i]->friction = file->defaultConstraintFriction;
}
constraintDlg->LoadFile( file );
}
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinConstraintfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_constraintFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditTotalmass() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_TOTALMASS ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnDeltaposSpinTotalmass(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_totalMass = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_TOTALMASS ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditLinearvelocity() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARVELOCITY ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngularvelocity() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARVELOCITY ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditLinearacceleration() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARACCELERATION ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngularacceleration() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARACCELERATION ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditNomovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_NO_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditMinimummovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MINIMUM_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditMaximummovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MAXIMUM_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditLineartolerance() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEAR_TOLERANCE ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngulartolerance() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULAR_TOLERANCE ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnBnClickedButtonBrowseModel() {
// m_editModel.SetWindowText( str );
// UpdateFile();
}
void DialogAFProperties::OnBnClickedButtonBrowseSkin() {
// m_editSkin.SetWindowText( str );
// UpdateFile();
// reload the .af file
// AFDialogReloadFile();
}

View File

@@ -0,0 +1,110 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFProperties dialog
class DialogAFProperties : public CDialog {
DECLARE_DYNAMIC(DialogAFProperties)
public:
DialogAFProperties( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFProperties();
void LoadFile( idDeclAF *af );
void SaveFile( void );
DialogAFBody * bodyDlg;
DialogAFConstraint *constraintDlg;
enum { IDD = IDD_DIALOG_AF_PROPERTIES };
protected:
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnEnChangeEditModel();
afx_msg void OnEnChangeEditSkin();
afx_msg void OnBnClickedButtonBrowseModel();
afx_msg void OnBnClickedButtonBrowseSkin();
afx_msg void OnBnClickedCheckSelfcollision();
afx_msg void OnEnChangeEditContents();
afx_msg void OnEnChangeEditClipmask();
afx_msg void OnEnChangeEditLinearfriction();
afx_msg void OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAngularfriction();
afx_msg void OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditContactfriction();
afx_msg void OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditConstraintfriction();
afx_msg void OnDeltaposSpinConstraintfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditTotalmass();
afx_msg void OnDeltaposSpinTotalmass(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditLinearvelocity();
afx_msg void OnEnChangeEditAngularvelocity();
afx_msg void OnEnChangeEditLinearacceleration();
afx_msg void OnEnChangeEditAngularacceleration();
afx_msg void OnEnChangeEditNomovetime();
afx_msg void OnEnChangeEditMinimummovetime();
afx_msg void OnEnChangeEditMaximummovetime();
afx_msg void OnEnChangeEditLineartolerance();
afx_msg void OnEnChangeEditAngulartolerance();
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
//{{AFX_DATA(DialogAFProperties)
CEdit m_editModel;
CEdit m_editSkin;
BOOL m_selfCollision;
CEdit m_editContents;
CEdit m_editClipMask;
float m_linearFriction;
float m_angularFriction;
float m_contactFriction;
float m_constraintFriction;
float m_totalMass;
float m_suspendLinearVelocity;
float m_suspendAngularVelocity;
float m_suspendLinearAcceleration;
float m_suspendAngularAcceleration;
float m_noMoveTime;
float m_minMoveTime;
float m_maxMoveTime;
float m_linearTolerance;
float m_angularTolerance;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void UpdateFile( void );
void ClearFile( void );
};

View File

@@ -0,0 +1,324 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFView.h"
// DialogAFView dialog
toolTip_t DialogAFView::toolTips[] = {
{ IDC_CHECK_VIEW_BODIES, "show bodies" },
{ IDC_CHECK_VIEW_BODYNAMES, "show body names" },
{ IDC_CHECK_VIEW_BODYMASS, "show body mass" },
{ IDC_CHECK_VIEW_TOTALMASS, "show total mass" },
{ IDC_CHECK_VIEW_INERTIATENSOR, "show body inertia tensor" },
{ IDC_CHECK_VIEW_VELOCITY, "show body velocity" },
{ IDC_CHECK_VIEW_CONSTRAINTNAMES, "show constraint names" },
{ IDC_CHECK_VIEW_CONSTRAINTS, "show constraints" },
{ IDC_CHECK_VIEW_PRIMARYONLY, "show only primary constraints" },
{ IDC_CHECK_VIEW_LIMITS, "show constraint limits" },
{ IDC_CHECK_VIEW_CONSTRAINEDBODIES, "show bodies constrained by current constraint (body1 = cyan, body2 = blue)" },
{ IDC_CHECK_VIEW_TREES, "show tree structures" },
{ IDC_CHECK_MD5_SKELETON, "show md5 with skeleton" },
{ IDC_CHECK_MD5_SKELETONONLY, "show only the md5 skeleton" },
{ IDC_CHECK_LINES_DEPTHTEST, "zbuffer lines" },
{ IDC_CHECK_LINES_USEARROWS, "use arrows" },
{ IDC_CHECK_PHYSICS_NOFRICTION, "disable all friction" },
{ IDC_CHECK_PHYSICS_NOLIMITS, "disable all joint limits" },
{ IDC_CHECK_PHYSICS_NOGRAVITY, "disable gravity" },
{ IDC_CHECK_PHYSICS_NOSELFCOLLISION, "disable self collision detection" },
{ IDC_CHECK_PHYSICS_TIMING, "show performance timings" },
{ IDC_CHECK_PHYSICS_DRAG_ENTITIES, "drag entities" },
{ IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, "show selection box around the entity selected for dragging" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFView, CDialog)
/*
================
DialogAFView::DialogAFView
================
*/
DialogAFView::DialogAFView(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFView::IDD, pParent)
{
m_showBodies = cvarSystem->GetCVarBool( "af_showBodies" );
m_showBodyNames = cvarSystem->GetCVarBool( "af_showBodyNames" );
m_showMass = cvarSystem->GetCVarBool( "af_showMass" );
m_showTotalMass = cvarSystem->GetCVarBool( "af_showTotalMass" );
m_showInertia = cvarSystem->GetCVarBool( "af_showInertia" );
m_showVelocity = cvarSystem->GetCVarBool( "af_showVelocity" );
m_showConstraints = cvarSystem->GetCVarBool( "af_showConstraints" );
m_showConstraintNames = cvarSystem->GetCVarBool( "af_showConstraintNames" );
m_showPrimaryOnly = cvarSystem->GetCVarBool( "af_showPrimaryOnly" );
m_showLimits = cvarSystem->GetCVarBool( "af_showLimits" );
m_showConstrainedBodies = cvarSystem->GetCVarBool( "af_showConstrainedBodies" );
m_showTrees = cvarSystem->GetCVarBool( "af_showTrees" );
m_showSkeleton = cvarSystem->GetCVarInteger( "af_showSkel" ) == 1;
m_showSkeletonOnly = cvarSystem->GetCVarInteger( "af_showSkel" ) == 2;
m_debugLineDepthTest = cvarSystem->GetCVarBool( "r_debugLineDepthTest" );
m_debugLineUseArrows = cvarSystem->GetCVarInteger( "r_debugArrowStep" ) != 0;
m_noFriction = cvarSystem->GetCVarBool( "af_skipFriction" );
m_noLimits = cvarSystem->GetCVarBool( "af_skipLimits" );
m_gravity = cvarSystem->GetCVarFloat( "g_gravity" );
m_noGravity = ( m_gravity == 0.0f );
m_noSelfCollision = cvarSystem->GetCVarBool( "af_skipSelfCollision" );
m_showTimings = cvarSystem->GetCVarBool( "af_showTimings" );
m_dragEntity = cvarSystem->GetCVarBool( "g_dragEntity" );
m_dragShowSelection = cvarSystem->GetCVarBool( "g_dragShowSelection" );
Create( IDD_DIALOG_AF_VIEW, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFView::~DialogAFView
================
*/
DialogAFView::~DialogAFView() {
}
/*
================
DialogAFView::DoDataExchange
================
*/
void DialogAFView::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFView)
DDX_Check(pDX, IDC_CHECK_VIEW_BODIES, m_showBodies);
DDX_Check(pDX, IDC_CHECK_VIEW_BODYNAMES, m_showBodyNames);
DDX_Check(pDX, IDC_CHECK_VIEW_BODYMASS, m_showMass);
DDX_Check(pDX, IDC_CHECK_VIEW_TOTALMASS, m_showTotalMass);
DDX_Check(pDX, IDC_CHECK_VIEW_INERTIATENSOR, m_showInertia);
DDX_Check(pDX, IDC_CHECK_VIEW_VELOCITY, m_showVelocity);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINTS, m_showConstraints);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINTNAMES, m_showConstraintNames);
DDX_Check(pDX, IDC_CHECK_VIEW_PRIMARYONLY, m_showPrimaryOnly);
DDX_Check(pDX, IDC_CHECK_VIEW_LIMITS, m_showLimits);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINEDBODIES, m_showConstrainedBodies);
DDX_Check(pDX, IDC_CHECK_VIEW_TREES, m_showTrees);
DDX_Check(pDX, IDC_CHECK_MD5_SKELETON, m_showSkeleton);
DDX_Check(pDX, IDC_CHECK_MD5_SKELETONONLY, m_showSkeletonOnly);
DDX_Check(pDX, IDC_CHECK_LINES_DEPTHTEST, m_debugLineDepthTest);
DDX_Check(pDX, IDC_CHECK_LINES_USEARROWS, m_debugLineUseArrows);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOFRICTION, m_noFriction);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOLIMITS, m_noLimits);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOGRAVITY, m_noGravity);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOSELFCOLLISION, m_noSelfCollision);
DDX_Check(pDX, IDC_CHECK_PHYSICS_TIMING, m_showTimings);
DDX_Check(pDX, IDC_CHECK_PHYSICS_DRAG_ENTITIES, m_dragEntity);
DDX_Check(pDX, IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, m_dragShowSelection);
//}}AFX_DATA_MAP
}
/*
================
DialogAFView::OnToolHitTest
================
*/
int DialogAFView::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFView, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODIES, OnBnClickedCheckViewBodies)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODYNAMES, OnBnClickedCheckViewBodynames)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODYMASS, OnBnClickedCheckViewBodyMass)
ON_BN_CLICKED(IDC_CHECK_VIEW_TOTALMASS, OnBnClickedCheckViewTotalMass)
ON_BN_CLICKED(IDC_CHECK_VIEW_INERTIATENSOR, OnBnClickedCheckViewInertiatensor)
ON_BN_CLICKED(IDC_CHECK_VIEW_VELOCITY, OnBnClickedCheckViewVelocity)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINTS, OnBnClickedCheckViewConstraints)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINTNAMES, OnBnClickedCheckViewConstraintnames)
ON_BN_CLICKED(IDC_CHECK_VIEW_PRIMARYONLY, OnBnClickedCheckViewPrimaryonly)
ON_BN_CLICKED(IDC_CHECK_VIEW_LIMITS, OnBnClickedCheckViewLimits)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINEDBODIES, OnBnClickedCheckViewConstrainedBodies)
ON_BN_CLICKED(IDC_CHECK_VIEW_TREES, OnBnClickedCheckViewTrees)
ON_BN_CLICKED(IDC_CHECK_MD5_SKELETON, OnBnClickedCheckMd5Skeleton)
ON_BN_CLICKED(IDC_CHECK_MD5_SKELETONONLY, OnBnClickedCheckMd5Skeletononly)
ON_BN_CLICKED(IDC_CHECK_LINES_DEPTHTEST, OnBnClickedCheckLinesDepthtest)
ON_BN_CLICKED(IDC_CHECK_LINES_USEARROWS, OnBnClickedCheckLinesUsearrows)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOFRICTION, OnBnClickedCheckPhysicsNofriction)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOLIMITS, OnBnClickedCheckPhysicsNolimits)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOGRAVITY, OnBnClickedCheckPhysicsNogravity)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOSELFCOLLISION, OnBnClickedCheckPhysicsNoselfcollision)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_TIMING, OnBnClickedCheckPhysicsTiming)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_DRAG_ENTITIES, OnBnClickedCheckPhysicsDragEntities)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, OnBnClickedCheckPhysicsShowDragSelection)
END_MESSAGE_MAP()
// DialogAFView message handlers
BOOL DialogAFView::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFView::OnBnClickedCheckViewBodies() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showBodies", m_showBodies != FALSE );
}
void DialogAFView::OnBnClickedCheckViewBodynames() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showBodyNames", m_showBodyNames != FALSE );
}
void DialogAFView::OnBnClickedCheckViewBodyMass() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showMass", m_showMass != FALSE );
}
void DialogAFView::OnBnClickedCheckViewTotalMass() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTotalMass", m_showTotalMass != FALSE );
}
void DialogAFView::OnBnClickedCheckViewInertiatensor() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showInertia", m_showInertia != FALSE );
}
void DialogAFView::OnBnClickedCheckViewVelocity() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showVelocity", m_showVelocity != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstraints() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstraints", m_showConstraints != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstraintnames() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstraintNames", m_showConstraintNames != FALSE );
}
void DialogAFView::OnBnClickedCheckViewPrimaryonly() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showPrimaryOnly", m_showPrimaryOnly != FALSE );
}
void DialogAFView::OnBnClickedCheckViewLimits() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showLimits", m_showLimits != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstrainedBodies() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstrainedBodies", m_showConstrainedBodies != FALSE );
}
void DialogAFView::OnBnClickedCheckViewTrees() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTrees", m_showTrees != FALSE );
}
void DialogAFView::OnBnClickedCheckMd5Skeleton() {
UpdateData(TRUE);
if ( !m_showSkeletonOnly ) {
if ( m_showSkeleton ) {
cvarSystem->SetCVarInteger( "r_showSkel", 1 );
} else {
cvarSystem->SetCVarInteger( "r_showSkel", 0 );
}
}
}
void DialogAFView::OnBnClickedCheckMd5Skeletononly() {
UpdateData(TRUE);
if ( m_showSkeletonOnly ) {
cvarSystem->SetCVarInteger( "r_showSkel", 2 );
} else {
if ( m_showSkeleton ) {
cvarSystem->SetCVarInteger( "r_showSkel", 1 );
} else {
cvarSystem->SetCVarInteger( "r_showSkel", 0 );
}
}
}
void DialogAFView::OnBnClickedCheckLinesDepthtest() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "r_debugLineDepthTest", m_debugLineDepthTest != FALSE );
}
void DialogAFView::OnBnClickedCheckLinesUsearrows() {
UpdateData(TRUE);
if ( m_debugLineUseArrows ) {
cvarSystem->SetCVarInteger( "r_debugArrowStep", 120 );
} else {
cvarSystem->SetCVarInteger( "r_debugArrowStep", 0 );
}
}
void DialogAFView::OnBnClickedCheckPhysicsNofriction() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipFriction", m_noFriction != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsNolimits() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipLimits", m_noLimits != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsNogravity() {
UpdateData(TRUE);
cvarSystem->SetCVarFloat( "g_gravity", m_noGravity ? 0.0f : m_gravity );
}
void DialogAFView::OnBnClickedCheckPhysicsNoselfcollision() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipSelfCollision", m_noSelfCollision != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsTiming() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTimings", m_showTimings != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsDragEntities() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "g_dragEntity", m_dragEntity != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsShowDragSelection() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "g_dragShowSelection", m_dragShowSelection != FALSE );
}

102
neo/tools/af/DialogAFView.h Normal file
View File

@@ -0,0 +1,102 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFView dialog
class DialogAFView : public CDialog {
DECLARE_DYNAMIC(DialogAFView)
public:
DialogAFView(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFView();
enum { IDD = IDD_DIALOG_AF_VIEW };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedCheckViewBodies();
afx_msg void OnBnClickedCheckViewBodynames();
afx_msg void OnBnClickedCheckViewBodyMass();
afx_msg void OnBnClickedCheckViewTotalMass();
afx_msg void OnBnClickedCheckViewInertiatensor();
afx_msg void OnBnClickedCheckViewVelocity();
afx_msg void OnBnClickedCheckViewConstraints();
afx_msg void OnBnClickedCheckViewConstraintnames();
afx_msg void OnBnClickedCheckViewPrimaryonly();
afx_msg void OnBnClickedCheckViewLimits();
afx_msg void OnBnClickedCheckViewConstrainedBodies();
afx_msg void OnBnClickedCheckViewTrees();
afx_msg void OnBnClickedCheckMd5Skeleton();
afx_msg void OnBnClickedCheckMd5Skeletononly();
afx_msg void OnBnClickedCheckLinesDepthtest();
afx_msg void OnBnClickedCheckLinesUsearrows();
afx_msg void OnBnClickedCheckPhysicsNofriction();
afx_msg void OnBnClickedCheckPhysicsNolimits();
afx_msg void OnBnClickedCheckPhysicsNogravity();
afx_msg void OnBnClickedCheckPhysicsNoselfcollision();
afx_msg void OnBnClickedCheckPhysicsTiming();
afx_msg void OnBnClickedCheckPhysicsDragEntities();
afx_msg void OnBnClickedCheckPhysicsShowDragSelection();
DECLARE_MESSAGE_MAP()
private:
//{{AFX_DATA(DialogAFView)
BOOL m_showBodies;
BOOL m_showBodyNames;
BOOL m_showMass;
BOOL m_showTotalMass;
BOOL m_showInertia;
BOOL m_showVelocity;
BOOL m_showConstraints;
BOOL m_showConstraintNames;
BOOL m_showPrimaryOnly;
BOOL m_showLimits;
BOOL m_showConstrainedBodies;
BOOL m_showTrees;
BOOL m_showSkeleton;
BOOL m_showSkeletonOnly;
BOOL m_debugLineDepthTest;
BOOL m_debugLineUseArrows;
BOOL m_noFriction;
BOOL m_noLimits;
BOOL m_noGravity;
BOOL m_noSelfCollision;
BOOL m_showTimings;
BOOL m_dragEntity;
BOOL m_dragShowSelection;
//}}AFX_DATA
float m_gravity;
static toolTip_t toolTips[];
};