Changed: #1193 Code cleanup.

This commit is contained in:
timon 2010-11-26 13:54:06 +02:00
parent 6934b285e2
commit ffb5b2678b
141 changed files with 4702 additions and 3665 deletions

View file

@ -29,10 +29,11 @@
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
CAnimationDialog::CAnimationDialog(QWidget *parent) CAnimationDialog::CAnimationDialog(QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -33,7 +33,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
/** /**
@class CAnimationDialog @class CAnimationDialog
@ -45,7 +46,7 @@ Therefore, the class provides a slot that requires a total duration of the anima
*/ */
class CAnimationDialog: public QDockWidget class CAnimationDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// Constructor, sets the default length of time from 0 to 99 /// Constructor, sets the default length of time from 0 to 99

View file

@ -29,10 +29,11 @@
#include "modules.h" #include "modules.h"
#include "entity.h" #include "entity.h"
namespace NLQT { namespace NLQT
{
CAnimationSetDialog::CAnimationSetDialog(QWidget *parent) CAnimationSetDialog::CAnimationSetDialog(QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
@ -57,7 +58,7 @@ CAnimationSetDialog::~CAnimationSetDialog()
void CAnimationSetDialog::setCurrentShape(const QString &name) void CAnimationSetDialog::setCurrentShape(const QString &name)
{ {
if (name.isEmpty()) if (name.isEmpty())
return; return;
Modules::objView().setCurrentObject(name.toStdString()); Modules::objView().setCurrentObject(name.toStdString());
@ -71,7 +72,7 @@ void CAnimationSetDialog::setModeAnim()
{ {
std::string curObj = Modules::objView().getCurrentObject(); std::string curObj = Modules::objView().getCurrentObject();
if (curObj.empty()) if (curObj.empty())
return; return;
CEntity &entity = Modules::objView().getEntity(curObj); CEntity &entity = Modules::objView().getEntity(curObj);
if (ui.mixerRadioButton->isChecked()) if (ui.mixerRadioButton->isChecked())
@ -114,7 +115,7 @@ void CAnimationSetDialog::updateListAnim()
std::string curObj = Modules::objView().getCurrentObject(); std::string curObj = Modules::objView().getCurrentObject();
if (curObj.empty()) if (curObj.empty())
return; return;
CEntity &entity = Modules::objView().getEntity(curObj); CEntity &entity = Modules::objView().getEntity(curObj);
std::vector<std::string>& animationList = entity.getAnimationList(); std::vector<std::string>& animationList = entity.getAnimationList();
@ -165,8 +166,8 @@ void CAnimationSetDialog::loadAnim()
CEntity &entity = Modules::objView().getEntity(Modules::objView().getCurrentObject()); CEntity &entity = Modules::objView().getEntity(Modules::objView().getCurrentObject());
QStringList fileNames = QFileDialog::getOpenFileNames(this, QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open NeL anim file"), ".", tr("Open NeL anim file"), ".",
tr("NeL anim files (*.anim);;")); tr("NeL anim files (*.anim);;"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
@ -188,11 +189,11 @@ void CAnimationSetDialog::loadAnim()
void CAnimationSetDialog::loadSwt() void CAnimationSetDialog::loadSwt()
{ {
CEntity &entity = Modules::objView().getEntity(Modules::objView().getCurrentObject()); CEntity &entity = Modules::objView().getEntity(Modules::objView().getCurrentObject());
QStringList fileNames = QFileDialog::getOpenFileNames(this, QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open NeL anim file"), ".", tr("Open NeL anim file"), ".",
tr("NeL Skeleton Weight Template files (*.swt);;")); tr("NeL Skeleton Weight Template files (*.swt);;"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);

View file

@ -28,8 +28,9 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
/** {
/**
@class CAnimationSetDialog @class CAnimationSetDialog
@brief Dialog - Animations control, loading animation, weight for skeleton and playlist composition. @brief Dialog - Animations control, loading animation, weight for skeleton and playlist composition.
@details Dialog loads animations files and weight for skeleton animation. Files can also be unloaded. @details Dialog loads animations files and weight for skeleton animation. Files can also be unloaded.
@ -39,10 +40,10 @@ Also, the dialogue has a control element to select the current shape (emit a sig
and switch of playlist/mixer (this functionality will soon be transferred to another specialized dialogue). and switch of playlist/mixer (this functionality will soon be transferred to another specialized dialogue).
As each shape has its own list of loaded animations and playlist,when you switch your current shape, As each shape has its own list of loaded animations and playlist,when you switch your current shape,
the dialogue should be notified through the slot setCurrentShape (). the dialogue should be notified through the slot setCurrentShape ().
*/ */
class CAnimationSetDialog: public QDockWidget class CAnimationSetDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CAnimationSetDialog(QWidget *parent = 0); CAnimationSetDialog(QWidget *parent = 0);

View file

@ -40,15 +40,16 @@
#include "spinner_dialog.h" #include "spinner_dialog.h"
#include "follow_path_dialog.h" #include "follow_path_dialog.h"
namespace NLQT { namespace NLQT
{
CAttribWidget::CAttribWidget(QWidget *parent) CAttribWidget::CAttribWidget(QWidget *parent)
: QGroupBox(parent), : QGroupBox(parent),
_SrcInputEnabled(true), _SrcInputEnabled(true),
_EnableConstantValue(true), _EnableConstantValue(true),
_DisableMemoryScheme(false), _DisableMemoryScheme(false),
_NbCycleEnabled(true), _NbCycleEnabled(true),
_Node(NULL), _SchemeWidget(NULL) _Node(NULL), _SchemeWidget(NULL)
{ {
_ui.setupUi(this); _ui.setupUi(this);
_ui.constRangeUIntWidget->hide(); _ui.constRangeUIntWidget->hide();
@ -210,7 +211,7 @@ void CAttribWidget::schemeValueUpdate()
if (k == -1) // unknow scheme ... if (k == -1) // unknow scheme ...
{ {
_ui.schemeComboBox->setCurrentIndex(k); _ui.schemeComboBox->setCurrentIndex(k);
k = 0; k = 0;
} }
if (k != _ui.schemeComboBox->currentIndex()) if (k != _ui.schemeComboBox->currentIndex())
@ -267,7 +268,7 @@ void CAttribWidget::enableMemoryScheme(bool enabled)
} }
CAttribFloatWidget::CAttribFloatWidget(QWidget *parent) CAttribFloatWidget::CAttribFloatWidget(QWidget *parent)
: CAttribWidgetT<float>(parent) : CAttribWidgetT<float>(parent)
{ {
_ui.schemeComboBox->addItem(tr("value blender")); _ui.schemeComboBox->addItem(tr("value blender"));
_ui.schemeComboBox->addItem(tr("values gradient")); _ui.schemeComboBox->addItem(tr("values gradient"));
@ -282,9 +283,9 @@ CAttribFloatWidget::~CAttribFloatWidget()
void CAttribFloatWidget::setRange(float minValue, float maxValue) void CAttribFloatWidget::setRange(float minValue, float maxValue)
{ {
_MinRange = minValue; _MinRange = minValue;
_MaxRange = maxValue; _MaxRange = maxValue;
_ui.constRangeFloatWidget->setRange(_MinRange, _MaxRange); _ui.constRangeFloatWidget->setRange(_MinRange, _MaxRange);
} }
void CAttribFloatWidget::setWrapper(IPSWrapper<float> *wrapper) void CAttribFloatWidget::setWrapper(IPSWrapper<float> *wrapper)
@ -322,8 +323,8 @@ QDialog *CAttribFloatWidget::editScheme(void)
CAttribFloatWidget *adf = new CAttribFloatWidget(); CAttribFloatWidget *adf = new CAttribFloatWidget();
adf->setRange(_MinRange, _MaxRange); adf->setRange(_MinRange, _MaxRange);
CValueFromEmitterDialogT<float> *vfe = new CValueFromEmitterDialogT<float>( (NL3D::CPSFloatMemory *)(scheme), CValueFromEmitterDialogT<float> *vfe = new CValueFromEmitterDialogT<float>( (NL3D::CPSFloatMemory *)(scheme),
adf, adf,
this); this);
vfe->init(); vfe->init();
adf->setWorkspaceNode(_Node); adf->setWorkspaceNode(_Node);
adf->updateUi(); adf->updateUi();
@ -338,8 +339,8 @@ QDialog *CAttribFloatWidget::editScheme(void)
ad[k]->setRange(_MinRange, _MaxRange); ad[k]->setRange(_MinRange, _MaxRange);
} }
CBinOpDialogT<float> *bod = new CBinOpDialogT<float>( (NL3D::CPSFloatBinOp *)(scheme), CBinOpDialogT<float> *bod = new CBinOpDialogT<float>( (NL3D::CPSFloatBinOp *)(scheme),
(CAttribWidgetT<float> **) ad, (CAttribWidgetT<float> **) ad,
this); this);
bod->init(); bod->init();
for (uint k = 0; k <2; ++k) for (uint k = 0; k <2; ++k)
{ {
@ -363,35 +364,35 @@ void CAttribFloatWidget::setCurrentScheme(uint index)
switch (index) switch (index)
{ {
case 0: case 0:
scheme = new NL3D::CPSFloatBlender(_MinRange, _MaxRange); scheme = new NL3D::CPSFloatBlender(_MinRange, _MaxRange);
break; break;
case 1: case 1:
{ {
static const float values[2] = { 0.1f, 1.f }; static const float values[2] = { 0.1f, 1.f };
scheme = new NL3D::CPSFloatGradient(values, 2, 16, 1.f); scheme = new NL3D::CPSFloatGradient(values, 2, 16, 1.f);
} }
break; break;
case 2: case 2:
{ {
NL3D::CPSFloatCurve *curve = new NL3D::CPSFloatCurve; NL3D::CPSFloatCurve *curve = new NL3D::CPSFloatCurve;
curve->_F.setNumSamples(128); curve->_F.setNumSamples(128);
curve->_F.addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(0, 0.5f)); curve->_F.addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(0, 0.5f));
curve->_F.addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(1, 0.5f)); curve->_F.addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(1, 0.5f));
scheme = curve; scheme = curve;
} }
break; break;
case 3: case 3:
scheme = new NL3D::CPSFloatMemory; scheme = new NL3D::CPSFloatMemory;
((NL3D::CPSAttribMakerMemory<float> *) scheme)->setScheme(new NL3D::CPSFloatBlender(_MinRange, _MaxRange)); ((NL3D::CPSAttribMakerMemory<float> *) scheme)->setScheme(new NL3D::CPSFloatBlender(_MinRange, _MaxRange));
break; break;
case 4 : case 4 :
scheme = new NL3D::CPSFloatBinOp; scheme = new NL3D::CPSFloatBinOp;
((NL3D::CPSFloatBinOp *) scheme)->setArg(0, new NL3D::CPSFloatBlender); ((NL3D::CPSFloatBinOp *) scheme)->setArg(0, new NL3D::CPSFloatBlender);
((NL3D::CPSFloatBinOp *) scheme)->setArg(1, new NL3D::CPSFloatBlender); ((NL3D::CPSFloatBinOp *) scheme)->setArg(1, new NL3D::CPSFloatBlender);
break; break;
default: default:
break; break;
} }
if (scheme) if (scheme)
@ -429,7 +430,7 @@ void CAttribFloatWidget::cstValueUpdate()
} }
CAttribUIntWidget::CAttribUIntWidget(QWidget *parent) CAttribUIntWidget::CAttribUIntWidget(QWidget *parent)
: CAttribWidgetT<uint32>(parent) : CAttribWidgetT<uint32>(parent)
{ {
_ui.schemeComboBox->addItem(tr("value blender")); _ui.schemeComboBox->addItem(tr("value blender"));
_ui.schemeComboBox->addItem(tr("values gradient")); _ui.schemeComboBox->addItem(tr("values gradient"));
@ -443,9 +444,9 @@ CAttribUIntWidget::~CAttribUIntWidget()
void CAttribUIntWidget::setRange(uint32 minValue, uint32 maxValue) void CAttribUIntWidget::setRange(uint32 minValue, uint32 maxValue)
{ {
_MinRange = minValue; _MinRange = minValue;
_MaxRange = maxValue; _MaxRange = maxValue;
_ui.constRangeUIntWidget->setRange(_MinRange, _MaxRange); _ui.constRangeUIntWidget->setRange(_MinRange, _MaxRange);
} }
void CAttribUIntWidget::setWrapper(IPSWrapper<uint32> *wrapper) void CAttribUIntWidget::setWrapper(IPSWrapper<uint32> *wrapper)
@ -484,12 +485,12 @@ QDialog *CAttribUIntWidget::editScheme(void)
CAttribUIntWidget *adu = new CAttribUIntWidget(); CAttribUIntWidget *adu = new CAttribUIntWidget();
adu->setRange(_MinRange, _MaxRange); adu->setRange(_MinRange, _MaxRange);
CValueFromEmitterDialogT<uint32> *vfe = new CValueFromEmitterDialogT<uint32>( (NL3D::CPSUIntMemory *)(scheme), CValueFromEmitterDialogT<uint32> *vfe = new CValueFromEmitterDialogT<uint32>( (NL3D::CPSUIntMemory *)(scheme),
adu, adu,
this); this);
vfe->init(); vfe->init();
adu->setWorkspaceNode(_Node); adu->setWorkspaceNode(_Node);
adu->updateUi(); adu->updateUi();
return vfe; return vfe;
} }
if (dynamic_cast<const NL3D::CPSUIntBinOp *>(scheme)) if (dynamic_cast<const NL3D::CPSUIntBinOp *>(scheme))
{ {
@ -500,8 +501,8 @@ QDialog *CAttribUIntWidget::editScheme(void)
ad[k]->setRange(_MinRange, _MaxRange); ad[k]->setRange(_MinRange, _MaxRange);
} }
CBinOpDialogT<uint32> *bod = new CBinOpDialogT<uint32>( (NL3D::CPSUIntBinOp *)(scheme), CBinOpDialogT<uint32> *bod = new CBinOpDialogT<uint32>( (NL3D::CPSUIntBinOp *)(scheme),
(CAttribWidgetT<uint32> **) ad, (CAttribWidgetT<uint32> **) ad,
this); this);
bod->init(); bod->init();
for (uint k = 0; k <2; ++k) for (uint k = 0; k <2; ++k)
{ {
@ -520,23 +521,23 @@ void CAttribUIntWidget::setCurrentScheme(uint index)
switch (index) switch (index)
{ {
case 0 : case 0 :
scheme = new NL3D::CPSUIntBlender(_MinRange, _MaxRange); scheme = new NL3D::CPSUIntBlender(_MinRange, _MaxRange);
break; break;
case 1 : case 1 :
scheme = new NL3D::CPSUIntGradient; scheme = new NL3D::CPSUIntGradient;
break; break;
case 2 : case 2 :
scheme = new NL3D::CPSUIntMemory; scheme = new NL3D::CPSUIntMemory;
((NL3D::CPSAttribMakerMemory<uint32> *) scheme)->setScheme(new NL3D::CPSUIntBlender(_MinRange, _MaxRange) ); ((NL3D::CPSAttribMakerMemory<uint32> *) scheme)->setScheme(new NL3D::CPSUIntBlender(_MinRange, _MaxRange) );
break; break;
case 3 : case 3 :
scheme = new NL3D::CPSUIntBinOp; scheme = new NL3D::CPSUIntBinOp;
((NL3D::CPSUIntBinOp *) scheme)->setArg(0, new NL3D::CPSUIntBlender); ((NL3D::CPSUIntBinOp *) scheme)->setArg(0, new NL3D::CPSUIntBlender);
((NL3D::CPSUIntBinOp *) scheme)->setArg(1, new NL3D::CPSUIntBlender); ((NL3D::CPSUIntBinOp *) scheme)->setArg(1, new NL3D::CPSUIntBlender);
break; break;
default: default:
break; break;
} }
if (scheme) if (scheme)
{ {
@ -566,7 +567,7 @@ void CAttribUIntWidget::cstValueUpdate()
} }
CAttribIntWidget::CAttribIntWidget(QWidget *parent) CAttribIntWidget::CAttribIntWidget(QWidget *parent)
: CAttribWidgetT<sint32>(parent) : CAttribWidgetT<sint32>(parent)
{ {
_ui.schemeComboBox->addItem(tr("value exact blender")); _ui.schemeComboBox->addItem(tr("value exact blender"));
_ui.schemeComboBox->addItem(tr("values gradient")); _ui.schemeComboBox->addItem(tr("values gradient"));
@ -580,9 +581,9 @@ CAttribIntWidget::~CAttribIntWidget()
void CAttribIntWidget::setRange(sint32 minValue, sint32 maxValue) void CAttribIntWidget::setRange(sint32 minValue, sint32 maxValue)
{ {
_MinRange = minValue; _MinRange = minValue;
_MaxRange = maxValue; _MaxRange = maxValue;
_ui.constRangeIntWidget->setRange(_MinRange, _MaxRange); _ui.constRangeIntWidget->setRange(_MinRange, _MaxRange);
} }
void CAttribIntWidget::setWrapper(IPSWrapper<sint32> *wrapper) void CAttribIntWidget::setWrapper(IPSWrapper<sint32> *wrapper)
@ -620,7 +621,7 @@ QDialog *CAttribIntWidget::editScheme(void)
CAttribIntWidget *adi = new CAttribIntWidget(); CAttribIntWidget *adi = new CAttribIntWidget();
adi->setRange(_MinRange, _MaxRange); adi->setRange(_MinRange, _MaxRange);
CValueFromEmitterDialogT<sint32> *vfe = new CValueFromEmitterDialogT<sint32>((NL3D::CPSIntMemory *) _SchemeWrapper->getScheme(), CValueFromEmitterDialogT<sint32> *vfe = new CValueFromEmitterDialogT<sint32>((NL3D::CPSIntMemory *) _SchemeWrapper->getScheme(),
adi, this); adi, this);
vfe->init(); vfe->init();
adi->setWorkspaceNode(_Node); adi->setWorkspaceNode(_Node);
adi->updateUi(); adi->updateUi();
@ -635,8 +636,8 @@ QDialog *CAttribIntWidget::editScheme(void)
ad[k]->setRange(_MinRange, _MaxRange); ad[k]->setRange(_MinRange, _MaxRange);
} }
CBinOpDialogT<sint32> *bod = new CBinOpDialogT<sint32>( (NL3D::CPSIntBinOp *)(scheme), CBinOpDialogT<sint32> *bod = new CBinOpDialogT<sint32>( (NL3D::CPSIntBinOp *)(scheme),
(CAttribWidgetT<sint32> **) ad, (CAttribWidgetT<sint32> **) ad,
this); this);
bod->init(); bod->init();
for (uint k = 0; k <2; ++k) for (uint k = 0; k <2; ++k)
{ {
@ -655,23 +656,23 @@ void CAttribIntWidget::setCurrentScheme(uint index)
switch (index) switch (index)
{ {
case 0 : case 0 :
scheme = new NL3D::CPSIntBlender; scheme = new NL3D::CPSIntBlender;
break; break;
case 1 : case 1 :
scheme = new NL3D::CPSIntGradient; scheme = new NL3D::CPSIntGradient;
break; break;
case 2 : case 2 :
scheme = new NL3D::CPSIntMemory; scheme = new NL3D::CPSIntMemory;
((NL3D::CPSAttribMakerMemory<sint32> *) scheme)->setScheme(new NL3D::CPSIntBlender(_MinRange, _MaxRange)); ((NL3D::CPSAttribMakerMemory<sint32> *) scheme)->setScheme(new NL3D::CPSIntBlender(_MinRange, _MaxRange));
break; break;
case 3 : case 3 :
scheme = new NL3D::CPSIntBinOp; scheme = new NL3D::CPSIntBinOp;
((NL3D::CPSIntBinOp *) scheme)->setArg(0, new NL3D::CPSIntBlender); ((NL3D::CPSIntBinOp *) scheme)->setArg(0, new NL3D::CPSIntBlender);
((NL3D::CPSIntBinOp *) scheme)->setArg(1, new NL3D::CPSIntBlender); ((NL3D::CPSIntBinOp *) scheme)->setArg(1, new NL3D::CPSIntBlender);
break; break;
default: default:
break; break;
} }
if (scheme) if (scheme)
{ {
@ -701,7 +702,7 @@ void CAttribIntWidget::cstValueUpdate()
} }
CAttribRGBAWidget::CAttribRGBAWidget(QWidget *parent) CAttribRGBAWidget::CAttribRGBAWidget(QWidget *parent)
: CAttribWidgetT<NLMISC::CRGBA>(parent) : CAttribWidgetT<NLMISC::CRGBA>(parent)
{ {
_ui.schemeComboBox->addItem(tr("color sampled blender")); _ui.schemeComboBox->addItem(tr("color sampled blender"));
_ui.schemeComboBox->addItem(tr("color gradient")); _ui.schemeComboBox->addItem(tr("color gradient"));
@ -748,8 +749,8 @@ QDialog *CAttribRGBAWidget::editScheme(void)
{ {
CAttribRGBAWidget *ad = new CAttribRGBAWidget(); CAttribRGBAWidget *ad = new CAttribRGBAWidget();
CValueFromEmitterDialogT<NLMISC::CRGBA> *vfe = new CValueFromEmitterDialogT<NLMISC::CRGBA>( (NL3D::CPSColorMemory *)(scheme), CValueFromEmitterDialogT<NLMISC::CRGBA> *vfe = new CValueFromEmitterDialogT<NLMISC::CRGBA>( (NL3D::CPSColorMemory *)(scheme),
ad, ad,
this); this);
vfe->init(); vfe->init();
ad->setWorkspaceNode(_Node); ad->setWorkspaceNode(_Node);
ad->updateUi(); ad->updateUi();
@ -763,8 +764,8 @@ QDialog *CAttribRGBAWidget::editScheme(void)
ad[k] = new CAttribRGBAWidget(); ad[k] = new CAttribRGBAWidget();
} }
CBinOpDialogT<NLMISC::CRGBA> *bod = new CBinOpDialogT<NLMISC::CRGBA>( (NL3D::CPSColorBinOp *)(scheme), CBinOpDialogT<NLMISC::CRGBA> *bod = new CBinOpDialogT<NLMISC::CRGBA>( (NL3D::CPSColorBinOp *)(scheme),
(CAttribWidgetT<NLMISC::CRGBA> **) ad, (CAttribWidgetT<NLMISC::CRGBA> **) ad,
this); this);
bod->init(); bod->init();
for (uint k = 0; k <2; ++k) for (uint k = 0; k <2; ++k)
{ {
@ -783,26 +784,26 @@ void CAttribRGBAWidget::setCurrentScheme(uint index)
switch (index) switch (index)
{ {
case 0 : case 0 :
scheme = new NL3D::CPSColorBlender; scheme = new NL3D::CPSColorBlender;
break; break;
case 1 : case 1 :
scheme = new NL3D::CPSColorGradient(NL3D::CPSColorGradient::_DefaultGradient, 2, 16, 1.f); scheme = new NL3D::CPSColorGradient(NL3D::CPSColorGradient::_DefaultGradient, 2, 16, 1.f);
break; break;
case 2 : case 2 :
scheme = new NL3D::CPSColorBlenderExact; scheme = new NL3D::CPSColorBlenderExact;
break; break;
case 3 : case 3 :
scheme = new NL3D::CPSColorMemory; scheme = new NL3D::CPSColorMemory;
((NL3D::CPSAttribMakerMemory<NLMISC::CRGBA> *) scheme)->setScheme(new NL3D::CPSColorBlender); ((NL3D::CPSAttribMakerMemory<NLMISC::CRGBA> *) scheme)->setScheme(new NL3D::CPSColorBlender);
break; break;
case 4 : case 4 :
scheme = new NL3D::CPSColorBinOp; scheme = new NL3D::CPSColorBinOp;
((NL3D::CPSColorBinOp *) scheme)->setArg(0, new NL3D::CPSColorBlender); ((NL3D::CPSColorBinOp *) scheme)->setArg(0, new NL3D::CPSColorBlender);
((NL3D::CPSColorBinOp *) scheme)->setArg(1, new NL3D::CPSColorBlender); ((NL3D::CPSColorBinOp *) scheme)->setArg(1, new NL3D::CPSColorBlender);
break; break;
default: default:
break; break;
} }
if (scheme) if (scheme)
{ {
@ -833,7 +834,7 @@ void CAttribRGBAWidget::cstValueUpdate()
} }
CAttribPlaneBasisWidget::CAttribPlaneBasisWidget(QWidget *parent) CAttribPlaneBasisWidget::CAttribPlaneBasisWidget(QWidget *parent)
: CAttribWidgetT<NL3D::CPlaneBasis>(parent) : CAttribWidgetT<NL3D::CPlaneBasis>(parent)
{ {
_ui.schemeComboBox->addItem(tr("basis gradient")); _ui.schemeComboBox->addItem(tr("basis gradient"));
_ui.schemeComboBox->addItem(tr("follow path")); _ui.schemeComboBox->addItem(tr("follow path"));
@ -873,8 +874,8 @@ QDialog *CAttribPlaneBasisWidget::editScheme(void)
{ {
CAttribPlaneBasisWidget *ad = new CAttribPlaneBasisWidget(); CAttribPlaneBasisWidget *ad = new CAttribPlaneBasisWidget();
CValueFromEmitterDialogT<NL3D::CPlaneBasis> *vfe = new CValueFromEmitterDialogT<NL3D::CPlaneBasis> CValueFromEmitterDialogT<NL3D::CPlaneBasis> *vfe = new CValueFromEmitterDialogT<NL3D::CPlaneBasis>
( (NL3D::CPSPlaneBasisMemory *)(scheme), ( (NL3D::CPSPlaneBasisMemory *)(scheme),
ad, this); ad, this);
vfe->init(); vfe->init();
ad->setWorkspaceNode(_Node); ad->setWorkspaceNode(_Node);
ad->updateUi(); ad->updateUi();
@ -888,8 +889,8 @@ QDialog *CAttribPlaneBasisWidget::editScheme(void)
ad[k] = new CAttribPlaneBasisWidget(); ad[k] = new CAttribPlaneBasisWidget();
} }
CBinOpDialogT<NL3D::CPlaneBasis> *bod = new CBinOpDialogT<NL3D::CPlaneBasis>( (NL3D::CPSPlaneBasisBinOp *)(scheme), CBinOpDialogT<NL3D::CPlaneBasis> *bod = new CBinOpDialogT<NL3D::CPlaneBasis>( (NL3D::CPSPlaneBasisBinOp *)(scheme),
(CAttribWidgetT<NL3D::CPlaneBasis> **) ad, (CAttribWidgetT<NL3D::CPlaneBasis> **) ad,
this); this);
bod->init(); bod->init();
for (uint k = 0; k <2; ++k) for (uint k = 0; k <2; ++k)
{ {
@ -913,31 +914,31 @@ void CAttribPlaneBasisWidget::setCurrentScheme(uint index)
switch (index) switch (index)
{ {
case 0: case 0:
scheme = new NL3D::CPSPlaneBasisGradient; scheme = new NL3D::CPSPlaneBasisGradient;
break; break;
case 1: case 1:
scheme = new NL3D::CPSPlaneBasisFollowSpeed; scheme = new NL3D::CPSPlaneBasisFollowSpeed;
break; break;
case 2: case 2:
scheme = new NL3D::CPSBasisSpinner; scheme = new NL3D::CPSBasisSpinner;
static_cast<NL3D::CPSBasisSpinner *>(scheme)->_F.setNumSamples(16); static_cast<NL3D::CPSBasisSpinner *>(scheme)->_F.setNumSamples(16);
break; break;
case 3: case 3:
scheme = new NL3D::CPSPlaneBasisMemory; scheme = new NL3D::CPSPlaneBasisMemory;
((NL3D::CPSAttribMakerMemory<NL3D::CPlaneBasis> *) scheme)->setScheme(new NL3D::CPSPlaneBasisFollowSpeed); ((NL3D::CPSAttribMakerMemory<NL3D::CPlaneBasis> *) scheme)->setScheme(new NL3D::CPSPlaneBasisFollowSpeed);
if (_Node) if (_Node)
{ {
_Node->setModified(true); _Node->setModified(true);
} }
break; break;
case 4 : case 4 :
scheme = new NL3D::CPSPlaneBasisBinOp; scheme = new NL3D::CPSPlaneBasisBinOp;
((NL3D::CPSPlaneBasisBinOp *) scheme)->setArg(0, new NL3D::CPSPlaneBasisFollowSpeed); ((NL3D::CPSPlaneBasisBinOp *) scheme)->setArg(0, new NL3D::CPSPlaneBasisFollowSpeed);
((NL3D::CPSPlaneBasisBinOp *) scheme)->setArg(1, new NL3D::CPSPlaneBasisFollowSpeed); ((NL3D::CPSPlaneBasisBinOp *) scheme)->setArg(1, new NL3D::CPSPlaneBasisFollowSpeed);
break; break;
default: default:
break; break;
} }
if (scheme) if (scheme)

View file

@ -38,14 +38,15 @@
#include "ps_wrapper.h" #include "ps_wrapper.h"
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CAttribWidget @class CAttribWidget
@brief Base attrib maker edition dialog. @brief Base attrib maker edition dialog.
*/ */
class CAttribWidget: public QGroupBox class CAttribWidget: public QGroupBox
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribWidget(QWidget *parent = 0); CAttribWidget(QWidget *parent = 0);
@ -70,9 +71,15 @@ public:
virtual void setSchemeNbCycles(float nbCycles) = 0; virtual void setSchemeNbCycles(float nbCycles) = 0;
/// Enable the srcInput /// Enable the srcInput
void enableSrcInput(bool enable = true) { _SrcInputEnabled = enable; } void enableSrcInput(bool enable = true)
{
_SrcInputEnabled = enable;
}
bool isSrcInputEnabled() const { return _SrcInputEnabled; } bool isSrcInputEnabled() const
{
return _SrcInputEnabled;
}
/// Disable the possibility to choose a scheme that has memory. (for example, a scheme for lifetime of a located has no sense /// Disable the possibility to choose a scheme that has memory. (for example, a scheme for lifetime of a located has no sense
/// because located have already some memory to store it) /// because located have already some memory to store it)
@ -80,11 +87,20 @@ public:
/// Tells wether memory schemes are enables /// Tells wether memory schemes are enables
/// @see enableMemoryScheme() /// @see enableMemoryScheme()
bool isMemorySchemeEnabled() const { return !_DisableMemoryScheme; } bool isMemorySchemeEnabled() const
{
return !_DisableMemoryScheme;
}
/// Enable Nb Cycle tuning /// Enable Nb Cycle tuning
void enableNbCycles(bool enabled) { _NbCycleEnabled = enabled; } void enableNbCycles(bool enabled)
bool isNbCycleEnabled() const { return _NbCycleEnabled; } {
_NbCycleEnabled = enabled;
}
bool isNbCycleEnabled() const
{
return _NbCycleEnabled;
}
private Q_SLOTS: private Q_SLOTS:
virtual void clickedEdit(); virtual void clickedEdit();
@ -159,9 +175,15 @@ protected:
/// wrapper to tune the number of cycles /// wrapper to tune the number of cycles
struct CNbCyclesWrapper : public IPSWrapperFloat struct CNbCyclesWrapper : public IPSWrapperFloat
{ {
CAttribWidget *widget; CAttribWidget *widget;
float get(void) const { return widget->getSchemeNbCycles(); } float get(void) const
void set(const float &v) { widget->setSchemeNbCycles(v); } {
return widget->getSchemeNbCycles();
}
void set(const float &v)
{
widget->setSchemeNbCycles(v);
}
} _NbCyclesWrapper; } _NbCyclesWrapper;
CWorkspaceNode *_Node; CWorkspaceNode *_Node;
@ -179,12 +201,16 @@ template <typename T> class CAttribWidgetT : public CAttribWidget
{ {
public: public:
CAttribWidgetT(QWidget *parent = 0): CAttribWidget(parent), CAttribWidgetT(QWidget *parent = 0): CAttribWidget(parent),
_Wrapper(NULL), _Wrapper(NULL),
_SchemeWrapper(NULL) _SchemeWrapper(NULL)
{ {
} }
virtual void setWrapper(IPSWrapper<T> *wrapper) = 0; virtual void setWrapper(IPSWrapper<T> *wrapper) = 0;
void setSchemeWrapper(IPSSchemeWrapper<T> *schemeWrapper) { nlassert(schemeWrapper); _SchemeWrapper = schemeWrapper; } void setSchemeWrapper(IPSSchemeWrapper<T> *schemeWrapper)
{
nlassert(schemeWrapper);
_SchemeWrapper = schemeWrapper;
}
// Inherited from CAttribWidget // Inherited from CAttribWidget
virtual QDialog *editScheme(void) = 0; virtual QDialog *editScheme(void) = 0;
@ -196,22 +222,51 @@ public:
_Wrapper->setAndUpdateModifiedFlag(_Wrapper->get()); // reuse current color _Wrapper->setAndUpdateModifiedFlag(_Wrapper->get()); // reuse current color
} }
virtual bool hasSchemeCustomInput(void) const { return _SchemeWrapper->getScheme()->hasCustomInput(); } virtual bool hasSchemeCustomInput(void) const
virtual NL3D::CPSInputType getSchemeInput(void) const { return _SchemeWrapper->getScheme()->getInput(); } {
virtual void setSchemeInput(const NL3D::CPSInputType &input) { _SchemeWrapper->getScheme()->setInput(input); } return _SchemeWrapper->getScheme()->hasCustomInput();
}
virtual NL3D::CPSInputType getSchemeInput(void) const
{
return _SchemeWrapper->getScheme()->getInput();
}
virtual void setSchemeInput(const NL3D::CPSInputType &input)
{
_SchemeWrapper->getScheme()->setInput(input);
}
virtual void setWorkspaceNode(CWorkspaceNode *node) virtual void setWorkspaceNode(CWorkspaceNode *node)
{ {
_Node = node; if (_Wrapper != NULL) _Wrapper->OwnerNode = _Node; if (_SchemeWrapper != NULL) _SchemeWrapper->OwnerNode = _Node; _Node = node;
if (_Wrapper != NULL) _Wrapper->OwnerNode = _Node;
if (_SchemeWrapper != NULL) _SchemeWrapper->OwnerNode = _Node;
}; };
virtual float getSchemeNbCycles(void) const { return _SchemeWrapper->getScheme()->getNbCycles(); } virtual float getSchemeNbCycles(void) const
virtual void setSchemeNbCycles(float nbCycles) { _SchemeWrapper->getScheme()->setNbCycles(nbCycles); } {
return _SchemeWrapper->getScheme()->getNbCycles();
}
virtual void setSchemeNbCycles(float nbCycles)
{
_SchemeWrapper->getScheme()->setNbCycles(nbCycles);
}
virtual bool isSchemeClamped(void) const { return _SchemeWrapper->getScheme()->getClamping(); } virtual bool isSchemeClamped(void) const
virtual void clampScheme(bool clamped = true) { _SchemeWrapper->getScheme()->setClamping(clamped); } {
virtual bool isClampingSupported(void) const { return _SchemeWrapper->getScheme()->isClampingSupported(); }; return _SchemeWrapper->getScheme()->getClamping();
virtual NL3D::CPSAttribMakerBase *getCurrentSchemePtr(void) const { return _SchemeWrapper->getScheme(); } }
virtual void clampScheme(bool clamped = true)
{
_SchemeWrapper->getScheme()->setClamping(clamped);
}
virtual bool isClampingSupported(void) const
{
return _SchemeWrapper->getScheme()->isClampingSupported();
};
virtual NL3D::CPSAttribMakerBase *getCurrentSchemePtr(void) const
{
return _SchemeWrapper->getScheme();
}
virtual void setCurrentSchemePtr(NL3D::CPSAttribMakerBase *s) virtual void setCurrentSchemePtr(NL3D::CPSAttribMakerBase *s)
{ {
_SchemeWrapper->setSchemeAndUpdateModifiedFlag(NLMISC::safe_cast<NL3D::CPSAttribMaker<T> *>(s)); _SchemeWrapper->setSchemeAndUpdateModifiedFlag(NLMISC::safe_cast<NL3D::CPSAttribMaker<T> *>(s));
@ -237,7 +292,7 @@ public:
*/ */
class CAttribFloatWidget: public CAttribWidgetT<float> class CAttribFloatWidget: public CAttribWidgetT<float>
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribFloatWidget(QWidget *parent = 0); CAttribFloatWidget(QWidget *parent = 0);
@ -263,7 +318,7 @@ private:
*/ */
class CAttribUIntWidget: public CAttribWidgetT<uint32> class CAttribUIntWidget: public CAttribWidgetT<uint32>
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribUIntWidget(QWidget *parent = 0); CAttribUIntWidget(QWidget *parent = 0);
@ -289,7 +344,7 @@ private:
*/ */
class CAttribIntWidget: public CAttribWidgetT<sint32> class CAttribIntWidget: public CAttribWidgetT<sint32>
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribIntWidget(QWidget *parent = 0); CAttribIntWidget(QWidget *parent = 0);
@ -315,7 +370,7 @@ private:
*/ */
class CAttribRGBAWidget: public CAttribWidgetT<NLMISC::CRGBA> class CAttribRGBAWidget: public CAttribWidgetT<NLMISC::CRGBA>
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribRGBAWidget(QWidget *parent = 0); CAttribRGBAWidget(QWidget *parent = 0);
@ -339,7 +394,7 @@ private:
*/ */
class CAttribPlaneBasisWidget: public CAttribWidgetT<NL3D::CPlaneBasis> class CAttribPlaneBasisWidget: public CAttribWidgetT<NL3D::CPlaneBasis>
{ {
Q_OBJECT Q_OBJECT
public: public:
CAttribPlaneBasisWidget(QWidget *parent = 0); CAttribPlaneBasisWidget(QWidget *parent = 0);

View file

@ -28,10 +28,11 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
CAutoLODDialog::CAutoLODDialog(CWorkspaceNode *ownerNode, NL3D::CParticleSystem *ps, QWidget *parent) CAutoLODDialog::CAutoLODDialog(CWorkspaceNode *ownerNode, NL3D::CParticleSystem *ps, QWidget *parent)
: QDialog(parent), _Node(ownerNode), _PS(ps) : QDialog(parent), _Node(ownerNode), _PS(ps)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -32,11 +32,12 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
class CAutoLODDialog: public QDialog class CAutoLODDialog: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CAutoLODDialog(CWorkspaceNode *ownerNode, NL3D::CParticleSystem *ps, QWidget *parent = 0); CAutoLODDialog(CWorkspaceNode *ownerNode, NL3D::CParticleSystem *ps, QWidget *parent = 0);
@ -54,15 +55,27 @@ private:
struct CDistRatioWrapper : IPSWrapperFloat struct CDistRatioWrapper : IPSWrapperFloat
{ {
NL3D::CParticleSystem *PS; NL3D::CParticleSystem *PS;
virtual float get() const { return PS->getAutoLODStartDistPercent(); } virtual float get() const
virtual void set(const float &v) { PS->setupAutoLOD(v, PS->getAutoLODDegradationExponent()); } {
return PS->getAutoLODStartDistPercent();
}
virtual void set(const float &v)
{
PS->setupAutoLOD(v, PS->getAutoLODDegradationExponent());
}
} _DistRatioWrapper; } _DistRatioWrapper;
struct CMaxDistLODBiasWrapper : IPSWrapperFloat struct CMaxDistLODBiasWrapper : IPSWrapperFloat
{ {
NL3D::CParticleSystem *PS; NL3D::CParticleSystem *PS;
virtual float get() const { return PS->getMaxDistLODBias(); } virtual float get() const
virtual void set(const float &v) { PS->setMaxDistLODBias(v); } {
return PS->getMaxDistLODBias();
}
virtual void set(const float &v)
{
PS->setMaxDistLODBias(v);
}
} _MaxDistLODBiasWrapper; } _MaxDistLODBiasWrapper;
Ui::CAutoLODDialog _ui; Ui::CAutoLODDialog _ui;

View file

@ -26,15 +26,16 @@
#include "nel/misc/matrix.h" #include "nel/misc/matrix.h"
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
namespace NLQT { namespace NLQT
{
// build an euler matrix // build an euler matrix
NLMISC::CMatrix BuildEulerMatrix(float psi, float theta, float phi) NLMISC::CMatrix BuildEulerMatrix(float psi, float theta, float phi)
{ {
float ca = cosf(psi), sa = sinf(psi) float ca = cosf(psi), sa = sinf(psi)
, cb = cosf(theta), sb = sinf(theta) , cb = cosf(theta), sb = sinf(theta)
, cc = cosf(phi), sc = sinf(phi); , cc = cosf(phi), sc = sinf(phi);
NLMISC::CMatrix m; NLMISC::CMatrix m;
m.identity(); m.identity();
m.setRot(NLMISC::CVector(ca * cb * cc - sa * sc, -cc * sa - ca * cb *sc, ca * sb) m.setRot(NLMISC::CVector(ca * cb * cc - sa * sc, -cc * sa - ca * cb *sc, ca * sb)
@ -53,7 +54,9 @@ NLMISC::CVector GetEulerAngles(const NLMISC::CMatrix &mat)
mat.getRot(v[0], v[1], v[2]); mat.getRot(v[0], v[1], v[2]);
for (uint l = 0; l < 3; ++l) for (uint l = 0; l < 3; ++l)
{ {
m[0][l] = v[l].x; m[1][l] = v[l].y; m[2][l] = v[l].z; m[0][l] = v[l].x;
m[1][l] = v[l].y;
m[2][l] = v[l].z;
} }
// there are eight triplet that may satisfy the equation // there are eight triplet that may satisfy the equation
@ -110,8 +113,8 @@ NLMISC::CVector GetEulerAngles(const NLMISC::CMatrix &mat)
for (uint k = 0; k < 8; ++k) for (uint k = 0; k < 8; ++k)
{ {
float ca = cosf(sol[k].x), sa = sinf(sol[k].x) float ca = cosf(sol[k].x), sa = sinf(sol[k].x)
, cb = cosf(sol[k].y), sb = sinf(sol[k].y) , cb = cosf(sol[k].y), sb = sinf(sol[k].y)
, cc = cosf(sol[k].z), sc = sinf(sol[k].z); , cc = cosf(sol[k].z), sc = sinf(sol[k].z);
float gap = fabsf(m[0][0] - ca * cb * cc + sa * sc); float gap = fabsf(m[0][0] - ca * cb * cc + sa * sc);
gap += fabsf(m[1][0] + cc * sa + ca * cb *sc); gap += fabsf(m[1][0] + cc * sa + ca * cb *sc);
@ -132,7 +135,7 @@ NLMISC::CVector GetEulerAngles(const NLMISC::CMatrix &mat)
} }
CBasicEditWidget::CBasicEditWidget(QWidget *parent) CBasicEditWidget::CBasicEditWidget(QWidget *parent)
: QWidget(parent), _Wrapper(NULL) : QWidget(parent), _Wrapper(NULL)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -178,9 +181,9 @@ void CBasicEditWidget::updateGraphics()
if (_Wrapper == NULL) return; if (_Wrapper == NULL) return;
NLMISC::CVector angles(2.f * (float) NLMISC::Pi * _ui.psiSpinBox->value() / 360.f NLMISC::CVector angles(2.f * (float) NLMISC::Pi * _ui.psiSpinBox->value() / 360.f
, 2.f * (float) NLMISC::Pi * _ui.thetaSpinBox->value() / 360.f , 2.f * (float) NLMISC::Pi * _ui.thetaSpinBox->value() / 360.f
, 2.f * (float) NLMISC::Pi * _ui.phiSpinBox->value() / 360.f , 2.f * (float) NLMISC::Pi * _ui.phiSpinBox->value() / 360.f
); );
NLMISC::CMatrix mat = BuildEulerMatrix(angles.x, angles.y, angles.z); NLMISC::CMatrix mat = BuildEulerMatrix(angles.x, angles.y, angles.z);
NL3D::CPlaneBasis pb; NL3D::CPlaneBasis pb;
pb.X = mat.getI(); pb.X = mat.getI();

View file

@ -31,11 +31,12 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
class CBasicEditWidget: public QWidget class CBasicEditWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CBasicEditWidget(QWidget *parent = 0); CBasicEditWidget(QWidget *parent = 0);

View file

@ -20,7 +20,8 @@
#include "stdpch.h" #include "stdpch.h"
#include "bin_op_dialog.h" #include "bin_op_dialog.h"
namespace NLQT { namespace NLQT
{
CBinOpDialog::CBinOpDialog(QWidget *widget1, QWidget *widget2, QWidget *parent) CBinOpDialog::CBinOpDialog(QWidget *widget1, QWidget *widget2, QWidget *parent)
: QDialog(parent) : QDialog(parent)

View file

@ -38,11 +38,12 @@
#include "ps_wrapper.h" #include "ps_wrapper.h"
#include "attrib_widget.h" #include "attrib_widget.h"
namespace NLQT { namespace NLQT
{
class CBinOpDialog : public QDialog class CBinOpDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CBinOpDialog(QWidget *widget1, QWidget *widget2, QWidget *parent = 0); CBinOpDialog(QWidget *widget1, QWidget *widget2, QWidget *parent = 0);
@ -140,15 +141,28 @@ protected:
{ {
NL3D::CPSAttribMakerBinOp<T> *S ; NL3D::CPSAttribMakerBinOp<T> *S ;
uint Index ; uint Index ;
virtual NL3D::CPSAttribMaker<T> *getScheme(void) const { return S->getArg(Index) ; } virtual NL3D::CPSAttribMaker<T> *getScheme(void) const
virtual void setScheme(NL3D::CPSAttribMaker<T> *s) { S->setArg(Index, s) ; } ; {
return S->getArg(Index) ;
}
virtual void setScheme(NL3D::CPSAttribMaker<T> *s)
{
S->setArg(Index, s) ;
} ;
} _SchemeWrapper[2] ; } _SchemeWrapper[2] ;
/// a dummy wrapper for constant value. This shouldn't be called , however /// a dummy wrapper for constant value. This shouldn't be called , however
struct CDummyWrapper : public IPSWrapper<T> struct CDummyWrapper : public IPSWrapper<T>
{ {
T get(void) const { nlassert(false) ; return T() ; } T get(void) const
void set(const T &) { nlassert(false) ; } {
nlassert(false) ;
return T() ;
}
void set(const T &)
{
nlassert(false) ;
}
} _DummyWrapper ; } _DummyWrapper ;

View file

@ -20,7 +20,8 @@
#include "stdpch.h" #include "stdpch.h"
#include "callback.h" #include "callback.h"
namespace NLQT { namespace NLQT
{
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -34,7 +34,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
#define NLQT_CALLBACK_TEMPLATE \ #define NLQT_CALLBACK_TEMPLATE \
/** \ /** \

View file

@ -27,10 +27,11 @@
// Nel includes // Nel includes
#include <nel/misc/rgba.h> #include <nel/misc/rgba.h>
namespace NLQT { namespace NLQT
{
CColorEditWidget::CColorEditWidget(QWidget *parent) CColorEditWidget::CColorEditWidget(QWidget *parent)
: QWidget(parent), _Wrapper(NULL), _emit(true) : QWidget(parent), _Wrapper(NULL), _emit(true)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -156,9 +157,9 @@ void CColorEditWidget::setAlpha(int a)
void CColorEditWidget::browseColor() void CColorEditWidget::browseColor()
{ {
QColor color = QColorDialog::getColor(QColor(_ui.rSpinBox->value(), QColor color = QColorDialog::getColor(QColor(_ui.rSpinBox->value(),
_ui.gSpinBox->value(), _ui.gSpinBox->value(),
_ui.bSpinBox->value(), _ui.bSpinBox->value(),
_ui.aSpinBox->value())); _ui.aSpinBox->value()));
if (!color.isValid()) return; if (!color.isValid()) return;
setColor(color); setColor(color);

View file

@ -27,7 +27,8 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CColorEditWidget @class CColorEditWidget
@ -52,7 +53,7 @@ to set the current values, need call class methods updateUi();
*/ */
class CColorEditWidget: public QWidget class CColorEditWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// Constructor, sets the default color (255, 255, 255, 255) /// Constructor, sets the default color (255, 255, 255, 255)

View file

@ -31,7 +31,8 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
CConfiguration::CConfiguration() CConfiguration::CConfiguration()
{ {
@ -70,7 +71,7 @@ void CConfiguration::release()
Modules::config().dropCallback("SearchPaths"); Modules::config().dropCallback("SearchPaths");
// save and release the config file // save and release the config file
if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool())
{ {
ConfigFile.save(); ConfigFile.save();
@ -101,7 +102,7 @@ void CConfiguration::configRemapExtensions()
var = ConfigFile.getVarPtr("RemapExtensions"); var = ConfigFile.getVarPtr("RemapExtensions");
uint varsize = var->size(); uint varsize = var->size();
for (uint i = 0; i < varsize; i += 2) for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true); CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
} }
void CConfiguration::setAndCallback(const std::string &varName, CConfigCallback configCallback) void CConfiguration::setAndCallback(const std::string &varName, CConfigCallback configCallback)
@ -216,7 +217,7 @@ void CConfiguration::cfcbSearchPaths(NLMISC::CConfigFile::CVar &var)
{ {
uint varsize = var.size(); uint varsize = var.size();
for (uint i = 0; i < varsize; ++i) for (uint i = 0; i < varsize; ++i)
CPath::addSearchPath(var.asString(i), true, false); CPath::addSearchPath(var.asString(i), true, false);
} }
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -35,7 +35,8 @@
#define NLQT_CONFIG_FILE "object_viewer.cfg" #define NLQT_CONFIG_FILE "object_viewer.cfg"
namespace NLQT { namespace NLQT
{
typedef CCallback<void, NLMISC::CConfigFile::CVar &> CConfigCallback; typedef CCallback<void, NLMISC::CConfigFile::CVar &> CConfigCallback;
@ -73,7 +74,10 @@ public:
NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue);
NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue);
inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } inline NLMISC::CConfigFile &getConfigFile()
{
return ConfigFile;
}
private: private:
static void cbConfigCallback(NLMISC::CConfigFile::CVar &var); static void cbConfigCallback(NLMISC::CConfigFile::CVar &var);

View file

@ -23,10 +23,11 @@
// NeL includes // NeL includes
#include "nel/3d/ps_mesh.h" #include "nel/3d/ps_mesh.h"
namespace NLQT { namespace NLQT
{
CConstraintMeshWidget::CConstraintMeshWidget(QWidget *parent ) CConstraintMeshWidget::CConstraintMeshWidget(QWidget *parent )
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -135,24 +136,24 @@ void CConstraintMeshWidget::setTexAnimType(int index)
{ {
switch(index) switch(index)
{ {
case 0: // no anim case 0: // no anim
_CM->setTexAnimType(NL3D::CPSConstraintMesh::NoAnim); _CM->setTexAnimType(NL3D::CPSConstraintMesh::NoAnim);
_ui.stageSpinBox->hide(); _ui.stageSpinBox->hide();
_ui.stageLabel->hide(); _ui.stageLabel->hide();
_ui.tabWidget->hide(); _ui.tabWidget->hide();
_ui.reinitCheckBox->hide(); _ui.reinitCheckBox->hide();
break; break;
case 1: // global anim case 1: // global anim
_CM->setTexAnimType(NL3D::CPSConstraintMesh::GlobalAnim); _CM->setTexAnimType(NL3D::CPSConstraintMesh::GlobalAnim);
_ui.stageSpinBox->show(); _ui.stageSpinBox->show();
_ui.stageLabel->show(); _ui.stageLabel->show();
_ui.tabWidget->show(); _ui.tabWidget->show();
_ui.reinitCheckBox->show(); _ui.reinitCheckBox->show();
_ui.stageSpinBox->setValue(0); _ui.stageSpinBox->setValue(0);
_ui.reinitCheckBox->setChecked(_CM->isGlobalAnimTimeResetOnNewElementForced()); _ui.reinitCheckBox->setChecked(_CM->isGlobalAnimTimeResetOnNewElementForced());
break; break;
default: default:
nlstop; nlstop;
break; break;
} }
} }

View file

@ -31,11 +31,13 @@
// Project includes // Project includes
#include "particle_node.h" #include "particle_node.h"
namespace NL3D { namespace NL3D
class CPSConstraintMesh; {
class CPSConstraintMesh;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CConstraintMeshWidget @class CConstraintMeshWidget
@ -43,7 +45,7 @@ namespace NLQT {
*/ */
class CConstraintMeshWidget: public QWidget class CConstraintMeshWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CConstraintMeshWidget(QWidget *parent = 0); CConstraintMeshWidget(QWidget *parent = 0);

View file

@ -23,7 +23,8 @@
// Project includes // Project includes
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
CurveEditDialog::CurveEditDialog(NL3D::CPSFloatCurveFunctor *curve, CWorkspaceNode *ownerNode, QWidget *parent) CurveEditDialog::CurveEditDialog(NL3D::CPSFloatCurveFunctor *curve, CWorkspaceNode *ownerNode, QWidget *parent)
: QDialog(parent) , _Curve(curve), _scale(1.0), _pos(0.0), _Node(ownerNode) : QDialog(parent) , _Curve(curve), _scale(1.0), _pos(0.0), _Node(ownerNode)
@ -91,7 +92,7 @@ void CurveEditDialog::curveChanged(const QPolygonF &points)
_Curve->addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(1, 0.5f)); _Curve->addControlPoint(NL3D::CPSFloatCurveFunctor::CCtrlPoint(1, 0.5f));
for (int i = 0; i < points.size(); i++) for (int i = 0; i < points.size(); i++)
_Curve->setCtrlPoint(uint(i), NL3D::CPSFloatCurveFunctor::CCtrlPoint(points.at(i).x() / _ui.curveWidget->width(), _Curve->setCtrlPoint(uint(i), NL3D::CPSFloatCurveFunctor::CCtrlPoint(points.at(i).x() / _ui.curveWidget->width(),
(_ui.curveWidget->height() - points.at(i).y() + _pos) / (_ui.curveWidget->height() * _scale))); (_ui.curveWidget->height() - points.at(i).y() + _pos) / (_ui.curveWidget->height() * _scale)));
} }
void CurveEditDialog::setScale(int value) void CurveEditDialog::setScale(int value)
@ -147,7 +148,7 @@ void CurveEditDialog::buildPoints()
QPolygonF points; QPolygonF points;
for (uint i = 0; i < _Curve->getNumCtrlPoints(); i++) for (uint i = 0; i < _Curve->getNumCtrlPoints(); i++)
points << QPointF((_Curve->getControlPoint(i).Date * _ui.curveWidget->width()), points << QPointF((_Curve->getControlPoint(i).Date * _ui.curveWidget->width()),
_pos + _ui.curveWidget->height() - (_scale * _Curve->getControlPoint(i).Value * _ui.curveWidget->height())); _pos + _ui.curveWidget->height() - (_scale * _Curve->getControlPoint(i).Value * _ui.curveWidget->height()));
_hoverPoints->setPoints(points); _hoverPoints->setPoints(points);
//_hoverPoints->setPointLock(0, HoverPoints::LockToLeft); //_hoverPoints->setPointLock(0, HoverPoints::LockToLeft);

View file

@ -36,7 +36,8 @@
#include "hoverpoints.h" #include "hoverpoints.h"
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CurveEditDialog @class CurveEditDialog
@brief Dialogue editing graphics curve. @brief Dialogue editing graphics curve.
@ -45,7 +46,7 @@ The choice of the interpolation algorithm.
*/ */
class CurveEditDialog : public QDialog class CurveEditDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CurveEditDialog(NL3D::CPSFloatCurveFunctor *curve, CWorkspaceNode *ownerNode, QWidget *parent = 0); CurveEditDialog(NL3D::CPSFloatCurveFunctor *curve, CWorkspaceNode *ownerNode, QWidget *parent = 0);

View file

@ -26,10 +26,11 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CDayNightDialog::CDayNightDialog(QWidget *parent) CDayNightDialog::CDayNightDialog(QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -28,7 +28,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
/** /**
@class CDayNightDialog @class CDayNightDialog
@ -37,7 +38,7 @@ namespace NLQT {
*/ */
class CDayNightDialog: public QDockWidget class CDayNightDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CDayNightDialog(QWidget *parent = 0); CDayNightDialog(QWidget *parent = 0);

View file

@ -26,10 +26,11 @@
// NeL includes // NeL includes
#include <nel/misc/vector.h> #include <nel/misc/vector.h>
namespace NLQT { namespace NLQT
{
CDirectionWidget::CDirectionWidget(QWidget *parent) CDirectionWidget::CDirectionWidget(QWidget *parent)
: QWidget(parent), _globalName("") : QWidget(parent), _globalName("")
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -100,8 +101,8 @@ void CDirectionWidget::setGlobalDirection()
{ {
bool ok; bool ok;
QString text = QInputDialog::getText(this, tr("Enter Name"), QString text = QInputDialog::getText(this, tr("Enter Name"),
"", QLineEdit::Normal, "", QLineEdit::Normal,
QString(_globalName), &ok); QString(_globalName), &ok);
if (ok) if (ok)
setGlobalName(text); setGlobalName(text);

View file

@ -29,7 +29,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
/** /**
@class CDirectionWidget @class CDirectionWidget
@ -38,7 +39,7 @@ namespace NLQT {
*/ */
class CDirectionWidget: public QWidget class CDirectionWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CDirectionWidget(QWidget *parent = 0); CDirectionWidget(QWidget *parent = 0);

View file

@ -111,9 +111,9 @@ NL3D::CParticleSystemProcess *DupPSLocated(const CParticleSystemProcess *in)
/** Duplicate the system, and detach. /** Duplicate the system, and detach.
* We can't duplicate the object direclty (it may be referencing other objects in the system, so these objects will be copied too...) * We can't duplicate the object direclty (it may be referencing other objects in the system, so these objects will be copied too...)
*/ */
std::auto_ptr<CParticleSystem> newPS(DupSerializable<CDupObjPolicy>(in->getOwner())); std::auto_ptr<CParticleSystem> newPS(DupSerializable<CDupObjPolicy>(in->getOwner()));
// scene pointer is not serialised, but 'detach' may need the scene to be specified // scene pointer is not serialised, but 'detach' may need the scene to be specified
newPS->setScene(in->getOwner()->getScene()); newPS->setScene(in->getOwner()->getScene());
return newPS->detach(index); return newPS->detach(index);
} }
} }

View file

@ -23,8 +23,8 @@
namespace NL3D namespace NL3D
{ {
class CParticleSystemProcess; class CParticleSystemProcess;
class CPSLocatedBindable; class CPSLocatedBindable;
} }

View file

@ -28,12 +28,13 @@
using namespace NL3D; using namespace NL3D;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
const int max_range = 9999; const int max_range = 9999;
CEditRangeUIntWidget::CEditRangeUIntWidget(QWidget *parent) CEditRangeUIntWidget::CEditRangeUIntWidget(QWidget *parent)
: QWidget(parent), _Wrapper(NULL), _emit(true) : QWidget(parent), _Wrapper(NULL), _emit(true)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -142,7 +143,7 @@ void CEditRangeUIntWidget::updateUi()
} }
CEditRangeIntWidget::CEditRangeIntWidget(QWidget *parent) CEditRangeIntWidget::CEditRangeIntWidget(QWidget *parent)
: QWidget(parent), _Wrapper(NULL) : QWidget(parent), _Wrapper(NULL)
{ {
_ui.setupUi(this); _ui.setupUi(this);
connect(_ui.startSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setMinimum(int))); connect(_ui.startSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setMinimum(int)));
@ -332,7 +333,7 @@ void CEditRangeFloatWidget::disableLowerBound(void)
void CEditRangeFloatWidget::changeRange() void CEditRangeFloatWidget::changeRange()
{ {
if ((_ui.startSpinBox->value() < _ui.currentSpinBox->value()) && if ((_ui.startSpinBox->value() < _ui.currentSpinBox->value()) &&
(_ui.endSpinBox->value() > _ui.currentSpinBox->value())) (_ui.endSpinBox->value() > _ui.currentSpinBox->value()))
setValue(_ui.currentSpinBox->value(), false); setValue(_ui.currentSpinBox->value(), false);
} }

View file

@ -28,7 +28,8 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CEditRangeUIntWidget @class CEditRangeUIntWidget
@ -56,7 +57,7 @@ to set the current values,it is need to call class methods updateUi();
class CEditRangeUIntWidget: public QWidget class CEditRangeUIntWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// Constructor, sets 0 default current value /// Constructor, sets 0 default current value
@ -99,7 +100,7 @@ Q_SIGNALS:
void valueChanged(uint32 value); void valueChanged(uint32 value);
public Q_SLOTS: public Q_SLOTS:
/// Set current value /// Set current value
/// @param value - current value /// @param value - current value
/// @param emit - will emit valueChanged() if the new value is different from the old one and param emit = true /// @param emit - will emit valueChanged() if the new value is different from the old one and param emit = true
void setValue(uint32 value, bool emit = true); void setValue(uint32 value, bool emit = true);
@ -143,7 +144,7 @@ to set the current values,it is need to call class methods updateUi();
class CEditRangeIntWidget: public QWidget class CEditRangeIntWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// Constructor, sets 0 default current value /// Constructor, sets 0 default current value
@ -230,7 +231,7 @@ to set the current values,it is need to call class methods updateUi();
class CEditRangeFloatWidget: public QWidget class CEditRangeFloatWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// Constructor, sets 0 default current value /// Constructor, sets 0 default current value
CEditRangeFloatWidget(QWidget *parent = 0); CEditRangeFloatWidget(QWidget *parent = 0);

View file

@ -21,7 +21,7 @@
#include "emitter_page.h" #include "emitter_page.h"
// Qt includes // Qt includes
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
// NeL includes // NeL includes
@ -29,11 +29,12 @@
#include "edit_range_widget.h" #include "edit_range_widget.h"
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CEmitterPage::CEmitterPage(QWidget *parent) CEmitterPage::CEmitterPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -194,15 +195,15 @@ void CEmitterPage::setEmittedType(int index)
if (_Emitter->getOwner()->getOwner()->getBehaviourType() == NL3D::CParticleSystem::SpellFX || _Emitter->getOwner()->getOwner()->getBypassMaxNumIntegrationSteps()) if (_Emitter->getOwner()->getOwner()->getBehaviourType() == NL3D::CParticleSystem::SpellFX || _Emitter->getOwner()->getOwner()->getBypassMaxNumIntegrationSteps())
{ {
QMessageBox::critical(this, tr("NeL Particle Editor"), QMessageBox::critical(this, tr("NeL Particle Editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX'," tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX',"
"and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden."), "and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden."),
QMessageBox::Ok); QMessageBox::Ok);
} }
else else
{ {
QMessageBox::critical(this, tr("NeL Particle Editor"), QMessageBox::critical(this, tr("NeL Particle Editor"),
tr("Loops with emitters are forbidden."), tr("Loops with emitters are forbidden."),
QMessageBox::Ok); QMessageBox::Ok);
} }
updateEmittedType(); updateEmittedType();
} }
@ -217,9 +218,9 @@ void CEmitterPage::setTypeOfEmission(int index)
if (!_Emitter->setEmissionType((NL3D::CPSEmitter::TEmissionType) index)) if (!_Emitter->setEmissionType((NL3D::CPSEmitter::TEmissionType) index))
{ {
QMessageBox::critical(this, tr("NeL Particle Editor"), QMessageBox::critical(this, tr("NeL Particle Editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first."), "and thus, should have a finite duration. Please remove that flag first."),
QMessageBox::Ok); QMessageBox::Ok);
_ui.typeEmissionComboBox->setCurrentIndex(int(_Emitter->getEmissionType())); _ui.typeEmissionComboBox->setCurrentIndex(int(_Emitter->getEmissionType()));
} }
@ -250,28 +251,28 @@ void CEmitterPage::setDirectionMode(int index)
nlassert(_Emitter); nlassert(_Emitter);
switch(index) switch(index)
{ {
case Default: case Default:
_Emitter->enableSpeedBasisEmission(false); _Emitter->enableSpeedBasisEmission(false);
_Emitter->enableUserMatrixModeForEmissionDirection(false); _Emitter->enableUserMatrixModeForEmissionDirection(false);
break; break;
case AlignOnEmitterDirection: case AlignOnEmitterDirection:
_Emitter->enableSpeedBasisEmission(true); _Emitter->enableSpeedBasisEmission(true);
_Emitter->enableUserMatrixModeForEmissionDirection(false); _Emitter->enableUserMatrixModeForEmissionDirection(false);
break; break;
case InWorld: case InWorld:
_Emitter->enableSpeedBasisEmission(false); _Emitter->enableSpeedBasisEmission(false);
_Emitter->enableUserMatrixModeForEmissionDirection(true); _Emitter->enableUserMatrixModeForEmissionDirection(true);
_Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSIdentityMatrix); _Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSIdentityMatrix);
break; break;
case LocalToSystem: case LocalToSystem:
_Emitter->enableSpeedBasisEmission(false); _Emitter->enableSpeedBasisEmission(false);
_Emitter->enableUserMatrixModeForEmissionDirection(true); _Emitter->enableUserMatrixModeForEmissionDirection(true);
_Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSFXWorldMatrix); _Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSFXWorldMatrix);
break; break;
case LocalToFatherSkeleton: case LocalToFatherSkeleton:
_Emitter->enableSpeedBasisEmission(false); _Emitter->enableSpeedBasisEmission(false);
_Emitter->enableUserMatrixModeForEmissionDirection(true); _Emitter->enableUserMatrixModeForEmissionDirection(true);
_Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSUserMatrix); _Emitter->setUserMatrixModeForEmissionDirection(NL3D::PSUserMatrix);
break; break;
} }
updateModifiedFlag(); updateModifiedFlag();
@ -302,9 +303,9 @@ void CEmitterPage::setMaxEmissionCount(uint32 value)
{ {
QMessageBox::critical(this, tr("NeL Particle Editor"), QMessageBox::critical(this, tr("NeL Particle Editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first."), "and thus, should have a finite duration. Please remove that flag first."),
QMessageBox::Ok); QMessageBox::Ok);
_ui.maxEmissionCountWidget->setValue((uint32)_Emitter->getMaxEmissionCount(), false); _ui.maxEmissionCountWidget->setValue((uint32)_Emitter->getMaxEmissionCount(), false);
updateModifiedFlag(); updateModifiedFlag();

View file

@ -33,7 +33,8 @@
#include "particle_node.h" #include "particle_node.h"
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CEmitterPage @class CEmitterPage
@ -41,7 +42,7 @@ namespace NLQT {
*/ */
class CEmitterPage: public QWidget class CEmitterPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/// This enum match the option in the combo box that allow to choose how the direction of emission is computed. /// This enum match the option in the combo box that allow to choose how the direction of emission is computed.
@ -80,9 +81,15 @@ private:
{ {
CWorkspaceNode *Node; CWorkspaceNode *Node;
NL3D::CPSEmitter *E; NL3D::CPSEmitter *E;
float get(void) const { return E->getPeriod(); } float get(void) const
{
return E->getPeriod();
}
void set(const float &v); void set(const float &v);
scheme_type *getScheme(void) const { return E->getPeriodScheme(); } scheme_type *getScheme(void) const
{
return E->getPeriodScheme();
}
void setScheme(scheme_type *s); void setScheme(scheme_type *s);
} _PeriodWrapper; } _PeriodWrapper;
@ -91,9 +98,15 @@ private:
{ {
CWorkspaceNode *Node; CWorkspaceNode *Node;
NL3D::CPSEmitter *E; NL3D::CPSEmitter *E;
uint32 get(void) const { return E->getGenNb(); } uint32 get(void) const
{
return E->getGenNb();
}
void set(const uint32 &v); void set(const uint32 &v);
scheme_type *getScheme(void) const { return E->getGenNbScheme(); } scheme_type *getScheme(void) const
{
return E->getGenNbScheme();
}
void setScheme(scheme_type *s); void setScheme(scheme_type *s);
} _GenNbWrapper; } _GenNbWrapper;
@ -101,10 +114,22 @@ private:
struct CModulateStrenghtWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CModulateStrenghtWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSModulatedEmitter *E; NL3D::CPSModulatedEmitter *E;
float get(void) const { return E->getEmitteeSpeed(); } float get(void) const
void set(const float &v) { E->setEmitteeSpeed(v); } {
scheme_type *getScheme(void) const { return E->getEmitteeSpeedScheme(); } return E->getEmitteeSpeed();
void setScheme(scheme_type *s) { E->setEmitteeSpeedScheme(s); } }
void set(const float &v)
{
E->setEmitteeSpeed(v);
}
scheme_type *getScheme(void) const
{
return E->getEmitteeSpeedScheme();
}
void setScheme(scheme_type *s)
{
E->setEmitteeSpeedScheme(s);
}
} _ModulatedStrenghtWrapper; } _ModulatedStrenghtWrapper;
// the emitter being edited // the emitter being edited
@ -117,7 +142,10 @@ private:
void updatePeriodWidget(); void updatePeriodWidget();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
CWorkspaceNode *_Node; CWorkspaceNode *_Node;

View file

@ -40,7 +40,8 @@
using namespace NLMISC; using namespace NLMISC;
using namespace NL3D; using namespace NL3D;
namespace NLQT { namespace NLQT
{
CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo) CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo)
{ {
@ -63,10 +64,10 @@ CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo)
} }
CEntity::CEntity(void): CEntity::CEntity(void):
_Name("<Unknown>"), _FileNameShape(""), _Name("<Unknown>"), _FileNameShape(""),
_FileNameSkeleton(""), _inPlace(false), _incPos(false), _FileNameSkeleton(""), _inPlace(false), _incPos(false),
_Instance(NULL), _Skeleton(NULL), _Instance(NULL), _Skeleton(NULL),
_PlayList(NULL), _AnimationSet(NULL) _PlayList(NULL), _AnimationSet(NULL)
{ {
_CharacterScalePos = 1; _CharacterScalePos = 1;
} }
@ -124,7 +125,7 @@ void CEntity::addAnimToPlayList(std::string &name)
void CEntity::removeAnimToPlayList(uint row) void CEntity::removeAnimToPlayList(uint row)
{ {
if (row < _PlayListAnimation.size()) if (row < _PlayListAnimation.size())
_PlayListAnimation.erase(_PlayListAnimation.begin() + row); _PlayListAnimation.erase(_PlayListAnimation.begin() + row);
_AnimationStatus.EndAnim = this->getPlayListLength(); _AnimationStatus.EndAnim = this->getPlayListLength();
} }
@ -132,7 +133,7 @@ void CEntity::removeAnimToPlayList(uint row)
void CEntity::swapAnimToPlayList(uint row1, uint row2) void CEntity::swapAnimToPlayList(uint row1, uint row2)
{ {
if ((row1 < _PlayListAnimation.size()) && (row2 < _PlayListAnimation.size())) if ((row1 < _PlayListAnimation.size()) && (row2 < _PlayListAnimation.size()))
std::swap(_PlayListAnimation[row1], _PlayListAnimation[row2]); std::swap(_PlayListAnimation[row1], _PlayListAnimation[row2]);
} }
void CEntity::playbackAnim(bool play) void CEntity::playbackAnim(bool play)
@ -175,12 +176,12 @@ void CEntity::update(NL3D::TAnimationTime time)
this->resetChannel(); this->resetChannel();
switch (_AnimationStatus.Mode) switch (_AnimationStatus.Mode)
{ {
case Mode::PlayList: case Mode::PlayList:
animatePlayList(time); animatePlayList(time);
break; break;
case Mode::Mixer: case Mode::Mixer:
animateChannelMixer(); animateChannelMixer();
break; break;
} }
} }
@ -188,11 +189,11 @@ void CEntity::update(NL3D::TAnimationTime time)
void CEntity::resetChannel() void CEntity::resetChannel()
{ {
for(uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) for(uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++)
_PlayList->setAnimation(i, UPlayList::empty); _PlayList->setAnimation(i, UPlayList::empty);
} }
void CEntity::addTransformation (CMatrix &current, UAnimation *anim, float begin, float end, UTrack *posTrack, UTrack *rotquatTrack, void CEntity::addTransformation (CMatrix &current, UAnimation *anim, float begin, float end, UTrack *posTrack, UTrack *rotquatTrack,
UTrack *nextPosTrack, UTrack *nextRotquatTrack, bool removeLast) UTrack *nextPosTrack, UTrack *nextRotquatTrack, bool removeLast)
{ {
// In place ? // In place ?
if (_inPlace) if (_inPlace)
@ -413,15 +414,15 @@ void CEntity::animateChannelMixer()
// Switch between wrap modes // Switch between wrap modes
switch (_SlotInfo[i].ClampMode) switch (_SlotInfo[i].ClampMode)
{ {
case 0: case 0:
_PlayList->setWrapMode (i, UPlayList::Clamp); _PlayList->setWrapMode (i, UPlayList::Clamp);
break; break;
case 1: case 1:
_PlayList->setWrapMode (i, UPlayList::Repeat); _PlayList->setWrapMode (i, UPlayList::Repeat);
break; break;
case 2: case 2:
_PlayList->setWrapMode (i, UPlayList::Disable); _PlayList->setWrapMode (i, UPlayList::Disable);
break; break;
} }
} }
} }

View file

@ -36,12 +36,14 @@
#include <nel/3d/u_skeleton.h> #include <nel/3d/u_skeleton.h>
#include <nel/3d/channel_mixer.h> #include <nel/3d/channel_mixer.h>
namespace NL3D { namespace NL3D
class UPlayList; {
class UAnimationSet; class UPlayList;
class UAnimationSet;
} }
namespace NLQT { namespace NLQT
{
class CSlotInfo class CSlotInfo
{ {
@ -145,56 +147,101 @@ public:
float getAnimLength(std::string name); float getAnimLength(std::string name);
/// Get slot infomation /// Get slot infomation
void setSlotInfo(uint num, CSlotInfo& slotInfo) { _SlotInfo[num] = slotInfo; } void setSlotInfo(uint num, CSlotInfo& slotInfo)
{
_SlotInfo[num] = slotInfo;
}
/// Set use mode playlist or mixer /// Set use mode playlist or mixer
void setMode(int mode) { _AnimationStatus.Mode = mode; } void setMode(int mode)
{
_AnimationStatus.Mode = mode;
}
/// Set in place mode animation /// Set in place mode animation
void setInPlace(bool enabled) { _inPlace = enabled; } void setInPlace(bool enabled)
{
_inPlace = enabled;
}
/// Get in place mode /// Get in place mode
bool getInPlace() { return _inPlace; } bool getInPlace()
{
return _inPlace;
}
/// Set inc position /// Set inc position
void setIncPos(bool enabled) { _incPos = enabled; } void setIncPos(bool enabled)
{
_incPos = enabled;
}
/// Get inc position /// Get inc position
bool getIncPos() { return _incPos; } bool getIncPos()
{
return _incPos;
}
/// Get information about the current status of playing a playlist /// Get information about the current status of playing a playlist
/// @return struct containing current information playback /// @return struct containing current information playback
SAnimationStatus getStatus() { return _AnimationStatus; } SAnimationStatus getStatus()
{
return _AnimationStatus;
}
/// Get name entity /// Get name entity
/// @return name entity /// @return name entity
std::string getName() { return _Name; } std::string getName()
{
return _Name;
}
/// Get file name shape /// Get file name shape
/// @return file name shape /// @return file name shape
std::string getFileNameShape() { return _FileNameShape; } std::string getFileNameShape()
{
return _FileNameShape;
}
/// Get file name skeleton /// Get file name skeleton
/// @return file name skeleton /// @return file name skeleton
std::string getFileNameSkeleton() { return _FileNameSkeleton; } std::string getFileNameSkeleton()
{
return _FileNameSkeleton;
}
/// Get slot information /// Get slot information
CSlotInfo getSlotInfo(uint num) { return _SlotInfo[num]; } CSlotInfo getSlotInfo(uint num)
{
return _SlotInfo[num];
}
/// Get list loaded animations files /// Get list loaded animations files
std::vector<std::string>& getAnimationList() { return _AnimationList; } std::vector<std::string>& getAnimationList()
{
return _AnimationList;
}
/// Get playlist animations /// Get playlist animations
std::vector<std::string>& getPlayListAnimation() { return _PlayListAnimation; } std::vector<std::string>& getPlayListAnimation()
{
return _PlayListAnimation;
}
/// Get list loaded skeleton weight template files /// Get list loaded skeleton weight template files
std::vector<std::string>& getSWTList() { return _SWTList; } std::vector<std::string>& getSWTList()
{
return _SWTList;
}
/// Get game interface for manipulating Skeleton. /// Get game interface for manipulating Skeleton.
NL3D::USkeleton getSkeleton() const { return _Skeleton; } NL3D::USkeleton getSkeleton() const
{
return _Skeleton;
}
private: private:
/// Constructor /// Constructor
CEntity(void); CEntity(void);
/// Update the animate from the playlist or channel mixer /// Update the animate from the playlist or channel mixer
@ -209,10 +256,10 @@ private:
/// Update the animate from the mixer /// Update the animate from the mixer
void animateChannelMixer(); void animateChannelMixer();
void addTransformation (NLMISC::CMatrix &current, NL3D::UAnimation *anim, void addTransformation (NLMISC::CMatrix &current, NL3D::UAnimation *anim,
float begin, float end, float begin, float end,
NL3D::UTrack *posTrack, NL3D::UTrack *rotquatTrack, NL3D::UTrack *posTrack, NL3D::UTrack *rotquatTrack,
NL3D::UTrack *nextPosTrack, NL3D::UTrack *nextRotquatTrack, NL3D::UTrack *nextPosTrack, NL3D::UTrack *nextRotquatTrack,
bool removeLast); bool removeLast);
// The name of the entity // The name of the entity
std::string _Name; std::string _Name;

View file

@ -26,38 +26,39 @@
// Project includes // Project includes
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
CFollowPathDialog::CFollowPathDialog(NL3D::CPSPlaneBasisFollowSpeed *pbfs, CWorkspaceNode *ownerNode, QWidget *parent) CFollowPathDialog::CFollowPathDialog(NL3D::CPSPlaneBasisFollowSpeed *pbfs, CWorkspaceNode *ownerNode, QWidget *parent)
: QDialog(parent), _FollowPath(pbfs), _Node(ownerNode) : QDialog(parent), _FollowPath(pbfs), _Node(ownerNode)
{ {
resize(270, 90); resize(270, 90);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0); sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0); sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
setSizePolicy(sizePolicy); setSizePolicy(sizePolicy);
setMinimumSize(QSize(0, 90)); setMinimumSize(QSize(0, 90));
setMaximumSize(QSize(16777215, 90)); setMaximumSize(QSize(16777215, 90));
gridLayout = new QGridLayout(this); gridLayout = new QGridLayout(this);
label = new QLabel(this); label = new QLabel(this);
gridLayout->addWidget(label, 0, 0, 1, 1); gridLayout->addWidget(label, 0, 0, 1, 1);
comboBox = new QComboBox(this); comboBox = new QComboBox(this);
gridLayout->addWidget(comboBox, 1, 0, 1, 2); gridLayout->addWidget(comboBox, 1, 0, 1, 2);
horizontalSpacer = new QSpacerItem(207, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalSpacer = new QSpacerItem(207, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout->addItem(horizontalSpacer, 2, 0, 1, 1); gridLayout->addItem(horizontalSpacer, 2, 0, 1, 1);
pushButton = new QPushButton(this); pushButton = new QPushButton(this);
gridLayout->addWidget(pushButton, 2, 1, 1, 1); gridLayout->addWidget(pushButton, 2, 1, 1, 1);
setWindowTitle(tr("Follow path param")); setWindowTitle(tr("Follow path param"));
label->setText(tr("Projection plane:")); label->setText(tr("Projection plane:"));
comboBox->clear(); comboBox->clear();
comboBox->insertItems(0, QStringList() comboBox->insertItems(0, QStringList()
<< tr("No projection") << tr("No projection")
<< tr("XY plane") << tr("XY plane")
<< tr("XZ plane") << tr("XZ plane")
<< tr("YZ plane")); << tr("YZ plane"));
pushButton->setText(("Ok")); pushButton->setText(("Ok"));
comboBox->setCurrentIndex(_FollowPath->getProjectionPlane()); comboBox->setCurrentIndex(_FollowPath->getProjectionPlane());

View file

@ -29,16 +29,17 @@
namespace NL3D namespace NL3D
{ {
class CPSPlaneBasisFollowSpeed; class CPSPlaneBasisFollowSpeed;
} }
namespace NLQT { namespace NLQT
{
class CWorkspaceNode; class CWorkspaceNode;
class CFollowPathDialog : public QDialog class CFollowPathDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CFollowPathDialog(NL3D::CPSPlaneBasisFollowSpeed *pbfs, CWorkspaceNode *ownerNode, QWidget *parent = 0); CFollowPathDialog(NL3D::CPSPlaneBasisFollowSpeed *pbfs, CWorkspaceNode *ownerNode, QWidget *parent = 0);

View file

@ -24,10 +24,11 @@
#include "modules.h" #include "modules.h"
#include <nel/3d/u_scene.h> #include <nel/3d/u_scene.h>
namespace NLQT { namespace NLQT
{
CGlobalWindDialog::CGlobalWindDialog(QWidget *parent) CGlobalWindDialog::CGlobalWindDialog(QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -28,11 +28,12 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
class CGlobalWindDialog: public QDockWidget class CGlobalWindDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CGlobalWindDialog(QWidget *parent = 0); CGlobalWindDialog(QWidget *parent = 0);
@ -44,11 +45,11 @@ private Q_SLOTS:
private: private:
/// wrappers to tune the direction of wind /// wrappers to tune the direction of wind
/* struct CDirectionWrapper : public IPSWrapper<NLMISC::CVector> /* struct CDirectionWrapper : public IPSWrapper<NLMISC::CVector>
{ {
NLMISC::CVector get(void) const; NLMISC::CVector get(void) const;
void set(const NLMISC::CVector &d); void set(const NLMISC::CVector &d);
} _DirectionWrapper;*/ } _DirectionWrapper;*/
Ui::CGlobalWindDialog _ui; Ui::CGlobalWindDialog _ui;

View file

@ -27,12 +27,13 @@
// STL includes // STL includes
namespace NLQT { namespace NLQT
{
const int directionSize = 35; const int directionSize = 35;
CGraphicsInfoWidget::CGraphicsInfoWidget(QWidget *parent) CGraphicsInfoWidget::CGraphicsInfoWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_color = Qt::white; _color = Qt::white;
_mode = Mode::Color; _mode = Mode::Color;
@ -94,7 +95,7 @@ void CGraphicsInfoWidget::paintEvent(QPaintEvent *event)
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
painter.drawLine(width() / 2, height() / 2, painter.drawLine(width() / 2, height() / 2,
int((width() / 2) + _x * 0.9f * directionSize), int((height() / 2) - _y * 0.9f * directionSize)); int((width() / 2) + _x * 0.9f * directionSize), int((height() / 2) - _y * 0.9f * directionSize));
} }
if (_mode == Mode::PlaneBasic) if (_mode == Mode::PlaneBasic)
{ {
@ -109,9 +110,9 @@ void CGraphicsInfoWidget::paintEvent(QPaintEvent *event)
for(uint k = 0; k < _verts.size() / 2; ++k) for(uint k = 0; k < _verts.size() / 2; ++k)
{ {
painter.drawLine(int((width() / 2.0) * (1 + _verts[2 * k].x)), painter.drawLine(int((width() / 2.0) * (1 + _verts[2 * k].x)),
int((height() / 2.0) * (1 - _verts[2 * k].y)), int((height() / 2.0) * (1 - _verts[2 * k].y)),
int((width() / 2.0) * (1 + _verts[2 * k + 1].x)), int((width() / 2.0) * (1 + _verts[2 * k + 1].x)),
int((height() / 2.0) * (1 - _verts[2 * k + 1].y))); int((height() / 2.0) * (1 - _verts[2 * k + 1].y)));
} }
} }
else else
@ -119,14 +120,14 @@ void CGraphicsInfoWidget::paintEvent(QPaintEvent *event)
for(uint k = 1; k < _verts.size(); k++) for(uint k = 1; k < _verts.size(); k++)
{ {
painter.drawLine(int((width() / 2.0) * (1 + _verts[k - 1].x)), painter.drawLine(int((width() / 2.0) * (1 + _verts[k - 1].x)),
int((height() / 2.0) * (1 - _verts[k - 1].y)), int((height() / 2.0) * (1 - _verts[k - 1].y)),
int((width() / 2.0) * (1 + _verts[ k].x)), int((width() / 2.0) * (1 + _verts[ k].x)),
int((height() / 2.0) * (1 - _verts[k].y))); int((height() / 2.0) * (1 - _verts[k].y)));
} }
painter.drawLine(int((width() / 2.0) * (1 + _verts[0].x)), painter.drawLine(int((width() / 2.0) * (1 + _verts[0].x)),
int((height() / 2.0) * (1 - _verts[0].y)), int((height() / 2.0) * (1 - _verts[0].y)),
int((width() / 2.0) * (1 + _verts[_verts.size() - 1].x)), int((width() / 2.0) * (1 + _verts[_verts.size() - 1].x)),
int((height() / 2.0) * (1 - _verts[_verts.size() - 1].y))); int((height() / 2.0) * (1 - _verts[_verts.size() - 1].y)));
} }
} }
} }

View file

@ -30,7 +30,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
struct Mode struct Mode
{ {
@ -45,7 +46,7 @@ struct Mode
class CGraphicsInfoWidget: public QWidget class CGraphicsInfoWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CGraphicsInfoWidget(QWidget *parent = 0); CGraphicsInfoWidget(QWidget *parent = 0);

View file

@ -43,7 +43,8 @@
using namespace std; using namespace std;
using namespace NL3D; using namespace NL3D;
namespace NLQT { namespace NLQT
{
CGraphicsViewport::CGraphicsViewport(QWidget *parent) CGraphicsViewport::CGraphicsViewport(QWidget *parent)
: QNLWidget(parent) : QNLWidget(parent)
@ -89,7 +90,7 @@ QAction *CGraphicsViewport::createSaveScreenshotAction(QObject *parent)
QAction *CGraphicsViewport::createSetBackgroundColor(QObject *parent) QAction *CGraphicsViewport::createSetBackgroundColor(QObject *parent)
{ {
QAction *action = new QAction(parent); QAction *action = new QAction(parent);
connect(action, SIGNAL(triggered()), this, SLOT(setBackgroundColor())); connect(action, SIGNAL(triggered()), this, SLOT(setBackgroundColor()));
return action; return action;
} }
@ -102,8 +103,8 @@ void CGraphicsViewport::saveScreenshot()
void CGraphicsViewport::setBackgroundColor() void CGraphicsViewport::setBackgroundColor()
{ {
QColor color = QColorDialog::getColor(QColor(Modules::objView().getBackgroundColor().R, QColor color = QColorDialog::getColor(QColor(Modules::objView().getBackgroundColor().R,
Modules::objView().getBackgroundColor().G, Modules::objView().getBackgroundColor().G,
Modules::objView().getBackgroundColor().B)); Modules::objView().getBackgroundColor().B));
if (color.isValid()) if (color.isValid())
Modules::objView().setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue())); Modules::objView().setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue()));
} }

View file

@ -44,7 +44,8 @@ typedef QGLWidget QNLWidget;
class QAction; class QAction;
namespace NLQT { namespace NLQT
{
/** /**
@class CGraphicsViewport @class CGraphicsViewport
@ -58,7 +59,10 @@ public:
CGraphicsViewport(QWidget *parent); CGraphicsViewport(QWidget *parent);
virtual ~CGraphicsViewport(); virtual ~CGraphicsViewport();
virtual QPaintEngine* paintEngine() const { return NULL; } virtual QPaintEngine* paintEngine() const
{
return NULL;
}
void init(); void init();
void release(); void release();

View file

@ -45,364 +45,407 @@
#define printf #define printf
HoverPoints::HoverPoints(QWidget *widget, PointShape shape) HoverPoints::HoverPoints(QWidget *widget, PointShape shape)
: QObject(widget) : QObject(widget)
{ {
m_widget = widget; m_widget = widget;
widget->installEventFilter(this); widget->installEventFilter(this);
widget->setAttribute(Qt::WA_AcceptTouchEvents); widget->setAttribute(Qt::WA_AcceptTouchEvents);
m_connectionType = CurveConnection; m_connectionType = CurveConnection;
m_sortType = NoSort; m_sortType = NoSort;
m_shape = shape; m_shape = shape;
m_pointPen = QPen(QColor(255, 255, 255, 191), 1); m_pointPen = QPen(QColor(255, 255, 255, 191), 1);
m_connectionPen = QPen(QColor(255, 255, 255, 127), 2); m_connectionPen = QPen(QColor(255, 255, 255, 127), 2);
m_pointBrush = QBrush(QColor(191, 191, 191, 127)); m_pointBrush = QBrush(QColor(191, 191, 191, 127));
m_pointSize = QSize(11, 11); m_pointSize = QSize(11, 11);
m_currentIndex = -1; m_currentIndex = -1;
m_editable = true; m_editable = true;
m_enabled = true; m_enabled = true;
m_minCountPoints = 2; m_minCountPoints = 2;
createGradient(); createGradient();
connect(this, SIGNAL(pointsChanged(QPolygonF)), connect(this, SIGNAL(pointsChanged(QPolygonF)),
m_widget, SLOT(update())); m_widget, SLOT(update()));
} }
void HoverPoints::setEnabled(bool enabled) void HoverPoints::setEnabled(bool enabled)
{ {
if (m_enabled != enabled) { if (m_enabled != enabled)
m_enabled = enabled; {
m_widget->update(); m_enabled = enabled;
} m_widget->update();
}
} }
bool HoverPoints::eventFilter(QObject *object, QEvent *event) bool HoverPoints::eventFilter(QObject *object, QEvent *event)
{ {
if (object == m_widget && m_enabled) { if (object == m_widget && m_enabled)
switch (event->type()) { {
switch (event->type())
{
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
if (!m_fingerPointMapping.isEmpty()) if (!m_fingerPointMapping.isEmpty())
return true; return true;
QMouseEvent *me = (QMouseEvent *) event; QMouseEvent *me = (QMouseEvent *) event;
QPointF clickPos = me->pos(); QPointF clickPos = me->pos();
int index = -1; int index = -1;
for (int i=0; i<m_points.size(); ++i) { for (int i=0; i<m_points.size(); ++i)
QPainterPath path; {
if (m_shape == CircleShape) QPainterPath path;
path.addEllipse(pointBoundingRect(i)); if (m_shape == CircleShape)
else path.addEllipse(pointBoundingRect(i));
path.addRect(pointBoundingRect(i)); else
path.addRect(pointBoundingRect(i));
if (path.contains(clickPos)) { if (path.contains(clickPos))
index = i; {
break; index = i;
} break;
} }
}
if (me->button() == Qt::LeftButton) { if (me->button() == Qt::LeftButton)
if (index == -1) { {
if (!m_editable) if (index == -1)
return false; {
int pos = 0; if (!m_editable)
// Insert sort for x or y return false;
if (m_sortType == XSort) { int pos = 0;
for (int i=0; i<m_points.size(); ++i) // Insert sort for x or y
if (m_points.at(i).x() > clickPos.x()) { if (m_sortType == XSort)
pos = i; {
break; for (int i=0; i<m_points.size(); ++i)
} if (m_points.at(i).x() > clickPos.x())
} else if (m_sortType == YSort) { {
for (int i=0; i<m_points.size(); ++i) pos = i;
if (m_points.at(i).y() > clickPos.y()) { break;
pos = i; }
break; }
} else if (m_sortType == YSort)
} {
for (int i=0; i<m_points.size(); ++i)
if (m_points.at(i).y() > clickPos.y())
{
pos = i;
break;
}
}
m_points.insert(pos, clickPos); m_points.insert(pos, clickPos);
m_locks.insert(pos, 0); m_locks.insert(pos, 0);
m_currentIndex = pos; m_currentIndex = pos;
firePointChange(); firePointChange();
} else { }
else
{
m_currentIndex = index; m_currentIndex = index;
} }
return true; return true;
} else if (me->button() == Qt::RightButton) { }
if (index >= 0 && m_editable) { else if (me->button() == Qt::RightButton)
if ((m_points.size() - 1) < m_minCountPoints) {
return true; if (index >= 0 && m_editable)
if (m_locks[index] == 0) { {
m_locks.remove(index); if ((m_points.size() - 1) < m_minCountPoints)
m_points.remove(index); return true;
} if (m_locks[index] == 0)
firePointChange(); {
return true; m_locks.remove(index);
} m_points.remove(index);
} }
firePointChange();
return true;
}
}
} }
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
if (!m_fingerPointMapping.isEmpty()) if (!m_fingerPointMapping.isEmpty())
return true; return true;
m_currentIndex = -1; m_currentIndex = -1;
break; break;
case QEvent::MouseMove: case QEvent::MouseMove:
if (!m_fingerPointMapping.isEmpty()) if (!m_fingerPointMapping.isEmpty())
return true; return true;
if (m_currentIndex >= 0) if (m_currentIndex >= 0)
movePoint(m_currentIndex, ((QMouseEvent *)event)->pos()); movePoint(m_currentIndex, ((QMouseEvent *)event)->pos());
break; break;
case QEvent::TouchBegin: case QEvent::TouchBegin:
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
{ {
const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event); const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints(); const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
Q_FOREACH (const QTouchEvent::TouchPoint &touchPoint, points) { Q_FOREACH (const QTouchEvent::TouchPoint &touchPoint, points)
const int id = touchPoint.id(); {
switch (touchPoint.state()) { const int id = touchPoint.id();
case Qt::TouchPointPressed: switch (touchPoint.state())
{ {
// find the point, move it case Qt::TouchPointPressed:
QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values()); {
int activePoint = -1; // find the point, move it
qreal distance = -1; QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values());
const int pointsCount = m_points.size(); int activePoint = -1;
const int activePointCount = activePoints.size(); qreal distance = -1;
if (pointsCount == 2 && activePointCount == 1) { // only two points const int pointsCount = m_points.size();
activePoint = activePoints.contains(0) ? 1 : 0; const int activePointCount = activePoints.size();
} else { if (pointsCount == 2 && activePointCount == 1) // only two points
for (int i=0; i<pointsCount; ++i) { {
if (activePoints.contains(i)) activePoint = activePoints.contains(0) ? 1 : 0;
continue; }
else
{
for (int i=0; i<pointsCount; ++i)
{
if (activePoints.contains(i))
continue;
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * pointSize) || d < distance) { if ((distance < 0 && d < 12 * pointSize) || d < distance)
distance = d; {
activePoint = i; distance = d;
} activePoint = i;
}
} }
} }
if (activePoint != -1) { if (activePoint != -1)
m_fingerPointMapping.insert(touchPoint.id(), activePoint); {
movePoint(activePoint, touchPoint.pos()); m_fingerPointMapping.insert(touchPoint.id(), activePoint);
} movePoint(activePoint, touchPoint.pos());
} }
break; }
case Qt::TouchPointReleased: break;
{ case Qt::TouchPointReleased:
// move the point and release {
QHash<int,int>::iterator it = m_fingerPointMapping.find(id); // move the point and release
movePoint(it.value(), touchPoint.pos()); QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
m_fingerPointMapping.erase(it); movePoint(it.value(), touchPoint.pos());
} m_fingerPointMapping.erase(it);
break; }
case Qt::TouchPointMoved: break;
{ case Qt::TouchPointMoved:
// move the point {
const int pointIdx = m_fingerPointMapping.value(id, -1); // move the point
if (pointIdx >= 0) // do we track this point? const int pointIdx = m_fingerPointMapping.value(id, -1);
movePoint(pointIdx, touchPoint.pos()); if (pointIdx >= 0) // do we track this point?
} movePoint(pointIdx, touchPoint.pos());
break; }
default: break;
break; default:
} break;
} }
if (m_fingerPointMapping.isEmpty()) { }
event->ignore(); if (m_fingerPointMapping.isEmpty())
return false; {
} else { event->ignore();
return true; return false;
} }
} else
break; {
case QEvent::TouchEnd: return true;
if (m_fingerPointMapping.isEmpty()) { }
event->ignore(); }
return false; break;
} case QEvent::TouchEnd:
return true; if (m_fingerPointMapping.isEmpty())
break; {
event->ignore();
return false;
}
return true;
break;
case QEvent::Resize: case QEvent::Resize:
{ {
QResizeEvent *e = (QResizeEvent *) event; QResizeEvent *e = (QResizeEvent *) event;
if (e->oldSize().width() == 0 || e->oldSize().height() == 0) if (e->oldSize().width() == 0 || e->oldSize().height() == 0)
break; break;
qreal stretch_x = e->size().width() / qreal(e->oldSize().width()); qreal stretch_x = e->size().width() / qreal(e->oldSize().width());
qreal stretch_y = e->size().height() / qreal(e->oldSize().height()); qreal stretch_y = e->size().height() / qreal(e->oldSize().height());
for (int i=0; i<m_points.size(); ++i) { for (int i=0; i<m_points.size(); ++i)
QPointF p = m_points[i]; {
movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false); QPointF p = m_points[i];
} movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false);
}
firePointChange(); firePointChange();
break; break;
} }
case QEvent::Paint: case QEvent::Paint:
{ {
QWidget *that_widget = m_widget; QWidget *that_widget = m_widget;
m_widget = 0; m_widget = 0;
QApplication::sendEvent(object, event); QApplication::sendEvent(object, event);
m_widget = that_widget; m_widget = that_widget;
paintPoints(); paintPoints();
return true; return true;
} }
default: default:
break; break;
} }
} }
return false; return false;
} }
void HoverPoints::paintPoints() void HoverPoints::paintPoints()
{ {
QPainter p; QPainter p;
p.begin(m_widget); p.begin(m_widget);
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
p.setBrush(m_gradient); p.setBrush(m_gradient);
//p.setBrush(QColor(230,230,230)); //p.setBrush(QColor(230,230,230));
p.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); p.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
p.drawRoundedRect(QRect(1, 1, m_widget->width() - 2, m_widget->height() - 2), 4.0, 4.0); p.drawRoundedRect(QRect(1, 1, m_widget->width() - 2, m_widget->height() - 2), 4.0, 4.0);
p.setBrush(QBrush()); p.setBrush(QBrush());
if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) { if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection)
p.setPen(m_connectionPen); {
p.setPen(m_connectionPen);
if (m_connectionType == CurveConnection) { if (m_connectionType == CurveConnection)
QPainterPath path; {
path.moveTo(m_points.at(0)); QPainterPath path;
for (int i=1; i<m_points.size(); ++i) { path.moveTo(m_points.at(0));
QPointF p1 = m_points.at(i-1); for (int i=1; i<m_points.size(); ++i)
QPointF p2 = m_points.at(i); {
qreal distance = p2.x() - p1.x(); QPointF p1 = m_points.at(i-1);
QPointF p2 = m_points.at(i);
qreal distance = p2.x() - p1.x();
path.cubicTo(p1.x() + distance / 2, p1.y(), path.cubicTo(p1.x() + distance / 2, p1.y(),
p1.x() + distance / 2, p2.y(), p1.x() + distance / 2, p2.y(),
p2.x(), p2.y()); p2.x(), p2.y());
} }
p.drawPath(path); p.drawPath(path);
} else { }
p.drawPolyline(m_points); else
} {
} p.drawPolyline(m_points);
}
}
p.setPen(m_pointPen); p.setPen(m_pointPen);
p.setBrush(m_pointBrush); p.setBrush(m_pointBrush);
for (int i=0; i<m_points.size(); ++i) { for (int i=0; i<m_points.size(); ++i)
QRectF bounds = pointBoundingRect(i); {
if (m_shape == CircleShape) QRectF bounds = pointBoundingRect(i);
p.drawEllipse(bounds); if (m_shape == CircleShape)
else p.drawEllipse(bounds);
p.drawRect(bounds); else
} p.drawRect(bounds);
}
} }
static QPointF bound_point(const QPointF &point, const QRectF &bounds, int lock) static QPointF bound_point(const QPointF &point, const QRectF &bounds, int lock)
{ {
QPointF p = point; QPointF p = point;
qreal left = bounds.left(); qreal left = bounds.left();
qreal right = bounds.right(); qreal right = bounds.right();
qreal top = bounds.top(); qreal top = bounds.top();
qreal bottom = bounds.bottom(); qreal bottom = bounds.bottom();
if (p.x() < left || (lock & HoverPoints::LockToLeft)) p.setX(left); if (p.x() < left || (lock & HoverPoints::LockToLeft)) p.setX(left);
else if (p.x() > right || (lock & HoverPoints::LockToRight)) p.setX(right); else if (p.x() > right || (lock & HoverPoints::LockToRight)) p.setX(right);
/* if (p.y() < top || (lock & HoverPoints::LockToTop)) p.setY(top); /* if (p.y() < top || (lock & HoverPoints::LockToTop)) p.setY(top);
else if (p.y() > bottom || (lock & HoverPoints::LockToBottom)) p.setY(bottom); else if (p.y() > bottom || (lock & HoverPoints::LockToBottom)) p.setY(bottom);
*/ */
return p; return p;
} }
void HoverPoints::setPoints(const QPolygonF &points) void HoverPoints::setPoints(const QPolygonF &points)
{ {
if (points.size() != m_points.size()) if (points.size() != m_points.size())
m_fingerPointMapping.clear(); m_fingerPointMapping.clear();
m_points.clear(); m_points.clear();
for (int i=0; i<points.size(); ++i) for (int i=0; i<points.size(); ++i)
m_points << bound_point(points.at(i), boundingRect(), 0); m_points << bound_point(points.at(i), boundingRect(), 0);
m_locks.clear(); m_locks.clear();
if (m_points.size() > 0) { if (m_points.size() > 0)
m_locks.resize(m_points.size()); {
m_locks.resize(m_points.size());
m_locks.fill(0); m_locks.fill(0);
} }
} }
void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate) void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate)
{ {
m_points[index] = bound_point(point, boundingRect(), m_locks.at(index)); m_points[index] = bound_point(point, boundingRect(), m_locks.at(index));
if (emitUpdate) if (emitUpdate)
firePointChange(); firePointChange();
} }
void HoverPoints::createGradient() void HoverPoints::createGradient()
{ {
m_gradient.setCoordinateMode(QGradient::ObjectBoundingMode); m_gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
m_gradient.setCenter(0.45, 0.50); m_gradient.setCenter(0.45, 0.50);
m_gradient.setFocalPoint(0.40, 0.45); m_gradient.setFocalPoint(0.40, 0.45);
m_gradient.setColorAt(0.0, QColor(175, 216, 252)); m_gradient.setColorAt(0.0, QColor(175, 216, 252));
m_gradient.setColorAt(0.4, QColor(151, 183, 220)); m_gradient.setColorAt(0.4, QColor(151, 183, 220));
m_gradient.setColorAt(0.8, QColor(86, 126, 191)); m_gradient.setColorAt(0.8, QColor(86, 126, 191));
} }
inline static bool x_less_than(const QPointF &p1, const QPointF &p2) inline static bool x_less_than(const QPointF &p1, const QPointF &p2)
{ {
return p1.x() < p2.x(); return p1.x() < p2.x();
} }
inline static bool y_less_than(const QPointF &p1, const QPointF &p2) inline static bool y_less_than(const QPointF &p1, const QPointF &p2)
{ {
return p1.y() < p2.y(); return p1.y() < p2.y();
} }
void HoverPoints::firePointChange() void HoverPoints::firePointChange()
{ {
if (m_sortType != NoSort) { if (m_sortType != NoSort)
{
QPointF oldCurrent; QPointF oldCurrent;
if (m_currentIndex != -1) { if (m_currentIndex != -1)
oldCurrent = m_points[m_currentIndex]; {
} oldCurrent = m_points[m_currentIndex];
}
if (m_sortType == XSort) if (m_sortType == XSort)
qSort(m_points.begin(), m_points.end(), x_less_than); qSort(m_points.begin(), m_points.end(), x_less_than);
else if (m_sortType == YSort) else if (m_sortType == YSort)
qSort(m_points.begin(), m_points.end(), y_less_than); qSort(m_points.begin(), m_points.end(), y_less_than);
// Compensate for changed order... // Compensate for changed order...
if (m_currentIndex != -1) { if (m_currentIndex != -1)
for (int i=0; i<m_points.size(); ++i) { {
if (m_points[i] == oldCurrent) { for (int i=0; i<m_points.size(); ++i)
m_currentIndex = i; {
break; if (m_points[i] == oldCurrent)
} {
} m_currentIndex = i;
} break;
} }
Q_EMIT pointsChanged(m_points); }
}
}
Q_EMIT pointsChanged(m_points);
} }

View file

@ -48,118 +48,167 @@ QT_FORWARD_DECLARE_CLASS(QBypassWidget)
class HoverPoints : public QObject class HoverPoints : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum PointShape { enum PointShape
CircleShape, {
RectangleShape CircleShape,
}; RectangleShape
};
enum LockType { enum LockType
LockToLeft = 0x01, {
LockToRight = 0x02, LockToLeft = 0x01,
LockToTop = 0x04, LockToRight = 0x02,
LockToBottom = 0x08 LockToTop = 0x04,
}; LockToBottom = 0x08
};
enum SortType { enum SortType
NoSort, {
XSort, NoSort,
YSort XSort,
}; YSort
};
enum ConnectionType { enum ConnectionType
NoConnection, {
LineConnection, NoConnection,
CurveConnection LineConnection,
}; CurveConnection
};
HoverPoints(QWidget *widget, PointShape shape); HoverPoints(QWidget *widget, PointShape shape);
bool eventFilter(QObject *object, QEvent *event); bool eventFilter(QObject *object, QEvent *event);
void paintPoints(); void paintPoints();
inline QRectF boundingRect() const; inline QRectF boundingRect() const;
void setBoundingRect(const QRectF &boundingRect) { m_bounds = boundingRect; } void setBoundingRect(const QRectF &boundingRect)
{
m_bounds = boundingRect;
}
QPolygonF points() const { return m_points; } QPolygonF points() const
void setPoints(const QPolygonF &points); {
return m_points;
}
void setPoints(const QPolygonF &points);
QSizeF pointSize() const { return m_pointSize; } QSizeF pointSize() const
void setPointSize(const QSizeF &size) { m_pointSize = size; } {
return m_pointSize;
}
void setPointSize(const QSizeF &size)
{
m_pointSize = size;
}
SortType sortType() const { return m_sortType; } SortType sortType() const
void setSortType(SortType sortType) { m_sortType = sortType; } {
return m_sortType;
}
void setSortType(SortType sortType)
{
m_sortType = sortType;
}
ConnectionType connectionType() const { return m_connectionType; } ConnectionType connectionType() const
void setConnectionType(ConnectionType connectionType) { m_connectionType = connectionType; } {
return m_connectionType;
}
void setConnectionType(ConnectionType connectionType)
{
m_connectionType = connectionType;
}
void setConnectionPen(const QPen &pen) { m_connectionPen = pen; } void setConnectionPen(const QPen &pen)
void setShapePen(const QPen &pen) { m_pointPen = pen; } {
void setShapeBrush(const QBrush &brush) { m_pointBrush = brush; } m_connectionPen = pen;
}
void setShapePen(const QPen &pen)
{
m_pointPen = pen;
}
void setShapeBrush(const QBrush &brush)
{
m_pointBrush = brush;
}
void setPointLock(int pos, LockType lock) { m_locks[pos] = lock; } void setPointLock(int pos, LockType lock)
{
m_locks[pos] = lock;
}
void setEditable(bool editable) { m_editable = editable; } void setEditable(bool editable)
bool editable() const { return m_editable; } {
m_editable = editable;
}
bool editable() const
{
return m_editable;
}
public Q_SLOTS: public Q_SLOTS:
void setEnabled(bool enabled); void setEnabled(bool enabled);
void setDisabled(bool disabled) { setEnabled(!disabled); } void setDisabled(bool disabled)
{
setEnabled(!disabled);
}
Q_SIGNALS: Q_SIGNALS:
void pointsChanged(const QPolygonF &points); void pointsChanged(const QPolygonF &points);
public: public:
void firePointChange(); void firePointChange();
private: private:
inline QRectF pointBoundingRect(int i) const; inline QRectF pointBoundingRect(int i) const;
void movePoint(int i, const QPointF &newPos, bool emitChange = true); void movePoint(int i, const QPointF &newPos, bool emitChange = true);
void createGradient(); void createGradient();
QWidget *m_widget; QWidget *m_widget;
QPolygonF m_points; QPolygonF m_points;
QRectF m_bounds; QRectF m_bounds;
PointShape m_shape; PointShape m_shape;
SortType m_sortType; SortType m_sortType;
ConnectionType m_connectionType; ConnectionType m_connectionType;
QVector<uint> m_locks; QVector<uint> m_locks;
QSizeF m_pointSize; QSizeF m_pointSize;
int m_currentIndex; int m_currentIndex;
int m_minCountPoints; int m_minCountPoints;
bool m_editable; bool m_editable;
bool m_enabled; bool m_enabled;
QHash<int, int> m_fingerPointMapping; QHash<int, int> m_fingerPointMapping;
QPen m_pointPen; QPen m_pointPen;
QBrush m_pointBrush; QBrush m_pointBrush;
QPen m_connectionPen; QPen m_connectionPen;
QRadialGradient m_gradient; QRadialGradient m_gradient;
}; };
inline QRectF HoverPoints::pointBoundingRect(int i) const inline QRectF HoverPoints::pointBoundingRect(int i) const
{ {
QPointF p = m_points.at(i); QPointF p = m_points.at(i);
qreal w = m_pointSize.width(); qreal w = m_pointSize.width();
qreal h = m_pointSize.height(); qreal h = m_pointSize.height();
qreal x = p.x() - w / 2; qreal x = p.x() - w / 2;
qreal y = p.y() - h / 2; qreal y = p.y() - h / 2;
return QRectF(x, y, w, h); return QRectF(x, y, w, h);
} }
inline QRectF HoverPoints::boundingRect() const inline QRectF HoverPoints::boundingRect() const
{ {
if (m_bounds.isEmpty()) if (m_bounds.isEmpty())
return m_widget->rect(); return m_widget->rect();
else else
return m_bounds; return m_bounds;
} }
#endif // HOVERPOINTS_H #endif // HOVERPOINTS_H

View file

@ -29,10 +29,11 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CLocatedBindablePage::CLocatedBindablePage(QWidget *parent) CLocatedBindablePage::CLocatedBindablePage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -384,8 +385,8 @@ void CLocatedBindablePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLoc
if (dynamic_cast<NL3D::CPSTexturedParticle *>(_Bindable)) if (dynamic_cast<NL3D::CPSTexturedParticle *>(_Bindable))
{ {
_ui.texAnimWidget->setCurrentTextureAnim(dynamic_cast<NL3D::CPSTexturedParticle *>(_Bindable), _ui.texAnimWidget->setCurrentTextureAnim(dynamic_cast<NL3D::CPSTexturedParticle *>(_Bindable),
dynamic_cast<NL3D::CPSMultiTexturedParticle *>(_Bindable), dynamic_cast<NL3D::CPSMultiTexturedParticle *>(_Bindable),
_Node); _Node);
_ui.texAnimWidget->show(); _ui.texAnimWidget->show();
_ui.tabWidget->addTab(_ui.texturePage, tr("Texture param")); _ui.tabWidget->addTab(_ui.texturePage, tr("Texture param"));

View file

@ -37,7 +37,8 @@
#include "ps_wrapper.h" #include "ps_wrapper.h"
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CLocatedBindablePage @class CLocatedBindablePage
@ -45,7 +46,7 @@ namespace NLQT {
*/ */
class CLocatedBindablePage: public QWidget class CLocatedBindablePage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CLocatedBindablePage(QWidget *parent = 0); CLocatedBindablePage(QWidget *parent = 0);
@ -80,166 +81,313 @@ private:
struct CSizeWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CSizeWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSSizedParticle *S; NL3D::CPSSizedParticle *S;
float get(void) const { return S->getSize(); } float get(void) const
void set(const float &v) { S->setSize(v); } {
scheme_type *getScheme(void) const { return S->getSizeScheme(); } return S->getSize();
void setScheme(scheme_type *s) { S->setSizeScheme(s); } }
void set(const float &v)
{
S->setSize(v);
}
scheme_type *getScheme(void) const
{
return S->getSizeScheme();
}
void setScheme(scheme_type *s)
{
S->setSizeScheme(s);
}
} _SizeWrapper; } _SizeWrapper;
/// Color /// Color
struct CColorWrapper : public IPSWrapperRGBA, IPSSchemeWrapperRGBA struct CColorWrapper : public IPSWrapperRGBA, IPSSchemeWrapperRGBA
{ {
NL3D::CPSColoredParticle *S; NL3D::CPSColoredParticle *S;
NLMISC::CRGBA get(void) const { return S->getColor(); } NLMISC::CRGBA get(void) const
void set(const NLMISC::CRGBA &v) { S->setColor(v); } {
scheme_type *getScheme(void) const { return S->getColorScheme(); } return S->getColor();
void setScheme(scheme_type *s) { S->setColorScheme(s); } }
void set(const NLMISC::CRGBA &v)
{
S->setColor(v);
}
scheme_type *getScheme(void) const
{
return S->getColorScheme();
}
void setScheme(scheme_type *s)
{
S->setColorScheme(s);
}
} _ColorWrapper; } _ColorWrapper;
/// Angle 2D /// Angle 2D
struct CAngle2DWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CAngle2DWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSRotated2DParticle *S; NL3D::CPSRotated2DParticle *S;
float get(void) const { return S->getAngle2D(); } float get(void) const
void set(const float &v) { S->setAngle2D(v); } {
scheme_type *getScheme(void) const { return S->getAngle2DScheme(); } return S->getAngle2D();
void setScheme(scheme_type *s) { S->setAngle2DScheme(s); } }
void set(const float &v)
{
S->setAngle2D(v);
}
scheme_type *getScheme(void) const
{
return S->getAngle2DScheme();
}
void setScheme(scheme_type *s)
{
S->setAngle2DScheme(s);
}
} _Angle2DWrapper; } _Angle2DWrapper;
/// Plane basis /// Plane basis
struct CPlaneBasisWrapper : public IPSWrapper<NL3D::CPlaneBasis>, IPSSchemeWrapper<NL3D::CPlaneBasis> struct CPlaneBasisWrapper : public IPSWrapper<NL3D::CPlaneBasis>, IPSSchemeWrapper<NL3D::CPlaneBasis>
{ {
NL3D::CPSRotated3DPlaneParticle *S; NL3D::CPSRotated3DPlaneParticle *S;
NL3D::CPlaneBasis get(void) const { return S->getPlaneBasis(); } NL3D::CPlaneBasis get(void) const
void set(const NL3D::CPlaneBasis &p) { S->setPlaneBasis(p); } {
scheme_type *getScheme(void) const { return S->getPlaneBasisScheme(); } return S->getPlaneBasis();
void setScheme(scheme_type *s) { S->setPlaneBasisScheme(s); } }
void set(const NL3D::CPlaneBasis &p)
{
S->setPlaneBasis(p);
}
scheme_type *getScheme(void) const
{
return S->getPlaneBasisScheme();
}
void setScheme(scheme_type *s)
{
S->setPlaneBasisScheme(s);
}
} _PlaneBasisWrapper; } _PlaneBasisWrapper;
/// Motion blur coeff /// Motion blur coeff
struct CMotionBlurCoeffWrapper : public IPSWrapperFloat struct CMotionBlurCoeffWrapper : public IPSWrapperFloat
{ {
NL3D::CPSFaceLookAt *P; NL3D::CPSFaceLookAt *P;
float get(void) const { return P->getMotionBlurCoeff(); } float get(void) const
void set(const float &v) { P->setMotionBlurCoeff(v); } {
return P->getMotionBlurCoeff();
}
void set(const float &v)
{
P->setMotionBlurCoeff(v);
}
} _MotionBlurCoeffWrapper; } _MotionBlurCoeffWrapper;
struct CMotionBlurThresholdWrapper : public IPSWrapperFloat struct CMotionBlurThresholdWrapper : public IPSWrapperFloat
{ {
NL3D::CPSFaceLookAt *P; NL3D::CPSFaceLookAt *P;
float get(void) const { return P->getMotionBlurThreshold(); } float get(void) const
void set(const float &v) { P->setMotionBlurThreshold(v); } {
return P->getMotionBlurThreshold();
}
void set(const float &v)
{
P->setMotionBlurThreshold(v);
}
} _MotionBlurThresholdWrapper; } _MotionBlurThresholdWrapper;
/// Fanlight /// Fanlight
struct CFanLightWrapper : public IPSWrapperUInt struct CFanLightWrapper : public IPSWrapperUInt
{ {
NL3D::CPSFanLight *P; NL3D::CPSFanLight *P;
uint32 get(void) const { return P->getNbFans(); } uint32 get(void) const
void set(const uint32 &v) { P->setNbFans(v); } {
return P->getNbFans();
}
void set(const uint32 &v)
{
P->setNbFans(v);
}
} _FanLightWrapper; } _FanLightWrapper;
struct CFanLightSmoothnessWrapper : public IPSWrapperUInt struct CFanLightSmoothnessWrapper : public IPSWrapperUInt
{ {
NL3D::CPSFanLight *P; NL3D::CPSFanLight *P;
uint32 get(void) const { return P->getPhaseSmoothness(); } uint32 get(void) const
void set(const uint32 &v) { P->setPhaseSmoothness(v); } {
return P->getPhaseSmoothness();
}
void set(const uint32 &v)
{
P->setPhaseSmoothness(v);
}
} _FanLightSmoothnessWrapper; } _FanLightSmoothnessWrapper;
struct CFanLightPhase : public IPSWrapperFloat struct CFanLightPhase : public IPSWrapperFloat
{ {
NL3D::CPSFanLight *P; NL3D::CPSFanLight *P;
float get(void) const { return P->getPhaseSpeed(); } float get(void) const
void set(const float &v) { P->setPhaseSpeed(v); } {
return P->getPhaseSpeed();
}
void set(const float &v)
{
P->setPhaseSpeed(v);
}
} _FanLightPhaseWrapper; } _FanLightPhaseWrapper;
struct CFanLightIntensityWrapper : public IPSWrapperFloat struct CFanLightIntensityWrapper : public IPSWrapperFloat
{ {
NL3D::CPSFanLight *P; NL3D::CPSFanLight *P;
float get(void) const { return P->getMoveIntensity(); } float get(void) const
void set(const float &v) { P->setMoveIntensity(v); } {
return P->getMoveIntensity();
}
void set(const float &v)
{
P->setMoveIntensity(v);
}
} _FanLightIntensityWrapper; } _FanLightIntensityWrapper;
/// Ribbon / tail dot /// Ribbon / tail dot
struct CTailParticleWrapper : public IPSWrapperUInt struct CTailParticleWrapper : public IPSWrapperUInt
{ {
NL3D::CPSTailParticle *P; NL3D::CPSTailParticle *P;
uint32 get(void) const { return P->getTailNbSeg(); } uint32 get(void) const
void set(const uint32 &v) { P->setTailNbSeg(v); } {
return P->getTailNbSeg();
}
void set(const uint32 &v)
{
P->setTailNbSeg(v);
}
} _TailParticleWrapper; } _TailParticleWrapper;
/// Duration of segment for a ribbon /// Duration of segment for a ribbon
struct CSegDurationWrapper : public IPSWrapperFloat struct CSegDurationWrapper : public IPSWrapperFloat
{ {
NL3D::CPSRibbonBase *R; NL3D::CPSRibbonBase *R;
float get(void) const { return R->getSegDuration(); } float get(void) const
void set(const float &v) { R->setSegDuration(v); } {
return R->getSegDuration();
}
void set(const float &v)
{
R->setSegDuration(v);
}
} _SegDurationWrapper; } _SegDurationWrapper;
/// Shockwave /// Shockwave
struct CRadiusCutWrapper : public IPSWrapperFloat struct CRadiusCutWrapper : public IPSWrapperFloat
{ {
NL3D::CPSShockWave *S; NL3D::CPSShockWave *S;
float get(void) const { return S->getRadiusCut(); } float get(void) const
void set(const float &v) { S->setRadiusCut(v); } {
return S->getRadiusCut();
}
void set(const float &v)
{
S->setRadiusCut(v);
}
} _RadiusCutWrapper; } _RadiusCutWrapper;
struct CShockWaveNbSegWrapper : public IPSWrapperUInt struct CShockWaveNbSegWrapper : public IPSWrapperUInt
{ {
NL3D::CPSShockWave *S; NL3D::CPSShockWave *S;
uint32 get(void) const { return S->getNbSegs(); } uint32 get(void) const
void set(const uint32 &v) { S->setNbSegs(v); } {
return S->getNbSegs();
}
void set(const uint32 &v)
{
S->setNbSegs(v);
}
} _ShockWaveNbSegWrapper; } _ShockWaveNbSegWrapper;
struct CShockWaveUFactorWrapper : public IPSWrapperFloat struct CShockWaveUFactorWrapper : public IPSWrapperFloat
{ {
NL3D::CPSShockWave *S; NL3D::CPSShockWave *S;
float get(void) const { return S->getUFactor(); } float get(void) const
void set(const float &v) { S->setUFactor(v); } {
return S->getUFactor();
}
void set(const float &v)
{
S->setUFactor(v);
}
} _ShockWaveUFactorWrapper; } _ShockWaveUFactorWrapper;
/// Unanimated texture /// Unanimated texture
struct CTextureNoAnimWrapper : public IPSWrapperTexture struct CTextureNoAnimWrapper : public IPSWrapperTexture
{ {
NL3D::CPSTexturedParticleNoAnim *TP; NL3D::CPSTexturedParticleNoAnim *TP;
virtual NL3D::ITexture *get(void) { return TP->getTexture(); } virtual NL3D::ITexture *get(void)
virtual void set(NL3D::ITexture *t) { TP->setTexture(t); } {
return TP->getTexture();
}
virtual void set(NL3D::ITexture *t)
{
TP->setTexture(t);
}
} _TextureNoAnimWrapper; } _TextureNoAnimWrapper;
/// u / v factors for ribbon /// u / v factors for ribbon
struct CRibbonUFactorWrapper : public IPSWrapperFloat struct CRibbonUFactorWrapper : public IPSWrapperFloat
{ {
NL3D::CPSRibbon *R; NL3D::CPSRibbon *R;
float get(void) const { return R->getUFactor(); } float get(void) const
void set(const float &u) { R->setTexFactor(u, R->getVFactor()); } {
return R->getUFactor();
}
void set(const float &u)
{
R->setTexFactor(u, R->getVFactor());
}
} _RibbonUFactorWrapper; } _RibbonUFactorWrapper;
struct CRibbonVFactorWrapper : public IPSWrapperFloat struct CRibbonVFactorWrapper : public IPSWrapperFloat
{ {
NL3D::CPSRibbon *R; NL3D::CPSRibbon *R;
float get(void) const { return R->getVFactor(); } float get(void) const
void set(const float &v) { R->setTexFactor(R->getUFactor(), v); } {
return R->getVFactor();
}
void set(const float &v)
{
R->setTexFactor(R->getUFactor(), v);
}
} _RibbonVFactorWrapper; } _RibbonVFactorWrapper;
struct CRibbonLengthWrapper : IPSWrapperFloat struct CRibbonLengthWrapper : IPSWrapperFloat
{ {
NL3D::CPSRibbonBase *R; NL3D::CPSRibbonBase *R;
float get() const { return R->getRibbonLength(); } float get() const
void set(const float &v) { R->setRibbonLength(v); } {
return R->getRibbonLength();
}
void set(const float &v)
{
R->setRibbonLength(v);
}
} _RibbonLengthWrapper; } _RibbonLengthWrapper;
struct CLODDegradationWrapper : IPSWrapperFloat struct CLODDegradationWrapper : IPSWrapperFloat
{ {
NL3D::CPSRibbonBase *R; NL3D::CPSRibbonBase *R;
float get() const { return R->getLODDegradation(); } float get() const
void set(const float &v) { R->setLODDegradation(v); } {
return R->getLODDegradation();
}
void set(const float &v)
{
R->setLODDegradation(v);
}
} _LODDegradationWrapper; } _LODDegradationWrapper;
void updateValidWidgetForAlignOnMotion(bool align); void updateValidWidgetForAlignOnMotion(bool align);
void updateSizeControl(); void updateSizeControl();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
void hideAllWidget(); void hideAllWidget();

View file

@ -30,10 +30,11 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CLocatedPage::CLocatedPage(QWidget *parent) CLocatedPage::CLocatedPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -89,10 +90,10 @@ void CLocatedPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocated *lo
_ui.massWidget->setWorkspaceNode(_Node); _ui.massWidget->setWorkspaceNode(_Node);
_ui.massWidget->updateUi(); _ui.massWidget->updateUi();
if (_Located->getOwner()) if (_Located->getOwner())
_ui.maxNumParticleWidget->setEnabled(!_Located->getOwner()->getAutoCountFlag()); _ui.maxNumParticleWidget->setEnabled(!_Located->getOwner()->getAutoCountFlag());
_ui.maxNumParticleWidget->setValue(_Located->getMaxSize(), false); _ui.maxNumParticleWidget->setValue(_Located->getMaxSize(), false);
_ui.coordSystemComboBox->setCurrentIndex(int(_Located->getMatrixMode())); _ui.coordSystemComboBox->setCurrentIndex(int(_Located->getMatrixMode()));
_ui.limitedLifeTimeCheckBox->setChecked(!_Located->getLastForever()); _ui.limitedLifeTimeCheckBox->setChecked(!_Located->getLastForever());
@ -131,9 +132,9 @@ void CLocatedPage::setLimitedLifeTime(bool state)
if (forceApplied) if (forceApplied)
{ {
int ret = QMessageBox::critical(this, tr("NeL particle system editor"), int ret = QMessageBox::critical(this, tr("NeL particle system editor"),
tr("The object has force(s) applied on it. If it last forever, " tr("The object has force(s) applied on it. If it last forever, "
"its motion can become instable after a while. Continue anyway ? (clue : you've been warned ..)"), "its motion can become instable after a while. Continue anyway ? (clue : you've been warned ..)"),
QMessageBox::Ok | QMessageBox::Cancel); QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Cancel) if (ret == QMessageBox::Cancel)
{ {
@ -148,9 +149,9 @@ void CLocatedPage::setLimitedLifeTime(bool state)
else else
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first."), "and thus, should have a finite duration. Please remove that flag first."),
QMessageBox::Ok); QMessageBox::Ok);
_ui.limitedLifeTimeCheckBox->setChecked(true); _ui.limitedLifeTimeCheckBox->setChecked(true);
} }
} }
@ -184,10 +185,10 @@ void CLocatedPage::setParametricMotion(bool state)
void CLocatedPage::editTriggerOnDeath() void CLocatedPage::editTriggerOnDeath()
{ {
bool ok; bool ok;
int i = QInputDialog::getInt(this, tr("Set the extern ID"), int i = QInputDialog::getInt(this, tr("Set the extern ID"),
tr("0 means no extern access."), tr("0 means no extern access."),
_Located->getTriggerEmitterID(), 0, 9999, 1, &ok); _Located->getTriggerEmitterID(), 0, 9999, 1, &ok);
if (ok) if (ok)
{ {
_Located->setTriggerEmitterID(uint32(i)); _Located->setTriggerEmitterID(uint32(i));
@ -246,7 +247,7 @@ void CLocatedPage::updateIntegrable(void)
void CLocatedPage::updateTriggerOnDeath(void) void CLocatedPage::updateTriggerOnDeath(void)
{ {
nlassert(_Located); nlassert(_Located);
bool enable = !_Located->getLastForever(); bool enable = !_Located->getLastForever();
_ui.trigerOnDeathCheckBox->setEnabled(enable); _ui.trigerOnDeathCheckBox->setEnabled(enable);
_ui.editPushButton->setEnabled(enable && _Located->isTriggerOnDeathEnabled()); _ui.editPushButton->setEnabled(enable && _Located->isTriggerOnDeathEnabled());

View file

@ -33,10 +33,11 @@
namespace NL3D namespace NL3D
{ {
class CPSLocated; class CPSLocated;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CLocatedPage @class CLocatedPage
@ -44,7 +45,7 @@ namespace NLQT {
*/ */
class CLocatedPage: public QWidget class CLocatedPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CLocatedPage(QWidget *parent = 0); CLocatedPage(QWidget *parent = 0);
@ -70,21 +71,39 @@ private:
/// wrapper to tune the mass of particles /// wrapper to tune the mass of particles
struct CMassWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CMassWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSLocated *Located; NL3D::CPSLocated *Located;
float get(void) const { return Located->getInitialMass(); } float get(void) const
void set(const float &v) { Located->setInitialMass(v); } {
virtual scheme_type *getScheme(void) const { return Located->getMassScheme(); } return Located->getInitialMass();
virtual void setScheme(scheme_type *s) { Located->setMassScheme(s); } }
void set(const float &v)
{
Located->setInitialMass(v);
}
virtual scheme_type *getScheme(void) const
{
return Located->getMassScheme();
}
virtual void setScheme(scheme_type *s)
{
Located->setMassScheme(s);
}
} _MassWrapper; } _MassWrapper;
struct CLifeWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CLifeWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSLocated *Located; NL3D::CPSLocated *Located;
CWorkspaceNode *Node; CWorkspaceNode *Node;
float get(void) const { return Located->getInitialLife(); } float get(void) const
void set(const float &v); {
virtual scheme_type *getScheme(void) const { return Located->getLifeScheme(); } return Located->getInitialLife();
virtual void setScheme(scheme_type *s); }
void set(const float &v);
virtual scheme_type *getScheme(void) const
{
return Located->getLifeScheme();
}
virtual void setScheme(scheme_type *s);
} _LifeWrapper; } _LifeWrapper;
/// the located this dialog is editing /// the located this dialog is editing
@ -98,7 +117,10 @@ private:
/// update the 'trigger on death' control /// update the 'trigger on death' control
void updateTriggerOnDeath(void); void updateTriggerOnDeath(void);
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
Ui::CLocatedPage _ui; Ui::CLocatedPage _ui;
}; /* class CLocatedPage */ }; /* class CLocatedPage */

View file

@ -32,9 +32,11 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
namespace { namespace
{
CFileDisplayer *s_FileDisplayer = NULL; CFileDisplayer *s_FileDisplayer = NULL;
@ -57,7 +59,7 @@ CFileDisplayer *s_FileDisplayer = NULL;
sint main(int argc, char **argv) sint main(int argc, char **argv)
{ {
// go nel! // go nel!
{ {
// use log.log if NEL_LOG_IN_FILE and NLQT_USE_LOG_LOG defined as 1 // use log.log if NEL_LOG_IN_FILE and NLQT_USE_LOG_LOG defined as 1
createDebug(NULL, NLQT_USE_LOG_LOG, false); createDebug(NULL, NLQT_USE_LOG_LOG, false);

View file

@ -49,14 +49,15 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
CMainWindow::CMainWindow(QWidget *parent) CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent), : QMainWindow(parent),
_isGraphicsInitialized(false), _isGraphicsEnabled(false), _isGraphicsInitialized(false), _isGraphicsEnabled(false),
_isSoundInitialized(false), _isSoundEnabled(false), _isSoundInitialized(false), _isSoundEnabled(false),
_isLandscapeInitialized(false), _isLandscapeEnabled(false), _isLandscapeInitialized(false), _isLandscapeEnabled(false),
_GraphicsViewport(NULL), _lastDir(".") _GraphicsViewport(NULL), _lastDir(".")
{ {
nldebug("CMainWindow::CMainWindow:"); nldebug("CMainWindow::CMainWindow:");
@ -107,7 +108,7 @@ CMainWindow::CMainWindow(QWidget *parent)
CMainWindow::~CMainWindow() CMainWindow::~CMainWindow()
{ {
nldebug("CMainWindow::~CMainWindow:"); nldebug("CMainWindow::~CMainWindow:");
// save state & geometry of window and widgets // save state & geometry of window and widgets
QSettings settings("object_viewer_qt.ini", QSettings::IniFormat); QSettings settings("object_viewer_qt.ini", QSettings::IniFormat);
@ -159,10 +160,10 @@ int CMainWindow::getFrameRate()
void CMainWindow::open() void CMainWindow::open()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(this, QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open NeL data file"), _lastDir, tr("Open NeL data file"), _lastDir,
tr("All NeL files (*.shape *.ps);;" tr("All NeL files (*.shape *.ps);;"
"NeL shape files (*.shape);;" "NeL shape files (*.shape);;"
"NeL particle system files (*.ps)")); "NeL particle system files (*.ps)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileNames.isEmpty()) if (!fileNames.isEmpty())
@ -171,11 +172,11 @@ void CMainWindow::open()
_lastDir = QFileInfo(list.front()).absolutePath(); _lastDir = QFileInfo(list.front()).absolutePath();
QString skelFileName = QFileDialog::getOpenFileName(this, QString skelFileName = QFileDialog::getOpenFileName(this,
tr("Open skeleton file"), _lastDir, tr("Open skeleton file"), _lastDir,
tr("NeL skeleton file (*.skel)")); tr("NeL skeleton file (*.skel)"));
Q_FOREACH(QString fileName, list) Q_FOREACH(QString fileName, list)
loadFile(fileName, skelFileName); loadFile(fileName, skelFileName);
_AnimationSetDialog->updateListObject(); _AnimationSetDialog->updateListObject();
_AnimationSetDialog->updateListAnim(); _AnimationSetDialog->updateListAnim();
@ -203,14 +204,14 @@ void CMainWindow::settings()
void CMainWindow::about() void CMainWindow::about()
{ {
QMessageBox::about(this, tr("About Object Viewer Qt"), QMessageBox::about(this, tr("About Object Viewer Qt"),
tr("<h2>Object Viewer Qt 8-)</h2>" tr("<h2>Object Viewer Qt 8-)</h2>"
"<p> Authors: dnk-88, sfb, Kaetemi, kervala <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__)); "<p> Authors: dnk-88, sfb, Kaetemi, kervala <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
} }
void CMainWindow::updateStatusBar() void CMainWindow::updateStatusBar()
{ {
if (_isGraphicsInitialized) if (_isGraphicsInitialized)
statusBar()->showMessage(QString(Modules::objView().getDriver()->getVideocardInformation())); statusBar()->showMessage(QString(Modules::objView().getDriver()->getVideocardInformation()));
} }
void CMainWindow::updateInitialization(bool visible) void CMainWindow::updateInitialization(bool visible)
@ -298,7 +299,8 @@ void CMainWindow::updateInitialization(bool visible)
} }
} }
} while (!done); }
while (!done);
} }
void CMainWindow::createActions() void CMainWindow::createActions()

View file

@ -30,11 +30,13 @@
// Project includes // Project includes
namespace NLMISC { namespace NLMISC
class CConfigFile; {
class CConfigFile;
} }
namespace NLQT { namespace NLQT
{
class CGraphicsViewport; class CGraphicsViewport;
class CAnimationDialog; class CAnimationDialog;
@ -63,7 +65,9 @@ public:
int getFrameRate(); int getFrameRate();
CSkeletonTreeModel *getSkeletonModel() const CSkeletonTreeModel *getSkeletonModel() const
{ return _SkeletonTreeModel; } {
return _SkeletonTreeModel;
}
private Q_SLOTS: private Q_SLOTS:
void open(); void open();

View file

@ -34,10 +34,11 @@
#include "mesh_widget.h" #include "mesh_widget.h"
#include "morph_mesh_dialog.h" #include "morph_mesh_dialog.h"
namespace NLQT { namespace NLQT
{
CMeshWidget::CMeshWidget(QWidget *parent) CMeshWidget::CMeshWidget(QWidget *parent)
: QGroupBox(parent) : QGroupBox(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -79,8 +80,8 @@ void CMeshWidget::setCurrentShape(CWorkspaceNode *ownerNode, NL3D::CPSShapeParti
void CMeshWidget::browseShape() void CMeshWidget::browseShape()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("NeL shape file (*.shape)")); tr("NeL shape file (*.shape)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
@ -137,7 +138,7 @@ void CMeshWidget::editMorph()
void CMeshWidget::updateForMorph() void CMeshWidget::updateForMorph()
{ {
NL3D::CPSConstraintMesh *cm = NLMISC::safe_cast<NL3D::CPSConstraintMesh *>(_ShapeParticle); NL3D::CPSConstraintMesh *cm = NLMISC::safe_cast<NL3D::CPSConstraintMesh *>(_ShapeParticle);
if (cm) if (cm)
{ {
bool enable = cm->getNumShapes() > 1; bool enable = cm->getNumShapes() > 1;
@ -185,10 +186,13 @@ QString CMeshWidget::getShapeErrorString(sint errorCode)
{ {
switch(errorCode) switch(errorCode)
{ {
case NL3D::CPSConstraintMesh::ShapeFileIsNotAMesh: return tr("Not a mesh"); case NL3D::CPSConstraintMesh::ShapeFileIsNotAMesh:
case NL3D::CPSConstraintMesh::ShapeFileNotLoaded: return tr("Shape not loaded"); return tr("Not a mesh");
case NL3D::CPSConstraintMesh::ShapeHasTooMuchVertices: return tr("Too much vertices"); case NL3D::CPSConstraintMesh::ShapeFileNotLoaded:
default: return tr("Shape not loaded");
case NL3D::CPSConstraintMesh::ShapeHasTooMuchVertices:
return tr("Too much vertices");
default:
break; break;
}; };
return QString(); return QString();

View file

@ -33,14 +33,15 @@
namespace NL3D namespace NL3D
{ {
struct CPSShapeParticle; struct CPSShapeParticle;
} }
namespace NLQT { namespace NLQT
{
class CMeshWidget: public QGroupBox class CMeshWidget: public QGroupBox
{ {
Q_OBJECT Q_OBJECT
public: public:
CMeshWidget(QWidget *parent = 0); CMeshWidget(QWidget *parent = 0);
@ -64,7 +65,10 @@ private:
void updateMeshErrorString(); void updateMeshErrorString();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
void touchPSState(); void touchPSState();

View file

@ -41,12 +41,18 @@ void Modules::init()
void Modules::release() void Modules::release()
{ {
delete _mainWindow; _mainWindow = NULL; delete _mainWindow;
delete _particleEditor; _particleEditor = NULL; _mainWindow = NULL;
delete _vegetableEditor; _vegetableEditor = NULL; delete _particleEditor;
delete _soundSystem; _soundSystem = NULL; _particleEditor = NULL;
delete _objectViewer; _objectViewer = NULL; delete _vegetableEditor;
_vegetableEditor = NULL;
delete _soundSystem;
_soundSystem = NULL;
delete _objectViewer;
_objectViewer = NULL;
config().release(); config().release();
delete _configuration; _configuration = NULL; delete _configuration;
_configuration = NULL;
} }

View file

@ -37,12 +37,30 @@ public:
static void init(); static void init();
static void release(); static void release();
static NLQT::CConfiguration &config() { return *_configuration; } static NLQT::CConfiguration &config()
static NLQT::CObjectViewer &objView() { return *_objectViewer; } {
static NLQT::CMainWindow &mainWin() { return *_mainWindow; } return *_configuration;
static NLQT::CParticleEditor &psEdit() { return *_particleEditor; } }
static NLQT::CSoundSystem &sound() { return *_soundSystem; } static NLQT::CObjectViewer &objView()
static NLQT::CVegetableEditor &veget() { return *_vegetableEditor; } {
return *_objectViewer;
}
static NLQT::CMainWindow &mainWin()
{
return *_mainWindow;
}
static NLQT::CParticleEditor &psEdit()
{
return *_particleEditor;
}
static NLQT::CSoundSystem &sound()
{
return *_soundSystem;
}
static NLQT::CVegetableEditor &veget()
{
return *_vegetableEditor;
}
private: private:
static NLQT::CConfiguration *_configuration; static NLQT::CConfiguration *_configuration;
static NLQT::CObjectViewer *_objectViewer; static NLQT::CObjectViewer *_objectViewer;

View file

@ -30,10 +30,11 @@
// Projects includes // Projects includes
#include "mesh_widget.h" #include "mesh_widget.h"
namespace NLQT { namespace NLQT
{
CMorphMeshDialog::CMorphMeshDialog(CWorkspaceNode *ownerNode, NL3D::CPSConstraintMesh *cm, QWidget *parent) CMorphMeshDialog::CMorphMeshDialog(CWorkspaceNode *ownerNode, NL3D::CPSConstraintMesh *cm, QWidget *parent)
: QDialog(parent), _Node(ownerNode), _CM(cm) : QDialog(parent), _Node(ownerNode), _CM(cm)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -97,8 +98,8 @@ QString CMorphMeshDialog::getShapeDescStr(uint shapeIndex, sint numVerts) const
void CMorphMeshDialog::add() void CMorphMeshDialog::add()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("NeL shape files (*.shape)")); tr("NeL shape files (*.shape)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
@ -139,8 +140,8 @@ void CMorphMeshDialog::remove()
void CMorphMeshDialog::insert() void CMorphMeshDialog::insert()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("NeL shape files (*.shape)")); tr("NeL shape files (*.shape)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
@ -162,8 +163,8 @@ void CMorphMeshDialog::insert()
void CMorphMeshDialog::change() void CMorphMeshDialog::change()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("NeL shape files (*.shape)")); tr("NeL shape files (*.shape)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
@ -193,7 +194,7 @@ void CMorphMeshDialog::up()
void CMorphMeshDialog::down() void CMorphMeshDialog::down()
{ {
sint row = _ui.listWidget->currentRow(); sint row = _ui.listWidget->currentRow();
if (row == (sint) (_CM->getNumShapes() - 1)) return; if (row == (sint) (_CM->getNumShapes() - 1)) return;
std::vector<std::string> shapeNames; std::vector<std::string> shapeNames;
shapeNames.resize(_CM->getNumShapes()); shapeNames.resize(_CM->getNumShapes());

View file

@ -33,14 +33,15 @@
namespace NL3D namespace NL3D
{ {
class CPSConstraintMesh; class CPSConstraintMesh;
} }
namespace NLQT { namespace NLQT
{
class CMorphMeshDialog: public QDialog class CMorphMeshDialog: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CMorphMeshDialog(CWorkspaceNode *ownerNode, NL3D::CPSConstraintMesh *cm, QWidget *parent = 0); CMorphMeshDialog(CWorkspaceNode *ownerNode, NL3D::CPSConstraintMesh *cm, QWidget *parent = 0);

View file

@ -27,10 +27,11 @@
// Project includes // Project includes
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
CMultiTexDialog::CMultiTexDialog(CWorkspaceNode *ownerNode, NL3D::CPSMultiTexturedParticle *mtp, QWidget *parent) CMultiTexDialog::CMultiTexDialog(CWorkspaceNode *ownerNode, NL3D::CPSMultiTexturedParticle *mtp, QWidget *parent)
: QDialog(parent), _Node(ownerNode), _MTP(mtp) : QDialog(parent), _Node(ownerNode), _MTP(mtp)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -146,7 +147,7 @@ void CMultiTexDialog::setMainOp(int index)
void CMultiTexDialog::setForceBasicCaps(bool state) void CMultiTexDialog::setForceBasicCaps(bool state)
{ {
NL3D::CPSMultiTexturedParticle::forceBasicCaps(state); NL3D::CPSMultiTexturedParticle::forceBasicCaps(state);
} }
void CMultiTexDialog::setUseParticleDate(bool state) void CMultiTexDialog::setUseParticleDate(bool state)

View file

@ -34,16 +34,17 @@
namespace NL3D namespace NL3D
{ {
class CPSMultiTexturedParticle; class CPSMultiTexturedParticle;
} }
namespace NLQT { namespace NLQT
{
class CWorkspaceNode; class CWorkspaceNode;
class CMultiTexDialog: public QDialog class CMultiTexDialog: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CMultiTexDialog(CWorkspaceNode *ownerNode, NL3D::CPSMultiTexturedParticle *mtp, QWidget *parent = 0); CMultiTexDialog(CWorkspaceNode *ownerNode, NL3D::CPSMultiTexturedParticle *mtp, QWidget *parent = 0);
@ -79,7 +80,10 @@ private:
NL3D::CPSMultiTexturedParticle *_MTP; NL3D::CPSMultiTexturedParticle *_MTP;
void readValues(); void readValues();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
Ui::CMultiTexDialog _ui; Ui::CMultiTexDialog _ui;
}; /* class CMultiTexDialog */ }; /* class CMultiTexDialog */

View file

@ -50,14 +50,15 @@ using namespace std;
using namespace NLMISC; using namespace NLMISC;
using namespace NL3D; using namespace NL3D;
namespace NLQT { namespace NLQT
{
CObjectViewer::CObjectViewer() CObjectViewer::CObjectViewer()
: _Driver(NULL), _TextContext(NULL), : _Driver(NULL), _TextContext(NULL),
_phi(0), _psi(0),_dist(20), _phi(0), _psi(0),_dist(20),
_CameraFocal(75), _CameraFocal(75),
_CurrentInstance(""), _CurrentInstance(""),
_BloomEffect(false), _Scene(0) _BloomEffect(false), _Scene(0)
{ {
} }
@ -182,7 +183,7 @@ void CObjectViewer::renderDriver()
// Render the scene. // Render the scene.
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().initBloom(); NL3D::CBloomEffect::instance().initBloom();
} }
_Driver->clearBuffers(_BackgroundColor); _Driver->clearBuffers(_BackgroundColor);
} }
@ -194,8 +195,8 @@ void CObjectViewer::renderScene()
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().endBloom(); NL3D::CBloomEffect::instance().endBloom();
NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); NL3D::CBloomEffect::instance().endInterfacesDisplayBloom();
} }
} }
@ -446,7 +447,7 @@ void CObjectViewer::cfcbFontName(NLMISC::CConfigFile::CVar &var)
void CObjectViewer::cfcbBloomEffect(NLMISC::CConfigFile::CVar &var) void CObjectViewer::cfcbBloomEffect(NLMISC::CConfigFile::CVar &var)
{ {
_BloomEffect = var.asBool(); _BloomEffect = var.asBool();
} }
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -34,19 +34,21 @@
// Project includes // Project includes
#include "entity.h" #include "entity.h"
namespace NL3D { namespace NL3D
class UDriver; {
class UScene; class UDriver;
class ULight; class UScene;
class UInstance; class ULight;
class UCamera; class UInstance;
class USkeleton; class UCamera;
class UTextContext; class USkeleton;
class UPlayListManager; class UTextContext;
class U3dMouseListener; class UPlayListManager;
class U3dMouseListener;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CObjectViewer @class CObjectViewer
@ -132,7 +134,10 @@ public:
/// @param h - height window. /// @param h - height window.
void setSizeViewport(uint16 w, uint16 h); void setSizeViewport(uint16 w, uint16 h);
void setBloomEffect(bool enabled) { _BloomEffect = enabled; } void setBloomEffect(bool enabled)
{
_BloomEffect = enabled;
}
/// Select instance from the scene /// Select instance from the scene
/// @param name - name instance, "" if no instance edited /// @param name - name instance, "" if no instance edited
@ -140,7 +145,10 @@ public:
/// Get current instance from the scene /// Get current instance from the scene
/// @return name current instance, "" if no instance edited /// @return name current instance, "" if no instance edited
const std::string& getCurrentObject() { return _CurrentInstance; } const std::string& getCurrentObject()
{
return _CurrentInstance;
}
/// Get entity from the scene /// Get entity from the scene
/// @return ref Entity /// @return ref Entity
@ -152,33 +160,57 @@ public:
/// Get value background color. /// Get value background color.
/// @return background color. /// @return background color.
inline NLMISC::CRGBA getBackgroundColor() const { return _BackgroundColor; } inline NLMISC::CRGBA getBackgroundColor() const
{
return _BackgroundColor;
}
/// Get type driver. /// Get type driver.
/// @return true if have used Direct3D driver, false OpenGL driver. /// @return true if have used Direct3D driver, false OpenGL driver.
inline bool getDirect3D() const { return _Direct3D; } inline bool getDirect3D() const
{
return _Direct3D;
}
inline bool getBloomEffect() const { return _BloomEffect; } inline bool getBloomEffect() const
{
return _BloomEffect;
}
/// Get a game interface for window driver. /// Get a game interface for window driver.
/// @return pointer to the driver. /// @return pointer to the driver.
inline NL3D::UDriver *getDriver() const { return _Driver; } inline NL3D::UDriver *getDriver() const
{
return _Driver;
}
/// Get a game interface for scene. /// Get a game interface for scene.
/// @return pointer to the scene. /// @return pointer to the scene.
inline NL3D::UScene *getScene() const { return _Scene; } inline NL3D::UScene *getScene() const
{
return _Scene;
}
/// Get a manager of playlist /// Get a manager of playlist
/// @return pointer to the UPlayListManager /// @return pointer to the UPlayListManager
inline NL3D::UPlayListManager *getPlayListManager() const { return _PlayListManager; } inline NL3D::UPlayListManager *getPlayListManager() const
{
return _PlayListManager;
}
/// Get a game interface to render string /// Get a game interface to render string
/// @return pointer to the UPlayListManager /// @return pointer to the UPlayListManager
inline NL3D::UTextContext *getTextContext() const { return _TextContext; } inline NL3D::UTextContext *getTextContext() const
{
return _TextContext;
}
/// Get a 3d mouse listener /// Get a 3d mouse listener
/// @return pointer to the U3dMouseListener /// @return pointer to the U3dMouseListener
inline NL3D::U3dMouseListener *get3dMouseListener() const { return _MouseListener; } inline NL3D::U3dMouseListener *get3dMouseListener() const
{
return _MouseListener;
}
private: private:
void loadConfig(); void loadConfig();

View file

@ -32,10 +32,11 @@
#include "particle_link_skeleton_dialog.h" #include "particle_link_skeleton_dialog.h"
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CParticleControlDialog::CParticleControlDialog(CSkeletonTreeModel *model, QWidget *parent) CParticleControlDialog::CParticleControlDialog(CSkeletonTreeModel *model, QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -25,14 +25,15 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
class CSkeletonTreeModel; class CSkeletonTreeModel;
class CParticleLinkDialog; class CParticleLinkDialog;
class CParticleControlDialog: public QDockWidget class CParticleControlDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CParticleControlDialog(CSkeletonTreeModel *model, QWidget *parent = 0); CParticleControlDialog(CSkeletonTreeModel *model, QWidget *parent = 0);
~CParticleControlDialog(); ~CParticleControlDialog();

View file

@ -31,15 +31,16 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CParticleEditor::CParticleEditor(void): CParticleEditor::CParticleEditor(void):
_ActiveNode(NULL), _State(State::Stopped), _Speed(1.0f), _ActiveNode(NULL), _State(State::Stopped), _Speed(1.0f),
_AutoRepeat(false), _DisplayBBox(false), _AutoRepeat(false), _DisplayBBox(false),
_DisplayHelpers(false), _AutoUpdateBBox(false), _DisplayHelpers(false), _AutoUpdateBBox(false),
_EmptyBBox(true), _PW(NULL), _EmptyBBox(true), _PW(NULL),
_Driver(NULL), _Scene(NULL), _Driver(NULL), _Scene(NULL),
_FontManager(NULL), _FontGen(NULL) _FontManager(NULL), _FontGen(NULL)
{ {
} }
@ -194,21 +195,21 @@ void CParticleEditor::start()
nlassert(_PlayingNodes.empty()); nlassert(_PlayingNodes.empty());
_PlayingNodes.push_back(_ActiveNode); _PlayingNodes.push_back(_ActiveNode);
} }
break; break;
case State::RunningSingle: case State::RunningSingle:
// no-op // no-op
return; return;
break; break;
case State::RunningMultiple: case State::RunningMultiple:
stop(); stop();
start(); start();
break; break;
case State::PausedSingle: case State::PausedSingle:
if (_ActiveNode) if (_ActiveNode)
{ {
unpause(*_ActiveNode); unpause(*_ActiveNode);
} }
break; break;
case State::PausedMultiple: case State::PausedMultiple:
for(uint k = 0; k < _PlayingNodes.size(); ++k) for(uint k = 0; k < _PlayingNodes.size(); ++k)
{ {
@ -219,10 +220,10 @@ void CParticleEditor::start()
} }
stop(); stop();
start(); start();
break; break;
default: default:
nlassert(0); nlassert(0);
break; break;
} }
_State = State::RunningSingle; _State = State::RunningSingle;
} }
@ -232,54 +233,54 @@ void CParticleEditor::startMultiple()
switch(_State) switch(_State)
{ {
case State::Stopped: case State::Stopped:
{
if (!_PW) return;
nlassert(_PlayingNodes.empty());
TPWNodeItr itr = _PW->getNodeList().begin();
while(itr != _PW->getNodeList().end())
{ {
if (!_PW) return; CWorkspaceNode *node = (*itr);
nlassert(_PlayingNodes.empty()); if (node->isLoaded())
TPWNodeItr itr = _PW->getNodeList().begin(); if (checkHasLoop(*node)) return;
while(itr != _PW->getNodeList().end()) itr++;
}
itr = _PW->getNodeList().begin();
while(itr != _PW->getNodeList().end())
{
CWorkspaceNode *node = (*itr);
if (node->isLoaded())
{ {
CWorkspaceNode *node = (*itr); // really start the node only if there's no trigger anim
if (node->isLoaded()) if (node->getTriggerAnim().empty())
if (checkHasLoop(*node)) return; play(*node);
itr++;
_PlayingNodes.push_back(node);
} }
itr++;
itr = _PW->getNodeList().begin(); }
while(itr != _PW->getNodeList().end()) }
break;
case State::PausedSingle:
case State::RunningSingle:
stop();
startMultiple();
break;
case State::RunningMultiple:
// no-op
return;
break;
case State::PausedMultiple:
for(uint k = 0; k < _PlayingNodes.size(); ++k)
{
if (_PlayingNodes[k])
{ {
CWorkspaceNode *node = (*itr); unpause(*_PlayingNodes[k]);
if (node->isLoaded())
{
// really start the node only if there's no trigger anim
if (node->getTriggerAnim().empty())
play(*node);
_PlayingNodes.push_back(node);
}
itr++;
} }
} }
break; break;
case State::PausedSingle: default:
case State::RunningSingle: nlassert(0);
stop();
startMultiple();
break;
case State::RunningMultiple:
// no-op
return;
break;
case State::PausedMultiple:
for(uint k = 0; k < _PlayingNodes.size(); ++k)
{
if (_PlayingNodes[k])
{
unpause(*_PlayingNodes[k]);
}
}
break;
default:
nlassert(0);
break; break;
} }
_State = State::RunningMultiple; _State = State::RunningMultiple;
@ -290,31 +291,31 @@ void CParticleEditor::pause()
switch(_State) switch(_State)
{ {
case State::Stopped: case State::Stopped:
// no-op // no-op
return; return;
case State::RunningSingle: case State::RunningSingle:
if (_ActiveNode) if (_ActiveNode)
{ {
pause(*_ActiveNode); pause(*_ActiveNode);
} }
_State = State::PausedSingle; _State = State::PausedSingle;
break; break;
case State::RunningMultiple: case State::RunningMultiple:
for(uint k = 0; k < _PlayingNodes.size(); ++k) for(uint k = 0; k < _PlayingNodes.size(); ++k)
{
if (_PlayingNodes[k])
{ {
if (_PlayingNodes[k]) pause(*_PlayingNodes[k]);
{
pause(*_PlayingNodes[k]);
}
} }
_State = State::PausedMultiple; }
_State = State::PausedMultiple;
break; break;
case State::PausedSingle: case State::PausedSingle:
case State::PausedMultiple: case State::PausedMultiple:
// no-op // no-op
return; return;
default: default:
nlassert(0); nlassert(0);
break; break;
} }
} }
@ -323,24 +324,24 @@ void CParticleEditor::stop()
{ {
switch(_State) switch(_State)
{ {
case State::Stopped: case State::Stopped:
// no-op // no-op
return; return;
case State::RunningSingle: case State::RunningSingle:
case State::RunningMultiple: case State::RunningMultiple:
case State::PausedSingle: case State::PausedSingle:
case State::PausedMultiple: case State::PausedMultiple:
for(uint k = 0; k < _PlayingNodes.size(); ++k) for(uint k = 0; k < _PlayingNodes.size(); ++k)
{
if (_PlayingNodes[k])
{ {
if (_PlayingNodes[k]) stop(*_PlayingNodes[k]);
{
stop(*_PlayingNodes[k]);
}
} }
_PlayingNodes.clear(); }
_PlayingNodes.clear();
break; break;
default: default:
nlassert(0); nlassert(0);
break; break;
} }
_State = State::Stopped; _State = State::Stopped;

View file

@ -34,17 +34,19 @@
// Projects includes // Projects includes
#include "particle_node.h" #include "particle_node.h"
namespace NL3D { namespace NL3D
class CParticleSystem; {
class CParticleSystemModel; class CParticleSystem;
class CShapeBank; class CParticleSystemModel;
class CScene; class CShapeBank;
class IDriver; class CScene;
class CFontManager; class IDriver;
class CFontGenerator; class CFontManager;
class CFontGenerator;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CParticleEditor @class CParticleEditor
@brief The main class of the particles editor. @brief The main class of the particles editor.
@ -84,10 +86,16 @@ public:
void setActiveNode(CWorkspaceNode *node); void setActiveNode(CWorkspaceNode *node);
/// Get the node of the workspace that is currently active /// Get the node of the workspace that is currently active
CWorkspaceNode *getActiveNode() const { return _ActiveNode; } CWorkspaceNode *getActiveNode() const
{
return _ActiveNode;
}
/// Get the particle system model that is currently active /// Get the particle system model that is currently active
NL3D::CParticleSystemModel *getActivePSM() const { return _ActiveNode ? _ActiveNode->getPSModel() : NULL; } NL3D::CParticleSystemModel *getActivePSM() const
{
return _ActiveNode ? _ActiveNode->getPSModel() : NULL;
}
/// Get a model from a ps pointer. The ps must belong to the workspace /// Get a model from a ps pointer. The ps must belong to the workspace
NL3D::CParticleSystemModel *getModelFromPS(NL3D::CParticleSystem *ps) const; NL3D::CParticleSystemModel *getModelFromPS(NL3D::CParticleSystem *ps) const;
@ -126,14 +134,26 @@ public:
void setDisplayBBox(bool enable); void setDisplayBBox(bool enable);
void setDisplayHelpers(bool enable) { _DisplayHelpers = enable; } void setDisplayHelpers(bool enable)
{
_DisplayHelpers = enable;
}
void setAutoRepeat(bool enable) { _AutoRepeat = enable; } void setAutoRepeat(bool enable)
{
_AutoRepeat = enable;
}
/// Auto bbox for fx /// Auto bbox for fx
void setAutoBBox(bool enable) { _AutoUpdateBBox = enable; } void setAutoBBox(bool enable)
{
_AutoUpdateBBox = enable;
}
bool getAutoBBox() const { return _AutoUpdateBBox; } bool getAutoBBox() const
{
return _AutoUpdateBBox;
}
/// Enable / disbale auto-count /// Enable / disbale auto-count
void enableAutoCount(bool enable); void enableAutoCount(bool enable);
@ -142,13 +162,22 @@ public:
void resetAutoCount(CWorkspaceNode *node, bool reset = true); void resetAutoCount(CWorkspaceNode *node, bool reset = true);
/// Reset the auto compute bbox /// Reset the auto compute bbox
void resetAutoBBox() { _EmptyBBox = true; } void resetAutoBBox()
{
_EmptyBBox = true;
}
/// Get current state /// Get current state
int getState() const { return _State; } int getState() const
{
return _State;
}
/// Return true if one or several system are being played /// Return true if one or several system are being played
bool isRunning() const { return _State == State::RunningSingle || _State == State::RunningMultiple; } bool isRunning() const
{
return _State == State::RunningSingle || _State == State::RunningMultiple;
}
/// Return true if a system is paused. /// Return true if a system is paused.
/// Must call only if running /// Must call only if running
@ -157,17 +186,32 @@ public:
return _State == State::PausedSingle || _State == State::PausedMultiple; return _State == State::PausedSingle || _State == State::PausedMultiple;
} }
CParticleWorkspace *getParticleWorkspace() const { return _PW; } CParticleWorkspace *getParticleWorkspace() const
{
return _PW;
}
NL3D::IDriver *getDriver() const { return _Driver; } NL3D::IDriver *getDriver() const
{
return _Driver;
}
NL3D::CScene *getScene() const { return _Scene; } NL3D::CScene *getScene() const
{
return _Scene;
}
/// Get the fontManager /// Get the fontManager
NL3D::CFontManager *getFontManager() const {return _FontManager;} NL3D::CFontManager *getFontManager() const
{
return _FontManager;
}
/// Get the fontGenerator /// Get the fontGenerator
NL3D::CFontGenerator *getFontGenerator () const { return _FontGen; } NL3D::CFontGenerator *getFontGenerator () const
{
return _FontGen;
}
private: private:
// Check if a node is inserted in the running list (it may be paused) // Check if a node is inserted in the running list (it may be paused)

View file

@ -21,17 +21,18 @@
#include "particle_force_page.h" #include "particle_force_page.h"
// Qt includes // Qt includes
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
// NeL includes // NeL includes
#include <nel/3d/particle_system.h> #include <nel/3d/particle_system.h>
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
CForcePage::CForcePage(QWidget *parent) CForcePage::CForcePage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -126,9 +127,9 @@ void CForcePage::addTarget()
if (loc->getLastForever()) if (loc->getLastForever())
{ {
int ret = QMessageBox::warning(this, tr("NeL particle system editor"), int ret = QMessageBox::warning(this, tr("NeL particle system editor"),
tr("The target object last forever. Applying a force on such an object may result in instability in the system after a while. " tr("The target object last forever. Applying a force on such an object may result in instability in the system after a while. "
"Continue ? (clue : you've been warned..)"), "Continue ? (clue : you've been warned..)"),
QMessageBox::Ok | QMessageBox::Cancel); QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Cancel) if (ret == QMessageBox::Cancel)
return; return;
@ -225,7 +226,7 @@ void CForcePage::updateTargets()
for(k = 0; k < nbTarg; ++k) for(k = 0; k < nbTarg; ++k)
{ {
CLocatedItem *item = new CLocatedItem(QString(_LBTarget->getTarget(k)->getName().c_str()), CLocatedItem *item = new CLocatedItem(QString(_LBTarget->getTarget(k)->getName().c_str()),
_ui.targetsListWidget); _ui.targetsListWidget);
item->setUserData(_LBTarget->getTarget(k)); item->setUserData(_LBTarget->getTarget(k));
targetSet.insert(_LBTarget->getTarget(k)); targetSet.insert(_LBTarget->getTarget(k));
}; };
@ -245,7 +246,7 @@ void CForcePage::updateTargets()
if (targetSet.find(loc) == targetSet.end()) if (targetSet.find(loc) == targetSet.end())
{ {
CLocatedItem *item = new CLocatedItem(QString(loc->getName().c_str()), CLocatedItem *item = new CLocatedItem(QString(loc->getName().c_str()),
_ui.avaibleTargetsListWidget); _ui.avaibleTargetsListWidget);
item->setUserData(loc); item->setUserData(loc);
} }
} }

View file

@ -33,7 +33,8 @@
#include "particle_node.h" #include "particle_node.h"
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CLocatedItem @class CLocatedItem
@ -43,10 +44,16 @@ class CLocatedItem: public QListWidgetItem
{ {
public: public:
CLocatedItem ( const QString & text, QListWidget * parent = 0, int type = UserType ): CLocatedItem ( const QString & text, QListWidget * parent = 0, int type = UserType ):
QListWidgetItem(text, parent, type), _loc(NULL) {} QListWidgetItem(text, parent, type), _loc(NULL) {}
void setUserData(NL3D::CPSLocated *loc) { _loc = loc;} void setUserData(NL3D::CPSLocated *loc)
NL3D::CPSLocated *getUserData() const { return _loc;} {
_loc = loc;
}
NL3D::CPSLocated *getUserData() const
{
return _loc;
}
private: private:
@ -59,7 +66,7 @@ private:
*/ */
class CForcePage: public QWidget class CForcePage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CForcePage(QWidget *parent = 0); CForcePage(QWidget *parent = 0);
@ -84,17 +91,32 @@ private:
struct CForceIntensityWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CForceIntensityWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSForceIntensity *F; NL3D::CPSForceIntensity *F;
float get(void) const { return F->getIntensity(); } float get(void) const
void set(const float &value) {F->setIntensity(value); } {
scheme_type *getScheme(void) const { return F->getIntensityScheme(); } return F->getIntensity();
void setScheme(scheme_type *s) {F->setIntensityScheme(s); } }
void set(const float &value)
{
F->setIntensity(value);
}
scheme_type *getScheme(void) const
{
return F->getIntensityScheme();
}
void setScheme(scheme_type *s)
{
F->setIntensityScheme(s);
}
} _ForceIntensityWrapper; } _ForceIntensityWrapper;
void hideAdditionalWidget(); void hideAdditionalWidget();
void updateTargets(); void updateTargets();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
// the target we're focusing on // the target we're focusing on
NL3D::CPSTargetLocatedBindable *_LBTarget; NL3D::CPSTargetLocatedBindable *_LBTarget;

View file

@ -27,10 +27,11 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CLightPage::CLightPage(QWidget *parent) CLightPage::CLightPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -32,7 +32,8 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CLightPage @class CLightPage
@ -40,7 +41,7 @@ namespace NLQT {
*/ */
class CLightPage: public QWidget class CLightPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CLightPage(QWidget *parent = 0); CLightPage(QWidget *parent = 0);
@ -56,30 +57,66 @@ private:
struct CColorWrapper : public IPSWrapperRGBA, IPSSchemeWrapperRGBA struct CColorWrapper : public IPSWrapperRGBA, IPSSchemeWrapperRGBA
{ {
NL3D::CPSLight *L; NL3D::CPSLight *L;
NLMISC::CRGBA get(void) const { return L->getColor(); } NLMISC::CRGBA get(void) const
void set(const NLMISC::CRGBA &v) { L->setColor(v); } {
scheme_type *getScheme(void) const { return L->getColorScheme(); } return L->getColor();
void setScheme(scheme_type *s) { L->setColorScheme(s); } }
void set(const NLMISC::CRGBA &v)
{
L->setColor(v);
}
scheme_type *getScheme(void) const
{
return L->getColorScheme();
}
void setScheme(scheme_type *s)
{
L->setColorScheme(s);
}
} _ColorWrapper; } _ColorWrapper;
/// wrapper to set start atten radius /// wrapper to set start atten radius
struct CAttenStartWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CAttenStartWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSLight *L; NL3D::CPSLight *L;
float get(void) const { return L->getAttenStart(); } float get(void) const
void set(const float &v) { L->setAttenStart(v); } {
scheme_type *getScheme(void) const { return L->getAttenStartScheme(); } return L->getAttenStart();
void setScheme(scheme_type *s) { L->setAttenStartScheme(s); } }
void set(const float &v)
{
L->setAttenStart(v);
}
scheme_type *getScheme(void) const
{
return L->getAttenStartScheme();
}
void setScheme(scheme_type *s)
{
L->setAttenStartScheme(s);
}
} _AttenStartWrapper; } _AttenStartWrapper;
/// wrapper to set end atten radius /// wrapper to set end atten radius
struct CAttenEndWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CAttenEndWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSLight *L; NL3D::CPSLight *L;
float get(void) const { return L->getAttenEnd(); } float get(void) const
void set(const float &v) { L->setAttenEnd(v); } {
scheme_type *getScheme(void) const { return L->getAttenEndScheme(); } return L->getAttenEnd();
void setScheme(scheme_type *s) { L->setAttenEndScheme(s); } }
void set(const float &v)
{
L->setAttenEnd(v);
}
scheme_type *getScheme(void) const
{
return L->getAttenEndScheme();
}
void setScheme(scheme_type *s)
{
L->setAttenEndScheme(s);
}
} _AttenEndWrapper; } _AttenEndWrapper;
NL3D::CPSLight *_Light; NL3D::CPSLight *_Light;

View file

@ -27,10 +27,11 @@
#include "modules.h" #include "modules.h"
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
CParticleLinkDialog::CParticleLinkDialog(CSkeletonTreeModel *model, QWidget *parent) CParticleLinkDialog::CParticleLinkDialog(CSkeletonTreeModel *model, QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);

View file

@ -29,11 +29,12 @@
// Project includes // Project includes
#include "skeleton_tree_model.h" #include "skeleton_tree_model.h"
namespace NLQT { namespace NLQT
{
class CParticleLinkDialog: public QDockWidget class CParticleLinkDialog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CParticleLinkDialog(CSkeletonTreeModel *model, QWidget *parent = 0); CParticleLinkDialog(CSkeletonTreeModel *model, QWidget *parent = 0);

View file

@ -34,7 +34,8 @@
using namespace NLMISC; using namespace NLMISC;
using namespace NL3D; using namespace NL3D;
namespace NLQT { namespace NLQT
{
CWorkspaceNode::CWorkspaceNode() CWorkspaceNode::CWorkspaceNode()
{ {
@ -72,9 +73,9 @@ bool CWorkspaceNode::isStateMemorized() const
} }
void CWorkspaceNode::stickPSToSkeleton(NL3D::CSkeletonModel *skel, void CWorkspaceNode::stickPSToSkeleton(NL3D::CSkeletonModel *skel,
uint bone, uint bone,
const std::string &parentSkelName, const std::string &parentSkelName,
const std::string &parentBoneName) const std::string &parentBoneName)
{ {
nlassert(_WS); nlassert(_WS);
if (!_PSM) return; if (!_PSM) return;
@ -222,17 +223,17 @@ void CWorkspaceNode::serial(NLMISC::IStream &f)
{ {
nlassert(_WS); nlassert(_WS);
f.xmlPush("PROJECT_FILE"); f.xmlPush("PROJECT_FILE");
sint version = f.serialVersion(2); sint version = f.serialVersion(2);
f.xmlSerial(_RelativePath, "RELATIVE_PATH"); f.xmlSerial(_RelativePath, "RELATIVE_PATH");
if (version >= 1) if (version >= 1)
{ {
f.xmlSerial(_TriggerAnim, "TRIGGER_ANIMATION"); f.xmlSerial(_TriggerAnim, "TRIGGER_ANIMATION");
} }
if (version >= 2) if (version >= 2)
{ {
f.xmlSerial(_ParentSkelName, "PARENT_SKEL_NAME"); f.xmlSerial(_ParentSkelName, "PARENT_SKEL_NAME");
f.xmlSerial(_ParentBoneName, "PARENT_BONE_NAME"); f.xmlSerial(_ParentBoneName, "PARENT_BONE_NAME");
} }
f.xmlPop(); f.xmlPop();
} }
@ -346,7 +347,7 @@ CWorkspaceNode *CParticleWorkspace::addNode(const std::string &filenameWithFullP
std::string relativePath; std::string relativePath;
// if (!PathRelativePathTo(resultPath, dosPath.c_str(), FILE_ATTRIBUTE_DIRECTORY, filenameWithFullPath.c_str(), 0)) // if (!PathRelativePathTo(resultPath, dosPath.c_str(), FILE_ATTRIBUTE_DIRECTORY, filenameWithFullPath.c_str(), 0))
// { // {
relativePath = filenameWithFullPath; relativePath = filenameWithFullPath;
// } // }
// else // else
// { // {
@ -492,32 +493,32 @@ bool CParticleWorkspace::isContentModified() const
void CParticleWorkspace::restickAllObjects() void CParticleWorkspace::restickAllObjects()
{ {
/* for(uint k = 0; k < _Nodes.size(); ++k) /* for(uint k = 0; k < _Nodes.size(); ++k)
{
std::string parentSkelName = _Nodes[k]->getParentSkelName();
std::string parentBoneName = _Nodes[k]->getParentBoneName();
//
_Nodes[k]->unstickPSFromSkeleton();
if (!parentSkelName.empty())
// find instance to stick to in the scene
for(uint l = 0; l < ov->getNumInstance(); ++l)
{ {
CInstanceInfo *ii = ov->getInstance(l); std::string parentSkelName = _Nodes[k]->getParentSkelName();
if (ii->TransformShape && ii->Saved.ShapeFilename == parentSkelName) std::string parentBoneName = _Nodes[k]->getParentBoneName();
//
_Nodes[k]->unstickPSFromSkeleton();
if (!parentSkelName.empty())
// find instance to stick to in the scene
for(uint l = 0; l < ov->getNumInstance(); ++l)
{ {
NL3D::CSkeletonModel *skel = dynamic_cast<NL3D::CSkeletonModel *>(ii->TransformShape); CInstanceInfo *ii = ov->getInstance(l);
if (skel) if (ii->TransformShape && ii->Saved.ShapeFilename == parentSkelName)
{ {
sint boneID = skel->getBoneIdByName(parentBoneName); NL3D::CSkeletonModel *skel = dynamic_cast<NL3D::CSkeletonModel *>(ii->TransformShape);
if (boneID != -1) if (skel)
{ {
_Nodes[k]->stickPSToSkeleton(skel, (uint) boneID, parentSkelName, parentBoneName); sint boneID = skel->getBoneIdByName(parentBoneName);
break; if (boneID != -1)
{
_Nodes[k]->stickPSToSkeleton(skel, (uint) boneID, parentSkelName, parentBoneName);
break;
}
} }
} }
} }
} }*/
}*/
} }
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -32,13 +32,15 @@
#include "ps_initial_pos.h" #include "ps_initial_pos.h"
namespace NL3D { namespace NL3D
class CParticleSystem; {
class CParticleSystemModel; class CParticleSystem;
class CShapeBank; class CParticleSystemModel;
class CShapeBank;
} }
namespace NLQT { namespace NLQT
{
class CParticleWorkspace; class CParticleWorkspace;
@ -62,11 +64,17 @@ public:
void setRelativePath(const std::string &relativePath); void setRelativePath(const std::string &relativePath);
const std::string &getRelativePath() const { return _RelativePath; } const std::string &getRelativePath() const
{
return _RelativePath;
}
std::string getFullPath() const; std::string getFullPath() const;
std::string getFilename() const { return NLMISC::CFile::getFilename(_RelativePath); } std::string getFilename() const
{
return NLMISC::CFile::getFilename(_RelativePath);
}
/// Serial node information into workspace stream. This does not save the particle system shape, only a reference to its file /// Serial node information into workspace stream. This does not save the particle system shape, only a reference to its file
void serial(NLMISC::IStream &f); void serial(NLMISC::IStream &f);
@ -89,17 +97,32 @@ public:
/// Helper flag to know if a ps has been modified /// Helper flag to know if a ps has been modified
/// @{ /// @{
bool isModified() const { return _Modified; } bool isModified() const
{
return _Modified;
}
void setModified(bool modified); void setModified(bool modified);
/// @} /// @}
NL3D::CParticleSystem *getPSPointer() const { return _PS; } NL3D::CParticleSystem *getPSPointer() const
NL3D::CParticleSystemModel *getPSModel() const { return _PSM; } {
return _PS;
}
NL3D::CParticleSystemModel *getPSModel() const
{
return _PSM;
}
/// See if this node ps has been loaded /// See if this node ps has been loaded
bool isLoaded() const { return _PS != NULL; } bool isLoaded() const
{
return _PS != NULL;
}
/// Get the workspace in which this node is inserted /// Get the workspace in which this node is inserted
CParticleWorkspace *getWorkspace() const { return _WS; } CParticleWorkspace *getWorkspace() const
{
return _WS;
}
/// Memorize current position of object in the system. Useful to play the system because instances can be created / deleted /// Memorize current position of object in the system. Useful to play the system because instances can be created / deleted
void memorizeState(); void memorizeState();
@ -117,13 +140,25 @@ public:
void removeLocatedBindable(NL3D::CPSLocatedBindable *lb); void removeLocatedBindable(NL3D::CPSLocatedBindable *lb);
/// Returns the skeleton to which the ps is currently sticked /// Returns the skeleton to which the ps is currently sticked
NL3D::CSkeletonModel *getParentSkel() const { return _ParentSkel; } NL3D::CSkeletonModel *getParentSkel() const
{
return _ParentSkel;
}
const std::string &getParentSkelName() const { return _ParentSkelName; } const std::string &getParentSkelName() const
{
return _ParentSkelName;
}
const std::string &getParentBoneName() const { return _ParentBoneName; } const std::string &getParentBoneName() const
{
return _ParentBoneName;
}
std::string getTriggerAnim() { return _TriggerAnim; } std::string getTriggerAnim()
{
return _TriggerAnim;
}
void setTriggerAnim(const std::string &anim); void setTriggerAnim(const std::string &anim);
@ -152,8 +187,14 @@ private:
private: private:
void setup(NL3D::CParticleSystemModel &psm); void setup(NL3D::CParticleSystemModel &psm);
public: public:
bool getResetAutoCountFlag() const { return _ResetAutoCount; } bool getResetAutoCountFlag() const
void setResetAutoCountFlag(bool reset) { _ResetAutoCount = reset; } {
return _ResetAutoCount;
}
void setResetAutoCountFlag(bool reset)
{
_ResetAutoCount = reset;
}
/// Stick to a skeleton /// Stick to a skeleton
void stickPSToSkeleton(NL3D::CSkeletonModel *skel, void stickPSToSkeleton(NL3D::CSkeletonModel *skel,
@ -209,18 +250,27 @@ public:
/// Set a new file name for the workspace /// Set a new file name for the workspace
void setFileName(const std::string &fileName); void setFileName(const std::string &fileName);
std::string getName() const { return _Name; } std::string getName() const
{
return _Name;
}
/// Get the path in which workpsace is located with a trailing slash /// Get the path in which workpsace is located with a trailing slash
std::string getPath() const; std::string getPath() const;
std::string getFilename() const; std::string getFilename() const;
/// Get Number of nodes in the workspace /// Get Number of nodes in the workspace
uint getNumNode() const { return (uint)_Nodes.size(); } uint getNumNode() const
{
return (uint)_Nodes.size();
}
/// Get a node in workspace /// Get a node in workspace
/// Can keep pointer safely as long as the node is not deleted /// Can keep pointer safely as long as the node is not deleted
CWorkspaceNode *getNode(uint index) const { return _Nodes[index]; } CWorkspaceNode *getNode(uint index) const
{
return _Nodes[index];
}
/// Get a node from a pointer on a particle system /// Get a node from a pointer on a particle system
CWorkspaceNode *getNodeFromPS(NL3D::CParticleSystem *ps) const; CWorkspaceNode *getNodeFromPS(NL3D::CParticleSystem *ps) const;
@ -253,21 +303,39 @@ public:
void load() throw(NLMISC::EStream); void load() throw(NLMISC::EStream);
/// Test whether the structure of the workspace has been modified (does not test if ps inside the workspace have been modified) /// Test whether the structure of the workspace has been modified (does not test if ps inside the workspace have been modified)
bool isModified() const { return _Modified; } bool isModified() const
{
return _Modified;
}
/// Test whether the content of the workspace has ben modified /// Test whether the content of the workspace has ben modified
bool isContentModified() const; bool isContentModified() const;
void touch() { setModifiedFlag(true); } void touch()
void clearModifiedFlag() { setModifiedFlag(false); } {
setModifiedFlag(true);
}
void clearModifiedFlag()
{
setModifiedFlag(false);
}
/// Set a callback to know when a node is modified /// Set a callback to know when a node is modified
void setModificationCallback(IModificationCallback *cb) { _ModificationCallback = cb; } void setModificationCallback(IModificationCallback *cb)
IModificationCallback *getModificationCallback() const { return _ModificationCallback; } {
_ModificationCallback = cb;
}
IModificationCallback *getModificationCallback() const
{
return _ModificationCallback;
}
/// Restick all objects, useful after loading /// Restick all objects, useful after loading
void restickAllObjects(); void restickAllObjects();
TNodeVect& getNodeList() { return _Nodes; } TNodeVect& getNodeList()
{
return _Nodes;
}
private: private:
// use smart ptr to avoir prb wih resize // use smart ptr to avoir prb wih resize

View file

@ -25,7 +25,8 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CPropertyDialog::CPropertyDialog(CParticleTreeModel *treeModel, QWidget *parent) CPropertyDialog::CPropertyDialog(CParticleTreeModel *treeModel, QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
@ -44,7 +45,7 @@ void CPropertyDialog::setupUi()
QIcon icon; QIcon icon;
icon.addFile(QString::fromUtf8(":/images/pqrticles.png"), QSize(), QIcon::Normal, QIcon::Off); icon.addFile(QString::fromUtf8(":/images/pqrticles.png"), QSize(), QIcon::Normal, QIcon::Off);
setWindowIcon(icon); setWindowIcon(icon);
_dockWidgetContents = new QWidget(); _dockWidgetContents = new QWidget();
_gridLayout = new QGridLayout(_dockWidgetContents); _gridLayout = new QGridLayout(_dockWidgetContents);
@ -128,8 +129,8 @@ void CPropertyDialog::setCurrentEditedElement(CParticleTreeItem *editedItem)
_psMoverPage->setEditedItem(_treeModel->getOwnerNode(editedItem) ,editedItem->getLoc(), editedItem->getLocatedInstanceIndex()); _psMoverPage->setEditedItem(_treeModel->getOwnerNode(editedItem) ,editedItem->getLoc(), editedItem->getLocatedInstanceIndex());
_stackedWidget->setCurrentWidget(_psMoverPage); _stackedWidget->setCurrentWidget(_psMoverPage);
_treeModel->getOwnerNode(editedItem)->getPSPointer()->setCurrentEditedElement(editedItem->getLoc(), _treeModel->getOwnerNode(editedItem)->getPSPointer()->setCurrentEditedElement(editedItem->getLoc(),
editedItem->getLocatedInstanceIndex(), editedItem->getLocatedInstanceIndex(),
_psMoverPage->getLocatedBindable()); _psMoverPage->getLocatedBindable());
break; break;
default: default:
_stackedWidget->setCurrentWidget(_wpPage); _stackedWidget->setCurrentWidget(_wpPage);

View file

@ -44,7 +44,8 @@
#include "particle_tree_model.h" #include "particle_tree_model.h"
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
class CPropertyDialog: public QDockWidget class CPropertyDialog: public QDockWidget
{ {
@ -55,8 +56,14 @@ public:
void setCurrentEditedElement(CParticleTreeItem *editedItem); void setCurrentEditedElement(CParticleTreeItem *editedItem);
CLocatedPage *getLocatedPage() const { return _locatedPage; }; CLocatedPage *getLocatedPage() const
CPSMoverPage *getMoverPage() const { return _psMoverPage; }; {
return _locatedPage;
};
CPSMoverPage *getMoverPage() const
{
return _psMoverPage;
};
private: private:
void setupUi(); void setupUi();

View file

@ -32,10 +32,11 @@
#include "modules.h" #include "modules.h"
#include "sound_system.h" #include "sound_system.h"
namespace NLQT { namespace NLQT
{
CSoundPage::CSoundPage(QWidget *parent) CSoundPage::CSoundPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -107,11 +108,11 @@ void CSoundPage::browse()
QStringList items; QStringList items;
items << tr(""); items << tr("");
for(size_t i = 0; i < names.size(); ++i) for(size_t i = 0; i < names.size(); ++i)
items << QString(names[i]->c_str()); items << QString(names[i]->c_str());
bool ok; bool ok;
QString item = QInputDialog::getItem(this, tr("Select your sound"), QString item = QInputDialog::getItem(this, tr("Select your sound"),
tr("Sound:"), items, 0, false, &ok); tr("Sound:"), items, 0, false, &ok);
if (ok) if (ok)
{ {
_ui.soundNameLineEdit->setText(item); _ui.soundNameLineEdit->setText(item);

View file

@ -35,10 +35,11 @@
namespace NLSOUND namespace NLSOUND
{ {
class UAudioMixer; class UAudioMixer;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CSoundPage @class CSoundPage
@ -46,7 +47,7 @@ namespace NLQT {
*/ */
class CSoundPage: public QWidget class CSoundPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CSoundPage(QWidget *parent = 0); CSoundPage(QWidget *parent = 0);
@ -70,23 +71,50 @@ private:
struct CGainWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CGainWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSSound *S; NL3D::CPSSound *S;
float get(void) const { return S->getGain(); } float get(void) const
void set(const float &v) { S->setGain(v); } {
scheme_type *getScheme(void) const { return S->getGainScheme(); } return S->getGain();
void setScheme(scheme_type *s) { S->setGainScheme(s); } }
void set(const float &v)
{
S->setGain(v);
}
scheme_type *getScheme(void) const
{
return S->getGainScheme();
}
void setScheme(scheme_type *s)
{
S->setGainScheme(s);
}
} _GainWrapper; } _GainWrapper;
/// wrapper to set the pitch of sounds /// wrapper to set the pitch of sounds
struct CPitchWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat struct CPitchWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat
{ {
NL3D::CPSSound *S; NL3D::CPSSound *S;
float get(void) const { return S->getPitch(); } float get(void) const
void set(const float &v) { S->setPitch(v); } {
scheme_type *getScheme(void) const { return S->getPitchScheme(); } return S->getPitch();
void setScheme(scheme_type *s) { S->setPitchScheme(s); } }
void set(const float &v)
{
S->setPitch(v);
}
scheme_type *getScheme(void) const
{
return S->getPitchScheme();
}
void setScheme(scheme_type *s)
{
S->setPitchScheme(s);
}
} _PitchWrapper; } _PitchWrapper;
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
/// the sound being edited /// the sound being edited
NL3D::CPSSound *_Sound; NL3D::CPSSound *_Sound;

View file

@ -38,22 +38,23 @@
using namespace NL3D; using namespace NL3D;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
static void chooseGlobalUserParam(uint userParam, NL3D::CParticleSystem *ps, QWidget *parent) static void chooseGlobalUserParam(uint userParam, NL3D::CParticleSystem *ps, QWidget *parent)
{ {
nlassert(ps); nlassert(ps);
bool ok; bool ok;
QString text = QInputDialog::getText(parent, "Choose Global User Param", QString text = QInputDialog::getText(parent, "Choose Global User Param",
"User name:", QLineEdit::Normal, "User name:", QLineEdit::Normal,
QString(ps->getGlobalValueName(userParam).c_str()), &ok); QString(ps->getGlobalValueName(userParam).c_str()), &ok);
if (ok) if (ok)
ps->bindGlobalValueToUserParam(text.toStdString(), userParam); ps->bindGlobalValueToUserParam(text.toStdString(), userParam);
} }
CParticleSystemPage::CParticleSystemPage(QWidget *parent) CParticleSystemPage::CParticleSystemPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -269,8 +270,8 @@ void CParticleSystemPage::setLoadBalancing(bool state)
{ {
QMessageBox::StandardButton reply; QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, tr("Are you sure?"), reply = QMessageBox::question(this, tr("Are you sure?"),
tr("Load balancing on/off"), tr("Load balancing on/off"),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) if (reply == QMessageBox::Yes)
_Node->getPSPointer()->enableLoadBalancing(false); _Node->getPSPointer()->enableLoadBalancing(false);
else else
@ -322,19 +323,19 @@ void CParticleSystemPage::setGloabal1()
void CParticleSystemPage::setGloabal2() void CParticleSystemPage::setGloabal2()
{ {
chooseGlobalUserParam(1, _Node->getPSPointer(), this); chooseGlobalUserParam(1, _Node->getPSPointer(), this);
updateModifiedFlag(); updateModifiedFlag();
} }
void CParticleSystemPage::setGloabal3() void CParticleSystemPage::setGloabal3()
{ {
chooseGlobalUserParam(2, _Node->getPSPointer(), this); chooseGlobalUserParam(2, _Node->getPSPointer(), this);
updateModifiedFlag(); updateModifiedFlag();
} }
void CParticleSystemPage::setGloabal4() void CParticleSystemPage::setGloabal4()
{ {
chooseGlobalUserParam(3, _Node->getPSPointer(), this); chooseGlobalUserParam(3, _Node->getPSPointer(), this);
updateModifiedFlag(); updateModifiedFlag();
} }
@ -366,7 +367,7 @@ void CParticleSystemPage::resetBbox()
void CParticleSystemPage::incBbox() void CParticleSystemPage::incBbox()
{ {
NLMISC::CAABBox b; NLMISC::CAABBox b;
_Node->getPSPointer()->computeBBox(b); _Node->getPSPointer()->computeBBox(b);
b.setHalfSize(1.1f * b.getHalfSize()); b.setHalfSize(1.1f * b.getHalfSize());
_Node->getPSPointer()->setPrecomputedBBox(b); _Node->getPSPointer()->setPrecomputedBBox(b);
@ -444,7 +445,7 @@ void CParticleSystemPage::setPresetBehaviour(int index)
updateLifeMgtPresets(); updateLifeMgtPresets();
if (index == _Node->getPSPointer()->getBehaviourType()) return; if (index == _Node->getPSPointer()->getBehaviourType()) return;
if (index == NL3D::CParticleSystem::SpellFX || if (index == NL3D::CParticleSystem::SpellFX ||
index == NL3D::CParticleSystem::SpawnedEnvironmentFX) index == NL3D::CParticleSystem::SpawnedEnvironmentFX)
{ {
NL3D::CPSLocatedBindable *lb; NL3D::CPSLocatedBindable *lb;
if (!_Node->getPSPointer()->canFinish(&lb)) if (!_Node->getPSPointer()->canFinish(&lb))
@ -455,13 +456,13 @@ void CParticleSystemPage::setPresetBehaviour(int index)
if (!lb) if (!lb)
{ {
errorMessage->showMessage(tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " errorMessage->showMessage(tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first.")); "and thus, should have a finite duration. Please remove that flag first."));
errorMessage->exec(); errorMessage->exec();
} }
else else
{ {
errorMessage->showMessage(tr("The system must have a finite duration for this setting! Please check that the following object " errorMessage->showMessage(tr("The system must have a finite duration for this setting! Please check that the following object "
"doesn't live forever or doesn't create a loop in the system :") + QString(lb->getName().c_str())); "doesn't live forever or doesn't create a loop in the system :") + QString(lb->getName().c_str()));
errorMessage->exec(); errorMessage->exec();
} }
delete errorMessage; delete errorMessage;

View file

@ -33,14 +33,15 @@
// Project includes // Project includes
#include "edit_range_widget.h" #include "edit_range_widget.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CParticleSystemPage @class CParticleSystemPage
@brief Page for QStackWidget, to edit workspace node in a particle system @brief Page for QStackWidget, to edit workspace node in a particle system
*/ */
class CParticleSystemPage: public QWidget class CParticleSystemPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CParticleSystemPage(QWidget *parent = 0); CParticleSystemPage(QWidget *parent = 0);
@ -110,7 +111,10 @@ private:
bool enabledModifiedFlag; bool enabledModifiedFlag;
void updateModifiedFlag() { if ((_Node) && (enabledModifiedFlag)) _Node->setModified(true); } void updateModifiedFlag()
{
if ((_Node) && (enabledModifiedFlag)) _Node->setModified(true);
}
CWorkspaceNode *_Node; CWorkspaceNode *_Node;

View file

@ -31,10 +31,11 @@
#include "value_gradient_dialog.h" #include "value_gradient_dialog.h"
#include "multi_tex_dialog.h" #include "multi_tex_dialog.h"
namespace NLQT { namespace NLQT
{
CParticleTextureAnimWidget::CParticleTextureAnimWidget(QWidget *parent) CParticleTextureAnimWidget::CParticleTextureAnimWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -80,7 +81,7 @@ void CParticleTextureAnimWidget::setCurrentTextureAnim(NL3D::CPSTexturedParticle
void CParticleTextureAnimWidget::setEnabledTexAnim(bool state) void CParticleTextureAnimWidget::setEnabledTexAnim(bool state)
{ {
if (state) if (state)
{ {
if (_MTP) if (_MTP)
_ui.multitexturingCheckBox->setChecked(false); _ui.multitexturingCheckBox->setChecked(false);

View file

@ -34,15 +34,16 @@
namespace NL3D namespace NL3D
{ {
class CPSTexturedParticle; class CPSTexturedParticle;
class CPSMultiTexturedParticle; class CPSMultiTexturedParticle;
} }
namespace NLQT { namespace NLQT
{
class CParticleTextureAnimWidget: public QWidget class CParticleTextureAnimWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CParticleTextureAnimWidget(QWidget *parent = 0); CParticleTextureAnimWidget(QWidget *parent = 0);
@ -63,21 +64,42 @@ private:
struct CTextureWrapper : public IPSWrapperTexture struct CTextureWrapper : public IPSWrapperTexture
{ {
NL3D::CPSTexturedParticle *P; NL3D::CPSTexturedParticle *P;
NL3D::ITexture *get(void) { return P->getTexture(); } NL3D::ITexture *get(void)
void set(NL3D::ITexture *t) { P->setTexture(t); } {
return P->getTexture();
}
void set(NL3D::ITexture *t)
{
P->setTexture(t);
}
} _TextureWrapper; } _TextureWrapper;
/// Wrapper for texture anim sequence /// Wrapper for texture anim sequence
struct CTextureIndexWrapper : public IPSWrapper<sint32>, IPSSchemeWrapper<sint32> struct CTextureIndexWrapper : public IPSWrapper<sint32>, IPSSchemeWrapper<sint32>
{ {
NL3D::CPSTexturedParticle *P; NL3D::CPSTexturedParticle *P;
sint32 get(void) const { return P->getTextureIndex(); } sint32 get(void) const
void set(const sint32 &v) { P->setTextureIndex(v); } {
scheme_type *getScheme(void) const { return P->getTextureIndexScheme(); } return P->getTextureIndex();
void setScheme(scheme_type *s) { P->setTextureIndexScheme(s); } }
void set(const sint32 &v)
{
P->setTextureIndex(v);
}
scheme_type *getScheme(void) const
{
return P->getTextureIndexScheme();
}
void setScheme(scheme_type *s)
{
P->setTextureIndexScheme(s);
}
} _TextureIndexWrapper; } _TextureIndexWrapper;
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
NL3D::CPSTexturedParticle *_EditedParticle; NL3D::CPSTexturedParticle *_EditedParticle;

View file

@ -30,10 +30,11 @@
#include "nel/3d/ps_particle_basic.h" #include "nel/3d/ps_particle_basic.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
namespace NLQT { namespace NLQT
{
CParticleTextureWidget::CParticleTextureWidget(QWidget *parent) CParticleTextureWidget::CParticleTextureWidget(QWidget *parent)
: QWidget(parent), _Wrapper(NULL) : QWidget(parent), _Wrapper(NULL)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -68,8 +69,8 @@ void CParticleTextureWidget::chooseTexture()
} }
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open texture file"), texName.c_str(), tr("Open texture file"), texName.c_str(),
tr("Image file (*.tga *.png)")); tr("Image file (*.tga *.png)"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())

View file

@ -34,11 +34,12 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
class CParticleTextureWidget: public QWidget class CParticleTextureWidget: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CParticleTextureWidget(QWidget *parent = 0); CParticleTextureWidget(QWidget *parent = 0);
@ -47,9 +48,15 @@ public:
void updateUi(); void updateUi();
// set a wrapper to get the datas, called before setCurrentTextureNoAnim // set a wrapper to get the datas, called before setCurrentTextureNoAnim
void setWrapper(IPSWrapperTexture *wrapper) { _Wrapper = wrapper ; } void setWrapper(IPSWrapperTexture *wrapper)
{
_Wrapper = wrapper ;
}
void enableRemoveButton(bool enabled) { _ui.removePushButton->setVisible(enabled); } void enableRemoveButton(bool enabled)
{
_ui.removePushButton->setVisible(enabled);
}
Q_SIGNALS: Q_SIGNALS:
void textureChanged(const QString &texName); void textureChanged(const QString &texName);

View file

@ -28,30 +28,31 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CParticleTreeItem::CParticleTreeItem(const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
} }
CParticleTreeItem::CParticleTreeItem(CParticleWorkspace *ws, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(CParticleWorkspace *ws, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
nlassert(ws); nlassert(ws);
_WS = ws; _WS = ws;
} }
CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocated *loc, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocated *loc, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
nlassert(loc); nlassert(loc);
_Loc = loc; _Loc = loc;
} }
CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocated *loc, uint32 index, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocated *loc, uint32 index, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
nlassert(loc); nlassert(loc);
_Loc = loc; _Loc = loc;
@ -59,15 +60,15 @@ CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocated *loc, uint32 index, const
} }
CParticleTreeItem::CParticleTreeItem(CWorkspaceNode *node, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(CWorkspaceNode *node, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
_PS = node; _PS = node;
} }
CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocatedBindable *lb, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent): CParticleTreeItem::CParticleTreeItem(NL3D::CPSLocatedBindable *lb, const QList<QVariant> &data, const int typeItem, CParticleTreeItem *parent):
_itemData(data), _itemIconType(typeItem), _parentItem(parent) _itemData(data), _itemIconType(typeItem), _parentItem(parent)
{ {
_Bind = lb; _Bind = lb;
} }
CParticleTreeItem::~CParticleTreeItem() CParticleTreeItem::~CParticleTreeItem()
@ -113,7 +114,7 @@ CParticleTreeItem *CParticleTreeItem::parent()
int CParticleTreeItem::row() const int CParticleTreeItem::row() const
{ {
if (_parentItem) if (_parentItem)
return _parentItem->_childItems.indexOf(const_cast<CParticleTreeItem*>(this)); return _parentItem->_childItems.indexOf(const_cast<CParticleTreeItem*>(this));
return 0; return 0;
} }
@ -160,7 +161,7 @@ void CParticleTreeItem::setLocatedInstanceIndex(uint32 index)
} }
CParticleTreeModel::CParticleTreeModel(QObject *parent) CParticleTreeModel::CParticleTreeModel(QObject *parent)
: QAbstractItemModel(parent) : QAbstractItemModel(parent)
{ {
QList<QVariant> rootData; QList<QVariant> rootData;
rootData << "Name"; rootData << "Name";
@ -175,15 +176,15 @@ CParticleTreeModel::~CParticleTreeModel()
int CParticleTreeModel::columnCount(const QModelIndex &parent) const int CParticleTreeModel::columnCount(const QModelIndex &parent) const
{ {
if (parent.isValid()) if (parent.isValid())
return static_cast<CParticleTreeItem*>(parent.internalPointer())->columnCount(); return static_cast<CParticleTreeItem*>(parent.internalPointer())->columnCount();
else else
return _rootItem->columnCount(); return _rootItem->columnCount();
} }
QVariant CParticleTreeModel::data(const QModelIndex &index, int role) const QVariant CParticleTreeModel::data(const QModelIndex &index, int role) const
{ {
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
{ {
@ -211,7 +212,7 @@ QVariant CParticleTreeModel::data(const QModelIndex &index, int role) const
return QFont("SansSerif", 9, QFont::Normal); return QFont("SansSerif", 9, QFont::Normal);
} }
if (role == Qt::DecorationRole) if (role == Qt::DecorationRole)
return qVariantFromValue(getIcon(index)); return qVariantFromValue(getIcon(index));
return QVariant(); return QVariant();
} }
@ -221,29 +222,29 @@ Qt::ItemFlags CParticleTreeModel::flags(const QModelIndex &index) const
Qt::ItemFlags itmFlags = Qt::NoItemFlags; Qt::ItemFlags itmFlags = Qt::NoItemFlags;
if (!index.isValid()) if (!index.isValid())
return itmFlags; return itmFlags;
CParticleTreeItem *item = static_cast<CParticleTreeItem*>(index.internalPointer()); CParticleTreeItem *item = static_cast<CParticleTreeItem*>(index.internalPointer());
switch (item->itemType()) switch (item->itemType())
{ {
case ItemType::Particle: case ItemType::Particle:
case ItemType::Emitter: case ItemType::Emitter:
case ItemType::Force: case ItemType::Force:
case ItemType::Light: case ItemType::Light:
case ItemType::Sound: case ItemType::Sound:
case ItemType::Located: case ItemType::Located:
case ItemType::CollisionZone: case ItemType::CollisionZone:
itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
break; break;
case ItemType::LocatedInstance: case ItemType::LocatedInstance:
if (Modules::psEdit().isRunning()) if (Modules::psEdit().isRunning())
itmFlags = Qt::NoItemFlags; itmFlags = Qt::NoItemFlags;
else else
itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
break;
default:
itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
break; break;
default:
itmFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
break;
} }
//CParticleWorkspaceDialog *pwsd = qobject_cast<CParticleWorkspaceDialog*>(QObject::parent()); //CParticleWorkspaceDialog *pwsd = qobject_cast<CParticleWorkspaceDialog*>(QObject::parent());
@ -253,44 +254,44 @@ Qt::ItemFlags CParticleTreeModel::flags(const QModelIndex &index) const
} }
QVariant CParticleTreeModel::headerData(int section, Qt::Orientation orientation, QVariant CParticleTreeModel::headerData(int section, Qt::Orientation orientation,
int role) const int role) const
{ {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return _rootItem->data(section); return _rootItem->data(section);
return QVariant(); return QVariant();
} }
QModelIndex CParticleTreeModel::index(int row, int column, const QModelIndex &parent) QModelIndex CParticleTreeModel::index(int row, int column, const QModelIndex &parent)
const const
{ {
if (!hasIndex(row, column, parent)) if (!hasIndex(row, column, parent))
return QModelIndex(); return QModelIndex();
CParticleTreeItem *parentItem; CParticleTreeItem *parentItem;
if (!parent.isValid()) if (!parent.isValid())
parentItem = _rootItem; parentItem = _rootItem;
else else
parentItem = static_cast<CParticleTreeItem*>(parent.internalPointer()); parentItem = static_cast<CParticleTreeItem*>(parent.internalPointer());
CParticleTreeItem *childItem = parentItem->child(row); CParticleTreeItem *childItem = parentItem->child(row);
if (childItem) if (childItem)
return createIndex(row, column, childItem); return createIndex(row, column, childItem);
else else
return QModelIndex(); return QModelIndex();
} }
QModelIndex CParticleTreeModel::parent(const QModelIndex &index) const QModelIndex CParticleTreeModel::parent(const QModelIndex &index) const
{ {
if (!index.isValid()) if (!index.isValid())
return QModelIndex(); return QModelIndex();
CParticleTreeItem *childItem = static_cast<CParticleTreeItem*>(index.internalPointer()); CParticleTreeItem *childItem = static_cast<CParticleTreeItem*>(index.internalPointer());
CParticleTreeItem *parentItem = childItem->parent(); CParticleTreeItem *parentItem = childItem->parent();
if (parentItem == _rootItem) if (parentItem == _rootItem)
return QModelIndex(); return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem); return createIndex(parentItem->row(), 0, parentItem);
} }
@ -299,12 +300,12 @@ int CParticleTreeModel::rowCount(const QModelIndex &parent) const
{ {
CParticleTreeItem *parentItem; CParticleTreeItem *parentItem;
if (parent.column() > 0) if (parent.column() > 0)
return 0; return 0;
if (!parent.isValid()) if (!parent.isValid())
parentItem = _rootItem; parentItem = _rootItem;
else else
parentItem = static_cast<CParticleTreeItem*>(parent.internalPointer()); parentItem = static_cast<CParticleTreeItem*>(parent.internalPointer());
return parentItem->childCount(); return parentItem->childCount();
} }
@ -333,30 +334,30 @@ QIcon CParticleTreeModel::getIcon(const QModelIndex &index) const
CParticleTreeItem *item = static_cast<CParticleTreeItem*>(index.internalPointer()); CParticleTreeItem *item = static_cast<CParticleTreeItem*>(index.internalPointer());
switch (item->itemType()) switch (item->itemType())
{ {
case ItemType::Root: case ItemType::Root:
break; break;
case ItemType::Workspace: case ItemType::Workspace:
return QIcon(":/images/Workspace.bmp"); return QIcon(":/images/Workspace.bmp");
case ItemType::ParticleSystem: case ItemType::ParticleSystem:
return QIcon(":/images/ParticleSystem.bmp"); return QIcon(":/images/ParticleSystem.bmp");
case ItemType::Particle: case ItemType::Particle:
return QIcon(":/images/Particle.bmp"); return QIcon(":/images/Particle.bmp");
case ItemType::Emitter: case ItemType::Emitter:
return QIcon(":/images/Emitter.bmp"); return QIcon(":/images/Emitter.bmp");
case ItemType::Force: case ItemType::Force:
return QIcon(":/images/Force.bmp"); return QIcon(":/images/Force.bmp");
case ItemType::Light: case ItemType::Light:
return QIcon(":/images/Light.bmp"); return QIcon(":/images/Light.bmp");
case ItemType::Sound: case ItemType::Sound:
return QIcon(":/images/Sound.bmp"); return QIcon(":/images/Sound.bmp");
case ItemType::Located: case ItemType::Located:
return QIcon(":/images/Located.bmp"); return QIcon(":/images/Located.bmp");
case ItemType::CollisionZone: case ItemType::CollisionZone:
return QIcon(":/images/CollisionZone.bmp"); return QIcon(":/images/CollisionZone.bmp");
case ItemType::LocatedInstance: case ItemType::LocatedInstance:
return QIcon(":/images/LocatedInstance.bmp"); return QIcon(":/images/LocatedInstance.bmp");
case ItemType::ParticleSystemNotLoaded: case ItemType::ParticleSystemNotLoaded:
return QIcon(":/images/ParticleSystemNotLoaded.bmp"); return QIcon(":/images/ParticleSystemNotLoaded.bmp");
} }
return QIcon(); return QIcon();
} }
@ -366,7 +367,7 @@ bool CParticleTreeModel::insertRows(CWorkspaceNode *node, int position, const QM
CParticleTreeItem *item = static_cast<CParticleTreeItem*>(parent.internalPointer()); CParticleTreeItem *item = static_cast<CParticleTreeItem*>(parent.internalPointer());
beginInsertRows(parent, position, position); beginInsertRows(parent, position, position);
setupModelFromPS(node, item); setupModelFromPS(node, item);
endInsertRows(); endInsertRows();
if (node->isLoaded()) if (node->isLoaded())
@ -386,7 +387,7 @@ bool CParticleTreeModel::insertRows(NL3D::CPSLocated *loc, int position, const Q
CParticleTreeItem *item = static_cast<CParticleTreeItem*>(parent.internalPointer()); CParticleTreeItem *item = static_cast<CParticleTreeItem*>(parent.internalPointer());
beginInsertRows(parent, position, position); beginInsertRows(parent, position, position);
createItemFromLocated(loc, item); createItemFromLocated(loc, item);
endInsertRows(); endInsertRows();
QModelIndex indexLocated = index(item->childCount() - 1, 0, parent); QModelIndex indexLocated = index(item->childCount() - 1, 0, parent);
@ -402,7 +403,7 @@ bool CParticleTreeModel::insertRows(NL3D::CPSLocated *loc, int position, const Q
bool CParticleTreeModel::insertRow(NL3D::CPSLocated *loc, uint32 index, int position, const QModelIndex &parent) bool CParticleTreeModel::insertRow(NL3D::CPSLocated *loc, uint32 index, int position, const QModelIndex &parent)
{ {
beginInsertRows(parent, position, position); beginInsertRows(parent, position, position);
createItemFromLocatedInstance(loc, index, static_cast<CParticleTreeItem*>(parent.internalPointer())); createItemFromLocatedInstance(loc, index, static_cast<CParticleTreeItem*>(parent.internalPointer()));
endInsertRows(); endInsertRows();
return true; return true;
} }
@ -422,7 +423,7 @@ bool CParticleTreeModel::removeRows(int position, const QModelIndex &parent)
removeRows(0, parent.child(position, 0)); removeRows(0, parent.child(position, 0));
beginRemoveRows(parent, position, position); beginRemoveRows(parent, position, position);
static_cast<CParticleTreeItem*>(parent.internalPointer())->deleteChild(position); static_cast<CParticleTreeItem*>(parent.internalPointer())->deleteChild(position);
endRemoveRows(); endRemoveRows();
return false; return false;
} }
@ -432,21 +433,21 @@ CWorkspaceNode *CParticleTreeModel::getOwnerNode(CParticleTreeItem *item) const
CWorkspaceNode *node = NULL; CWorkspaceNode *node = NULL;
switch (item->itemType()) switch (item->itemType())
{ {
case ItemType::ParticleSystem: case ItemType::ParticleSystem:
node = item->getNode(); node = item->getNode();
break; break;
case ItemType::Located: case ItemType::Located:
node = item->parent()->getNode(); node = item->parent()->getNode();
break; break;
case ItemType::LocatedInstance: case ItemType::LocatedInstance:
case ItemType::Particle: case ItemType::Particle:
case ItemType::Emitter: case ItemType::Emitter:
case ItemType::Force: case ItemType::Force:
case ItemType::Light: case ItemType::Light:
case ItemType::Sound: case ItemType::Sound:
case ItemType::CollisionZone: case ItemType::CollisionZone:
node = item->parent()->parent()->getNode(); node = item->parent()->parent()->getNode();
break; break;
} }
return node; return node;
} }

View file

@ -34,7 +34,8 @@
// Projects includes // Projects includes
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
struct ItemType struct ItemType
{ {
@ -128,9 +129,9 @@ public:
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const; int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const; const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const; QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;

View file

@ -42,9 +42,11 @@
#include "dup_ps.h" #include "dup_ps.h"
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
static const char * const LocatedBindable[] = { static const char * const LocatedBindable[] =
{
QT_TR_NOOP("Point"), QT_TR_NOOP("Point"),
QT_TR_NOOP("LookAt"), QT_TR_NOOP("LookAt"),
QT_TR_NOOP("FanLight"), QT_TR_NOOP("FanLight"),
@ -121,7 +123,7 @@ struct Action
static std::map<std::string, uint> _PSElementIdentifiers; static std::map<std::string, uint> _PSElementIdentifiers;
CParticleWorkspaceDialog::CParticleWorkspaceDialog(QWidget *parent) CParticleWorkspaceDialog::CParticleWorkspaceDialog(QWidget *parent)
: QDockWidget(parent), _currentItem(NULL) : QDockWidget(parent), _currentItem(NULL)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -222,7 +224,7 @@ void CParticleWorkspaceDialog::clickedItem(const QModelIndex & index)
_PropertyDialog->setCurrentEditedElement(_currentItem); _PropertyDialog->setCurrentEditedElement(_currentItem);
if ((_currentItem->itemType() == ItemType::Workspace) || if ((_currentItem->itemType() == ItemType::Workspace) ||
(_currentItem->itemType() == ItemType::ParticleSystemNotLoaded)) (_currentItem->itemType() == ItemType::ParticleSystemNotLoaded))
_currentItem = NULL; _currentItem = NULL;
} }
@ -234,56 +236,56 @@ void CParticleWorkspaceDialog::customContextMenu()
QMenu *popurMenu = new QMenu(this); QMenu *popurMenu = new QMenu(this);
switch (_currentItem->itemType()) switch (_currentItem->itemType())
{ {
case ItemType::ParticleSystem: case ItemType::ParticleSystem:
popurMenu->addAction(_setActivePSAction); popurMenu->addAction(_setActivePSAction);
popurMenu->addAction(_savePSAction); popurMenu->addAction(_savePSAction);
popurMenu->addAction(_saveAsPSAction); popurMenu->addAction(_saveAsPSAction);
popurMenu->addAction(_clearContentAction); popurMenu->addAction(_clearContentAction);
popurMenu->addAction(_removeFromWSAction); popurMenu->addAction(_removeFromWSAction);
popurMenu->addAction(_mergeAction); popurMenu->addAction(_mergeAction);
popurMenu->addSeparator(); popurMenu->addSeparator();
popurMenu->addAction(_newLocatedAction); popurMenu->addAction(_newLocatedAction);
popurMenu->addAction(_pasteLocatedAction); popurMenu->addAction(_pasteLocatedAction);
popurMenu->addSeparator(); popurMenu->addSeparator();
buildMenu(popurMenu); buildMenu(popurMenu);
popurMenu->addSeparator(); popurMenu->addSeparator();
popurMenu->addAction(_forceZBiasAction); popurMenu->addAction(_forceZBiasAction);
break; break;
case ItemType::Located: case ItemType::Located:
popurMenu->addAction(_instanciateAction); popurMenu->addAction(_instanciateAction);
popurMenu->addSeparator(); popurMenu->addSeparator();
buildMenu(popurMenu); buildMenu(popurMenu);
popurMenu->addSeparator(); popurMenu->addSeparator();
popurMenu->addAction(_copyLocatedAction); popurMenu->addAction(_copyLocatedAction);
popurMenu->addAction(_pasteBindableAction); popurMenu->addAction(_pasteBindableAction);
popurMenu->addAction(_deleteAction); popurMenu->addAction(_deleteAction);
break; break;
case ItemType::Force: case ItemType::Force:
case ItemType::Particle: case ItemType::Particle:
case ItemType::Emitter: case ItemType::Emitter:
case ItemType::Light: case ItemType::Light:
case ItemType::CollisionZone: case ItemType::CollisionZone:
case ItemType::Sound: case ItemType::Sound:
popurMenu->addAction(_copyBindableAction); popurMenu->addAction(_copyBindableAction);
popurMenu->addAction(_deleteAction); popurMenu->addAction(_deleteAction);
popurMenu->addSeparator(); popurMenu->addSeparator();
popurMenu->addAction(_allLODAction); popurMenu->addAction(_allLODAction);
popurMenu->addAction(_lod1Action); popurMenu->addAction(_lod1Action);
popurMenu->addAction(_lod2Action); popurMenu->addAction(_lod2Action);
popurMenu->addSeparator(); popurMenu->addSeparator();
popurMenu->addAction(_externIDAction); popurMenu->addAction(_externIDAction);
// check the menu to tell which lod is used for this located bindable // check the menu to tell which lod is used for this located bindable
if (_currentItem->getBind()->getLOD() == NL3D::PSLod1n2) _allLODAction->setChecked(true); if (_currentItem->getBind()->getLOD() == NL3D::PSLod1n2) _allLODAction->setChecked(true);
else _allLODAction->setChecked(false); else _allLODAction->setChecked(false);
if (_currentItem->getBind()->getLOD() == NL3D::PSLod1) _lod1Action->setChecked(true); if (_currentItem->getBind()->getLOD() == NL3D::PSLod1) _lod1Action->setChecked(true);
else _lod1Action->setChecked(false); else _lod1Action->setChecked(false);
if (_currentItem->getBind()->getLOD() == NL3D::PSLod2) _lod2Action->setChecked(true); if (_currentItem->getBind()->getLOD() == NL3D::PSLod2) _lod2Action->setChecked(true);
else _lod2Action->setChecked(false); else _lod2Action->setChecked(false);
break; break;
case ItemType::LocatedInstance: case ItemType::LocatedInstance:
popurMenu->addAction(_deleteAction); popurMenu->addAction(_deleteAction);
break; break;
} }
bool stopped = Modules::psEdit().getState() == CParticleEditor::State::Stopped ? true : false; bool stopped = Modules::psEdit().getState() == CParticleEditor::State::Stopped ? true : false;
@ -320,18 +322,18 @@ void CParticleWorkspaceDialog::saveAsPS()
if (node->getPSPointer()->getAutoCountFlag()) if (node->getPSPointer()->getAutoCountFlag())
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
QString(node->getFilename().c_str()) + tr(" uses auto count feature, and it has been modified. " QString(node->getFilename().c_str()) + tr(" uses auto count feature, and it has been modified. "
"You should run the system entirely at least once at full detail before saving so that the editor can compute the number of particles in the system. " "You should run the system entirely at least once at full detail before saving so that the editor can compute the number of particles in the system. "
"If user params are used to modify system aspect, you should run the system for extreme cases before saving. "), "If user params are used to modify system aspect, you should run the system for extreme cases before saving. "),
QMessageBox::Ok); QMessageBox::Ok);
} }
else else
{ {
Modules::psEdit().stop(); Modules::psEdit().stop();
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as ps file"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as ps file"),
".", ".",
tr("ps files (*.ps)")); tr("ps files (*.ps)"));
// after check // after check
if (!fileName.isEmpty()) if (!fileName.isEmpty())
node->savePSAs(fileName.toStdString()); node->savePSAs(fileName.toStdString());
@ -341,7 +343,7 @@ void CParticleWorkspaceDialog::saveAsPS()
void CParticleWorkspaceDialog::clearContent() void CParticleWorkspaceDialog::clearContent()
{ {
int ret = QMessageBox::question(this, tr("NeL particle system editor"), int ret = QMessageBox::question(this, tr("NeL particle system editor"),
tr("Clear content ?"), QMessageBox::Yes | QMessageBox::No); tr("Clear content ?"), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) if (ret == QMessageBox::Yes)
{ {
@ -392,9 +394,9 @@ void CParticleWorkspaceDialog::pasteLocated()
{ {
delete copy; delete copy;
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first."), "and thus, should have a finite duration. Please remove that flag first."),
QMessageBox::Ok); QMessageBox::Ok);
} }
} }
@ -403,101 +405,101 @@ void CParticleWorkspaceDialog::bindNewLocatedBindable(int id)
NL3D::CPSLocatedBindable *toCreate = NULL; NL3D::CPSLocatedBindable *toCreate = NULL;
switch (id) switch (id)
{ {
case Action::ParticlePoint: case Action::ParticlePoint:
toCreate = new NL3D::CPSDot; toCreate = new NL3D::CPSDot;
break; break;
case Action::ParticleLookAt: case Action::ParticleLookAt:
toCreate = new NL3D::CPSFaceLookAt; toCreate = new NL3D::CPSFaceLookAt;
break; break;
case Action::ParticleFanLight: case Action::ParticleFanLight:
toCreate = new NL3D::CPSFanLight; toCreate = new NL3D::CPSFanLight;
break; break;
case Action::ParticleRibbon: case Action::ParticleRibbon:
toCreate = new NL3D::CPSRibbon; toCreate = new NL3D::CPSRibbon;
break; break;
case Action::ParticleTailDot: case Action::ParticleTailDot:
toCreate = new NL3D::CPSTailDot; toCreate = new NL3D::CPSTailDot;
break; break;
case Action::ParticleMesh: case Action::ParticleMesh:
toCreate = new NL3D::CPSMesh; toCreate = new NL3D::CPSMesh;
break; break;
case Action::ParticleConstraintMesh: case Action::ParticleConstraintMesh:
toCreate = new NL3D::CPSConstraintMesh; toCreate = new NL3D::CPSConstraintMesh;
break; break;
case Action::ParticleFace: case Action::ParticleFace:
toCreate = new NL3D::CPSFace; toCreate = new NL3D::CPSFace;
break; break;
case Action::ParticleShockWave: case Action::ParticleShockWave:
toCreate = new NL3D::CPSShockWave; toCreate = new NL3D::CPSShockWave;
break; break;
case Action::ParticleRibbonLookAt: case Action::ParticleRibbonLookAt:
toCreate = new NL3D::CPSRibbonLookAt; toCreate = new NL3D::CPSRibbonLookAt;
break; break;
case Action::ForceGravity: case Action::ForceGravity:
toCreate = new NL3D::CPSGravity; toCreate = new NL3D::CPSGravity;
break; break;
case Action::ForceDirectional: case Action::ForceDirectional:
toCreate = new NL3D::CPSDirectionnalForce; toCreate = new NL3D::CPSDirectionnalForce;
break; break;
case Action::ForceSpring: case Action::ForceSpring:
toCreate = new NL3D::CPSSpring; toCreate = new NL3D::CPSSpring;
break; break;
case Action::ForceFlyidFriction: case Action::ForceFlyidFriction:
toCreate = new NL3D::CPSFluidFriction; toCreate = new NL3D::CPSFluidFriction;
break; break;
case Action::ForceCentralGravity: case Action::ForceCentralGravity:
toCreate = new NL3D::CPSCentralGravity; toCreate = new NL3D::CPSCentralGravity;
break; break;
case Action::ForceCylindricVortex: case Action::ForceCylindricVortex:
toCreate = new NL3D::CPSCylindricVortex; toCreate = new NL3D::CPSCylindricVortex;
break; break;
case Action::ForceBrownianMove: case Action::ForceBrownianMove:
toCreate = new NL3D::CPSBrownianForce; toCreate = new NL3D::CPSBrownianForce;
break; break;
case Action::ForceMagnetic: case Action::ForceMagnetic:
toCreate = new NL3D::CPSMagneticForce; toCreate = new NL3D::CPSMagneticForce;
break; break;
case Action::ZonePlane: case Action::ZonePlane:
toCreate = new NL3D::CPSZonePlane; toCreate = new NL3D::CPSZonePlane;
break; break;
case Action::ZoneSphere: case Action::ZoneSphere:
toCreate = new NL3D::CPSZoneSphere; toCreate = new NL3D::CPSZoneSphere;
break; break;
case Action::ZoneRectangle: case Action::ZoneRectangle:
toCreate = new NL3D::CPSZoneRectangle; toCreate = new NL3D::CPSZoneRectangle;
break; break;
case Action::ZoneDisc: case Action::ZoneDisc:
toCreate = new NL3D::CPSZoneDisc; toCreate = new NL3D::CPSZoneDisc;
break; break;
case Action::ZoneCylinder: case Action::ZoneCylinder:
toCreate = new NL3D::CPSZoneCylinder; toCreate = new NL3D::CPSZoneCylinder;
break; break;
case Action::EmitterDirectional: case Action::EmitterDirectional:
toCreate = new NL3D::CPSEmitterDirectionnal; toCreate = new NL3D::CPSEmitterDirectionnal;
break; break;
case Action::EmitterOmniDirectional: case Action::EmitterOmniDirectional:
toCreate = new NL3D::CPSEmitterOmni; toCreate = new NL3D::CPSEmitterOmni;
break; break;
case Action::EmitterRectangle: case Action::EmitterRectangle:
toCreate = new NL3D::CPSEmitterRectangle; toCreate = new NL3D::CPSEmitterRectangle;
break; break;
case Action::EmitterConic: case Action::EmitterConic:
toCreate = new NL3D::CPSEmitterConic; toCreate = new NL3D::CPSEmitterConic;
break; break;
case Action::EmitterSpherical: case Action::EmitterSpherical:
toCreate = new NL3D::CPSSphericalEmitter; toCreate = new NL3D::CPSSphericalEmitter;
break; break;
case Action::EmitterRadial: case Action::EmitterRadial:
toCreate = new NL3D::CPSRadialEmitter; toCreate = new NL3D::CPSRadialEmitter;
break; break;
case Action::Sound: case Action::Sound:
toCreate = new NL3D::CPSSound; toCreate = new NL3D::CPSSound;
if (!Modules::psEdit().isRunning()) if (!Modules::psEdit().isRunning())
(static_cast<NL3D::CPSSound *>(toCreate))->stopSound(); (static_cast<NL3D::CPSSound *>(toCreate))->stopSound();
break; break;
case Action::Light: case Action::Light:
toCreate = new NL3D::CPSLight; toCreate = new NL3D::CPSLight;
break; break;
} }
_treeModel->getOwnerNode(_currentItem)->setModified(true); _treeModel->getOwnerNode(_currentItem)->setModified(true);
@ -510,7 +512,7 @@ void CParticleWorkspaceDialog::bindNewLocatedBindable(int id)
if (_treeModel->getOwnerNode(_currentItem)->getPSPointer()->getBypassMaxNumIntegrationSteps()) if (_treeModel->getOwnerNode(_currentItem)->getPSPointer()->getBypassMaxNumIntegrationSteps())
{ {
if (toCreate->getType() == NL3D::PSParticle || toCreate->getType() == NL3D::PSEmitter) if (toCreate->getType() == NL3D::PSParticle || toCreate->getType() == NL3D::PSEmitter)
loc->setInitialLife(1.f); loc->setInitialLife(1.f);
// object must have finite duration with that flag // object must have finite duration with that flag
} }
} }
@ -520,9 +522,9 @@ void CParticleWorkspaceDialog::bindNewLocatedBindable(int id)
if (!loc->bind(toCreate)) if (!loc->bind(toCreate))
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
tr("The system is flagged with 'No max Nb steps', or uses the preset 'Spell FX'." tr("The system is flagged with 'No max Nb steps', or uses the preset 'Spell FX'."
"System must have finite duration. Can't add object. To solve this, set a limited life time for the father."), "System must have finite duration. Can't add object. To solve this, set a limited life time for the father."),
QMessageBox::Ok); QMessageBox::Ok);
delete toCreate; delete toCreate;
return; return;
} }
@ -593,9 +595,9 @@ void CParticleWorkspaceDialog::pasteBindable()
{ {
delete copy; delete copy;
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', "
"and thus, should have a finite duration. Please remove that flag first."), "and thus, should have a finite duration. Please remove that flag first."),
QMessageBox::Ok); QMessageBox::Ok);
} }
} }
@ -610,50 +612,50 @@ void CParticleWorkspaceDialog::deleteItem()
clickedItem(index.parent()); clickedItem(index.parent());
switch(item->itemType()) switch(item->itemType())
{ {
case ItemType::Located: case ItemType::Located:
{ {
NL3D::CPSLocated *loc = item->getLoc(); NL3D::CPSLocated *loc = item->getLoc();
touchPSState(item); touchPSState(item);
ownerNode->setModified(true); ownerNode->setModified(true);
// if the system is running, we must destroy initial infos about the located, // if the system is running, we must destroy initial infos about the located,
// as they won't need to be restored when the stop button will be pressed // as they won't need to be restored when the stop button will be pressed
ownerNode->removeLocated(loc); ownerNode->removeLocated(loc);
Modules::psEdit().resetAutoCount(ownerNode); Modules::psEdit().resetAutoCount(ownerNode);
ownerNode->getPSPointer()->remove(loc); ownerNode->getPSPointer()->remove(loc);
_treeModel->removeRows(index.row(), index.parent()); _treeModel->removeRows(index.row(), index.parent());
} }
break; break;
case ItemType::LocatedInstance: case ItemType::LocatedInstance:
{ {
Modules::psEdit().resetAutoCount(ownerNode); Modules::psEdit().resetAutoCount(ownerNode);
NL3D::CPSEmitter::setBypassEmitOnDeath(true); NL3D::CPSEmitter::setBypassEmitOnDeath(true);
item->getLoc()->deleteElement(item->getLocatedInstanceIndex()); item->getLoc()->deleteElement(item->getLocatedInstanceIndex());
NL3D::CPSEmitter::setBypassEmitOnDeath(false); NL3D::CPSEmitter::setBypassEmitOnDeath(false);
_treeModel->removeRows(index.row(), index.parent()); _treeModel->removeRows(index.row(), index.parent());
_treeModel->rebuildLocatedInstance(_ui.treeView->currentIndex()); _treeModel->rebuildLocatedInstance(_ui.treeView->currentIndex());
} }
break; break;
case ItemType::Particle: case ItemType::Particle:
case ItemType::Emitter: case ItemType::Emitter:
case ItemType::Force: case ItemType::Force:
case ItemType::Light: case ItemType::Light:
case ItemType::Sound: case ItemType::Sound:
case ItemType::CollisionZone: case ItemType::CollisionZone:
{ {
NL3D::CPSLocatedBindable *lb = item->getBind(); NL3D::CPSLocatedBindable *lb = item->getBind();
touchPSState(item); touchPSState(item);
// if the system is running, we must destroy initial infos // if the system is running, we must destroy initial infos
// that what saved about the located bindable, when the start button was pressed, as they won't need // that what saved about the located bindable, when the start button was pressed, as they won't need
// to be restored // to be restored
ownerNode->removeLocatedBindable(lb); ownerNode->removeLocatedBindable(lb);
ownerNode->setModified(true); ownerNode->setModified(true);
Modules::psEdit().resetAutoCount(ownerNode); Modules::psEdit().resetAutoCount(ownerNode);
lb->getOwner()->remove(lb); lb->getOwner()->remove(lb);
_treeModel->removeRows(index.row(), index.parent()); _treeModel->removeRows(index.row(), index.parent());
} }
break; break;
} }
} }
@ -667,7 +669,7 @@ void CParticleWorkspaceDialog::setInstanciate()
_currentItem->getLoc()->resize(_currentItem->getLoc()->getMaxSize() + 1); _currentItem->getLoc()->resize(_currentItem->getLoc()->getMaxSize() + 1);
sint32 objIndex = _currentItem->getLoc()->newElement(NLMISC::CVector::Null, NLMISC::CVector::Null, sint32 objIndex = _currentItem->getLoc()->newElement(NLMISC::CVector::Null, NLMISC::CVector::Null,
NULL, 0, _currentItem->getLoc()->getMatrixMode(), 0.f); NULL, 0, _currentItem->getLoc()->getMatrixMode(), 0.f);
_treeModel->insertRow(_currentItem->getLoc(), objIndex, _currentItem->childCount(), _ui.treeView->currentIndex()); _treeModel->insertRow(_currentItem->getLoc(), objIndex, _currentItem->childCount(), _ui.treeView->currentIndex());
} }
@ -694,8 +696,8 @@ void CParticleWorkspaceDialog::setExternID()
{ {
bool ok; bool ok;
int i = QInputDialog::getInt(this, tr("Set the extern ID"), int i = QInputDialog::getInt(this, tr("Set the extern ID"),
tr("0 means no extern access."), tr("0 means no extern access."),
_currentItem->getBind()->getExternID(), 0, 9999, 1, &ok); _currentItem->getBind()->getExternID(), 0, 9999, 1, &ok);
if (ok) if (ok)
{ {
_currentItem->getBind()->setExternID(uint32(i)); _currentItem->getBind()->setExternID(uint32(i));

View file

@ -34,7 +34,8 @@
#include "particle_tree_model.h" #include "particle_tree_model.h"
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
/** /**
@class ParticleWorkspaceDialog @class ParticleWorkspaceDialog
@ -48,7 +49,10 @@ public:
~CParticleWorkspaceDialog(); ~CParticleWorkspaceDialog();
void touchPSState(CParticleTreeItem *item); void touchPSState(CParticleTreeItem *item);
CPropertyDialog *getPropertyDialog() const { return _PropertyDialog; } CPropertyDialog *getPropertyDialog() const
{
return _PropertyDialog;
}
Q_SIGNALS: Q_SIGNALS:
/// Emits change active particle system node. /// Emits change active particle system node.

View file

@ -30,10 +30,11 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CWorkspacePage::CWorkspacePage(CParticleTreeModel *treeModel, QWidget *parent) CWorkspacePage::CWorkspacePage(CParticleTreeModel *treeModel, QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -57,8 +58,8 @@ void CWorkspacePage::newWP()
//checkModifiedWorkSpace(); //checkModifiedWorkSpace();
// ask name of the new workspace to create // ask name of the new workspace to create
QString fileName = QFileDialog::getSaveFileName(this, tr("Create new pws file"), QString fileName = QFileDialog::getSaveFileName(this, tr("Create new pws file"),
".", ".",
tr("pws files (*.pws)")); tr("pws files (*.pws)"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
Modules::psEdit().createNewWorkspace(fileName.toStdString()); Modules::psEdit().createNewWorkspace(fileName.toStdString());
@ -75,8 +76,8 @@ void CWorkspacePage::loadWP()
{ {
//checkModifiedWorkSpace(); //checkModifiedWorkSpace();
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("Particle Workspace file (*.pws);;")); tr("Particle Workspace file (*.pws);;"));
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
@ -102,8 +103,8 @@ void CWorkspacePage::saveWP()
void CWorkspacePage::saveAsWP() void CWorkspacePage::saveAsWP()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as pws file"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as pws file"),
".", ".",
tr("pws files (*.pws)")); tr("pws files (*.pws)"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
Modules::psEdit().getParticleWorkspace()->setFileName(fileName.toStdString()); Modules::psEdit().getParticleWorkspace()->setFileName(fileName.toStdString());
@ -116,8 +117,8 @@ void CWorkspacePage::saveAsWP()
void CWorkspacePage::insertPS() void CWorkspacePage::insertPS()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open NeL data file"), ".", tr("Open NeL data file"), ".",
tr("Particle System file (*.ps);;")); tr("Particle System file (*.ps);;"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
@ -132,8 +133,8 @@ void CWorkspacePage::insertPS()
catch(NLMISC::EStream &e) catch(NLMISC::EStream &e)
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
QString(e.what()), QString(e.what()),
QMessageBox::Ok); QMessageBox::Ok);
} }
if (!node->isLoaded()) if (!node->isLoaded())
Modules::psEdit().getParticleWorkspace()->removeNode(Modules::psEdit().getParticleWorkspace()->getNumNode() - 1); Modules::psEdit().getParticleWorkspace()->removeNode(Modules::psEdit().getParticleWorkspace()->getNumNode() - 1);
@ -149,8 +150,8 @@ void CWorkspacePage::insertPS()
void CWorkspacePage::createPS() void CWorkspacePage::createPS()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Create new particle system file"), QString fileName = QFileDialog::getSaveFileName(this, tr("Create new particle system file"),
".", ".",
tr("ps files (*.ps)")); tr("ps files (*.ps)"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
@ -158,8 +159,8 @@ void CWorkspacePage::createPS()
if (Modules::psEdit().getParticleWorkspace()->containsFile(NLMISC::CFile::getFilename(fileName.toStdString()))) if (Modules::psEdit().getParticleWorkspace()->containsFile(NLMISC::CFile::getFilename(fileName.toStdString())))
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
tr("Failed to create new particle system"), tr("Failed to create new particle system"),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
CWorkspaceNode *node = Modules::psEdit().getParticleWorkspace()->addNode(NLMISC::CFile::getFilename(fileName.toStdString())); CWorkspaceNode *node = Modules::psEdit().getParticleWorkspace()->addNode(NLMISC::CFile::getFilename(fileName.toStdString()));
@ -174,9 +175,9 @@ void CWorkspacePage::createPS()
catch (NLMISC::Exception &e) catch (NLMISC::Exception &e)
{ {
QMessageBox::critical(this, tr("NeL particle system editor"), QMessageBox::critical(this, tr("NeL particle system editor"),
QString(e.what()), QString(e.what()),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
QModelIndex index = _treeModel->index(0, 0); QModelIndex index = _treeModel->index(0, 0);
_treeModel->insertRows(node, static_cast<CParticleTreeItem*>(index.internalPointer())->childCount(), index); _treeModel->insertRows(node, static_cast<CParticleTreeItem*>(index.internalPointer())->childCount(), index);

View file

@ -31,7 +31,8 @@
// Project includes // Project includes
#include "particle_tree_model.h" #include "particle_tree_model.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CWorkspacePage @class CWorkspacePage
@ -39,7 +40,7 @@ namespace NLQT {
*/ */
class CWorkspacePage: public QWidget class CWorkspacePage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CWorkspacePage(CParticleTreeModel *treeModel, QWidget *parent = 0); CWorkspacePage(CParticleTreeModel *treeModel, QWidget *parent = 0);

View file

@ -28,10 +28,11 @@
#include "particle_force_page.h" #include "particle_force_page.h"
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
CZonePage::CZonePage(QWidget *parent) CZonePage::CZonePage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -50,7 +51,7 @@ CZonePage::~CZonePage()
void CZonePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindable *locatedBindable) void CZonePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindable *locatedBindable)
{ {
_Node = ownerNode; _Node = ownerNode;
_LBTarget = static_cast<NL3D::CPSTargetLocatedBindable *>(locatedBindable); _LBTarget = static_cast<NL3D::CPSTargetLocatedBindable *>(locatedBindable);
_Zone = dynamic_cast<NL3D::CPSZone *>(_LBTarget); _Zone = dynamic_cast<NL3D::CPSZone *>(_LBTarget);
@ -107,7 +108,7 @@ void CZonePage::setBounce(int index)
void CZonePage::setBounceFactor(float value) void CZonePage::setBounceFactor(float value)
{ {
_Zone->setBounceFactor(value); _Zone->setBounceFactor(value);
updateModifiedFlag(); updateModifiedFlag();
} }
void CZonePage::updateTargets() void CZonePage::updateTargets()
@ -123,7 +124,7 @@ void CZonePage::updateTargets()
for(k = 0; k < nbTarg; ++k) for(k = 0; k < nbTarg; ++k)
{ {
CLocatedItem *item = new CLocatedItem(QString(_LBTarget->getTarget(k)->getName().c_str()), CLocatedItem *item = new CLocatedItem(QString(_LBTarget->getTarget(k)->getName().c_str()),
_ui.targetsListWidget); _ui.targetsListWidget);
item->setUserData(_LBTarget->getTarget(k)); item->setUserData(_LBTarget->getTarget(k));
targetSet.insert(_LBTarget->getTarget(k)); targetSet.insert(_LBTarget->getTarget(k));
}; };
@ -143,7 +144,7 @@ void CZonePage::updateTargets()
if (targetSet.find(loc) == targetSet.end()) if (targetSet.find(loc) == targetSet.end())
{ {
CLocatedItem *item = new CLocatedItem(QString(loc->getName().c_str()), CLocatedItem *item = new CLocatedItem(QString(loc->getName().c_str()),
_ui.avaibleTargetsListWidget); _ui.avaibleTargetsListWidget);
item->setUserData(loc); item->setUserData(loc);
} }
} }

View file

@ -31,11 +31,12 @@
// Project includes // Project includes
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
class CZonePage: public QWidget class CZonePage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CZonePage(QWidget *parent = 0); CZonePage(QWidget *parent = 0);
@ -53,7 +54,10 @@ private Q_SLOTS:
private: private:
void updateTargets(); void updateTargets();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
/// the target we're focusing on /// the target we're focusing on
NL3D::CPSTargetLocatedBindable *_LBTarget; NL3D::CPSTargetLocatedBindable *_LBTarget;

View file

@ -23,7 +23,8 @@
#include "nel/3d/ps_edit.h" #include "nel/3d/ps_edit.h"
#include "nel/3d/ps_emitter.h" #include "nel/3d/ps_emitter.h"
namespace NLQT { namespace NLQT
{
void CPSInitialPos::reset() void CPSInitialPos::reset()
{ {
@ -87,19 +88,28 @@ struct CRemoveLocatedPred
// private : predicate to remove located from a CPSInitialPos::TInitialLocatedSizeVect vector // private : predicate to remove located from a CPSInitialPos::TInitialLocatedSizeVect vector
struct CRemoveLocatedFromLocatedSizePred : public CRemoveLocatedPred struct CRemoveLocatedFromLocatedSizePred : public CRemoveLocatedPred
{ {
bool operator()(const std::pair<NL3D::CPSLocated *, uint32> &value) { return Loc == value.first; } bool operator()(const std::pair<NL3D::CPSLocated *, uint32> &value)
{
return Loc == value.first;
}
}; };
// private : predicate to remove located from a PSInitialPos::CInitPSInstanceInfo vector // private : predicate to remove located from a PSInitialPos::CInitPSInstanceInfo vector
struct CRemoveLocatedFromInitPSInstanceInfoVectPred : public CRemoveLocatedPred struct CRemoveLocatedFromInitPSInstanceInfoVectPred : public CRemoveLocatedPred
{ {
bool operator()(const CPSInitialPos::CInitPSInstanceInfo &value) { return value.Loc == Loc; } bool operator()(const CPSInitialPos::CInitPSInstanceInfo &value)
{
return value.Loc == Loc;
}
}; };
// private : predicate to remove located from a PSInitialPos::CRotScaleInfo vector // private : predicate to remove located from a PSInitialPos::CRotScaleInfo vector
struct CRemoveLocatedFromRotScaleInfoVectPred : public CRemoveLocatedPred struct CRemoveLocatedFromRotScaleInfoVectPred : public CRemoveLocatedPred
{ {
bool operator()(const CPSInitialPos::CRotScaleInfo &value) { return value.Loc == Loc; } bool operator()(const CPSInitialPos::CRotScaleInfo &value)
{
return value.Loc == Loc;
}
}; };
// private : predicate to remove located bindable pointers in a TRotScaleInfoVect vect // private : predicate to remove located bindable pointers in a TRotScaleInfoVect vect
@ -107,7 +117,10 @@ struct CRemoveLocatedBindableFromRotScaleInfoVectPred
{ {
// the located bindable taht has been removed // the located bindable taht has been removed
NL3D::CPSLocatedBindable *LB; NL3D::CPSLocatedBindable *LB;
bool operator()(const CPSInitialPos::CRotScaleInfo &value) { return value.LB == LB; } bool operator()(const CPSInitialPos::CRotScaleInfo &value)
{
return value.LB == LB;
}
}; };
void CPSInitialPos::removeLocated(NL3D::CPSLocated *loc) void CPSInitialPos::removeLocated(NL3D::CPSLocated *loc)
@ -118,7 +131,7 @@ void CPSInitialPos::removeLocated(NL3D::CPSLocated *loc)
CRemoveLocatedFromLocatedSizePred p; CRemoveLocatedFromLocatedSizePred p;
p.Loc = loc; p.Loc = loc;
_InitialSizeVect.erase(std::remove_if(_InitialSizeVect.begin(), _InitialSizeVect.end(), p) _InitialSizeVect.erase(std::remove_if(_InitialSizeVect.begin(), _InitialSizeVect.end(), p)
, _InitialSizeVect.end() ); , _InitialSizeVect.end() );
CRemoveLocatedFromInitPSInstanceInfoVectPred p2; CRemoveLocatedFromInitPSInstanceInfoVectPred p2;
p2.Loc = loc; p2.Loc = loc;
@ -128,7 +141,7 @@ void CPSInitialPos::removeLocated(NL3D::CPSLocated *loc)
CRemoveLocatedFromRotScaleInfoVectPred p3; CRemoveLocatedFromRotScaleInfoVectPred p3;
p3.Loc = loc; p3.Loc = loc;
_RotScaleInfoVect.erase(std::remove_if(_RotScaleInfoVect.begin(), _RotScaleInfoVect.end(), p3) _RotScaleInfoVect.erase(std::remove_if(_RotScaleInfoVect.begin(), _RotScaleInfoVect.end(), p3)
, _RotScaleInfoVect.end()); , _RotScaleInfoVect.end());
} }
@ -162,7 +175,7 @@ void CPSInitialPos::restoreSystem()
// recreate the initial number of instances // recreate the initial number of instances
for (TInitialLocatedSizeVect ::iterator itSize = _InitialSizeVect.begin(); itSize != _InitialSizeVect.end(); ++itSize) for (TInitialLocatedSizeVect ::iterator itSize = _InitialSizeVect.begin(); itSize != _InitialSizeVect.end(); ++itSize)
{ {
// nlassert(itSize->first->getSize() == 0) // nlassert(itSize->first->getSize() == 0)
for (uint l = 0; l < itSize->second; ++l) for (uint l = 0; l < itSize->second; ++l)
{ {
itSize->first->newElement(NLMISC::CVector::Null, NLMISC::CVector::Null, NULL, 0, itSize->first->getMatrixMode(), 0.f); itSize->first->newElement(NLMISC::CVector::Null, NLMISC::CVector::Null, NULL, 0, itSize->first->getMatrixMode(), 0.f);

View file

@ -24,13 +24,14 @@
namespace NL3D namespace NL3D
{ {
class CParticleSystem; class CParticleSystem;
class CPSLocated; class CPSLocated;
class CPSLocatedBindable; class CPSLocatedBindable;
struct IPSMover; struct IPSMover;
} }
namespace NLQT { namespace NLQT
{
/** /**
@class CPSInitialPos @class CPSInitialPos
This class helps to copy the position of initial instances in a particle This class helps to copy the position of initial instances in a particle
@ -77,9 +78,18 @@ public:
NLMISC::CMatrix Rot; NLMISC::CMatrix Rot;
NLMISC::CVector Scale; NLMISC::CVector Scale;
}; };
NL3D::CParticleSystem *getPS() { return _PS; } NL3D::CParticleSystem *getPS()
const NL3D::CParticleSystem *getPS() const { return _PS; } {
bool isStateMemorized() const { return _PS != NULL; } return _PS;
}
const NL3D::CParticleSystem *getPS() const
{
return _PS;
}
bool isStateMemorized() const
{
return _PS != NULL;
}
private: private:
typedef std::vector<CInitPSInstanceInfo> TInitInfoVect; typedef std::vector<CInitPSInstanceInfo> TInitInfoVect;

View file

@ -27,12 +27,13 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
namespace NLQT { namespace NLQT
{
const float epsilon = 10E-3f; const float epsilon = 10E-3f;
CPSMoverPage::CPSMoverPage(QWidget *parent) CPSMoverPage::CPSMoverPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
@ -57,7 +58,7 @@ CPSMoverPage::CPSMoverPage(QWidget *parent)
connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector))); connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector)));
connect(_ui.listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), connect(_ui.listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changeSubComponent())); this, SLOT(changeSubComponent()));
} }
CPSMoverPage::~CPSMoverPage() CPSMoverPage::~CPSMoverPage()
@ -84,7 +85,7 @@ void CPSMoverPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocated *lo
if (dynamic_cast<NL3D::IPSMover *>(_EditedLocated->getBoundObject(k))) if (dynamic_cast<NL3D::IPSMover *>(_EditedLocated->getBoundObject(k)))
{ {
CLocatedBindableItem *item = new CLocatedBindableItem(QString(_EditedLocated->getBoundObject(k)->getName().c_str()), CLocatedBindableItem *item = new CLocatedBindableItem(QString(_EditedLocated->getBoundObject(k)->getName().c_str()),
_ui.listWidget); _ui.listWidget);
item->setUserData(_EditedLocated->getBoundObject(k)); item->setUserData(_EditedLocated->getBoundObject(k));
++nbCandidates; ++nbCandidates;
} }
@ -118,15 +119,15 @@ void CPSMoverPage::hideAdditionalWidget()
void CPSMoverPage::updateListener(void) void CPSMoverPage::updateListener(void)
{ {
/* if(_ParticleDlg->MainFrame->isMoveElement()) /* if(_ParticleDlg->MainFrame->isMoveElement())
{ {
const NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; const NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
NLMISC::CMatrix m; NLMISC::CMatrix m;
m = _MouseListener->getModelMatrix(); m = _MouseListener->getModelMatrix();
m.setPos(pos); m.setPos(pos);
_MouseListener->setModelMatrix(m); _MouseListener->setModelMatrix(m);
_Node->setModified(true); _Node->setModified(true);
}*/ }*/
} }
void CPSMoverPage::setXPosition(double value) void CPSMoverPage::setXPosition(double value)

View file

@ -35,7 +35,8 @@
// Project includes // Project includes
#include "ps_wrapper.h" #include "ps_wrapper.h"
namespace NLQT { namespace NLQT
{
/** /**
@class CLocatedBindableItem @class CLocatedBindableItem
@ -45,10 +46,16 @@ class CLocatedBindableItem: public QListWidgetItem
{ {
public: public:
CLocatedBindableItem ( const QString & text, QListWidget * parent = 0, int type = UserType ): CLocatedBindableItem ( const QString & text, QListWidget * parent = 0, int type = UserType ):
QListWidgetItem(text, parent, type), _lb(NULL) {} QListWidgetItem(text, parent, type), _lb(NULL) {}
void setUserData(NL3D::CPSLocatedBindable *loc) { _lb = loc;} void setUserData(NL3D::CPSLocatedBindable *loc)
NL3D::CPSLocatedBindable *getUserData() const { return _lb;} {
_lb = loc;
}
NL3D::CPSLocatedBindable *getUserData() const
{
return _lb;
}
private: private:
@ -61,7 +68,7 @@ private:
*/ */
class CPSMoverPage: public QWidget class CPSMoverPage: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CPSMoverPage(QWidget *parent = 0); CPSMoverPage(QWidget *parent = 0);
@ -77,11 +84,20 @@ public:
NL3D::IPSMover *getMoverInterface(void) ; NL3D::IPSMover *getMoverInterface(void) ;
/// get the located being edited /// get the located being edited
NL3D::CPSLocated *getLocated(void) { return _EditedLocated ; } NL3D::CPSLocated *getLocated(void)
const NL3D::CPSLocated *getLocated(void) const { return _EditedLocated ; } {
return _EditedLocated ;
}
const NL3D::CPSLocated *getLocated(void) const
{
return _EditedLocated ;
}
/// get the index of the current edited item /// get the index of the current edited item
uint32 getLocatedIndex(void) const { return _EditedLocatedIndex ; } uint32 getLocatedIndex(void) const
{
return _EditedLocatedIndex ;
}
/// ghet the current located bindable being edited, or null /// ghet the current located bindable being edited, or null
NL3D::CPSLocatedBindable *getLocatedBindable(void) ; NL3D::CPSLocatedBindable *getLocatedBindable(void) ;
@ -101,8 +117,14 @@ private:
{ {
uint32 Index ; uint32 Index ;
NL3D::IPSMover *M ; NL3D::IPSMover *M ;
float get(void) const { return M->getScale(Index).x ; } float get(void) const
void set(const float &v) { M->setScale(Index, v) ; } {
return M->getScale(Index).x ;
}
void set(const float &v)
{
M->setScale(Index, v) ;
}
} _UniformScaleWrapper ; } _UniformScaleWrapper ;
/// wrapper to scale the X coordinate /// wrapper to scale the X coordinate
@ -110,7 +132,10 @@ private:
{ {
uint32 Index ; uint32 Index ;
NL3D::IPSMover *M ; NL3D::IPSMover *M ;
float get(void) const { return M->getScale(Index).x ; } float get(void) const
{
return M->getScale(Index).x ;
}
void set(const float &s) void set(const float &s)
{ {
NLMISC::CVector v = M->getScale(Index) ; NLMISC::CVector v = M->getScale(Index) ;
@ -123,7 +148,10 @@ private:
{ {
uint32 Index ; uint32 Index ;
NL3D::IPSMover *M ; NL3D::IPSMover *M ;
float get(void) const { return M->getScale(Index).y ; } float get(void) const
{
return M->getScale(Index).y ;
}
void set(const float &s) void set(const float &s)
{ {
NLMISC::CVector v = M->getScale(Index) ; NLMISC::CVector v = M->getScale(Index) ;
@ -136,7 +164,10 @@ private:
{ {
uint32 Index ; uint32 Index ;
NL3D::IPSMover *M ; NL3D::IPSMover *M ;
float get(void) const { return M->getScale(Index).z ; } float get(void) const
{
return M->getScale(Index).z ;
}
void set(const float &s) void set(const float &s)
{ {
NLMISC::CVector v = M->getScale(Index) ; NLMISC::CVector v = M->getScale(Index) ;
@ -146,7 +177,10 @@ private:
void hideAdditionalWidget(); void hideAdditionalWidget();
void updateModifiedFlag() { if (_Node) _Node->setModified(true); } void updateModifiedFlag()
{
if (_Node) _Node->setModified(true);
}
/// update the mouse listener position when the user entered a value with the keyboard /// update the mouse listener position when the user entered a value with the keyboard
void updateListener(void) ; void updateListener(void) ;

View file

@ -30,7 +30,8 @@
// //
#include "particle_node.h" #include "particle_node.h"
namespace NLQT { namespace NLQT
{
/// Wrapper to read/write a value of type T /// Wrapper to read/write a value of type T
template <class T> class IPSWrapper template <class T> class IPSWrapper

View file

@ -34,10 +34,11 @@
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
CSettingsDialog::CSettingsDialog(QWidget *parent) CSettingsDialog::CSettingsDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
@ -120,9 +121,9 @@ void CSettingsDialog::applyPressed()
// settings take after restart the program // settings take after restart the program
QMessageBox::warning(this, tr("Settings"), QMessageBox::warning(this, tr("Settings"),
tr("Graphics and sound settings " tr("Graphics and sound settings "
"take after restart the program"), "take after restart the program"),
QMessageBox::Ok); QMessageBox::Ok);
saveGraphicsSettings(); saveGraphicsSettings();
saveSoundSettings(); saveSoundSettings();
@ -139,8 +140,8 @@ void CSettingsDialog::applyPressed()
void CSettingsDialog::setTileBank() void CSettingsDialog::setTileBank()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Set new tile bank"), QString fileName = QFileDialog::getOpenFileName(this, tr("Set new tile bank"),
ui.tileBankLineEdit->text(), ui.tileBankLineEdit->text(),
tr("Tile Bank file (*.smallbank *.bank);;")); tr("Tile Bank file (*.smallbank *.bank);;"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
ui.tileBankLineEdit->setText(fileName); ui.tileBankLineEdit->setText(fileName);
@ -149,9 +150,9 @@ void CSettingsDialog::setTileBank()
void CSettingsDialog::setTileFarBank() void CSettingsDialog::setTileFarBank()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Set new tile far bank"), QString fileName = QFileDialog::getOpenFileName(this, tr("Set new tile far bank"),
ui.tileFarBankLineEdit->text(), ui.tileFarBankLineEdit->text(),
tr("Tile Far Bank file (*.farbank);;")); tr("Tile Far Bank file (*.farbank);;"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
ui.tileFarBankLineEdit->setText(fileName); ui.tileFarBankLineEdit->setText(fileName);
@ -161,8 +162,8 @@ void CSettingsDialog::setTileFarBank()
void CSettingsDialog::setTextureVegetable() void CSettingsDialog::setTextureVegetable()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Set MicroVegetable texture"), QString fileName = QFileDialog::getOpenFileName(this, tr("Set MicroVegetable texture"),
ui.vegetTextureLineEdit->text(), ui.vegetTextureLineEdit->text(),
tr("Texture file (*.tga *.png *.jpg *.dds);;")); tr("Texture file (*.tga *.png *.jpg *.dds);;"));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
ui.vegetTextureLineEdit->setText(fileName); ui.vegetTextureLineEdit->setText(fileName);
@ -172,8 +173,8 @@ void CSettingsDialog::setTextureVegetable()
void CSettingsDialog::addZone() void CSettingsDialog::addZone()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(this, QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Add zone files"), ".", tr("Add zone files"), ".",
tr("Zonel files (*.zonel);;")); tr("Zonel files (*.zonel);;"));
if (!fileNames.isEmpty()) if (!fileNames.isEmpty())
{ {

View file

@ -30,7 +30,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
/** /**
@class CSettingsDialog @class CSettingsDialog
@ -38,7 +39,7 @@ namespace NLQT {
*/ */
class CSettingsDialog: public QDialog class CSettingsDialog: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CSettingsDialog(QWidget *parent = 0); CSettingsDialog(QWidget *parent = 0);

View file

@ -34,10 +34,11 @@
using namespace NL3D; using namespace NL3D;
using namespace NLMISC; using namespace NLMISC;
namespace NLQT { namespace NLQT
{
CSetupFog::CSetupFog(QWidget *parent) CSetupFog::CSetupFog(QWidget *parent)
: QDockWidget(parent) : QDockWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
@ -64,16 +65,16 @@ CSetupFog::~CSetupFog()
void CSetupFog::apply() void CSetupFog::apply()
{ {
Modules::objView().getDriver()->setupFog(ui.startDoubleSpinBox->value(), Modules::objView().getDriver()->setupFog(ui.startDoubleSpinBox->value(),
ui.endDoubleSpinBox->value(), ui.endDoubleSpinBox->value(),
colorFog); colorFog);
Modules::objView().getDriver()->enableFog(ui.enableFogCheckBox->isChecked()); Modules::objView().getDriver()->enableFog(ui.enableFogCheckBox->isChecked());
} }
void CSetupFog::setColor() void CSetupFog::setColor()
{ {
QColor color = QColorDialog::getColor(QColor(colorFog.R, QColor color = QColorDialog::getColor(QColor(colorFog.R,
colorFog.G, colorFog.G,
colorFog.B)); colorFog.B));
colorFog.set(color.red(), color.green(), color.blue()); colorFog.set(color.red(), color.green(), color.blue());
} }

View file

@ -31,7 +31,8 @@
// Project includes // Project includes
namespace NLQT { namespace NLQT
{
/** /**
@class CSetupFog @class CSetupFog
@ -39,7 +40,7 @@ namespace NLQT {
*/ */
class CSetupFog: public QDockWidget class CSetupFog: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CSetupFog(QWidget *parent = 0); CSetupFog(QWidget *parent = 0);

Some files were not shown because too many files have changed in this diff Show more