diff --git a/code/nel/tools/3d/object_viewer_qt/src/description.h b/code/nel/tools/3d/object_viewer_qt/src/description.h
index f1e3fc8a7..a9f4c496f 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/description.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/description.h
@@ -84,7 +84,6 @@ Using this widget you can set the color(RGBA) using the four sliders or through
CDirectionWidget
This widget helps to choose from several preset directions, or to choose a custom one.
-To use it you have to create a wrapper.
@see
diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp
index 79af10959..dee9d1b47 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp
@@ -25,12 +25,11 @@
// NeL includes
#include
-#include
namespace NLQT {
CDirectionWidget::CDirectionWidget(QWidget *parent)
- : QWidget(parent), _Wrapper(NULL), _DirectionWrapper(NULL), _globalName("")
+ : QWidget(parent), _globalName("")
{
_ui.setupUi(this);
@@ -59,31 +58,10 @@ CDirectionWidget::~CDirectionWidget()
{
}
-void CDirectionWidget::enableGlobalVariable()
+void CDirectionWidget::enabledGlobalVariable(bool enabled)
{
- _ui.globalPushButton->setVisible(true);
- _globalName = "";
-}
-
-void CDirectionWidget::setWrapper(IPSWrapper *wrapper)
-{
- _Wrapper = wrapper;
- _ui.globalPushButton->hide();
-}
-
-void CDirectionWidget::setDirectionWrapper(NL3D::CPSDirection *wrapper)
-{
- _DirectionWrapper = wrapper;
- if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue())
- _ui.globalPushButton->show();
- else
- _ui.globalPushButton->hide();
-}
-
-void CDirectionWidget::updateUi()
-{
- setValue(_Wrapper->get(), false);
- checkEnabledGlobalDirection();
+ _ui.globalPushButton->setVisible(enabled);
+ setGlobalName("", false);
}
void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit)
@@ -97,8 +75,6 @@ void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit)
if (emit)
{
Q_EMIT valueChanged(_value);
- if (_Wrapper)
- _Wrapper->setAndUpdateModifiedFlag(_value);
}
}
@@ -122,24 +98,13 @@ void CDirectionWidget::setGlobalName(const QString &globalName, bool emit)
void CDirectionWidget::setGlobalDirection()
{
- nlassert(_DirectionWrapper);
-
bool ok;
QString text = QInputDialog::getText(this, tr("Enter Name"),
"", QLineEdit::Normal,
- QString(_DirectionWrapper->getGlobalVectorValueName().c_str()), &ok);
+ QString(_globalName), &ok);
if (ok)
- {
setGlobalName(text);
-
- _DirectionWrapper->enableGlobalVectorValue(text.toStdString());
- if (!_globalName.isEmpty())
- {
- // take a non NULL value for the direction
- NL3D::CParticleSystem::setGlobalVectorValue(text.toStdString(), NLMISC::CVector::I);
- }
- }
}
void CDirectionWidget::incVecI()
@@ -175,11 +140,7 @@ void CDirectionWidget::decVecK()
void CDirectionWidget::setNewVecXZ(float x, float y)
{
const float epsilon = 10E-3f;
- NLMISC::CVector v;
- if (_Wrapper)
- v = _Wrapper->get();
- else
- v = _value;
+ NLMISC::CVector v = _value;
v.x = x;
v.z = y;
@@ -202,11 +163,7 @@ void CDirectionWidget::setNewVecXZ(float x, float y)
void CDirectionWidget::setNewVecYZ(float x, float y)
{
const float epsilon = 10E-3f;
- NLMISC::CVector v;
- if (_Wrapper)
- v = _Wrapper->get();
- else
- v = _value;
+ NLMISC::CVector v = _value;
v.y = x;
v.z = y;
@@ -226,23 +183,4 @@ void CDirectionWidget::setNewVecYZ(float x, float y)
setValue(v);
}
-void CDirectionWidget::checkEnabledGlobalDirection()
-{
- bool enableUserDirection = true;
- _ui.xzWidget->show();
- _ui.yzWidget->show();
- if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue() && !_DirectionWrapper->getGlobalVectorValueName().empty())
- {
- enableUserDirection = false;
- _ui.xzWidget->hide();
- _ui.yzWidget->hide();
- }
- _ui.incVecIPushButton->setEnabled(enableUserDirection);
- _ui.incVecJPushButton->setEnabled(enableUserDirection);
- _ui.incVecKPushButton->setEnabled(enableUserDirection);
- _ui.decVecIPushButton->setEnabled(enableUserDirection);
- _ui.decVecJPushButton->setEnabled(enableUserDirection);
- _ui.decVecKPushButton->setEnabled(enableUserDirection);
-}
-
} /* namespace NLQT */
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h
index 5f0093da1..aaee615a1 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h
@@ -28,7 +28,6 @@
#include
// Project includes
-#include "ps_wrapper.h"
namespace NLQT {
@@ -45,13 +44,7 @@ public:
CDirectionWidget(QWidget *parent = 0);
~CDirectionWidget();
- void enableGlobalVariable();
- void setWrapper(IPSWrapper *wrapper);
-
- /// The CPSDirection object is used to see if a global variable can be bound to the direction.
- /// When set to NULL it has no effect (the default)
- void setDirectionWrapper(NL3D::CPSDirection *wrapper);
- void updateUi();
+ void enabledGlobalVariable(bool enabled);
Q_SIGNALS:
void valueChanged(const NLMISC::CVector &value);
@@ -73,10 +66,6 @@ private Q_SLOTS:
void setNewVecYZ(float x, float y);
private:
- void checkEnabledGlobalDirection();
-
- IPSWrapper *_Wrapper ;
- NL3D::CPSDirection *_DirectionWrapper;
NLMISC::CVector _value;
QString _globalName;
diff --git a/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp
index 5c3021277..f77a3498d 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp
@@ -280,17 +280,20 @@ void CEmitterPage::setDirectionMode(int index)
void CEmitterPage::setSpeedInheritanceFactor(float value)
{
_Emitter->setSpeedInheritanceFactor(value);
+ updateModifiedFlag();
}
void CEmitterPage::setConicEmitterRadius(float value)
{
dynamic_cast(_Emitter)->setRadius(value);
+ updateModifiedFlag();
}
void CEmitterPage::setEmitDelay(float value)
{
_Emitter->setEmitDelay(value);
Modules::psEdit().resetAutoCount(_Node);
+ updateModifiedFlag();
}
void CEmitterPage::setMaxEmissionCount(uint32 value)
@@ -304,6 +307,7 @@ void CEmitterPage::setMaxEmissionCount(uint32 value)
QMessageBox::Ok);
_ui.maxEmissionCountWidget->setValue((uint32)_Emitter->getMaxEmissionCount(), false);
+ updateModifiedFlag();
}
Modules::psEdit().resetAutoCount(_Node);
}
@@ -311,6 +315,7 @@ void CEmitterPage::setMaxEmissionCount(uint32 value)
void CEmitterPage::setDir(const NLMISC::CVector &value)
{
dynamic_cast(_Emitter)->setDir(value);
+ updateModifiedFlag();
}
void CEmitterPage::updatePeriodWidget()
diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp
index b2d516022..766a89898 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp
@@ -41,18 +41,17 @@ CForcePage::CForcePage(QWidget *parent)
_ui.forceIntensityWidget->init();
_ui.parametricFactorWidget->setRange(0.0, 64.0);
- _ui.parametricFactorWidget->setWrapper(&_ParamFactorWrapper);
-
_ui.radialViscosityWidget->setRange(0.0, 1.0);
- _ui.radialViscosityWidget->setWrapper(&_RadialViscosityWrapper);
-
_ui.tangentialViscosityWidget->setRange(0, 1);
- _ui.tangentialViscosityWidget->setWrapper(&_TangentialViscosityWrapper);
-
- _ui.directionWidget->setWrapper(&_DirectionWrapper);
connect(_ui.toTargetsPushButton, SIGNAL(clicked()), this, SLOT(addTarget()));
connect(_ui.toAvaibleTargetsPushButton, SIGNAL(clicked()), this, SLOT(removeTarget()));
+
+ connect(_ui.parametricFactorWidget, SIGNAL(valueChanged(float)), this, SLOT(setFactorBrownianForce(float)));
+ connect(_ui.radialViscosityWidget, SIGNAL(valueChanged(float)), this, SLOT(setRadialViscosity(float)));
+ connect(_ui.tangentialViscosityWidget, SIGNAL(valueChanged(float)), this, SLOT(setTangentialViscosity(float)));
+ connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector)));
+ connect(_ui.directionWidget, SIGNAL(globalNameChanged(QString)), this, SLOT(setGlobalName(QString)));
}
CForcePage::~CForcePage()
@@ -61,10 +60,11 @@ CForcePage::~CForcePage()
void CForcePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindable *locatedBindable)
{
- hideWrappersWidget();
+ nlassert(locatedBindable);
+
+ hideAdditionalWidget();
_Node = ownerNode;
_LBTarget = static_cast(locatedBindable);
-
updateTargets();
// force with intensity case
@@ -77,41 +77,33 @@ void CForcePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab
}
// vortex (to tune viscosity)
- if (dynamic_cast(_LBTarget))
+ NL3D::CPSCylindricVortex *cylindricVortex = dynamic_cast(_LBTarget);
+ if (cylindricVortex)
{
- _RadialViscosityWrapper.OwnerNode = _Node;
- _RadialViscosityWrapper.V = dynamic_cast(_LBTarget);
-
- _ui.radialViscosityWidget->updateUi();
+ _ui.radialViscosityWidget->setValue(cylindricVortex->getRadialViscosity(), false);
_ui.radialViscosityLabel->show();
_ui.radialViscosityWidget->show();
- _TangentialViscosityWrapper.OwnerNode = _Node;
- _TangentialViscosityWrapper.V = dynamic_cast(_LBTarget);
-
- _ui.tangentialViscosityWidget->updateUi();
+ _ui.tangentialViscosityWidget->setValue(cylindricVortex->getTangentialViscosity(), false);
_ui.tangentialViscosityLabel->show();
_ui.tangentialViscosityWidget->show();
}
// deals with emitters that have a direction
- if (dynamic_cast(_LBTarget))
+ NL3D::CPSDirection *direction = dynamic_cast(_LBTarget);
+ if (direction)
{
- _DirectionWrapper.OwnerNode = _Node;
- _DirectionWrapper.E = dynamic_cast(_LBTarget);
- _ui.directionWidget->setDirectionWrapper(dynamic_cast(_LBTarget));
-
- _ui.directionWidget->updateUi();
+ _ui.directionWidget->setValue(direction->getDir(), false);
+ _ui.directionWidget->enabledGlobalVariable(direction->supportGlobalVectorValue());
+ _ui.directionWidget->setGlobalName(QString(direction->getGlobalVectorValueName().c_str()), false);
_ui.directionWidget->show();
}
// Brownian (to tune parametric factor)
- if (dynamic_cast(_LBTarget))
+ NL3D::CPSBrownianForce *brownianForce = dynamic_cast(_LBTarget);
+ if (brownianForce)
{
- _ParamFactorWrapper.OwnerNode = _Node;
- _ParamFactorWrapper.F = static_cast(_LBTarget);
-
- _ui.parametricFactorWidget->updateUi();
+ _ui.parametricFactorWidget->setValue(brownianForce->getParametricFactor(), false);
_ui.parametricFactorLabel->show();
_ui.parametricFactorWidget->show();
}
@@ -168,8 +160,47 @@ void CForcePage::removeTarget()
_ui.avaibleTargetsListWidget->addItem(item);
updateModifiedFlag();
}
+void CForcePage::setRadialViscosity(float value)
+{
+ nlassert(_LBTarget);
+ dynamic_cast(_LBTarget)->setRadialViscosity(value);
+ updateModifiedFlag();
+}
-void CForcePage::hideWrappersWidget()
+void CForcePage::setTangentialViscosity(float value)
+{
+ nlassert(_LBTarget);
+ dynamic_cast(_LBTarget)->setTangentialViscosity(value);
+ updateModifiedFlag();
+}
+
+void CForcePage::setDir(const NLMISC::CVector &value)
+{
+ nlassert(_LBTarget);
+ dynamic_cast(_LBTarget)->setDir(value);
+ updateModifiedFlag();
+}
+
+void CForcePage::setGlobalName(const QString &globalName)
+{
+ nlassert(_LBTarget);
+ dynamic_cast(_LBTarget)->enableGlobalVectorValue(globalName.toStdString());
+ if (!globalName.isEmpty())
+ {
+ // take a non NULL value for the direction
+ NL3D::CParticleSystem::setGlobalVectorValue(globalName.toStdString(), NLMISC::CVector::I);
+ }
+ updateModifiedFlag();
+}
+
+void CForcePage::setFactorBrownianForce(float value)
+{
+ nlassert(_LBTarget);
+ dynamic_cast(_LBTarget)->setParametricFactor(value);
+ updateModifiedFlag();
+}
+
+void CForcePage::hideAdditionalWidget()
{
_ui.directionWidget->hide();
_ui.parametricFactorLabel->hide();
@@ -182,6 +213,7 @@ void CForcePage::hideWrappersWidget()
void CForcePage::updateTargets()
{
+ nlassert(_LBTarget);
uint k;
uint nbTarg = _LBTarget->getNbTargets();
diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h
index 80c1f541a..37d5a89dd 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h
@@ -71,7 +71,13 @@ public:
private Q_SLOTS:
void addTarget();
void removeTarget();
-
+
+ void setRadialViscosity(float value);
+ void setTangentialViscosity(float value);
+ void setDir(const NLMISC::CVector &value);
+ void setGlobalName(const QString &globalName);
+ void setFactorBrownianForce(float value);
+
private:
/// wrapper to tune the intensity of a force
@@ -84,40 +90,7 @@ private:
void setScheme(scheme_type *s) {F->setIntensityScheme(s); }
} _ForceIntensityWrapper;
- /// wrapper to tune the radial viscosity for vortices
- struct CRadialViscosityWrapper : public IPSWrapperFloat
- {
- NL3D::CPSCylindricVortex *V;
- float get(void) const { return V->getRadialViscosity(); }
- void set(const float &value) { V->setRadialViscosity(value); }
- } _RadialViscosityWrapper;
-
- /// wrapper to tune the tangential viscosity for vortices
- struct CTangentialViscosityWrapper : public IPSWrapperFloat
- {
- NL3D::CPSCylindricVortex *V;
- float get(void) const { return V->getTangentialViscosity(); }
- void set(const float &value) { V->setTangentialViscosity(value); }
- } _TangentialViscosityWrapper;
-
- /// wrappers to tune the direction
- struct CDirectionWrapper : public IPSWrapper
- {
- NL3D::CPSDirection *E;
- NLMISC::CVector get(void) const { return E->getDir(); }
- void set(const NLMISC::CVector &d){ E->setDir(d); }
- } _DirectionWrapper;
-
- /// wrappers to tune the parametric factor of brownian force
- struct CParamFactorWrapper : public IPSWrapperFloat
- {
- NL3D::CPSBrownianForce *F;
- float get(void) const { return F->getParametricFactor(); }
- void set(const float &f){ F->setParametricFactor(f); }
- } _ParamFactorWrapper;
-
-
- void hideWrappersWidget();
+ void hideAdditionalWidget();
void updateTargets();
diff --git a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp
index fa717591f..2afd5b66d 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp
@@ -48,12 +48,14 @@ CPSMoverPage::CPSMoverPage(QWidget *parent)
_ui.scaleZWidget->setRange(0.f, 4.f);
_ui.scaleZWidget->setWrapper(&_ZScaleWrapper);
- _ui.directionWidget->setWrapper(&_DirectionWrapper);
+ //_ui.directionWidget->setWrapper(&_DirectionWrapper);
connect(_ui.xDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setXPosition(double)));
connect(_ui.yDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setYPosition(double)));
connect(_ui.zDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZPosition(double)));
-
+
+ connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector)));
+
connect(_ui.listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changeSubComponent()));
}
@@ -71,7 +73,7 @@ void CPSMoverPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocated *lo
updatePosition();
_ui.listWidget->clear();
- hideWrappersWidget();
+ hideAdditionalWidget();
uint numBound = _EditedLocated->getNbBoundObjects();
@@ -101,7 +103,7 @@ void CPSMoverPage::updatePosition(void)
}
-void CPSMoverPage::hideWrappersWidget()
+void CPSMoverPage::hideAdditionalWidget()
{
_ui.scaleLabel->hide();
_ui.scaleXLabel->hide();
@@ -162,7 +164,7 @@ void CPSMoverPage::setZPosition(double value)
void CPSMoverPage::changeSubComponent()
{
- hideWrappersWidget();
+ hideAdditionalWidget();
NL3D::IPSMover *m = getMoverInterface();
if (!m) return;
@@ -213,15 +215,17 @@ void CPSMoverPage::changeSubComponent()
if (m->onlyStoreNormal())
{
- _DirectionWrapper.OwnerNode = _Node;
- _DirectionWrapper.M = m;
- _DirectionWrapper.Index = _EditedLocatedIndex;
-
- _ui.directionWidget->updateUi();
+ _ui.directionWidget->setValue(getMoverInterface()->getNormal(getLocatedIndex()), false);
_ui.directionWidget->show();
}
}
+void CPSMoverPage::setDir(const NLMISC::CVector &value)
+{
+ getMoverInterface()->setNormal(getLocatedIndex(), value);
+ updateModifiedFlag();
+}
+
NL3D::IPSMover *CPSMoverPage::getMoverInterface(void)
{
nlassert(_EditedLocated);
diff --git a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h
index f2403ca7f..d3e9e37b4 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h
@@ -92,6 +92,8 @@ private Q_SLOTS:
void setZPosition(double value);
void changeSubComponent();
+ void setDir(const NLMISC::CVector &value);
+
private:
/// wrappers to scale objects
@@ -142,19 +144,10 @@ private:
}
} _ZScaleWrapper ;
- /// wrapper for direction
- struct CDirectionWrapper : public IPSWrapper
- {
- uint32 Index ;
- NL3D::IPSMover *M ;
- NLMISC::CVector get(void) const { return M->getNormal(Index) ; }
- void set(const NLMISC::CVector &v) { M->setNormal(Index, v) ; }
-
-
- } _DirectionWrapper ;
-
- void hideWrappersWidget();
+ void hideAdditionalWidget();
+ void updateModifiedFlag() { if (_Node) _Node->setModified(true); }
+
/// update the mouse listener position when the user entered a value with the keyboard
void updateListener(void) ;
diff --git a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp
index 9915e1fda..713a1b393 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp
@@ -1,19 +1,19 @@
/*
- Object Viewer Qt
- Copyright (C) 2010 Dzmitry Kamiahin
+Object Viewer Qt
+Copyright (C) 2010 Dzmitry Kamiahin
- This program 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.
+This program 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.
- This program 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.
+This program 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 this program. If not, see .
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
*/
@@ -21,48 +21,59 @@
#include "spinner_dialog.h"
namespace NLQT {
-
+
CSpinnerDialog::CSpinnerDialog(NL3D::CPSBasisSpinner *sf, CWorkspaceNode *ownerNode, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent), _Node(ownerNode), _BasicSpinner(sf)
{
- _verticalLayout = new QVBoxLayout(this);
- _nbSamplesLabel = new QLabel(this);
- _verticalLayout->addWidget(_nbSamplesLabel);
+ nlassert(_BasicSpinner);
- _nbSamplesWidget = new NLQT::CEditRangeUIntWidget(this);
- QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(_nbSamplesWidget->sizePolicy().hasHeightForWidth());
- _nbSamplesWidget->setSizePolicy(sizePolicy);
- _verticalLayout->addWidget(_nbSamplesWidget);
+ _verticalLayout = new QVBoxLayout(this);
+ _nbSamplesLabel = new QLabel(this);
+ _verticalLayout->addWidget(_nbSamplesLabel);
+
+ _nbSamplesWidget = new NLQT::CEditRangeUIntWidget(this);
+ QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+ sizePolicy.setHorizontalStretch(0);
+ sizePolicy.setVerticalStretch(0);
+ sizePolicy.setHeightForWidth(_nbSamplesWidget->sizePolicy().hasHeightForWidth());
+ _nbSamplesWidget->setSizePolicy(sizePolicy);
+ _verticalLayout->addWidget(_nbSamplesWidget);
+
+ _dirWidget = new NLQT::CDirectionWidget(this);
+ sizePolicy.setHeightForWidth(_dirWidget->sizePolicy().hasHeightForWidth());
+ _dirWidget->setSizePolicy(sizePolicy);
+ _verticalLayout->addWidget(_dirWidget);
- _dirWidget = new NLQT::CDirectionWidget(this);
- sizePolicy.setHeightForWidth(_dirWidget->sizePolicy().hasHeightForWidth());
- _dirWidget->setSizePolicy(sizePolicy);
- _verticalLayout->addWidget(_dirWidget);
-
setWindowTitle(tr("Edit spinner"));
- _nbSamplesLabel->setText(tr("Nb samples:"));
-
- _AxisWrapper.OwnerNode = ownerNode;
- _NbSampleWrapper.OwnerNode = ownerNode;
- _NbSampleWrapper.S = sf;
- _AxisWrapper.S = sf;
+ _nbSamplesLabel->setText(tr("Nb samples:"));
_nbSamplesWidget->setRange(1, 512);
- _nbSamplesWidget->setWrapper(&_NbSampleWrapper);
_nbSamplesWidget->enableLowerBound(0, true);
- _nbSamplesWidget->updateUi();
-
- _dirWidget->setWrapper(&_AxisWrapper);
- _dirWidget->updateUi();
+ _nbSamplesWidget->setValue(_BasicSpinner->_F.getNumSamples(), false);
+ _dirWidget->setValue(_BasicSpinner->_F.getAxis());
setFixedHeight(sizeHint().height());
+
+ connect(_nbSamplesWidget, SIGNAL(valueChanged(uint32)), this, SLOT(setNumSamples(uint32)));
+ connect(_dirWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setAxis(NLMISC::CVector)));
}
CSpinnerDialog::~CSpinnerDialog()
{
}
+void CSpinnerDialog::setNumSamples(uint32 value)
+{
+ nlassert(_BasicSpinner);
+ _BasicSpinner->_F.setNumSamples(value);
+ updateModifiedFlag();
+}
+
+void CSpinnerDialog::setAxis(const NLMISC::CVector &axis)
+{
+ nlassert(_BasicSpinner);
+ _BasicSpinner->_F.setAxis(axis);
+ updateModifiedFlag();
+}
+
} /* namespace NLQT */
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h
index 62497b8bc..416f06d91 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h
@@ -43,29 +43,20 @@ public:
CSpinnerDialog(NL3D::CPSBasisSpinner *sf, CWorkspaceNode *ownerNode, QWidget *parent = 0);
~CSpinnerDialog();
+private Q_SLOTS:
+ void setNumSamples(uint32 value);
+ void setAxis(const NLMISC::CVector &axis);
+
protected:
-
- /// Wrapper to set the number of samples in the spinner
- struct CNbSampleWrapper : public IPSWrapperUInt
- {
- NL3D::CPSBasisSpinner *S;
- uint32 get(void) const { return S->_F.getNumSamples(); }
- void set(const uint32 &val) { S->_F.setNumSamples(val); }
- } _NbSampleWrapper;
+ void updateModifiedFlag() { if (_Node) _Node->setModified(true); }
-
- /// Wrapper to set the axis of the spinner
- struct CAxisWrapper : public IPSWrapper
- {
- NL3D::CPSBasisSpinner *S;
- NLMISC::CVector get(void) const { return S->_F.getAxis(); }
- void set(const NLMISC::CVector &axis) { S->_F.setAxis(axis); }
- } _AxisWrapper;
-
QLabel *_nbSamplesLabel;
QVBoxLayout *_verticalLayout;
CEditRangeUIntWidget *_nbSamplesWidget;
CDirectionWidget *_dirWidget;
+
+ CWorkspaceNode *_Node;
+ NL3D::CPSBasisSpinner *_BasicSpinner;
};
} /* namespace NLQT */
diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt
index 7919ed9fa..d3ca049eb 100644
--- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt
+++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt
@@ -3,7 +3,7 @@ INCLUDE( ${QT_USE_FILE} )
FILE(GLOB GEORGES_EDITOR_SRC *.cpp *.h)
SET(GEORGES_EDITOR_HDR georges_dirtree_dialog.h georges_treeview_dialog.h main_window.h
- objectviewer_dialog.h settings_dialog.h progress_dialog.h)
+ objectviewer_dialog.h settings_dialog.h progress_dialog.h object_viewer_widget.h)
SET(GEORGES_EDITOR_UIS settings_form.ui objectviewer_form.ui log_form.ui georges_treeview_form.ui georges_dirtree_form.ui)
SET(GEORGES_EDITOR_RCS georges_editor_qt.qrc)
diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp
index 878b8e730..304ff62bf 100644
--- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp
+++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp
@@ -1,32 +1,32 @@
-/*
- Georges Editor Qt
- Copyright (C) 2010 Adrian Jaekel
-
- This program 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.
-
- This program 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 this program. If not, see .
+/*
+ Object Viewer Qt
+ Copyright (C) 2010 Dzmitry Kamiahin
+
+ This program 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.
+
+ This program 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 this program. If not, see .
+
*/
+#include "stdpch.h"
#include "entity.h"
+#include
+
// NeL includes
#include
-#include
#include
-#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -63,14 +63,38 @@ CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo)
}
CEntity::CEntity(void):
- _Name(""),
+ _Name(""), _FileNameShape(""),
+ _FileNameSkeleton(""), _inPlace(false), _incPos(false),
_Instance(NULL), _Skeleton(NULL),
_PlayList(NULL), _AnimationSet(NULL)
{
+ _CharacterScalePos = 1;
}
CEntity::~CEntity(void)
{
+ if (_PlayList != NULL)
+ {
+ _PlayList->resetAllChannels();
+ Modules::objView().getPlayListManager()->deletePlayList (_PlayList);
+ _PlayList = NULL;
+ }
+ if (_AnimationSet != NULL)
+ {
+ Modules::objView().getDriver()->deleteAnimationSet(_AnimationSet);
+ _AnimationSet = NULL;
+ }
+ if (!_Skeleton.empty())
+ {
+ _Skeleton.detachSkeletonSon(_Instance);
+ Modules::objView().getScene()->deleteSkeleton(_Skeleton);
+ _Skeleton = NULL;
+ }
+ if (!_Instance.empty())
+ {
+ Modules::objView().getScene()->deleteInstance(_Instance);
+ _Instance = NULL;
+ }
}
void CEntity::loadAnimation(std::string &fileName)
@@ -93,6 +117,8 @@ void CEntity::addAnimToPlayList(std::string &name)
_PlayListAnimation.push_back(name);
_AnimationStatus.EndAnim = this->getPlayListLength();
+
+ _Instance.start();
}
void CEntity::removeAnimToPlayList(uint row)
@@ -112,6 +138,11 @@ void CEntity::swapAnimToPlayList(uint row1, uint row2)
void CEntity::playbackAnim(bool play)
{
_AnimationStatus.PlayAnim = play;
+
+ if (play)
+ _Instance.start();
+ else
+ _Instance.freezeHRC();
}
void CEntity::reset()
@@ -144,22 +175,97 @@ void CEntity::update(NL3D::TAnimationTime time)
this->resetChannel();
switch (_AnimationStatus.Mode)
{
- case Mode::PlayList:
- animatePlayList(time);
- break;
- case Mode::Mixer:
- animateChannelMixer();
- break;
+ case Mode::PlayList:
+ animatePlayList(time);
+ break;
+ case Mode::Mixer:
+ animateChannelMixer();
+ break;
}
}
void CEntity::resetChannel()
{
- for(size_t i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++)
+ for(uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++)
_PlayList->setAnimation(i, UPlayList::empty);
}
+void CEntity::addTransformation (CMatrix ¤t, UAnimation *anim, float begin, float end, UTrack *posTrack, UTrack *rotquatTrack,
+ UTrack *nextPosTrack, UTrack *nextRotquatTrack, bool removeLast)
+{
+ // In place ?
+ if (_inPlace)
+ {
+ // Just identity
+ current.identity();
+ }
+ else
+ {
+ // Remove the start of the animation
+ CQuat rotEnd (0,0,0,1);
+ CVector posEnd (0,0,0);
+ if (rotquatTrack)
+ {
+ // Interpolate the rotation
+ rotquatTrack->interpolate (end, rotEnd);
+ }
+ if (posTrack)
+ {
+ // Interpolate the position
+ posTrack->interpolate (end, posEnd);
+ }
+
+ // Add the final rotation and position
+ CMatrix tmp;
+ tmp.identity ();
+ tmp.setRot (rotEnd);
+ tmp.setPos (posEnd);
+
+ // Incremental ?
+ if (_incPos)
+ current *= tmp;
+ else
+ current = tmp;
+
+ if (removeLast)
+ {
+ CQuat rotStart (0,0,0,1);
+ CVector posStart (0,0,0);
+ if (nextRotquatTrack)
+ {
+ // Interpolate the rotation
+ nextRotquatTrack->interpolate (begin, rotStart);
+ }
+ if (nextPosTrack)
+ {
+ // Interpolate the position
+ nextPosTrack->interpolate (begin, posStart);
+ }
+ // Remove the init rotation and position of the next animation
+ tmp.identity ();
+ tmp.setRot (rotStart);
+ tmp.setPos (posStart);
+ tmp.invert ();
+ current *= tmp;
+
+ // Normalize the mt
+ CVector I = current.getI ();
+ CVector J = current.getJ ();
+ I.z = 0;
+ J.z = 0;
+ J.normalize ();
+ CVector K = I^J;
+ K.normalize ();
+ I = J^K;
+ I.normalize ();
+ tmp.setRot (I, J, K);
+ tmp.setPos (current.getPos ());
+ current = tmp;
+ }
+ }
+}
+
void CEntity::animatePlayList(NL3D::TAnimationTime time)
{
if (!_PlayListAnimation.empty())
@@ -170,6 +276,21 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
// Try channel AnimationSet
NL3D::UAnimation *anim = _AnimationSet->getAnimation(id);
+ bool there = false;
+
+ UTrack *posTrack = NULL;
+ UTrack *rotQuatTrack = NULL;
+
+ // Current matrix
+ CMatrix current;
+ current.identity();
+
+ // read an animation for init matrix
+ rotQuatTrack = anim->getTrackByName("rotquat");
+ posTrack = anim->getTrackByName("pos");
+
+ there = posTrack || rotQuatTrack;
+
// Accumul time
float startTime = 0;
float endTime = anim->getEndTime() - anim->getBeginTime();
@@ -181,14 +302,29 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
if (index < _PlayListAnimation.size())
{
id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str());
- anim = _AnimationSet->getAnimation(id);
-
+ NL3D::UAnimation *newAnim = _AnimationSet->getAnimation(id);
+
+ UTrack *newPosTrack = newAnim->getTrackByName ("pos");
+ UTrack *newRotquatTrack = newAnim->getTrackByName ("rotquat");
+
+ // Add the transformation
+ addTransformation (current, anim, newAnim->getBeginTime(), anim->getEndTime(), posTrack, rotQuatTrack, newPosTrack, newRotquatTrack, true);
+
+
+ anim = newAnim;
+ posTrack = newPosTrack;
+ rotQuatTrack = newRotquatTrack;
+
// Add start time
startTime = endTime;
endTime = startTime + (anim->getEndTime() - anim->getBeginTime());
}
else
- break;
+ {
+ // Add the transformation
+ addTransformation (current, anim, 0, anim->getEndTime(), posTrack, rotQuatTrack, NULL, NULL, false);
+ break;
+ }
}
// Time cropped ?
@@ -205,6 +341,10 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
else
{
// No
+
+ // Add the transformation
+ addTransformation (current, anim, 0, anim->getBeginTime() + time - startTime, posTrack, rotQuatTrack, NULL, NULL, false);
+
id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str());
anim = _AnimationSet->getAnimation(id);
@@ -215,10 +355,31 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
// Set the slot
_PlayList->setAnimation(0, id);
_PlayList->setTimeOrigin(0, startTime);
+ _PlayList->setSpeedFactor(0, 1.0f);
_PlayList->setWeightSmoothness(0, 1.0f);
_PlayList->setStartWeight(0, 1, 0);
_PlayList->setEndWeight(0, 1, 1);
_PlayList->setWrapMode(0, UPlayList::Clamp);
+
+ // Setup the pos and rot for this shape
+ if (there)
+ {
+ CVector pos = current.getPos();
+
+ // If a skeleton model
+ if(!_Skeleton.empty())
+ {
+ // scale animated pos value with the CFG scale
+ pos *= _CharacterScalePos;
+ _Skeleton.setPos(pos);
+ _Skeleton.setRotQuat(current.getRot());
+ }
+ else
+ {
+ _Instance.setPos(pos);
+ _Instance.setRotQuat(current.getRot());
+ }
+ }
}
}
@@ -252,15 +413,15 @@ void CEntity::animateChannelMixer()
// Switch between wrap modes
switch (_SlotInfo[i].ClampMode)
{
- case 0:
- _PlayList->setWrapMode (i, UPlayList::Clamp);
- break;
- case 1:
- _PlayList->setWrapMode (i, UPlayList::Repeat);
- break;
- case 2:
- _PlayList->setWrapMode (i, UPlayList::Disable);
- break;
+ case 0:
+ _PlayList->setWrapMode (i, UPlayList::Clamp);
+ break;
+ case 1:
+ _PlayList->setWrapMode (i, UPlayList::Repeat);
+ break;
+ case 2:
+ _PlayList->setWrapMode (i, UPlayList::Disable);
+ break;
}
}
}
diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h
index 9ad938ec8..fba0d46c8 100644
--- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h
+++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h
@@ -1,6 +1,6 @@
/*
- Georges Editor Qt
- Copyright (C) 2010 Adrian Jaekel
+ Object Viewer Qt
+ Copyright (C) 2010 Dzmitry Kamiahin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,21 +14,27 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
+
*/
#ifndef ENTITY_H
#define ENTITY_H
+#include
+
// STL includes
#include