1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "object_viewer.h"
22 #include "precomputed_rotations_dlg.h"
23 #include "nel/3d/ps_particle.h"
24 #include "nel/3d/ps_mesh.h"
25 #include "attrib_dlg.h"
28 /////////////////////////////////////////////////////////////////////////////
29 // CPrecomputedRotationsDlg dialog
32 CPrecomputedRotationsDlg::CPrecomputedRotationsDlg(CParticleWorkspace::CNode
*ownerNode
, NL3D::CPSHintParticleRotateTheSame
*prts
, CAttribDlg
*toDisable
)
33 : _Node(ownerNode
), _RotatedParticle(prts
), _WndToDisable(toDisable
)
35 float minValue
, maxValue
;
36 uint32 nbModels
= prts
->checkHintRotateTheSame(minValue
, maxValue
);
37 //{{AFX_DATA_INIT(CPrecomputedRotationsDlg)
38 m_RotSpeedMax
= _T("");
39 m_PrecomputedRotations
= nbModels
? TRUE
: FALSE
;
40 m_RotSpeedMin
= _T("");
46 void CPrecomputedRotationsDlg::init(CWnd
*pParent
, sint x
, sint y
)
48 Create(IDD_HINT_ROTATE_THE_SAME
, pParent
);
54 wr
.bottom
= r
.bottom
+ y
;
55 wr
.right
= r
.right
+ x
;
58 enablePrecompRotationControl();
62 void CPrecomputedRotationsDlg::enablePrecompRotationControl(void)
64 nlassert(_RotatedParticle
);
66 m_RotSpeedMinCtrl
.EnableWindow(m_PrecomputedRotations
);
67 m_RotSpeedMaxCtrl
.EnableWindow(m_PrecomputedRotations
);
68 m_NbModelsCtrl
.EnableWindow(m_PrecomputedRotations
);
69 GetDlgItem(IDC_UPDATE_MIN_ROT_SPEED
)->EnableWindow(m_PrecomputedRotations
);
70 GetDlgItem(IDC_UPDATE_MAX_ROT_SPEED
)->EnableWindow(m_PrecomputedRotations
);
71 GetDlgItem(IDC_UPDATE_NB_MODELS
)->EnableWindow(m_PrecomputedRotations
);
75 void CPrecomputedRotationsDlg::updateFromReader(void)
78 if (m_PrecomputedRotations
)
81 float minVelocity
, maxVelocity
;
82 sprintf(out
, "%d", _RotatedParticle
->checkHintRotateTheSame(minVelocity
, maxVelocity
));
84 sprintf(out
, "%g", minVelocity
);
86 sprintf(out
, "%g", maxVelocity
);
92 m_RotSpeedMin
.Empty();
93 m_RotSpeedMax
.Empty();
100 void CPrecomputedRotationsDlg::DoDataExchange(CDataExchange
* pDX
)
102 CDialog::DoDataExchange(pDX
);
103 //{{AFX_DATA_MAP(CPrecomputedRotationsDlg)
104 DDX_Control(pDX
, IDC_ROT_SPEED_MIN
, m_RotSpeedMinCtrl
);
105 DDX_Control(pDX
, IDC_NB_MODELS
, m_NbModelsCtrl
);
106 DDX_Control(pDX
, IDC_ROT_SPEED_MAX
, m_RotSpeedMaxCtrl
);
107 DDX_Text(pDX
, IDC_ROT_SPEED_MAX
, m_RotSpeedMax
);
108 DDX_Check(pDX
, IDC_HINT_PRECOMPUTED_ROTATIONS
, m_PrecomputedRotations
);
109 DDX_Text(pDX
, IDC_ROT_SPEED_MIN
, m_RotSpeedMin
);
110 DDX_Text(pDX
, IDC_NB_MODELS
, m_NbModels
);
115 BEGIN_MESSAGE_MAP(CPrecomputedRotationsDlg
, CDialog
)
116 //{{AFX_MSG_MAP(CPrecomputedRotationsDlg)
117 ON_BN_CLICKED(IDC_UPDATE_MIN_ROT_SPEED
, OnUpdateMinRotSpeed
)
118 ON_BN_CLICKED(IDC_UPDATE_MAX_ROT_SPEED
, OnUpdateMaxRotSpeed
)
119 ON_BN_CLICKED(IDC_UPDATE_NB_MODELS
, OnUpdateNbModels
)
120 ON_BN_CLICKED(IDC_HINT_PRECOMPUTED_ROTATIONS
, OnHintPrecomputedRotations
)
124 /////////////////////////////////////////////////////////////////////////////
125 // CPrecomputedRotationsDlg message handlers
127 void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed()
129 nlassert(_RotatedParticle
);
131 float newValue
, valueMin
, valueMax
;
132 if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMin
), newValue
))
134 uint32 nbModels
= _RotatedParticle
->checkHintRotateTheSame(valueMin
, valueMax
);
136 _RotatedParticle
->hintRotateTheSame(nbModels
, valueMin
, valueMax
);
137 updateModifiedFlag();
141 MessageBox(_T("invalid value !!"));
144 updateModifiedFlag();
147 void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed()
149 nlassert(_RotatedParticle
);
151 float newValue
, valueMin
, valueMax
;
152 if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMax
), newValue
))
154 uint32 nbModels
= _RotatedParticle
->checkHintRotateTheSame(valueMin
, valueMax
);
156 _RotatedParticle
->hintRotateTheSame(nbModels
, valueMin
, valueMax
);
157 updateModifiedFlag();
161 MessageBox(_T("invalid value !!"));
164 updateModifiedFlag();
167 void CPrecomputedRotationsDlg::OnUpdateNbModels()
169 nlassert(_RotatedParticle
);
171 float valueMin
, valueMax
;
173 bool valid
= (NLMISC::fromString(NLMISC::tStrToUtf8(m_NbModels
), newNbModels
) && newNbModels
> 0);
174 if (dynamic_cast<NL3D::CPSConstraintMesh
*>(_RotatedParticle
))
176 valid
&= (newNbModels
< NL3D::ConstraintMeshMaxNumPrerotatedModels
);
180 _RotatedParticle
->checkHintRotateTheSame(valueMin
, valueMax
);
181 _RotatedParticle
->hintRotateTheSame((uint32
) newNbModels
, valueMin
, valueMax
);
182 updateModifiedFlag();
186 MessageBox(_T("invalid value !!"));
189 updateModifiedFlag();
192 void CPrecomputedRotationsDlg::OnHintPrecomputedRotations()
194 nlassert(_RotatedParticle
);
198 _WndToDisable
->EnableWindow(!m_PrecomputedRotations
);
200 if (m_PrecomputedRotations
)
202 _RotatedParticle
->hintRotateTheSame(32);
203 updateModifiedFlag();
207 _RotatedParticle
->disableHintRotateTheSame();
208 updateModifiedFlag();
211 enablePrecompRotationControl();