Kalgar
22-06-2009 14:23:27
Hey all.
I'm new to NxOgre, and figured I could use a little help, since I'm at my wits end here >.>
Basically, I've taken my knowledge of OGRE, and some info from multiple tutorials and attempted to put together a small test program. All I do is load up NxOgre, a test mesh, and a test Convex file (generated via Flour), and attempt to draw it to the screen.
The catch is that I've tried to incorporate this into a single main.cpp file (since I'm not a big fan of the example framework, and would like to get this working without it so that I can learn how to integrate it with my own class structure).
When I run the program, all I get is a blank screen, and I spent a while re-orienting the camera with no luck, so I believe I may have done something wrong with the OGRE3DRenderSystem, or something.
here is my code: (warning: long block of code!)
It may be worth noting that I've currently commented out the lighting sections, since my test mesh has no materials on it whatsoever. When I tried this using raw OGRE, and raw PhysX (before I decided to try NxOgre) the test mesh (which was a cube at the time) showed up as a pure white mesh, so I'd assume that the case should be the same here.
Main reason I decided to try NxOgre was due to having difficulties loading the PhysX binary files to create a convex mesh, but if I can't get this going, I may be stuck with just playing with loads and loads of cubes
Thanks in advance!
~Kalgar
I'm new to NxOgre, and figured I could use a little help, since I'm at my wits end here >.>
Basically, I've taken my knowledge of OGRE, and some info from multiple tutorials and attempted to put together a small test program. All I do is load up NxOgre, a test mesh, and a test Convex file (generated via Flour), and attempt to draw it to the screen.
The catch is that I've tried to incorporate this into a single main.cpp file (since I'm not a big fan of the example framework, and would like to get this working without it so that I can learn how to integrate it with my own class structure).
When I run the program, all I get is a blank screen, and I spent a while re-orienting the camera with no luck, so I believe I may have done something wrong with the OGRE3DRenderSystem, or something.
here is my code: (warning: long block of code!)
int main()
{
//////////////////////////////////////////////// initialisation stuffs ///////////////////////////////////////////////
gRoot = new Ogre::Root("", "ogre.cfg"); // creates the OGRE root without loading a plugins file - we will do plugins manually
#if defined(_DEBUG)
gRoot->loadPlugin("RenderSystem_Direct3D9_d");
gRoot->loadPlugin("Plugin_BSPSceneManager_d");
gRoot->loadPlugin("Plugin_CgProgramManager_d");
gRoot->loadPlugin("Plugin_OctreeSceneManager_d");
gRoot->loadPlugin("Plugin_ParticleFX_d");
#else
gRoot->loadPlugin("RenderSystem_Direct3D9");
gRoot->loadPlugin("Plugin_BSPSceneManager");
gRoot->loadPlugin("Plugin_CgProgramManager");
gRoot->loadPlugin("Plugin_OctreeSceneManager");
gRoot->loadPlugin("Plugin_ParticleFX");
#endif
if(gRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
gWindow = gRoot->initialise(true);
}
else
{
delete gRoot;
return 1;
}
gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC, "SceneManager");
// set ambient light
//gSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
// create a light
//Ogre::Light *l = gSceneMgr->createLight("MainLight");
//l->setPosition(20, 80, 50);
// create and position the camera
gCamera = gSceneMgr->createCamera("Camera1");
gCamera->setPosition(0, 0, 10);
gCamera->lookAt(0, 0, 0);
Ogre::Viewport* vp = gWindow->addViewport(gCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
gCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
// resource management
Ogre::ResourceGroupManager *rgm = Ogre::ResourceGroupManager::getSingletonPtr();
rgm->addResourceLocation("meshes", "FileSystem", "meshes");
// initialise all previously defined resource groups
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// NXOgre World
gWorld = NxOgre::World::createWorld();
// create a NxOgre scene description
NxOgre::SceneDescription sceneDesc;
sceneDesc.mGravity = NxOgre::Real3(0, -9.8f, 0);
sceneDesc.mName = "Stuff";
// actually create the scene
gScene = gWorld->createScene(sceneDesc);
// set some physics values for our scene
gScene->getMaterial(0)->setStaticFriction(0.5);
gScene->getMaterial(0)->setDynamicFriction(0.5);
gScene->getMaterial(0)->setRestitution(0.1); // coefficient of restitution
// create the render system
gRenderSystem = new OGRE3DRenderSystem(gScene, gSceneMgr);
// create the time controller
gTimeController = NxOgre::TimeController::getSingleton();
// load a convex mesh
NxOgre::Mesh *mesh;
NxOgre::ResourceSystem::getSingleton()->openArchive("objects", "file:nxobjects");
mesh = NxOgre::MeshManager::getSingleton()->load("objects:physicsTest.nxs");
// put the convex mesh into an actual body
OGRE3DBody *body;
body = gRenderSystem->createBody(new NxOgre::Convex(mesh), NxOgre::Real3(0, 3.5f, 0), "physicsTest.mesh");
// loop
while(true)
{
std::cout << "I'm in a loop! My mesh is at " << body->getGlobalPosition().x << " " << body->getGlobalPosition().y << " " << body->getGlobalPosition().x << std::endl;
gTimeController->advance(0.0001);
gRoot->renderOneFrame();
}
return 0;
}
It may be worth noting that I've currently commented out the lighting sections, since my test mesh has no materials on it whatsoever. When I tried this using raw OGRE, and raw PhysX (before I decided to try NxOgre) the test mesh (which was a cube at the time) showed up as a pure white mesh, so I'd assume that the case should be the same here.
Main reason I decided to try NxOgre was due to having difficulties loading the PhysX binary files to create a convex mesh, but if I can't get this going, I may be stuck with just playing with loads and loads of cubes
Thanks in advance!
~Kalgar