mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-13 02:39:34 +00:00
Changed: #1193 Added camera control panel.
This commit is contained in:
parent
c62f551e30
commit
bc2e712dc9
13 changed files with 540 additions and 193 deletions
|
@ -22,7 +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_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_noise_value_widget.h vegetable_density_page.h vegetable_landscape_page.h
|
||||||
vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h
|
vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h
|
||||||
tune_mrm_dialog.h tune_timer_dialog.h
|
tune_mrm_dialog.h tune_timer_dialog.h camera_control.h
|
||||||
extension_system/iplugin_manager.h extension_system/plugin_manager.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
|
SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui
|
||||||
|
|
281
code/nel/tools/3d/object_viewer_qt/src/camera_control.cpp
Normal file
281
code/nel/tools/3d/object_viewer_qt/src/camera_control.cpp
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
/*
|
||||||
|
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 "camera_control.h"
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include "nel/misc/debug.h"
|
||||||
|
#include "nel/3d/u_driver.h"
|
||||||
|
#include "nel/3d/u_scene.h"
|
||||||
|
#include <nel/3d/u_camera.h>
|
||||||
|
#include <nel/3d/u_3d_mouse_listener.h>
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
static int camId = 0;
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
|
||||||
|
CCameraItem::CCameraItem(const QString &name):
|
||||||
|
_cameraFocal(75),
|
||||||
|
_speed(5.0),
|
||||||
|
_active(false),
|
||||||
|
_name(name)
|
||||||
|
{
|
||||||
|
_camera = Modules::objView().getScene()->createCamera();
|
||||||
|
_camera.setTransformMode (NL3D::UTransformable::DirectMatrix);
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
CCameraItem::~CCameraItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraItem::setActive(bool active)
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
sint w = Modules::objView().getDriver()->getWindowWidth();
|
||||||
|
sint h = Modules::objView().getDriver()->getWindowHeight();
|
||||||
|
_camera.setPerspective(_cameraFocal * float(NLMISC::Pi) / 180.f, float(w) / h, 0.1f, 1000);
|
||||||
|
Modules::objView().getScene()->setCam(_camera);
|
||||||
|
setupListener();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hotSpot = Modules::objView().get3dMouseListener()->getHotSpot();
|
||||||
|
}
|
||||||
|
_active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraItem::setSpeed(float value)
|
||||||
|
{
|
||||||
|
_speed = value;
|
||||||
|
Modules::objView().get3dMouseListener()->setSpeed(_speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraItem::reset()
|
||||||
|
{
|
||||||
|
_hotSpot = NLMISC::CVector(0, 0, 0);
|
||||||
|
float radius=10.f;
|
||||||
|
|
||||||
|
// Setup camera
|
||||||
|
_camera.lookAt(_hotSpot + NLMISC::CVector(0.57735f, 0.57735f, 0.57735f) * radius, _hotSpot);
|
||||||
|
|
||||||
|
if (_active)
|
||||||
|
setupListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraItem::setupListener()
|
||||||
|
{
|
||||||
|
NL3D::U3dMouseListener *_mouseListener = Modules::objView().get3dMouseListener();
|
||||||
|
_mouseListener->setMatrix (_camera.getMatrix());
|
||||||
|
_mouseListener->setFrustrum (_camera.getFrustum());
|
||||||
|
_mouseListener->setViewport (NL3D::CViewport());
|
||||||
|
_mouseListener->setHotSpot (_hotSpot);
|
||||||
|
Modules::objView().get3dMouseListener()->setSpeed(_speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
CCameraControl::CCameraControl(QWidget *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
_currentCamera(0)
|
||||||
|
{
|
||||||
|
_camToolBar = new QToolBar(tr("CameraControl"), parent);
|
||||||
|
|
||||||
|
_fpsAction = _camToolBar->addAction(tr("Fly"));
|
||||||
|
_fpsAction->setStatusTip(tr("Set firstPerson camera mode"));
|
||||||
|
_fpsAction->setCheckable(true);
|
||||||
|
|
||||||
|
_edit3dAction = _camToolBar->addAction(tr("Edit"));
|
||||||
|
_edit3dAction->setStatusTip(tr("Set edit3d camera mode"));
|
||||||
|
_edit3dAction->setCheckable(true);
|
||||||
|
|
||||||
|
QActionGroup *cameraModeGroup = new QActionGroup(this);
|
||||||
|
cameraModeGroup->addAction(_fpsAction);
|
||||||
|
cameraModeGroup->addAction(_edit3dAction);
|
||||||
|
_edit3dAction->setChecked(true);
|
||||||
|
|
||||||
|
connect(_fpsAction, SIGNAL(triggered()), this, SLOT(setFirstPersonMode()));
|
||||||
|
connect(_edit3dAction, SIGNAL(triggered()), this, SLOT(setEditMode()));
|
||||||
|
|
||||||
|
_renderModeMenu = new QMenu(tr("Render Mode"), _camToolBar);
|
||||||
|
_renderModeMenu->setIcon(QIcon(":/images/polymode.png"));
|
||||||
|
_camToolBar->addAction(_renderModeMenu->menuAction());
|
||||||
|
connect(_renderModeMenu->menuAction(), SIGNAL(triggered()), this, SLOT(setRenderMode()));
|
||||||
|
|
||||||
|
QSignalMapper *modeMapper = new QSignalMapper(this);
|
||||||
|
|
||||||
|
_pointRenderModeAction = _renderModeMenu->addAction(tr("Point mode"));
|
||||||
|
_pointRenderModeAction->setIcon(QIcon(":/images/rmpoints.png"));
|
||||||
|
_pointRenderModeAction->setStatusTip(tr("Set point render mode"));
|
||||||
|
connect(_pointRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
|
modeMapper->setMapping(_pointRenderModeAction, 0);
|
||||||
|
|
||||||
|
_lineRenderModeAction = _renderModeMenu->addAction(tr("Line mode"));
|
||||||
|
_lineRenderModeAction->setStatusTip(tr("Set line render mode"));
|
||||||
|
_lineRenderModeAction->setIcon(QIcon(":/images/rmline.png"));
|
||||||
|
connect(_lineRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
|
modeMapper->setMapping(_lineRenderModeAction, 1);
|
||||||
|
|
||||||
|
_fillRenderModeAction = _renderModeMenu->addAction(tr("Fill mode"));
|
||||||
|
_fillRenderModeAction->setIcon(QIcon(":/images/rmfill.png"));
|
||||||
|
_fillRenderModeAction->setStatusTip(tr("Set fill render mode"));
|
||||||
|
connect(_fillRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
|
modeMapper->setMapping(_fillRenderModeAction, 2);
|
||||||
|
|
||||||
|
connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setRenderMode(int)));
|
||||||
|
|
||||||
|
_camToolBar->addSeparator();
|
||||||
|
_speedLabel = new QLabel(tr("Speed:"), _camToolBar);
|
||||||
|
_camToolBar->addWidget(_speedLabel);
|
||||||
|
_speedSpinBox = new QSpinBox(_camToolBar);
|
||||||
|
_speedSpinBox->setMinimum(1);
|
||||||
|
_speedSpinBox->setMaximum(1000);
|
||||||
|
_camToolBar->addWidget(_speedSpinBox);
|
||||||
|
connect(_speedSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setSpeed(int)));
|
||||||
|
|
||||||
|
_camToolBar->addSeparator();
|
||||||
|
_addCamAction = _camToolBar->addAction(tr("Create camera"));
|
||||||
|
_addCamAction->setIcon(QIcon(":/images/cam_add.png"));
|
||||||
|
_addCamAction->setStatusTip(tr("Create new camera"));
|
||||||
|
connect(_addCamAction, SIGNAL(triggered()), this, SLOT(addCamera()));
|
||||||
|
|
||||||
|
_delCamAction = _camToolBar->addAction(tr("Delete camera"));
|
||||||
|
_delCamAction->setIcon(QIcon(":/images/cam_del.png"));
|
||||||
|
_delCamAction->setStatusTip(tr("Delete current camera"));
|
||||||
|
connect(_delCamAction, SIGNAL(triggered()), this, SLOT(delCamera()));
|
||||||
|
|
||||||
|
_listCamComboBox = new QComboBox(_camToolBar);
|
||||||
|
connect(_listCamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCamera(int)));
|
||||||
|
_listCamComboBox->setCurrentIndex(createCamera(tr("defaultCamera")));
|
||||||
|
_camToolBar->addWidget(_listCamComboBox);
|
||||||
|
|
||||||
|
_camToolBar->addSeparator();
|
||||||
|
_resetCamAction = _camToolBar->addAction(tr("Reset camera"));
|
||||||
|
_resetCamAction->setStatusTip(tr("Reset current camera"));
|
||||||
|
//_resetCamAction->setShortcut(tr("Ctrl+R"));
|
||||||
|
connect(_resetCamAction, SIGNAL(triggered()), this, SLOT(resetCamera()));
|
||||||
|
}
|
||||||
|
|
||||||
|
CCameraControl::~CCameraControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::setEditMode()
|
||||||
|
{
|
||||||
|
Modules::objView().get3dMouseListener()->setMouseMode(NL3D::U3dMouseListener::edit3d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::setFirstPersonMode()
|
||||||
|
{
|
||||||
|
Modules::objView().get3dMouseListener()->setMouseMode(NL3D::U3dMouseListener::firstPerson);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::addCamera()
|
||||||
|
{
|
||||||
|
_listCamComboBox->setCurrentIndex(createCamera(tr("%1_Camera").arg(++camId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::delCamera()
|
||||||
|
{
|
||||||
|
int index = _listCamComboBox->currentIndex();
|
||||||
|
_listCamComboBox->setCurrentIndex(index - 1);
|
||||||
|
|
||||||
|
_listCamComboBox->removeItem(index);
|
||||||
|
delete _cameraList[index];
|
||||||
|
_cameraList.erase(_cameraList.begin() + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::setSpeed(int value)
|
||||||
|
{
|
||||||
|
nlassert(_currentCamera);
|
||||||
|
_currentCamera->setSpeed(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::changeCamera(int index)
|
||||||
|
{
|
||||||
|
if (_currentCamera)
|
||||||
|
_currentCamera->setActive(false);
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
_delCamAction->setEnabled(false);
|
||||||
|
else
|
||||||
|
_delCamAction->setEnabled(true);
|
||||||
|
|
||||||
|
_currentCamera = _cameraList[index];
|
||||||
|
|
||||||
|
nlassert(_currentCamera);
|
||||||
|
_currentCamera->setActive(true);
|
||||||
|
_speedSpinBox->setValue(int(_currentCamera->getSpeed()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::setRenderMode(int value)
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::setRenderMode()
|
||||||
|
{
|
||||||
|
switch (Modules::objView().getDriver()->getPolygonMode())
|
||||||
|
{
|
||||||
|
case NL3D::UDriver::Filled:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line);
|
||||||
|
break;
|
||||||
|
case NL3D::UDriver::Line:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point);
|
||||||
|
break;
|
||||||
|
case NL3D::UDriver::Point:
|
||||||
|
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCameraControl::resetCamera()
|
||||||
|
{
|
||||||
|
nlassert(_currentCamera);
|
||||||
|
_currentCamera->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CCameraControl::createCamera(const QString &name)
|
||||||
|
{
|
||||||
|
CCameraItem *newCamera = new CCameraItem(name);
|
||||||
|
_cameraList.push_back(newCamera);
|
||||||
|
_listCamComboBox->addItem(newCamera->getName());
|
||||||
|
return _cameraList.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
125
code/nel/tools/3d/object_viewer_qt/src/camera_control.h
Normal file
125
code/nel/tools/3d/object_viewer_qt/src/camera_control.h
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
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 CAMERA_CONTROL_H
|
||||||
|
#define CAMERA_CONTROL_H
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QSignalMapper>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
#include <QtGui/QSpinBox>
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QToolBar>
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/3d/u_camera.h>
|
||||||
|
#include "nel/misc/vector.h"
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
|
||||||
|
class CCameraItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCameraItem(const QString &name);
|
||||||
|
~CCameraItem();
|
||||||
|
|
||||||
|
void setSpeed(float value);
|
||||||
|
float getSpeed()
|
||||||
|
{
|
||||||
|
return _speed;
|
||||||
|
}
|
||||||
|
void setActive(bool active);
|
||||||
|
void setName(const QString &name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
QString getName() const
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupListener();
|
||||||
|
|
||||||
|
NL3D::UCamera _camera;
|
||||||
|
NLMISC::CVector _hotSpot;
|
||||||
|
|
||||||
|
float _cameraFocal;
|
||||||
|
float _speed;
|
||||||
|
bool _active;
|
||||||
|
QString _name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CCameraControl: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CCameraControl(QWidget *parent = 0);
|
||||||
|
~CCameraControl();
|
||||||
|
|
||||||
|
QToolBar *getToolBar() const
|
||||||
|
{
|
||||||
|
return _camToolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setEditMode();
|
||||||
|
void setFirstPersonMode();
|
||||||
|
void addCamera();
|
||||||
|
void delCamera();
|
||||||
|
void setSpeed(int value);
|
||||||
|
void changeCamera(int index);
|
||||||
|
void setRenderMode(int value);
|
||||||
|
void setRenderMode();
|
||||||
|
void resetCamera();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int createCamera(const QString &name);
|
||||||
|
|
||||||
|
QAction *_fpsAction;
|
||||||
|
QAction *_edit3dAction;
|
||||||
|
QAction *_pointRenderModeAction;
|
||||||
|
QAction *_lineRenderModeAction;
|
||||||
|
QAction *_fillRenderModeAction;
|
||||||
|
QAction *_addCamAction;
|
||||||
|
QAction *_delCamAction;
|
||||||
|
QAction *_resetCamAction;
|
||||||
|
QSpinBox *_speedSpinBox;
|
||||||
|
QComboBox *_listCamComboBox;
|
||||||
|
QMenu *_renderModeMenu;
|
||||||
|
QLabel *_speedLabel;
|
||||||
|
QToolBar *_camToolBar;
|
||||||
|
|
||||||
|
CCameraItem *_currentCamera;
|
||||||
|
std::vector<CCameraItem *> _cameraList;
|
||||||
|
|
||||||
|
}; /* class CCameraControl */
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
||||||
|
|
||||||
|
#endif // CAMERA_CONTROL_H
|
BIN
code/nel/tools/3d/object_viewer_qt/src/images/cam_add.png
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/images/cam_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
code/nel/tools/3d/object_viewer_qt/src/images/cam_del.png
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/images/cam_del.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmfill.png
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmfill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmline.png
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmpoints.png
Normal file
BIN
code/nel/tools/3d/object_viewer_qt/src/images/rmpoints.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -49,6 +49,7 @@
|
||||||
#include "sun_color_dialog.h"
|
#include "sun_color_dialog.h"
|
||||||
#include "tune_mrm_dialog.h"
|
#include "tune_mrm_dialog.h"
|
||||||
#include "tune_timer_dialog.h"
|
#include "tune_timer_dialog.h"
|
||||||
|
#include "camera_control.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
@ -58,13 +59,13 @@ namespace NLQT
|
||||||
|
|
||||||
CMainWindow::CMainWindow(QWidget *parent)
|
CMainWindow::CMainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
_isGraphicsInitialized(false),
|
_isGraphicsInitialized(false),
|
||||||
_isGraphicsEnabled(false),
|
_isGraphicsEnabled(false),
|
||||||
_isSoundInitialized(false),
|
_isSoundInitialized(false),
|
||||||
_isSoundEnabled(false),
|
_isSoundEnabled(false),
|
||||||
_GraphicsViewport(NULL),
|
_GraphicsViewport(NULL),
|
||||||
_lastDir("."),
|
_lastDir("."),
|
||||||
_mouseMode(NL3D::U3dMouseListener::edit3d)
|
_mouseMode(NL3D::U3dMouseListener::edit3d)
|
||||||
{
|
{
|
||||||
nldebug("CMainWindow::CMainWindow:");
|
nldebug("CMainWindow::CMainWindow:");
|
||||||
setObjectName("CMainWindow");
|
setObjectName("CMainWindow");
|
||||||
|
@ -83,7 +84,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
|
|
||||||
_GraphicsViewport->init();
|
_GraphicsViewport->init();
|
||||||
_isGraphicsInitialized = true;
|
_isGraphicsInitialized = true;
|
||||||
|
|
||||||
if (_isSoundEnabled)
|
if (_isSoundEnabled)
|
||||||
{
|
{
|
||||||
Modules::sound().init();
|
Modules::sound().init();
|
||||||
|
@ -144,7 +145,7 @@ CMainWindow::~CMainWindow()
|
||||||
delete _TuneTimerDialog;
|
delete _TuneTimerDialog;
|
||||||
delete _ParticleControlDialog;
|
delete _ParticleControlDialog;
|
||||||
delete _ParticleWorkspaceDialog;
|
delete _ParticleWorkspaceDialog;
|
||||||
|
|
||||||
if (_isSoundInitialized)
|
if (_isSoundInitialized)
|
||||||
Modules::sound().releaseGraphics();
|
Modules::sound().releaseGraphics();
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ void CMainWindow::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
QMainWindow::setVisible(true);
|
QMainWindow::setVisible(true);
|
||||||
if (_isSoundInitialized)
|
if (_isSoundInitialized)
|
||||||
Modules::sound().initGraphics();
|
Modules::sound().initGraphics();
|
||||||
_mainTimer->start();
|
_mainTimer->start();
|
||||||
_statusBarTimer->start(1000);
|
_statusBarTimer->start(1000);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,7 @@ void CMainWindow::open()
|
||||||
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();
|
||||||
|
@ -220,43 +221,6 @@ void CMainWindow::resetScene()
|
||||||
_SkeletonTreeModel->resetTreeModel();
|
_SkeletonTreeModel->resetTreeModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::changeRenderMode()
|
|
||||||
{
|
|
||||||
// Change render mode
|
|
||||||
switch (Modules::objView().getDriver()->getPolygonMode())
|
|
||||||
{
|
|
||||||
case NL3D::UDriver::Filled:
|
|
||||||
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line);
|
|
||||||
break;
|
|
||||||
case NL3D::UDriver::Line:
|
|
||||||
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point);
|
|
||||||
break;
|
|
||||||
case NL3D::UDriver::Point:
|
|
||||||
Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMainWindow::resetCamera()
|
|
||||||
{
|
|
||||||
Modules::objView().resetCamera();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMainWindow::changeCameraMode()
|
|
||||||
{
|
|
||||||
switch (_mouseMode)
|
|
||||||
{
|
|
||||||
case NL3D::U3dMouseListener::edit3d:
|
|
||||||
Modules::objView().get3dMouseListener()->setMouseMode(NL3D::U3dMouseListener::firstPerson);
|
|
||||||
_mouseMode = NL3D::U3dMouseListener::firstPerson;
|
|
||||||
break;
|
|
||||||
case NL3D::U3dMouseListener::firstPerson:
|
|
||||||
_mouseMode = NL3D::U3dMouseListener::edit3d;
|
|
||||||
Modules::objView().get3dMouseListener()->setMouseMode(NL3D::U3dMouseListener::edit3d);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMainWindow::reloadTextures()
|
void CMainWindow::reloadTextures()
|
||||||
{
|
{
|
||||||
Modules::objView().reloadTextures();
|
Modules::objView().reloadTextures();
|
||||||
|
@ -286,10 +250,10 @@ void CMainWindow::updateStatusBar()
|
||||||
if (_isGraphicsInitialized)
|
if (_isGraphicsInitialized)
|
||||||
{
|
{
|
||||||
_statusInfo->setText(QString("%1, Nb tri: %2 , Texture used (Mb): %3 , fps: %4 ").arg(
|
_statusInfo->setText(QString("%1, Nb tri: %2 , Texture used (Mb): %3 , fps: %4 ").arg(
|
||||||
Modules::objView().getDriver()->getVideocardInformation()).arg(
|
Modules::objView().getDriver()->getVideocardInformation()).arg(
|
||||||
_numTri).arg(
|
_numTri).arg(
|
||||||
_texMem, 0,'f',4).arg(
|
_texMem, 0,'f',4).arg(
|
||||||
_fps, 0,'f',2));
|
_fps, 0,'f',2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,18 +278,11 @@ void CMainWindow::createActions()
|
||||||
_resetCameraAction = new QAction(tr("Reset camera"), this);
|
_resetCameraAction = new QAction(tr("Reset camera"), this);
|
||||||
_resetCameraAction->setShortcut(tr("Ctrl+R"));
|
_resetCameraAction->setShortcut(tr("Ctrl+R"));
|
||||||
_resetCameraAction->setStatusTip(tr("Reset current camera"));
|
_resetCameraAction->setStatusTip(tr("Reset current camera"));
|
||||||
connect(_resetCameraAction, SIGNAL(triggered()), this, SLOT(resetCamera()));
|
|
||||||
|
|
||||||
_renderModeAction = new QAction("Change render mode", this);
|
_renderModeAction = new QAction("Change render mode", this);
|
||||||
_renderModeAction->setIcon(QIcon(":/images/polymode.png"));
|
_renderModeAction->setIcon(QIcon(":/images/polymode.png"));
|
||||||
_renderModeAction->setShortcut(tr("Ctrl+M"));
|
_renderModeAction->setShortcut(tr("Ctrl+M"));
|
||||||
_renderModeAction->setStatusTip(tr("Change render mode (Line, Point, Filled)"));
|
_renderModeAction->setStatusTip(tr("Change render mode (Line, Point, Filled)"));
|
||||||
connect(_renderModeAction, SIGNAL(triggered()), this, SLOT(changeRenderMode()));
|
|
||||||
|
|
||||||
_cameraModeAction = new QAction("Change camera mode", this);
|
|
||||||
_cameraModeAction->setShortcut(tr("Ctrl+W"));
|
|
||||||
_cameraModeAction->setStatusTip(tr("Change camera mode (edit3d, firstPerson)"));
|
|
||||||
connect(_cameraModeAction, SIGNAL(triggered()), this, SLOT(changeCameraMode()));
|
|
||||||
|
|
||||||
_resetSceneAction = new QAction(tr("&Reset scene"), this);
|
_resetSceneAction = new QAction(tr("&Reset scene"), this);
|
||||||
_resetSceneAction->setStatusTip(tr("Reset current scene"));
|
_resetSceneAction->setStatusTip(tr("Reset current scene"));
|
||||||
|
@ -366,7 +323,6 @@ void CMainWindow::createMenus()
|
||||||
_viewMenu->addAction(_setBackColorAction);
|
_viewMenu->addAction(_setBackColorAction);
|
||||||
_viewMenu->addAction(_resetCameraAction);
|
_viewMenu->addAction(_resetCameraAction);
|
||||||
_viewMenu->addAction(_renderModeAction);
|
_viewMenu->addAction(_renderModeAction);
|
||||||
_viewMenu->addAction(_cameraModeAction);
|
|
||||||
_viewMenu->addAction(_SetupFog->toggleViewAction());
|
_viewMenu->addAction(_SetupFog->toggleViewAction());
|
||||||
|
|
||||||
_sceneMenu = menuBar()->addMenu(tr("&Scene"));
|
_sceneMenu = menuBar()->addMenu(tr("&Scene"));
|
||||||
|
@ -457,6 +413,12 @@ void CMainWindow::createToolBars()
|
||||||
_toolsBar->addAction(_TuneTimerDialog->toggleViewAction());
|
_toolsBar->addAction(_TuneTimerDialog->toggleViewAction());
|
||||||
_toolsBar->addAction(_SkeletonScaleDialog->toggleViewAction());
|
_toolsBar->addAction(_SkeletonScaleDialog->toggleViewAction());
|
||||||
_toolsBar->addAction(_TuneMRMDialog->toggleViewAction());
|
_toolsBar->addAction(_TuneMRMDialog->toggleViewAction());
|
||||||
|
|
||||||
|
_cameraControl = new CCameraControl(this);
|
||||||
|
this->addToolBar(_cameraControl->getToolBar());
|
||||||
|
|
||||||
|
connect(_resetCameraAction, SIGNAL(triggered()), _cameraControl, SLOT(resetCamera()));
|
||||||
|
connect(_renderModeAction, SIGNAL(triggered()), _cameraControl, SLOT(setRenderMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createStatusBar()
|
void CMainWindow::createStatusBar()
|
||||||
|
@ -555,7 +517,7 @@ bool CMainWindow::loadFile(const QString &fileName, const QString &skelName)
|
||||||
bool loaded;
|
bool loaded;
|
||||||
if (fileInfo.suffix() == "ig")
|
if (fileInfo.suffix() == "ig")
|
||||||
loaded = Modules::objView().loadInstanceGroup(fileName.toStdString());
|
loaded = Modules::objView().loadInstanceGroup(fileName.toStdString());
|
||||||
else
|
else
|
||||||
loaded = Modules::objView().loadMesh(fileName.toStdString(), skelName.toStdString());
|
loaded = Modules::objView().loadMesh(fileName.toStdString(), skelName.toStdString());
|
||||||
|
|
||||||
if (!loaded)
|
if (!loaded)
|
||||||
|
@ -646,17 +608,17 @@ void CMainWindow::updateRender()
|
||||||
|
|
||||||
// 14. Update Debug (stuff for dev)
|
// 14. Update Debug (stuff for dev)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// 15. Calc FPS
|
// 15. Calc FPS
|
||||||
static sint64 lastTime = NLMISC::CTime::getPerformanceTime ();
|
static sint64 lastTime = NLMISC::CTime::getPerformanceTime ();
|
||||||
sint64 newTime = NLMISC::CTime::getPerformanceTime ();
|
sint64 newTime = NLMISC::CTime::getPerformanceTime ();
|
||||||
_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime));
|
_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime));
|
||||||
lastTime = newTime;
|
lastTime = newTime;
|
||||||
|
|
||||||
if (_isGraphicsInitialized && !Modules::objView().getDriver()->isLost())
|
if (_isGraphicsInitialized && !Modules::objView().getDriver()->isLost())
|
||||||
{
|
{
|
||||||
// 01. Render Driver (background color)
|
// 01. Render Driver (background color)
|
||||||
//Modules::objView().getDriver()->activate();
|
//Modules::objView().getDriver()->activate();
|
||||||
Modules::objView().renderDriver(); // clear all buffers
|
Modules::objView().renderDriver(); // clear all buffers
|
||||||
|
|
||||||
// 02. Render Sky (sky scene)
|
// 02. Render Sky (sky scene)
|
||||||
|
@ -681,7 +643,7 @@ void CMainWindow::updateRender()
|
||||||
Modules::objView().renderDebug2D();
|
Modules::objView().renderDebug2D();
|
||||||
|
|
||||||
// 10. Get profile information
|
// 10. Get profile information
|
||||||
NL3D::CPrimitiveProfile in, out;
|
NL3D::CPrimitiveProfile in, out;
|
||||||
Modules::objView().getDriver()->profileRenderedPrimitives (in, out);
|
Modules::objView().getDriver()->profileRenderedPrimitives (in, out);
|
||||||
|
|
||||||
_numTri = in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips;
|
_numTri = in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips;
|
||||||
|
|
|
@ -56,6 +56,8 @@ class CSunColorDialog;
|
||||||
class CTuneMRMDialog;
|
class CTuneMRMDialog;
|
||||||
class CTuneTimerDialog;
|
class CTuneTimerDialog;
|
||||||
|
|
||||||
|
class CCameraControl;
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
class CMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -79,9 +81,6 @@ public:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
void resetScene();
|
void resetScene();
|
||||||
void changeRenderMode();
|
|
||||||
void resetCamera();
|
|
||||||
void changeCameraMode();
|
|
||||||
void reloadTextures();
|
void reloadTextures();
|
||||||
void settings();
|
void settings();
|
||||||
void about();
|
void about();
|
||||||
|
@ -122,6 +121,8 @@ private:
|
||||||
CSkeletonTreeModel *_SkeletonTreeModel;
|
CSkeletonTreeModel *_SkeletonTreeModel;
|
||||||
CTuneTimerDialog *_TuneTimerDialog;
|
CTuneTimerDialog *_TuneTimerDialog;
|
||||||
|
|
||||||
|
CCameraControl *_cameraControl;
|
||||||
|
|
||||||
QPalette _originalPalette;
|
QPalette _originalPalette;
|
||||||
QString _lastDir;
|
QString _lastDir;
|
||||||
|
|
||||||
|
@ -143,7 +144,6 @@ private:
|
||||||
QAction *_frameDelayAction;
|
QAction *_frameDelayAction;
|
||||||
QAction *_lightGroupAction;
|
QAction *_lightGroupAction;
|
||||||
QAction *_reloadTexturesAction;
|
QAction *_reloadTexturesAction;
|
||||||
QAction *_cameraModeAction;
|
|
||||||
QAction *_resetCameraAction;
|
QAction *_resetCameraAction;
|
||||||
QAction *_resetSceneAction;
|
QAction *_resetSceneAction;
|
||||||
QAction *_saveScreenshotAction;
|
QAction *_saveScreenshotAction;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
// STL includes
|
// STL includes
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/common.h>
|
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/misc/file.h>
|
#include <nel/misc/file.h>
|
||||||
#include <nel/misc/bitmap.h>
|
#include <nel/misc/bitmap.h>
|
||||||
|
@ -59,13 +58,13 @@ namespace NLQT
|
||||||
|
|
||||||
CObjectViewer::CObjectViewer()
|
CObjectViewer::CObjectViewer()
|
||||||
: _IDriver(0),
|
: _IDriver(0),
|
||||||
_CScene(0),
|
_CScene(0),
|
||||||
_Driver(0),
|
_Driver(0),
|
||||||
_Scene(0),
|
_Scene(0),
|
||||||
_TextContext(0),
|
_TextContext(0),
|
||||||
_CameraFocal(75),
|
_CameraFocal(75),
|
||||||
_CurrentInstance(""),
|
_CurrentInstance(""),
|
||||||
_BloomEffect(false)
|
_BloomEffect(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,19 +114,11 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
|
||||||
|
|
||||||
_Scene->enableLightingSystem(true);
|
_Scene->enableLightingSystem(true);
|
||||||
|
|
||||||
// create the camera
|
|
||||||
UCamera camera = _Scene->getCam();
|
|
||||||
camera.setTransformMode (UTransformable::DirectMatrix);
|
|
||||||
|
|
||||||
setSizeViewport(w, h);
|
|
||||||
|
|
||||||
NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0);
|
NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0);
|
||||||
|
|
||||||
_MouseListener = _Driver->create3dMouseListener();
|
_MouseListener = _Driver->create3dMouseListener();
|
||||||
_MouseListener->setMouseMode(U3dMouseListener::edit3d);
|
_MouseListener->setMouseMode(U3dMouseListener::edit3d);
|
||||||
|
|
||||||
resetCamera();
|
|
||||||
|
|
||||||
// set the cache size for the font manager(in bytes)
|
// set the cache size for the font manager(in bytes)
|
||||||
_Driver->setFontManagerMaxMemory(2097152);
|
_Driver->setFontManagerMaxMemory(2097152);
|
||||||
|
|
||||||
|
@ -184,7 +175,7 @@ void CObjectViewer::release()
|
||||||
void CObjectViewer::updateInput()
|
void CObjectViewer::updateInput()
|
||||||
{
|
{
|
||||||
_Driver->EventServer.pump();
|
_Driver->EventServer.pump();
|
||||||
|
|
||||||
// New matrix from camera
|
// New matrix from camera
|
||||||
_Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix);
|
_Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix);
|
||||||
_Scene->getCam().setMatrix (_MouseListener->getViewMatrix());
|
_Scene->getCam().setMatrix (_MouseListener->getViewMatrix());
|
||||||
|
@ -218,53 +209,38 @@ void CObjectViewer::renderDebug2D()
|
||||||
|
|
||||||
void CObjectViewer::reloadTextures()
|
void CObjectViewer::reloadTextures()
|
||||||
{
|
{
|
||||||
// For each instances
|
// For each instances
|
||||||
std::vector<std::string> listObjects;
|
std::vector<std::string> listObjects;
|
||||||
getListObjects(listObjects);
|
getListObjects(listObjects);
|
||||||
|
|
||||||
for (size_t i = 0; i < listObjects.size(); ++i)
|
|
||||||
{
|
|
||||||
// Get the shape
|
|
||||||
NL3D::UInstance instance = getEntity(listObjects[i]).getInstance();
|
|
||||||
|
|
||||||
// For each material
|
|
||||||
if (!instance.empty())
|
|
||||||
{
|
|
||||||
uint numMaterial = instance.getNumMaterials();
|
|
||||||
uint mat;
|
|
||||||
for (mat = 0; mat < numMaterial; mat++)
|
|
||||||
{
|
|
||||||
// Get the material
|
|
||||||
NL3D::CMaterial *material = instance.getMaterial(mat).getObjectPtr();
|
|
||||||
|
|
||||||
// For each texture
|
|
||||||
int tex;
|
|
||||||
for (tex = 0; tex < NL3D::IDRV_MAT_MAXTEXTURES; tex++)
|
|
||||||
{
|
|
||||||
ITexture *texture = material->getTexture(tex);
|
|
||||||
|
|
||||||
// Touch it!
|
|
||||||
if (texture)
|
|
||||||
getIDriver()->invalidateShareTexture(*texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CObjectViewer::resetCamera()
|
for (size_t i = 0; i < listObjects.size(); ++i)
|
||||||
{
|
{
|
||||||
CVector hotSpot = CVector (0,0,0);
|
// Get the shape
|
||||||
float radius=10.f;
|
NL3D::UInstance instance = getEntity(listObjects[i]).getInstance();
|
||||||
|
|
||||||
// Setup camera
|
// For each material
|
||||||
_Scene->getCam().lookAt(hotSpot + CVector(0.57735f, 0.57735f, 0.57735f) * radius, hotSpot);
|
if (!instance.empty())
|
||||||
|
{
|
||||||
// Setup mouse listener
|
uint numMaterial = instance.getNumMaterials();
|
||||||
_MouseListener->setMatrix (_Scene->getCam().getMatrix());
|
uint mat;
|
||||||
_MouseListener->setFrustrum (_Scene->getCam().getFrustum());
|
for (mat = 0; mat < numMaterial; mat++)
|
||||||
_MouseListener->setViewport (CViewport());
|
{
|
||||||
_MouseListener->setHotSpot (hotSpot);
|
// Get the material
|
||||||
|
NL3D::CMaterial *material = instance.getMaterial(mat).getObjectPtr();
|
||||||
|
|
||||||
|
// For each texture
|
||||||
|
int tex;
|
||||||
|
for (tex = 0; tex < NL3D::IDRV_MAT_MAXTEXTURES; tex++)
|
||||||
|
{
|
||||||
|
ITexture *texture = material->getTexture(tex);
|
||||||
|
|
||||||
|
// Touch it!
|
||||||
|
if (texture)
|
||||||
|
getIDriver()->invalidateShareTexture(*texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CObjectViewer::saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga)
|
void CObjectViewer::saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga)
|
||||||
|
@ -316,11 +292,11 @@ bool CObjectViewer::loadMesh(const std::string &meshFileName, const std::string
|
||||||
|
|
||||||
// if we can't create entity, skip it
|
// if we can't create entity, skip it
|
||||||
if (Entity.empty()) return false;
|
if (Entity.empty()) return false;
|
||||||
|
|
||||||
CAABBox bbox;
|
CAABBox bbox;
|
||||||
Entity.getShapeAABBox(bbox);
|
Entity.getShapeAABBox(bbox);
|
||||||
setCamera(bbox , Entity, true);
|
setCamera(bbox , Entity, true);
|
||||||
|
|
||||||
_MouseListener->setMatrix(_Scene->getCam().getMatrix());
|
_MouseListener->setMatrix(_Scene->getCam().getMatrix());
|
||||||
|
|
||||||
USkeleton Skeleton = _Scene->createSkeleton(skelFileName);
|
USkeleton Skeleton = _Scene->createSkeleton(skelFileName);
|
||||||
|
@ -348,57 +324,57 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igName)
|
||||||
{
|
{
|
||||||
CPath::addSearchPath (CFile::getPath(igName));
|
CPath::addSearchPath (CFile::getPath(igName));
|
||||||
UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(igName);
|
UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(igName);
|
||||||
if (ig == 0)
|
if (ig == 0)
|
||||||
return false;
|
return false;
|
||||||
ig->addToScene(*_Scene, _Driver);
|
ig->addToScene(*_Scene, _Driver);
|
||||||
ig->unfreezeHRC();
|
ig->unfreezeHRC();
|
||||||
_ListIG.push_back(ig);
|
_ListIG.push_back(ig);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CObjectViewer::setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z)
|
void CObjectViewer::setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z)
|
||||||
{
|
{
|
||||||
CVector pos(0.f, 0.f, 0.f);
|
CVector pos(0.f, 0.f, 0.f);
|
||||||
CQuat quat(0.f, 0.f, 0.f, 0.f);
|
CQuat quat(0.f, 0.f, 0.f, 0.f);
|
||||||
NL3D::UInstance inst;
|
NL3D::UInstance inst;
|
||||||
inst.cast(entity);
|
inst.cast(entity);
|
||||||
if (!inst.empty())
|
if (!inst.empty())
|
||||||
{
|
{
|
||||||
inst.getDefaultPos(pos);
|
inst.getDefaultPos(pos);
|
||||||
inst.getDefaultRotQuat(quat);
|
inst.getDefaultRotQuat(quat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix scale (some shapes have a different value)
|
// fix scale (some shapes have a different value)
|
||||||
entity.setScale(1.f, 1.f, 1.f);
|
entity.setScale(1.f, 1.f, 1.f);
|
||||||
UCamera Camera = _Scene->getCam();
|
UCamera Camera = _Scene->getCam();
|
||||||
CVector max_radius = bbox.getHalfSize();
|
CVector max_radius = bbox.getHalfSize();
|
||||||
CVector center = bbox.getCenter();
|
CVector center = bbox.getCenter();
|
||||||
entity.setPivot(center);
|
entity.setPivot(center);
|
||||||
center += pos;
|
center += pos;
|
||||||
float fov = float(_CameraFocal * (float)Pi/180.0);
|
float fov = float(_CameraFocal * (float)Pi/180.0);
|
||||||
float radius = max(max(max_radius.x, max_radius.y), max_radius.z);
|
float radius = max(max(max_radius.x, max_radius.y), max_radius.z);
|
||||||
if (radius == 0.f) radius = 1.f;
|
if (radius == 0.f) radius = 1.f;
|
||||||
float left, right, bottom, top, znear, zfar;
|
float left, right, bottom, top, znear, zfar;
|
||||||
Camera.getFrustum(left, right, bottom, top, znear, zfar);
|
Camera.getFrustum(left, right, bottom, top, znear, zfar);
|
||||||
float dist = radius / (tan(fov/2));
|
float dist = radius / (tan(fov/2));
|
||||||
CVector eye(center);
|
CVector eye(center);
|
||||||
|
|
||||||
CVector ax(quat.getAxis());
|
CVector ax(quat.getAxis());
|
||||||
|
|
||||||
if (ax.isNull() || ax == CVector::I)
|
if (ax.isNull() || ax == CVector::I)
|
||||||
{
|
{
|
||||||
ax = CVector::J;
|
ax = CVector::J;
|
||||||
}
|
}
|
||||||
else if (ax == -CVector::K)
|
else if (ax == -CVector::K)
|
||||||
{
|
{
|
||||||
ax = -CVector::J;
|
ax = -CVector::J;
|
||||||
}
|
}
|
||||||
|
|
||||||
eye -= ax * (dist+radius);
|
eye -= ax * (dist+radius);
|
||||||
if (high_z)
|
if (high_z)
|
||||||
eye.z += max_radius.z/1.0f;
|
eye.z += max_radius.z/1.0f;
|
||||||
get3dMouseListener()->setHotSpot(center);
|
get3dMouseListener()->setHotSpot(center);
|
||||||
Camera.lookAt(eye, center);
|
Camera.lookAt(eye, center);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CObjectViewer::resetScene()
|
void CObjectViewer::resetScene()
|
||||||
|
|
|
@ -100,8 +100,6 @@ public:
|
||||||
|
|
||||||
void reloadTextures();
|
void reloadTextures();
|
||||||
|
|
||||||
void resetCamera();
|
|
||||||
|
|
||||||
/// Make a screenshot of the current scene and save.
|
/// Make a screenshot of the current scene and save.
|
||||||
void saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga);
|
void saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga);
|
||||||
|
|
||||||
|
@ -188,19 +186,19 @@ public:
|
||||||
{
|
{
|
||||||
return _Driver;
|
return _Driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::IDriver *getIDriver() const
|
NL3D::IDriver *getIDriver() const
|
||||||
{
|
{
|
||||||
return _IDriver;
|
return _IDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
inline NL3D::UScene *getScene() const
|
||||||
{
|
{
|
||||||
return _Scene;
|
return _Scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::CScene *getCScene() const
|
NL3D::CScene *getCScene() const
|
||||||
{
|
{
|
||||||
return _CScene;
|
return _CScene;
|
||||||
|
|
|
@ -36,8 +36,13 @@
|
||||||
<file>images/save-as.png</file>
|
<file>images/save-as.png</file>
|
||||||
<file>images/save.png</file>
|
<file>images/save.png</file>
|
||||||
<file>images/insert-horizontal.png</file>
|
<file>images/insert-horizontal.png</file>
|
||||||
<file>images/polymode.png</file>
|
<file>images/polymode.png</file>
|
||||||
|
<file>images/rmfill.png</file>
|
||||||
|
<file>images/rmline.png</file>
|
||||||
|
<file>images/rmpoints.png</file>
|
||||||
|
<file>images/cam_del.png</file>
|
||||||
|
<file>images/cam_add.png</file>
|
||||||
|
|
||||||
<file>images/Emitter.bmp</file>
|
<file>images/Emitter.bmp</file>
|
||||||
<file>images/Force.bmp</file>
|
<file>images/Force.bmp</file>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue