Changed: #1193 Added menu entry reload textures.

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

View file

@ -228,6 +228,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
{

View file

@ -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)

View file

@ -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

View file

@ -41,6 +41,9 @@
#include <nel/3d/u_play_list_manager.h>
#include <nel/3d/u_3d_mouse_listener.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>
// 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<NL3D::CDriverUser *>(Modules::objView().getDriver());
_IDriver = driver->getDriver();
NL3D::CSceneUser *scene = dynamic_cast<NL3D::CSceneUser *>(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<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()
@ -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();

View file

@ -46,6 +46,8 @@ class UTextContext;
class UPlayListManager;
class U3dMouseListener;
class UInstanceGroup;
class CScene;
class IDriver;
}
namespace NLQT
@ -187,6 +189,11 @@ 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
@ -194,6 +201,11 @@ public:
return _Scene;
}
NL3D::CScene *getCScene() const
{
return _CScene;
}
/// Get a manager of playlist
/// @return pointer to the UPlayListManager
inline NL3D::UPlayListManager *getPlayListManager() const
@ -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;

View file

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