From 415c43693684fb3b801f22dfec9bdcb9f323c2ab Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 23 Jan 2011 13:04:03 +0200 Subject: [PATCH] Changed: #1193 Added menu entry reload textures. --- .../tools/3d/object_viewer_qt/src/entity.h | 6 ++ .../src/graphics_viewport.cpp | 4 +- .../object_viewer_qt/src/graphics_viewport.h | 2 +- .../3d/object_viewer_qt/src/object_viewer.cpp | 63 ++++++++++++++++--- .../3d/object_viewer_qt/src/object_viewer.h | 16 ++++- .../object_viewer_qt/src/particle_editor.cpp | 8 +-- 6 files changed, 79 insertions(+), 20 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/entity.h b/code/nel/tools/3d/object_viewer_qt/src/entity.h index 1022018c1..f051de174 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/entity.h +++ b/code/nel/tools/3d/object_viewer_qt/src/entity.h @@ -227,6 +227,12 @@ public: { return _SWTList; } + + /// Get game interface for manipulating Skeleton. + NL3D::UInstance getInstance() const + { + return _Instance; + } /// Get game interface for manipulating Skeleton. NL3D::USkeleton getSkeleton() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp index 00202d0d7..2128cdbd1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp @@ -118,7 +118,7 @@ void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent) Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); } -#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) +#if defined(NL_OS_MAC) // Qt does not provide wheel events through winEvent() and macEvent() (but it // does through x11Event(), which is inconsistent...) // Workaround is to handle wheel events like implemented below. @@ -148,7 +148,7 @@ void CGraphicsViewport::wheelEvent(QWheelEvent *event) Modules::objView().getDriver()->EventServer.postEvent( new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL)); } -#endif // defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) +#endif // defined(NL_OS_MAC) #if defined(NL_OS_WINDOWS) diff --git a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.h b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.h index fd2adf510..00b2c80d2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.h +++ b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.h @@ -80,7 +80,7 @@ private Q_SLOTS: protected: virtual void resizeEvent(QResizeEvent *resizeEvent); -#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) +#if defined(NL_OS_MAC) virtual void wheelEvent(QWheelEvent *event); #endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp index a00fecbde..37df70475 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp @@ -41,6 +41,9 @@ #include #include #include +#include +#include +#include #include // Project includes @@ -55,12 +58,14 @@ namespace NLQT { CObjectViewer::CObjectViewer() - : _Driver(NULL), - _TextContext(NULL), + : _IDriver(0), + _CScene(0), + _Driver(0), + _Scene(0), + _TextContext(0), _CameraFocal(75), _CurrentInstance(""), - _BloomEffect(false), - _Scene(0) + _BloomEffect(false) { } @@ -102,7 +107,7 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h) _Driver->enableLight(0); // Create a scene - _Scene = _Driver->createScene(true); + _Scene = _Driver->createScene(false); _PlayListManager = _Scene->createPlayListManager(); @@ -134,6 +139,12 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h) NL3D::CBloomEffect::instance().init(!_Direct3D); NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt()); NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool()); + + NL3D::CDriverUser *driver = dynamic_cast(Modules::objView().getDriver()); + _IDriver = driver->getDriver(); + + NL3D::CSceneUser *scene = dynamic_cast(Modules::objView().getScene()); + _CScene = &scene->getScene(); } void CObjectViewer::release() @@ -146,7 +157,7 @@ void CObjectViewer::release() // release text context nlassert(_TextContext); _Driver->deleteTextContext(_TextContext); - _TextContext = NULL; + _TextContext = 0; _Driver->delete3dMouseListener(_MouseListener); @@ -165,7 +176,7 @@ void CObjectViewer::release() nlassert(_Driver); _Driver->release(); delete _Driver; - _Driver = NULL; + _Driver = 0; } void CObjectViewer::updateInput() @@ -180,7 +191,7 @@ void CObjectViewer::updateInput() void CObjectViewer::renderDriver() { // Render the scene. - if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) + if((NL3D::CBloomEffect::instance().getDriver() != 0) && (_BloomEffect)) { NL3D::CBloomEffect::instance().initBloom(); } @@ -192,7 +203,7 @@ void CObjectViewer::renderScene() // render the scene _Scene->render(); - if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) + if((NL3D::CBloomEffect::instance().getDriver() != 0) && (_BloomEffect)) { NL3D::CBloomEffect::instance().endBloom(); NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); @@ -205,6 +216,38 @@ void CObjectViewer::renderDebug2D() void CObjectViewer::reloadTextures() { + // For each instances + std::vector 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() @@ -303,7 +346,7 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igName) { CPath::addSearchPath (CFile::getPath(igName)); UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(igName); - if (ig == NULL) + if (ig == 0) return false; ig->addToScene(*_Scene, _Driver); ig->unfreezeHRC(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.h b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.h index c846a7dae..2cdefe426 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.h +++ b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.h @@ -46,6 +46,8 @@ class UTextContext; class UPlayListManager; class U3dMouseListener; class UInstanceGroup; +class CScene; +class IDriver; } namespace NLQT @@ -186,13 +188,23 @@ public: { return _Driver; } - + + NL3D::IDriver *getIDriver() const + { + return _IDriver; + } + /// Get a game interface for scene. /// @return pointer to the scene. inline NL3D::UScene *getScene() const { return _Scene; } + + NL3D::CScene *getCScene() const + { + return _CScene; + } /// Get a manager of playlist /// @return pointer to the UPlayListManager @@ -231,6 +243,8 @@ private: void cfcbBloomEffect(NLMISC::CConfigFile::CVar &var); NLMISC::CRGBA _BackgroundColor; + NL3D::IDriver *_IDriver; + NL3D::CScene *_CScene; NL3D::UDriver *_Driver; NL3D::UScene *_Scene; diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_editor.cpp index 4e4744136..1a7edfeaa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_editor.cpp @@ -22,7 +22,6 @@ // NeL includes #include -#include #include #include #include @@ -57,11 +56,8 @@ CParticleEditor::~CParticleEditor(void) void CParticleEditor::init() { - NL3D::CDriverUser *driver = dynamic_cast(Modules::objView().getDriver()); - _Driver = driver->getDriver(); - - NL3D::CSceneUser *scene = dynamic_cast(Modules::objView().getScene()); - _Scene = &scene->getScene(); + _Driver = Modules::objView().getIDriver(); + _Scene = Modules::objView().getCScene(); NL3D::CTextContextUser *textContext = dynamic_cast(Modules::objView().getTextContext()); _FontManager = textContext->getTextContext().getFontManager();