Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / tail_particle_dlg.cpp
blobf8ba14169e66c0b61b77f7a76d8016912fee8332
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std_afx.h"
18 #include "object_viewer.h"
19 #include "nel/3d/ps_particle.h"
20 #include "tail_particle_dlg.h"
25 /////////////////////////////////////////////////////////////////////////////
26 // CTailParticleDlg dialog
29 CTailParticleDlg::CTailParticleDlg(CParticleWorkspace::CNode *ownerNode, NL3D::CPSTailParticle *tp)
31 nlassert(tp);
32 _TailParticle = tp;
33 _Node = ownerNode;
34 //{{AFX_DATA_INIT(CTailParticleDlg)
35 m_TailFade = tp->getColorFading();
36 m_TailPersistAfterDeath = FALSE;
37 //}}AFX_DATA_INIT
41 void CTailParticleDlg::init(CWnd *pParent, sint x, sint y)
43 Create(IDD_TAIL_PARTICLE, pParent);
44 RECT r;
45 GetClientRect(&r);
46 r.top += y; r.bottom += y;
47 r.right += x; r.left += x;
48 MoveWindow(&r);
50 if (!dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))
52 m_TailShape.EnableWindow(FALSE);
53 m_TailShape.ShowWindow(FALSE);
54 m_TailPersistAfterDeathCtrl.EnableWindow(FALSE);
55 m_TailPersistAfterDeathCtrl.ShowWindow(FALSE);
57 else
59 /// m_TailPersistAfterDeath = (dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))->getPersistAfterDeath();
61 NL3D::CPSRibbon *ribbon = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
62 if (ribbon)
64 ((CComboBox *) GetDlgItem(IDC_RIBBON_ORIENTATION))->SetCurSel(ribbon->getOrientation());
66 else
68 GetDlgItem(IDC_RIBBON_ORIENTATION)->ShowWindow(SW_HIDE);
70 UpdateData();
71 ShowWindow(SW_SHOW);
74 void CTailParticleDlg::DoDataExchange(CDataExchange* pDX)
76 CDialog::DoDataExchange(pDX);
77 //{{AFX_DATA_MAP(CTailParticleDlg)
78 DDX_Control(pDX, IDC_TAIL_SHAPE, m_TailShape);
79 DDX_Control(pDX, IDC_TAIL_PERSIST_AFTER_DEATH, m_TailPersistAfterDeathCtrl);
80 DDX_Check(pDX, IDC_TAIL_FADE, m_TailFade);
81 DDX_Check(pDX, IDC_TAIL_PERSIST_AFTER_DEATH, m_TailPersistAfterDeath);
82 //}}AFX_DATA_MAP
86 BEGIN_MESSAGE_MAP(CTailParticleDlg, CDialog)
87 //{{AFX_MSG_MAP(CTailParticleDlg)
88 ON_BN_CLICKED(IDC_TAIL_FADE, OnTailFade)
89 ON_BN_CLICKED(IDC_TAIL_PERSIST_AFTER_DEATH, OnTailPersistAfterDeath)
90 ON_CBN_SELCHANGE(IDC_TAIL_SHAPE, OnSelchangeTailShape)
91 ON_WM_PAINT()
92 ON_CBN_SELCHANGE(IDC_RIBBON_ORIENTATION, OnSelchangeRibbonOrientation)
93 //}}AFX_MSG_MAP
94 END_MESSAGE_MAP()
96 /////////////////////////////////////////////////////////////////////////////
97 // CTailParticleDlg message handlers
99 void CTailParticleDlg::OnTailFade()
101 UpdateData();
102 _TailParticle->setColorFading(m_TailFade ? true : false);
103 _Node->setModified(true);
104 UpdateData(FALSE);
109 void CTailParticleDlg::OnTailPersistAfterDeath()
111 UpdateData();
112 nlassert(dynamic_cast<NL3D::CPSRibbon *>(_TailParticle));
113 /// (dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))->setPersistAfterDeath(m_TailPersistAfterDeath ? true : false);
114 _Node->setModified(true);
115 UpdateData(FALSE);
118 void CTailParticleDlg::OnSelchangeTailShape()
120 UpdateData();
121 NL3D::CPSRibbon *r = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
122 nlassert(r);
123 switch (m_TailShape.GetCurSel() )
125 case 0: // triangle
126 r->setShape(NL3D::CPSRibbon::Triangle, NL3D::CPSRibbon::NbVerticesInTriangle);
127 break;
128 case 1: // quad
129 r->setShape(NL3D::CPSRibbon::Losange, NL3D::CPSRibbon::NbVerticesInLosange);
130 break;
131 case 2: // octogon
132 r->setShape(NL3D::CPSRibbon::HeightSides, NL3D::CPSRibbon::NbVerticesInHeightSide);
133 break;
134 case 3: // pentagram
135 r->setShape(NL3D::CPSRibbon::Pentagram, NL3D::CPSRibbon::NbVerticesInPentagram);
136 break;
137 case 4: // simple segment x
138 r->setShape(NL3D::CPSRibbon::SimpleSegmentX, NL3D::CPSRibbon::NbVerticesInSimpleSegmentX, true);
139 break;
140 case 5: // simple segment y
141 r->setShape(NL3D::CPSRibbon::SimpleSegmentY, NL3D::CPSRibbon::NbVerticesInSimpleSegmentY, true);
142 break;
143 case 6: // simple segment z
144 r->setShape(NL3D::CPSRibbon::SimpleSegmentZ, NL3D::CPSRibbon::NbVerticesInSimpleSegmentZ, true);
145 break;
146 case 7: // simple brace
147 r->setShape(NL3D::CPSRibbon::SimpleBrace, NL3D::CPSRibbon::NbVerticesInSimpleBrace, true);
148 break;
150 _Node->setModified(true);
151 Invalidate();
154 void CTailParticleDlg::OnPaint()
156 CPaintDC dc(this); // device context for painting
158 NL3D::CPSRibbon *r = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
159 // if we're dealing with a ribbon, we draw the shape used for extrusion
160 if (r)
162 const uint x = 270, y = 15, size = 32;
165 dc.FillSolidRect(x, y, size, size, 0xffffff);
167 std::vector<NLMISC::CVector> verts;
168 verts.resize(r->getNbVerticesInShape() );
169 r->getShape(&verts[0]);
171 CPen p;
172 p.CreatePen(PS_SOLID, 1, (COLORREF) 0);
173 CPen *old = dc.SelectObject(&p);
175 if (r->getBraceMode())
177 for(uint k = 0; k < verts.size() / 2; ++k)
179 dc.MoveTo((int) (x + (size / 2) * (1 + verts[2 * k].x)), (int) (y + (size / 2) * (1 - verts[2 * k].y)));
180 dc.LineTo((int) (x + (size / 2) * (1 + verts[2 * k + 1].x)), (int) (y + (size / 2) * (1 - verts[2 * k + 1].y)));
183 else
185 dc.MoveTo((int) (x + (size / 2) * (1 + verts[0].x)), (int) (y + (size / 2) * (1 - verts[0].y)));
186 for (std::vector<NLMISC::CVector>::const_iterator it = verts.begin(); it != verts.end(); ++it)
188 dc.LineTo((int) (x + (size / 2) * (1 + it->x)), (int) (y + (size / 2) * (1 - it->y)));
190 dc.LineTo((int) (x + (size / 2) * (1 + verts[0].x)), (int) (y + (size / 2) * (1 - verts[0].y)));
192 dc.SelectObject(old);
196 void CTailParticleDlg::OnSelchangeRibbonOrientation()
198 NL3D::CPSRibbon *r = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
199 nlassert(r);
200 r->setOrientation((NL3D::CPSRibbon::TOrientation) ((CComboBox *) GetDlgItem(IDC_RIBBON_ORIENTATION))->GetCurSel());
201 _Node->setModified(true);