Fixed: Build object viewer widget on Mac OS X (and line terminator consistency)

This commit is contained in:
rti 2010-12-11 20:51:49 +01:00
parent f91733c9f2
commit f4d6f77ab1

View file

@ -54,10 +54,10 @@ namespace NLQT
CObjectViewerWidget *CObjectViewerWidget::_objectViewerWidget = NULL; CObjectViewerWidget *CObjectViewerWidget::_objectViewerWidget = NULL;
CObjectViewerWidget::CObjectViewerWidget(QWidget *parent) CObjectViewerWidget::CObjectViewerWidget(QWidget *parent)
: _isGraphicsInitialized(false), _isGraphicsEnabled(false), : _isGraphicsInitialized(false), _isGraphicsEnabled(false),
_Driver(NULL), _Light(0), _phi(0), _psi(0),_dist(2), _Driver(NULL), _Light(0), _phi(0), _psi(0),_dist(2),
_CameraFocal(75), _CurrentInstance(""), _BloomEffect(false), _CameraFocal(75), _CurrentInstance(""), _BloomEffect(false),
_Scene(0), QWidget(parent) _Scene(0), QWidget(parent)
{ {
_objectViewerWidget = this; _objectViewerWidget = this;
@ -89,7 +89,7 @@ namespace NLQT
//dynamic_cast<QNLWidget*>(widget())->makeCurrent(); //dynamic_cast<QNLWidget*>(widget())->makeCurrent();
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC) #endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
nlWindow wnd = winId(); nlWindow wnd = (nlWindow)winId();
uint16 w = width(); uint16 w = width();
uint16 h = height(); uint16 h = height();
@ -112,7 +112,7 @@ namespace NLQT
//else nlwarning("Invalid driver specified, defaulting to OpenGL"); //else nlwarning("Invalid driver specified, defaulting to OpenGL");
#endif #endif
//Modules::config().setAndCallback("CameraFocal",CConfigCallback(this,&CObjectViewer::cfcbCameraFocal)); //Modules::config().setAndCallback("CameraFocal",CConfigCallback(this,&CObjectViewer::cfcbCameraFocal));
//Modules::config().setAndCallback("BloomEffect",CConfigCallback(this,&CObjectViewer::cfcbBloomEffect)); //Modules::config().setAndCallback("BloomEffect",CConfigCallback(this,&CObjectViewer::cfcbBloomEffect));
// create the driver // create the driver
@ -164,10 +164,10 @@ namespace NLQT
_MouseListener->setHotSpot(hotSpot); _MouseListener->setHotSpot(hotSpot);
_MouseListener->setMouseMode(U3dMouseListener::edit3d); _MouseListener->setMouseMode(U3dMouseListener::edit3d);
NL3D::CBloomEffect::instance().setDriver(_Driver); NL3D::CBloomEffect::instance().setDriver(_Driver);
NL3D::CBloomEffect::instance().setScene(_Scene); NL3D::CBloomEffect::instance().setScene(_Scene);
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());
} }
@ -344,11 +344,11 @@ namespace NLQT
void CObjectViewerWidget::renderDriver() void CObjectViewerWidget::renderDriver()
{ {
// Render the scene. // Render the scene.
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().initBloom(); NL3D::CBloomEffect::instance().initBloom();
} }
_Driver->clearBuffers(_BackgroundColor); _Driver->clearBuffers(_BackgroundColor);
} }
@ -357,10 +357,10 @@ namespace NLQT
// render the scene // render the scene
_Scene->render(); _Scene->render();
if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect))
{ {
NL3D::CBloomEffect::instance().endBloom(); NL3D::CBloomEffect::instance().endBloom();
NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); NL3D::CBloomEffect::instance().endInterfacesDisplayBloom();
} }
} }
@ -406,8 +406,8 @@ namespace NLQT
bool CObjectViewerWidget::loadMesh(const std::string &meshFileName, const std::string &skelFileName) bool CObjectViewerWidget::loadMesh(const std::string &meshFileName, const std::string &skelFileName)
{ {
std::string fileName = CFile::getFilenameWithoutExtension(meshFileName); std::string fileName = CFile::getFilenameWithoutExtension(meshFileName);
if ( _Entities.count(fileName) != 0) if ( _Entities.count(fileName) != 0)
return false; return false;
CPath::display(); CPath::display();
@ -432,17 +432,17 @@ namespace NLQT
CEntity &entity = (*eit).second; CEntity &entity = (*eit).second;
// set the entity up // set the entity up
entity._Name = fileName; entity._Name = fileName;
entity._FileNameShape = meshFileName; entity._FileNameShape = meshFileName;
entity._FileNameSkeleton = skelFileName; entity._FileNameSkeleton = skelFileName;
entity._Instance = Entity; entity._Instance = Entity;
if (!Skeleton.empty()) if (!Skeleton.empty())
{ {
entity._Skeleton = Skeleton; entity._Skeleton = Skeleton;
entity._Skeleton.bindSkin (entity._Instance); entity._Skeleton.bindSkin (entity._Instance);
} }
entity._AnimationSet = _Driver->createAnimationSet(false); entity._AnimationSet = _Driver->createAnimationSet(false);
entity._PlayList = _PlayListManager->createPlayList(entity._AnimationSet); entity._PlayList = _PlayListManager->createPlayList(entity._AnimationSet);
return true; return true;
} }
@ -699,65 +699,65 @@ namespace NLQT
return true; return true;
} }
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
bool CObjectViewerWidget::winEvent(MSG * message, long * result) bool CObjectViewerWidget::winEvent(MSG * message, long * result)
{ {
if (getDriver() && getDriver()->isActive()) if (getDriver() && getDriver()->isActive())
{ {
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver(); NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver) if (driver)
{ {
winProc proc = (winProc)driver->getWindowProc(); winProc proc = (winProc)driver->getWindowProc();
return proc(driver, message->hwnd, message->message, message->wParam, message->lParam); return proc(driver, message->hwnd, message->message, message->wParam, message->lParam);
} }
} }
return false; return false;
} }
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event) bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event)
{ {
if(caller) if(caller)
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
if (getDriver() && getDriver()->isActive()) if (getDriver() && getDriver()->isActive())
{ {
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver(); NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver) if (driver)
{ {
cocoaProc proc = (cocoaProc)driver->getWindowProc(); cocoaProc proc = (cocoaProc)driver->getWindowProc();
return proc(driver, event); return proc(driver, event);
} }
} }
return false; return false;
} }
#elif defined(NL_OS_UNIX) #elif defined(NL_OS_UNIX)
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
bool CObjectViewerWidget::x11Event(XEvent *event) bool CObjectViewerWidget::x11Event(XEvent *event)
{ {
if (getDriver() && getDriver()->isActive()) if (getDriver() && getDriver()->isActive())
{ {
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver(); NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver) if (driver)
{ {
x11Proc proc = (x11Proc)driver->getWindowProc(); x11Proc proc = (x11Proc)driver->getWindowProc();
return proc(driver, event); return proc(driver, event);
} }
} }
return false; return false;
} }
#endif #endif
} /* namespace NLQT */ } /* namespace NLQT */