[NxOgre 0.9] Creating a Plane and a simple Cube

Coiote

19-04-2008 19:38:58

Hi,

I'm a newbie in Ogre and NxOGre so, hopefully, someone here can help me with my problem:


private:
Root *mRoot;
RenderWindow* mWindow;
Camera* mCamera;

SceneManager* mgr;


NxOgre::World* mWorld;
NxOgre::Scene* mScene;


OIS::Keyboard *mKeyboard;
OIS::InputManager *mInputManager;
CEGUI::OgreCEGUIRenderer *mRenderer;
CEGUI::System *mSystem;
ExitListener *mListener;

void createRoot()
{
mRoot = new Root();
}

void defineResources()
{
String secName, typeName, archName;
ConfigFile cf;
cf.load("resources.cfg");

ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;

for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
}

void setupRenderSystem()
{
mRoot->showConfigDialog();

}

void createRenderWindow()
{
mWindow = mRoot->initialise(true, "Wheelies Window");

}
void defineSceneManager(){

mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
}
void createCamera()
{
mCamera = mgr->createCamera("Camera");


// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,500));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
//mCamera->setNearClipDistance(5);
}



void initializeResourceGroups()
{
TextureManager::getSingleton().setDefaultNumMipmaps(5);
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

}

void setupScene()
{
Viewport *vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));


mgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));

mgr->setSkyDome(true, "Examples/CloudySky", 5, 8);

// Create a light
Light* l = mgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
l->setPosition(20,80,50);

Entity *ent;

// Define a floor plane mesh
Plane p;
p.normal = Vector3::UNIT_Y;
p.d = 200;
Ogre::MeshManager::getSingleton().createPlane(
"FloorPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
p, 200000, 200000, 20, 20, true, 1, 50, 50, Vector3::UNIT_Z);

// Create an entity (the floor)
ent = mgr->createEntity("floor", "FloorPlane");
ent->setMaterialName("Examples/RustySteel");
// Attach to child of root node, better for culling (otherwise bounds are the combination of the 2)
mgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

mWorld = new World("log: html");
mScene = mWorld->createScene("Main", mgr, "gravity: yes, floor: yes");
mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,3,0), "Mass: 100");

}



The problem is that the plan appears, and the box not, or I think not.
I think the ogre objects are appearing and the NxOgre objects not.

Am I doing everything wrong or what ???

Thankx for the help

betajaen

19-04-2008 20:01:16

Either your camera is too far away and you can't see it, or the Plane is above the cube.

Coiote

20-04-2008 05:02:14

Thankx betajaen, it was the values of the camera, I uncomment the:
mCamera->setNearClipDistance(5); too, and now works fine.

Ready to start putting some more stuff's in the world.

Just for curiosity betajaen, did you think that this structure of code make sense or there is a more easy way or structured to do it ?

Once again thankx

betajaen

20-04-2008 11:11:48

It's fine for a first application, a second application should be more modular though.