Changed: #1193 Added menu entry reload textures.

This commit is contained in:
dnk-88 2011-01-23 13:04:03 +02:00
parent 99eddec26c
commit ba31b1fcc2
6 changed files with 79 additions and 20 deletions

View file

@ -228,6 +228,12 @@ public:
return _SWTList; return _SWTList;
} }
/// Get game interface for manipulating Skeleton.
NL3D::UInstance getInstance() const
{
return _Instance;
}
/// Get game interface for manipulating Skeleton. /// Get game interface for manipulating Skeleton.
NL3D::USkeleton getSkeleton() const NL3D::USkeleton getSkeleton() const
{ {

View file

@ -118,7 +118,7 @@ void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent)
Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); 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 // Qt does not provide wheel events through winEvent() and macEvent() (but it
// does through x11Event(), which is inconsistent...) // does through x11Event(), which is inconsistent...)
// Workaround is to handle wheel events like implemented below. // Workaround is to handle wheel events like implemented below.
@ -148,7 +148,7 @@ void CGraphicsViewport::wheelEvent(QWheelEvent *event)
Modules::objView().getDriver()->EventServer.postEvent( Modules::objView().getDriver()->EventServer.postEvent(
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL)); 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) #if defined(NL_OS_WINDOWS)

View file

@ -80,7 +80,7 @@ private Q_SLOTS:
protected: protected:
virtual void resizeEvent(QResizeEvent *resizeEvent); virtual void resizeEvent(QResizeEvent *resizeEvent);
#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) #if defined(NL_OS_MAC)
virtual void wheelEvent(QWheelEvent *event); virtual void wheelEvent(QWheelEvent *event);
#endif #endif

View file

@ -41,6 +41,9 @@
#include <nel/3d/u_play_list_manager.h> #include <nel/3d/u_play_list_manager.h>
#include <nel/3d/u_3d_mouse_listener.h> #include <nel/3d/u_3d_mouse_listener.h>
#include <nel/3d/u_instance_group.h> #include <nel/3d/u_instance_group.h>
#include <nel/3d/material.h>
#include <nel/3d/driver.h>
#include <nel/3d/scene_user.h>
#include <nel/3d/bloom_effect.h> #include <nel/3d/bloom_effect.h>
// Project includes // Project includes
@ -55,12 +58,14 @@ namespace NLQT
{ {
CObjectViewer::CObjectViewer() CObjectViewer::CObjectViewer()
: _Driver(NULL), : _IDriver(0),
_TextContext(NULL), _CScene(0),
_Driver(0),
_Scene(0),
_TextContext(0),
_CameraFocal(75), _CameraFocal(75),
_CurrentInstance(""), _CurrentInstance(""),
_BloomEffect(false), _BloomEffect(false)
_Scene(0)
{ {
} }
@ -102,7 +107,7 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
_Driver->enableLight(0); _Driver->enableLight(0);
// Create a scene // Create a scene
_Scene = _Driver->createScene(true); _Scene = _Driver->createScene(false);
_PlayListManager = _Scene->createPlayListManager(); _PlayListManager = _Scene->createPlayListManager();
@ -134,6 +139,12 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
NL3D::CBloomEffect::instance().init(!_Direct3D); NL3D::CBloomEffect::instance().init(!_Direct3D);
NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt()); NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt());
NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool()); NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool());
NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver());
_IDriver = driver->getDriver();
NL3D::CSceneUser *scene = dynamic_cast<NL3D::CSceneUser *>(Modules::objView().getScene());
_CScene = &scene->getScene();
} }
void CObjectViewer::release() void CObjectViewer::release()
@ -146,7 +157,7 @@ void CObjectViewer::release()
// release text context // release text context
nlassert(_TextContext); nlassert(_TextContext);
_Driver->deleteTextContext(_TextContext); _Driver->deleteTextContext(_TextContext);
_TextContext = NULL; _TextContext = 0;
_Driver->delete3dMouseListener(_MouseListener); _Driver->delete3dMouseListener(_MouseListener);
@ -165,7 +176,7 @@ void CObjectViewer::release()
nlassert(_Driver); nlassert(_Driver);
_Driver->release(); _Driver->release();
delete _Driver; delete _Driver;
_Driver = NULL; _Driver = 0;
} }
void CObjectViewer::updateInput() void CObjectViewer::updateInput()
@ -180,7 +191,7 @@ void CObjectViewer::updateInput()
void CObjectViewer::renderDriver() void CObjectViewer::renderDriver()
{ {
// Render the scene. // Render the scene.
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != 0) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().initBloom(); NL3D::CBloomEffect::instance().initBloom();
} }
@ -192,7 +203,7 @@ void CObjectViewer::renderScene()
// render the scene // render the scene
_Scene->render(); _Scene->render();
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != 0) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().endBloom(); NL3D::CBloomEffect::instance().endBloom();
NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); NL3D::CBloomEffect::instance().endInterfacesDisplayBloom();
@ -205,6 +216,38 @@ void CObjectViewer::renderDebug2D()
void CObjectViewer::reloadTextures() void CObjectViewer::reloadTextures()
{ {
// For each instances
std::vector<std::string> 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() void CObjectViewer::resetCamera()
@ -303,7 +346,7 @@ 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 == NULL) if (ig == 0)
return false; return false;
ig->addToScene(*_Scene, _Driver); ig->addToScene(*_Scene, _Driver);
ig->unfreezeHRC(); ig->unfreezeHRC();

View file

@ -46,6 +46,8 @@ class UTextContext;
class UPlayListManager; class UPlayListManager;
class U3dMouseListener; class U3dMouseListener;
class UInstanceGroup; class UInstanceGroup;
class CScene;
class IDriver;
} }
namespace NLQT namespace NLQT
@ -187,6 +189,11 @@ public:
return _Driver; return _Driver;
} }
NL3D::IDriver *getIDriver() const
{
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
@ -194,6 +201,11 @@ public:
return _Scene; return _Scene;
} }
NL3D::CScene *getCScene() const
{
return _CScene;
}
/// 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 inline NL3D::UPlayListManager *getPlayListManager() const
@ -231,6 +243,8 @@ private:
void cfcbBloomEffect(NLMISC::CConfigFile::CVar &var); void cfcbBloomEffect(NLMISC::CConfigFile::CVar &var);
NLMISC::CRGBA _BackgroundColor; NLMISC::CRGBA _BackgroundColor;
NL3D::IDriver *_IDriver;
NL3D::CScene *_CScene;
NL3D::UDriver *_Driver; NL3D::UDriver *_Driver;
NL3D::UScene *_Scene; NL3D::UScene *_Scene;

View file

@ -22,7 +22,6 @@
// NeL includes // NeL includes
#include <nel/3d/driver.h> #include <nel/3d/driver.h>
#include <nel/3d/scene_user.h>
#include <nel/3d/text_context_user.h> #include <nel/3d/text_context_user.h>
#include <nel/3d/scene.h> #include <nel/3d/scene.h>
#include <nel/3d/particle_system_model.h> #include <nel/3d/particle_system_model.h>
@ -57,11 +56,8 @@ CParticleEditor::~CParticleEditor(void)
void CParticleEditor::init() void CParticleEditor::init()
{ {
NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver()); _Driver = Modules::objView().getIDriver();
_Driver = driver->getDriver(); _Scene = Modules::objView().getCScene();
NL3D::CSceneUser *scene = dynamic_cast<NL3D::CSceneUser *>(Modules::objView().getScene());
_Scene = &scene->getScene();
NL3D::CTextContextUser *textContext = dynamic_cast<NL3D::CTextContextUser *>(Modules::objView().getTextContext()); NL3D::CTextContextUser *textContext = dynamic_cast<NL3D::CTextContextUser *>(Modules::objView().getTextContext());
_FontManager = textContext->getTextContext().getFontManager(); _FontManager = textContext->getTextContext().getFontManager();