This commit is contained in:
rti 2011-01-27 18:01:38 +01:00
commit a0df0fb938
16 changed files with 324 additions and 137 deletions

View file

@ -22,6 +22,7 @@ SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h
vegetable_dialog.h global_wind_dialog.h day_night_dialog.h sun_color_dialog.h
vegetable_noise_value_widget.h vegetable_density_page.h vegetable_landscape_page.h
vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h
tune_mrm_dialog.h
extension_system/iplugin_manager.h extension_system/plugin_manager.h)
SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui
@ -35,7 +36,7 @@ SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui
particle_link_skeleton_form.ui water_pool_form.ui vegetable_dialog_form.ui
vegetable_noise_value_form.ui global_wind_form.ui sun_color_form.ui day_night_form.ui
vegetable_density_form.ui vegetable_apperance_form.ui vegetable_landscape_form.ui
vegetable_rotate_form.ui vegetable_scale_form.ui)
vegetable_rotate_form.ui vegetable_scale_form.ui tune_mrm_form.ui)
SET(OBJECT_VIEWER_RCS object_viewer_qt.qrc)

View file

@ -32,8 +32,9 @@ CGlobalWindDialog::CGlobalWindDialog(QWidget *parent)
{
_ui.setupUi(this);
_ui.horizontalSlider->setValue(int(Modules::objView().getScene()->getGlobalWindPower() * _ui.horizontalSlider->maximum()));
connect(_ui.horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(setWndPower(int)));
connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateWnd(bool)));
}
CGlobalWindDialog::~CGlobalWindDialog()
@ -47,12 +48,4 @@ void CGlobalWindDialog::setWndPower(int value)
Modules::objView().getScene()->setGlobalWindPower(fValue);
}
void CGlobalWindDialog::updateWnd(bool visible)
{
if (!visible || !Modules::objView().getScene())
return;
_ui.horizontalSlider->setValue(int(Modules::objView().getScene()->getGlobalWindPower() * _ui.horizontalSlider->maximum()));
}
} /* namespace NLQT */

View file

@ -41,7 +41,6 @@ public:
private Q_SLOTS:
void setWndPower(int value);
void updateWnd(bool visible);
private:

View file

@ -68,6 +68,7 @@ void CGraphicsViewport::init()
Modules::objView().init((nlWindow)winId(), width(), height());
Modules::psEdit().init();
Modules::veget().init();
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
@ -77,7 +78,8 @@ void CGraphicsViewport::release()
{
//H_AUTO2
nldebug("CGraphicsViewport::release");
Modules::veget().release();
Modules::psEdit().release();
Modules::objView().release();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -47,6 +47,7 @@
#include "global_wind_dialog.h"
#include "day_night_dialog.h"
#include "sun_color_dialog.h"
#include "tune_mrm_dialog.h"
using namespace std;
using namespace NLMISC;
@ -60,8 +61,6 @@ CMainWindow::CMainWindow(QWidget *parent)
_isGraphicsEnabled(false),
_isSoundInitialized(false),
_isSoundEnabled(false),
_isLandscapeInitialized(false),
_isLandscapeEnabled(false),
_GraphicsViewport(NULL),
_lastDir("."),
_mouseMode(NL3D::U3dMouseListener::edit3d)
@ -79,6 +78,16 @@ CMainWindow::CMainWindow(QWidget *parent)
_originalPalette = QApplication::palette();
Modules::config().setAndCallback("QtStyle", CConfigCallback(this, &CMainWindow::cfcbQtStyle));
Modules::config().setAndCallback("QtPalette", CConfigCallback(this, &CMainWindow::cfcbQtPalette));
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
_GraphicsViewport->init();
_isGraphicsInitialized = true;
if (_isSoundEnabled)
{
Modules::sound().init();
_isSoundInitialized = true;
}
_SkeletonTreeModel = new CSkeletonTreeModel(this);
@ -96,24 +105,16 @@ CMainWindow::CMainWindow(QWidget *parent)
restoreGeometry(settings.value("QtWindowGeometry").toByteArray());
settings.endGroup();
_isGraphicsEnabled = true;
_isLandscapeEnabled = true;
// As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed.
// This can be used to do heavy work while providing a snappy user interface.
_mainTimer = new QTimer(this);
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
// timer->start(); // <- timeout 0
// it's heavy on cpu, though, when no 3d driver initialized :)
_mainTimer->start(23); // 25fps
_statusBarTimer = new QTimer(this);
connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
_statusBarTimer->start(1000);
_statusInfo = new QLabel(this);
this->statusBar()->addPermanentWidget(_statusInfo);
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
}
CMainWindow::~CMainWindow()
@ -131,15 +132,18 @@ CMainWindow::~CMainWindow()
Modules::config().dropCallback("QtPalette");
Modules::config().dropCallback("QtStyle");
_mainTimer->stop();
_statusBarTimer->stop();
delete _AnimationDialog;
delete _AnimationSetDialog;
delete _SlotManagerDialog;
delete _SetupFog;
delete _TuneMRMDialog;
delete _ParticleControlDialog;
delete _ParticleWorkspaceDialog;
if (_isSoundInitialized)
Modules::sound().releaseGraphics();
_GraphicsViewport->release();
delete _GraphicsViewport;
}
@ -152,11 +156,17 @@ void CMainWindow::setVisible(bool visible)
if (visible)
{
QMainWindow::setVisible(true);
updateInitialization(true);
if (_isSoundInitialized)
Modules::sound().initGraphics();
_mainTimer->start(23);
_statusBarTimer->start(1000);
}
else
{
updateInitialization(false);
_mainTimer->stop();
_statusBarTimer->stop();
if (_isSoundInitialized)
Modules::sound().releaseGraphics();
QMainWindow::setVisible(false);
}
}
@ -273,95 +283,6 @@ void CMainWindow::updateStatusBar()
}
}
void CMainWindow::updateInitialization(bool visible)
{
bool done;
do
{
done = true; // set false whenever change
bool wantSound = _isSoundEnabled && visible;
bool wantGraphics = _isGraphicsEnabled && visible;
// TODO WARNING: made Landscape stuff
bool wantLandscape = wantGraphics && _isGraphicsInitialized && _isLandscapeEnabled;
// .. stuff that depends on other stuff goes on top to prioritize deinitialization
// Landscape
if (_isLandscapeInitialized)
{
if (!wantLandscape)
{
_isLandscapeInitialized = false;
// if (_isGraphicsInitialized)
// Modules::veget().releaseGraphics();
Modules::veget().release();
done = false;
}
}
else
{
if (wantLandscape)
{
Modules::veget().init();
// if (_isGraphicsInitialized)
// Modules::veget().initGraphics();
_isLandscapeInitialized = true;
done = false;
}
}
// Graphics (Driver)
if (_isGraphicsInitialized)
{
if (!wantGraphics)
{
_isGraphicsInitialized = false;
if (_isSoundInitialized)
Modules::sound().releaseGraphics();
_GraphicsViewport->release();
done = false;
}
}
else
{
if (wantGraphics)
{
_GraphicsViewport->init();
if (_isSoundInitialized)
Modules::sound().initGraphics();
_isGraphicsInitialized = true;
done = false;
}
}
// Sound (AudioMixer)
if (_isSoundInitialized)
{
if (!wantSound)
{
_isSoundInitialized = false;
if (_isGraphicsInitialized)
Modules::sound().releaseGraphics();
Modules::sound().release();
done = false;
}
}
else
{
if (wantSound)
{
Modules::sound().init();
if (_isGraphicsInitialized)
Modules::sound().initGraphics();
_isSoundInitialized = true;
done = false;
}
}
}
while (!done);
}
void CMainWindow::createActions()
{
_openAction = new QAction(tr("&Open..."), this);
@ -477,6 +398,9 @@ void CMainWindow::createMenus()
_toolsMenu->addAction(_SunColorDialog->toggleViewAction());
_toolsMenu->addAction(_TuneMRMDialog->toggleViewAction());
_TuneMRMDialog->toggleViewAction()->setIcon(QIcon(":/images/ico_mrm_mesh.png"));
connect(_ParticleControlDialog->toggleViewAction(), SIGNAL(triggered(bool)),
_ParticleWorkspaceDialog, SLOT(setVisible(bool)));
@ -518,6 +442,7 @@ void CMainWindow::createToolBars()
_toolsBar->addAction(_VegetableDialog->toggleViewAction());
_toolsBar->addAction(_GlobalWindDialog->toggleViewAction());
_toolsBar->addAction(_SkeletonScaleDialog->toggleViewAction());
_toolsBar->addAction(_TuneMRMDialog->toggleViewAction());
}
void CMainWindow::createStatusBar()
@ -591,6 +516,11 @@ void CMainWindow::createDialogs()
addDockWidget(Qt::RightDockWidgetArea, _SetupFog);
_SetupFog->setVisible(false);
// create tune mrm dialog
_TuneMRMDialog = new CTuneMRMDialog(this);
addDockWidget(Qt::BottomDockWidgetArea, _TuneMRMDialog);
_TuneMRMDialog->setVisible(false);
connect(_ParticleControlDialog, SIGNAL(changeState()), _ParticleWorkspaceDialog, SLOT(setNewState()));
connect(_ParticleWorkspaceDialog, SIGNAL(changeActiveNode()), _ParticleControlDialog, SLOT(updateActiveNode()));
connect(_AnimationSetDialog->ui.setLengthPushButton, SIGNAL(clicked()), _AnimationDialog, SLOT(changeAnimLength()));
@ -637,8 +567,6 @@ void CMainWindow::cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var)
void CMainWindow::updateRender()
{
updateInitialization(isVisible());
if (isVisible())
{

View file

@ -53,6 +53,7 @@ class CVegetableDialog;
class CGlobalWindDialog;
class CDayNightDialog;
class CSunColorDialog;
class CTuneMRMDialog;
class CMainWindow : public QMainWindow
{
@ -93,7 +94,6 @@ private:
void createStatusBar();
void createDialogs();
void updateInitialization(bool visible);
bool loadFile(const QString &fileName, const QString &skelName);
void cfcbQtStyle(NLMISC::CConfigFile::CVar &var);
@ -102,7 +102,6 @@ private:
bool _isGraphicsInitialized, _isGraphicsEnabled;
bool _isSoundInitialized, _isSoundEnabled;
bool _isLandscapeInitialized, _isLandscapeEnabled;
CGraphicsViewport *_GraphicsViewport;
CAnimationDialog *_AnimationDialog;
@ -117,7 +116,7 @@ private:
CSkeletonScaleDialog *_SkeletonScaleDialog;
CDayNightDialog *_DayNightDialog;
CSunColorDialog *_SunColorDialog;
CTuneMRMDialog *_TuneMRMDialog;
CSkeletonTreeModel *_SkeletonTreeModel;
QPalette _originalPalette;
@ -140,7 +139,6 @@ private:
QAction *_renderModeAction;
QAction *_frameDelayAction;
QAction *_lightGroupAction;
QAction *_tuneMRMAction;
QAction *_reloadTexturesAction;
QAction *_cameraModeAction;
QAction *_resetCameraAction;

View file

@ -89,6 +89,11 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
// initialize the window with config file values
_Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32));
// Create a scene
_Scene = _Driver->createScene(false);
_Scene->setPolygonBalancingMode(NL3D::UScene::PolygonBalancingClamp);
_Driver->enableUsedTextureMemorySum();
_Light = ULight::createLight();
@ -106,9 +111,6 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
_Driver->setLight(0, *_Light);
_Driver->enableLight(0);
// Create a scene
_Scene = _Driver->createScene(false);
_PlayListManager = _Scene->createPlayListManager();
_Scene->enableLightingSystem(true);

View file

@ -27,6 +27,8 @@
<file>images/ico_bgcolor.png</file>
<file>images/ico_framedelay.png</file>
<file>images/ico_skelscale.png</file>
<file>images/ico_mrm_mesh.png</file>
<file>images/ico_light_group.png</file>
<file>images/clear.png</file>
<file>images/insert.png</file>
<file>images/new.png</file>

View file

@ -34,7 +34,11 @@ CSunColorDialog::CSunColorDialog(QWidget *parent)
{
_ui.setupUi(this);
connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateSunColor(bool)));
_ui.ambientWidget->setColor(Modules::objView().getScene()->getSunAmbient());
_ui.diffuseWidget->setColor(Modules::objView().getScene()->getSunDiffuse());
_ui.specularWidget->setColor(Modules::objView().getScene()->getSunSpecular());
//connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateSunColor(bool)));
connect(_ui.ambientWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setAmbientSunColor(NLMISC::CRGBA)));
connect(_ui.diffuseWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setDiffuseSunColor(NLMISC::CRGBA)));
connect(_ui.specularWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setSpecularSunColor(NLMISC::CRGBA)));
@ -44,16 +48,6 @@ CSunColorDialog::~CSunColorDialog()
{
}
void CSunColorDialog::updateSunColor(bool visible)
{
if (!visible || !Modules::objView().getScene())
return;
_ui.ambientWidget->setColor(Modules::objView().getScene()->getSunAmbient());
_ui.diffuseWidget->setColor(Modules::objView().getScene()->getSunDiffuse());
_ui.specularWidget->setColor(Modules::objView().getScene()->getSunSpecular());
}
void CSunColorDialog::setAmbientSunColor(NLMISC::CRGBA color)
{
Modules::objView().getScene()->setSunAmbient(color);

View file

@ -44,7 +44,6 @@ public:
~CSunColorDialog();
private Q_SLOTS:
void updateSunColor(bool visible);
void setAmbientSunColor(NLMISC::CRGBA color);
void setDiffuseSunColor(NLMISC::CRGBA color);
void setSpecularSunColor(NLMISC::CRGBA color);

View file

@ -0,0 +1,65 @@
/*
Object Viewer Qt
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdpch.h"
#include "tune_mrm_dialog.h"
// NeL includes
#include <nel/3d/u_scene.h>
// Project includes
#include "modules.h"
const int sliderStepSize = 5000;
namespace NLQT
{
CTuneMRMDialog::CTuneMRMDialog(QWidget *parent)
: QDockWidget(parent)
{
_ui.setupUi(this);
connect(_ui.maxValueSlider, SIGNAL(valueChanged(int)), this, SLOT(setMaxValue(int)));
connect(_ui.currentValueSlider, SIGNAL(valueChanged(int)), this, SLOT(setCurrentValue(int)));
_ui.maxValueSlider->setValue(_ui.maxValueSlider->maximum());
}
CTuneMRMDialog::~CTuneMRMDialog()
{
}
void CTuneMRMDialog::setMaxValue(int value)
{
int actualMaxValue = value * sliderStepSize;
int actualValue = float(actualMaxValue) * _ui.currentValueSlider->value() / _ui.currentValueSlider->maximum();
_ui.currentValueSlider->setMaximum(actualMaxValue);
_ui.currentValueSlider->setValue(actualValue);
_ui.maxValueSpinBox->setValue(actualMaxValue);
}
void CTuneMRMDialog::setCurrentValue(int value)
{
Modules::objView().getScene()->setGroupLoadMaxPolygon("Skin", value);
_ui.currentValueSpinBox->setValue(value);
}
} /* namespace NLQT */

View file

@ -0,0 +1,54 @@
/*
Object Viewer Qt
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TUNE_MRM_DIALOG_H
#define TUNE_MRM_DIALOG_H
#include "ui_tune_mrm_form.h"
// STL includes
// NeL includes
// Project includes
namespace NLQT
{
class CTuneMRMDialog: public QDockWidget
{
Q_OBJECT
public:
CTuneMRMDialog(QWidget *parent = 0);
~CTuneMRMDialog();
private Q_SLOTS:
void setMaxValue(int value);
void setCurrentValue(int value);
private:
Ui::CTuneMRMDialog _ui;
}; /* class CTuneMRMDialog */
} /* namespace NLQT */
#endif // TUNE_MRM_DIALOG_H

View file

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CTuneMRMDialog</class>
<widget class="QDockWidget" name="CTuneMRMDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>576</width>
<height>92</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>476</width>
<height>92</height>
</size>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Tune MRM (The maximum faces in scene)</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max (specify the max value)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="maxValueSpinBox">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>10000000</number>
</property>
<property name="value">
<number>100000</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Current (real final max polygon value)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="currentValueSpinBox">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>10000000</number>
</property>
<property name="value">
<number>100000</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QSlider" name="maxValueSlider">
<property name="maximum">
<number>20</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="sliderPosition">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="currentValueSlider">
<property name="maximum">
<number>100000</number>
</property>
<property name="sliderPosition">
<number>100000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>