mhebel
11-02-2008 23:18:43
Hi,
I'm having problems getting the ofusion loader running in the compositor demo which is coming with the standard OgreSDK.
As I've read the tutorials and especially this post
Problem load .osm file-Post
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=5368&postdays=0&postorder=asc&start=0
I managed to run the oSceneLoader_demo_dagon from the ofusion website. My Scene is working, everything is loading, just fine.
As I'm going to write some shaders "specialized" on my scene, I wanted to load the exact same scene into the compositor demo where I already have plugined some new shaders.
I thought it must be very simple to add some code lines and the scene will load, but it doesn't. There is always a crash. Here's what I've got (only my parts mentioned in the named methods:
file compositor.cpp
What am I doing wrong? The compiler tells me everything is ok, the original compositor demo is compiling perfectly but when my scene is loaded via "oScene.createScene" on execution the build crashes.
I'm having problems getting the ofusion loader running in the compositor demo which is coming with the standard OgreSDK.
As I've read the tutorials and especially this post
Problem load .osm file-Post
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=5368&postdays=0&postorder=asc&start=0
I managed to run the oSceneLoader_demo_dagon from the ofusion website. My Scene is working, everything is loading, just fine.
As I'm going to write some shaders "specialized" on my scene, I wanted to load the exact same scene into the compositor demo where I already have plugined some new shaders.
I thought it must be very simple to add some code lines and the scene will load, but it doesn't. There is always a crash. Here's what I've got (only my parts mentioned in the named methods:
file compositor.cpp
// ...
#include "OgreOSMScene.cpp"
#include "tinystr.cpp"
#include "tinystr.h"
#include "tinyxml.cpp"
#include "tinyxml.h"
#include "tinyxmlerror.cpp"
#include "tinyxmlparser.cpp"
// more code...
bool CompositorDemo::setup(void)
{
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
Ogre::String mResourcePath;
mResourcePath = bundlePath() + "/Contents/Resources/";
mRoot = new Ogre::Root(mResourcePath + "plugins.cfg",
mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
#else
mRoot = new Ogre::Root();
#endif
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
// now here is the ofusion stuff
OSMScene oScene;
oScene.initialise("scene.osm");
oScene.createScene();
mSceneMgr = oScene.getSceneManager();
/* comment out the original methods handling scene manager, camera, viewports
*/
//chooseSceneManager();
//createCamera();
//createViewports();
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
loadResources();
// Create the scene
createScene();
createFrameListener();
// load some GUI stuff for demo.
//loadAllMaterialControlFiles(mMaterialControlsContainer);
return true;
}
// ...
/* and in method createScene() I commented out some parts that will collide with my scene*/
void CompositorDemo::createScene(void)
{
/*mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE);
mSceneMgr->setShadowFarDistance(1000);
*/
// setup GUI system
mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
// load scheme and set up defaults
mGUISystem = new CEGUI::System(mGUIRenderer, (CEGUI::ResourceProvider *)0, (CEGUI::XMLParser*)0,
(CEGUI::ScriptModule*)0, (CEGUI::utf8*)"CompositorDemoCegui.config");
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
Ogre::MovableObject::setDefaultVisibilityFlags(0x00000001);
/* // Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.2));
Ogre::Light* l = mSceneMgr->createLight("Light2");
Ogre::Vector3 dir(-1,-1,0);
dir.normalise();
l->setType(Ogre::Light::LT_DIRECTIONAL);
l->setDirection(dir);
l->setDiffuseColour(1, 1, 0.8);
l->setSpecularColour(1, 1, 1);
Ogre::Entity* pEnt;
// House
pEnt = mSceneMgr->createEntity( "1", "tudorhouse.mesh" );
Ogre::SceneNode* n1 = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(350, 450, -200));
n1->attachObject( pEnt );
pEnt = mSceneMgr->createEntity( "2", "tudorhouse.mesh" );
Ogre::SceneNode* n2 = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(-350, 450, -200));
n2->attachObject( pEnt );
pEnt = mSceneMgr->createEntity( "3", "knot.mesh" );
mSpinny = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, 0, 300));
mSpinny->attachObject( pEnt );
pEnt->setMaterialName("Examples/MorningCubeMap");
//pEnt = mSceneMgr->createEntity( "3", "hut.mesh" );
//mSpinny = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, 0, 300));
//mSpinny->attachObject( pEnt );
//pEnt->setMaterialName("Examples/MorningCubeMap");
mSceneMgr->setSkyBox(true, "Examples/MorningSkyBox");
Ogre::Plane plane;
plane.normal = Ogre::Vector3::UNIT_Y;
plane.d = 100;
Ogre::MeshManager::getSingleton().createPlane("Myplane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500, 1500, 10, 10, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
pPlaneEnt->setMaterialName("Examples/Rockwall");
pPlaneEnt->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
mCamera->setPosition(-400, 50, 900);
mCamera->lookAt(0,80,0);
*/
connectEventHandlers();
/// Create a couple of hard coded postfilter effects as an example of how to do it
/// but the preferred method is to use compositor scripts.
createEffects();
}
}
// ...
What am I doing wrong? The compiler tells me everything is ok, the original compositor demo is compiling perfectly but when my scene is loaded via "oScene.createScene" on execution the build crashes.