Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / precomputed_rotations_dlg.cpp
blobecc99d60634580cacd856ffbaf617aa3d35627ec
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
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/>.
20 #include "std_afx.h"
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("");
41 m_NbModels = _T("");
42 //}}AFX_DATA_INIT
46 void CPrecomputedRotationsDlg::init(CWnd *pParent, sint x, sint y)
48 Create(IDD_HINT_ROTATE_THE_SAME, pParent);
49 RECT r;
50 GetClientRect(&r);
51 CRect wr;
52 wr.left = r.left + x;
53 wr.top = r.top + y;
54 wr.bottom = r.bottom + y;
55 wr.right = r.right + x;
56 MoveWindow(wr);
57 ShowWindow(SW_SHOW);
58 enablePrecompRotationControl();
59 updateFromReader();
62 void CPrecomputedRotationsDlg::enablePrecompRotationControl(void)
64 nlassert(_RotatedParticle);
65 UpdateData();
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);
72 UpdateData(FALSE);
75 void CPrecomputedRotationsDlg::updateFromReader(void)
77 UpdateData();
78 if (m_PrecomputedRotations)
80 char out[256];
81 float minVelocity, maxVelocity;
82 sprintf(out, "%d", _RotatedParticle->checkHintRotateTheSame(minVelocity, maxVelocity));
83 m_NbModels = out;
84 sprintf(out, "%g", minVelocity);
85 m_RotSpeedMin = out;
86 sprintf(out, "%g", maxVelocity);
87 m_RotSpeedMax = out;
89 else
91 m_NbModels.Empty();
92 m_RotSpeedMin.Empty();
93 m_RotSpeedMax.Empty();
96 UpdateData(FALSE);
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);
111 //}}AFX_DATA_MAP
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)
121 //}}AFX_MSG_MAP
122 END_MESSAGE_MAP()
124 /////////////////////////////////////////////////////////////////////////////
125 // CPrecomputedRotationsDlg message handlers
127 void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed()
129 nlassert(_RotatedParticle);
130 UpdateData();
131 float newValue, valueMin, valueMax;
132 if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMin), newValue))
134 uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
135 valueMin = newValue;
136 _RotatedParticle->hintRotateTheSame(nbModels, valueMin, valueMax);
137 updateModifiedFlag();
139 else
141 MessageBox(_T("invalid value !!"));
143 UpdateData(FALSE);
144 updateModifiedFlag();
147 void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed()
149 nlassert(_RotatedParticle);
150 UpdateData();
151 float newValue, valueMin, valueMax;
152 if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMax), newValue))
154 uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
155 valueMax = newValue;
156 _RotatedParticle->hintRotateTheSame(nbModels, valueMin, valueMax);
157 updateModifiedFlag();
159 else
161 MessageBox(_T("invalid value !!"));
163 UpdateData(FALSE);
164 updateModifiedFlag();
167 void CPrecomputedRotationsDlg::OnUpdateNbModels()
169 nlassert(_RotatedParticle);
170 UpdateData();
171 float valueMin, valueMax;
172 sint32 newNbModels;
173 bool valid = (NLMISC::fromString(NLMISC::tStrToUtf8(m_NbModels), newNbModels) && newNbModels > 0);
174 if (dynamic_cast<NL3D::CPSConstraintMesh *>(_RotatedParticle))
176 valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels);
178 if (valid)
180 _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
181 _RotatedParticle->hintRotateTheSame((uint32) newNbModels, valueMin, valueMax);
182 updateModifiedFlag();
184 else
186 MessageBox(_T("invalid value !!"));
188 UpdateData(FALSE);
189 updateModifiedFlag();
192 void CPrecomputedRotationsDlg::OnHintPrecomputedRotations()
194 nlassert(_RotatedParticle);
195 UpdateData();
196 if (_WndToDisable)
198 _WndToDisable->EnableWindow(!m_PrecomputedRotations);
200 if (m_PrecomputedRotations)
202 _RotatedParticle->hintRotateTheSame(32);
203 updateModifiedFlag();
205 else
207 _RotatedParticle->disableHintRotateTheSame();
208 updateModifiedFlag();
211 enablePrecompRotationControl();
212 updateFromReader();
213 UpdateData(FALSE);