how to get world & scene from external function

mtx123

07-11-2007 22:28:36

in my SourceCode.cpp, in function
void CreateScene(void)....
I have:
World *mWorld = new World();
Scene *mScene = mWorld->createScene("Main",mSceneMgr, "gravity: 0 -150 0, floor: yes");

then in Input.cpp, in function
bool keyPressed(const OIS::KeyEvent &e)....
I want to create HERE a World and a Scene variables that belong from the original mWorld and mScene. There must be something like ->getScene("...") but I have not found.

betajaen

07-11-2007 22:43:01

Make them member variables of your class.

mtx123

07-11-2007 22:47:12

ehm....
can you make some example?
thank you :D

betajaen

07-11-2007 22:53:08

class A {
public:

World* mWorld;
Scene* mScene;

void createScene();

};


void A::createScene() {
mWorld = new World();
mScene = mWorld->createScene(....);
}


If you don't know what all of that means. You really need to delete your NxOgre folder, and learn about C++ again.

mtx123

07-11-2007 23:03:35

now this is my code:


class TutorialApplication : public ExampleApplication
{
public:
World* mWorld;
Scene* mScene;

void createScene(void)
{
mWorld = new World();
mScene = mWorld->createScene("Main",mSceneMgr, "gravity: 0 -150 0, floor: yes");


in the external function (in another class) I call
Body *temp = mScene->getActor("mybody9");

compiler error:
'mScene': identifier not declared (TRANSLATE)

betajaen

07-11-2007 23:04:57

Alright. Time to delete NxOgre and learn C++.

I'm serious. I'm not helping you anymore.

mtx123

07-11-2007 23:07:33

noooooooooo :cry: :cry: :cry: :cry: :cry:

please.....

betajaen

07-11-2007 23:14:37

If you don't know how to make two objects interact with each other and share other variables, then you don't know C++ that well, and you don't have the required knowledge to use NxOgre and even Ogre.

I don't expect people to know anything about physics with NxOgre, but at least some knowledge of Ogre which requires C++ skills, that is all I ask.

Horizon

08-11-2007 07:49:52

Physics-enabled games or simulation, or whatever you want to make, can quickly become really complex pieces of software and are NOT viable projects to learn C++ from. One exception may be for programmers proficient with another OO-language.

For you, though: Drop Ogre, drop NxOgre and go program a pong clone or something, you will learn alot more from that.