tutorials in .9

ncomputerm4

17-06-2007 20:39:45

Ok, I've read about the changes in how to make objects in .9 but I haven’t found a list of the needed includes. I've added more includes than the tutorial had in it (trying 101)
heres my code:
#include "NxOgre.h"
#include "NxogreStable.h"
#include "NxOgreWorld.h"
#include "NxOgreScene.h" // For: Scene operations
#include "NxOgreHelpers.h" // For: Incase of Scene duplicate names.
#include "NxOgreCharacterController.h" // For: Setting up character controller
#include "time.h"
#include "Ogre.h"


//using namespace nxOgre;
using namespace Ogre;
using namespace std;

class NxTutorial : public SimpleTutorial {

public:
world *mWorld;
scene *mScene;

//////////////////////////////////////////////////////////////////////////////////////////////////
void start() {

mWorld = new World();
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");
mScene->createActor("FakeFloor", new CubeShape(100,2.1f,100), Vector3(0,-0.05f,0), "static: yes");
mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,3,0), "Mass: 100");
mScene->createBody("sphere.50cm.mesh", new SphereShape(0.5), Vector3(0,6,0), "Mass: 20");
mScene->createBody("capsule.50cmx1m.mesh", new CapsuleShape(0.5,1), Vector3(0,8,0), "Mass: 15");
mScene->createBody("convex1.mesh", new ConvexShape("convex1.mesh"), Vector3(0,10,0), "Mass: 7.5");
mScene->createBody("prism.8x50cmx2m.mesh", new PrismShape(0.5,2,8), Vector3(0,12,0), "Mass: 5");

mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,3,5), "static: yes");

mScene->createBody("nx.convex.mesh", new ConvexShape("nx.convex.mesh"), NxOgre::Pose(Vector3(5,5,5),Quaternion(sqrt(0.5),-sqrt(0.5),0,0)), "Mass: 1000");

for (int i=0;i < 32;i++) {
NxReal h = NxMath::rand(1,4);
mScene->createBody("cube.1m.mesh", new CubeShape(1.0f,h,1.0f), Vector3(0,10.25f + h,i), "Mass: 100, node-scale: 1 " + Ogre::StringConverter::toString(h) + " 1");
}

}
//////////////////////////////////////////////////////////////////////////////////////////////////
void stop() {
// Time to go, better tell NxOgre we are leaving.
delete mWorld;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

void getTutorialSettings() {
mTutorialName = "101";
mTutorialDescription = "Cube on a plane";
}

//////////////////////////////////////////////////////////////////////////////////////////////////

void prestart() {}
void prestop() {}
// void GUIbuttonPressed(BetaGUI::Button *ref) {}

//////////////////////////////////////////////////////////////////////////////////////////////////

};


TUTORIAL_VOIDMAIN

The first part does not work at all, but when I take it out I get
"Error 1 error C2065: 'mWorld' : undeclared identifier h:\game files\nxogre\compiler\main.cpp 27 "

I know this is a very newbie question, but I can't find any working examples on the form.

betajaen

17-06-2007 21:04:46

You should only need to include "NxOgre.h" anything else is just confusing it to it all.

Notice 0.9 class names start with Capitals:-


This is my Tutorial101:

#include "Ogre.h"
#include "NxOgre.h"
#include "Tutorial.h"

using namespace NxOgre;
using namespace Ogre;
using namespace std;

class NxTutorial : public Tutorial {

public:


World* mWorld;
Scene* mScene;
Body* mBody;



void start() {

mWorld = new World();

mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");
mBody = mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,5,0), "mass: 100");

}

//////////////////////////////////////////////////////////////////////////////////////////////////

void stop() {
delete mWorld;
}

//////////////////////////////////////////////////////////////////////////////////////////////////

void onFrame(float deltaTime) {
// ...
}

//////////////////////////////////////////////////////////////////////////////////////////////////

SetupTutorial();
};

RunAs(SandBox)

ncomputerm4

17-06-2007 21:08:40

Error 1 fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "NxOgreStable.h"' to your source? h:\game files\nxogre\compiler\main.cpp 47

:?:

Adding NxPgreStable.h makes tons of errors... :?

Edit,
Whats in tutorial.h? I don't have that file

betajaen

17-06-2007 22:34:07

It's just an example.

Your looking to deep into this, just include "NxOgre.h" by itself. I've noticed your referring to the classes in the lowerCase format. It should be ThisFormat. i.e. World and not world.

ncomputerm4

17-06-2007 22:59:26

Nothing is modified, I added a .cpp to the nxogre project, put the code you gave me in it and it doesn't compile. Any other steps I can take to resolve this? Is there anything in your tutorial.h file? thats the only thing in your code I don't have.

betajaen

17-06-2007 23:20:46

Your adding the .cpp directly into the NxOgre project?

No wonder it won't work. The NxOgre project stands alone, you need to reference it in a seperate C++ project; Like how the Ogre Samples work with Ogre.

If your unsure. Download the earlier tutorials that come with NxOgre 0.4RC3, and copy them into the NxOgre folder. Load up the Tutorials Project and you can use the code I posted (almost) in there.

ncomputerm4

18-06-2007 14:47:43

Ok I feel really stupid about not knowing that :oops:

Ok, so now I have it in the 101.cpp from the tutorials, but it still does not work. So I have a few questions:

First: You have a Tutorial class, without the tutorial.h I don't know what your class looks like, are there any other classes that I would have so I can write a Tutorial class?

Second: Why do I get this error:
"Error 4 error C2065: 'mSceneMgr' : undeclared identifier h:\game files\nxogre\tutorials\nxtutorials\101.cpp 22"

I also tried linking to the old tutorialApplication.h, after fixing as many errors as I could (ended up having to take out the mouse draging), I ended up getting this error:
“Error 1 error C2059: syntax error : 'namespace' h:\game files\nxogre\tutorials\nxtutorials\101.cpp 6â€

betajaen

18-06-2007 15:15:04

Just work with the tutorial code given. (Copy the tutorials folder over), load up 101. Change the class names, and adjust the createBody function.

It's about 10-20 character changes, tops ;)

ncomputerm4

18-06-2007 15:55:47

102.cpp
Error 1 error C2059: syntax error : 'namespace' h:\game files\nxogre\tutorials\nxtutorials\102.cpp 45

Error 7 error C2504: 'SimpleTutorialEihort' : base class undefined h:\game files\nxogre\tutorials\nxtutorials\102.cpp 49


/*

#####################################################################
# #
# NxOgre Tutorial 102 : Sphere and Torque #
# #
# #
# Written by Robin Southern #
# #
#####################################################################

Preamble:

If you don't know the difference between a SceneManager and a Scene-
Node you should start with the Ogre tutorials at the Wiki[1]. As
these tutorials tend to push the Ogre code aside and deal more with
NxOgre.

[1] http://www.ogre3d.org/wiki/


Documentation and Tutorials:

- Betajaen's Guide to NxOgre, Chapter ?
- http://www.NxOgre.org/NxTutorial102
- PhysX Training Programs, Lesson 102


Keys:

- Escape Quit
- F1 Save a screenshot
- F2 Debug Rendering On
- F3 Debug Rendering Off
- I,J,K,L Apply torque to the sphere in the X or Z Axis.
- U,M Apply torque to the sphere in the Y axis.


*/

#include "NxOgre.h"
#include "Ogre.h"
#include "tutorialApplication.h"

using namespace NxOgre;
using namespace Ogre;
using namespace std;

class NxTutorial : public SimpleTutorial {

public:


World* mWorld;
Scene* mScene;
Body* mBody;


//////////////////////////////////////////////////////////////////////////////////////////////////

void start() {

// 1. Start up NxOgre and pass on Ogre Root and the SceneManager as arguments.
mWorld = new World();

// 2. Create our scene, this is where the physics is simulated into.
// We can have more than one scene, but physics objects of one scene
// cannot interact with another scene.
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");

// 5. Create a simple sphere using the sphere shape.

mySphere = mScene->createBody(

"sphere.50cm.mesh", // sphere.50cm.mesh Mesh name to use
new SphereShape(0.5f), // Sphere Shape with a 0.5 metre radius
Vector3(3,1.5,0),
"mass: 100"
);


/*
// 6. Create another cube.
myCube = mScene->createBody(
"myCube", // Name of the body
"cube.1m.mesh", // Mesh to use
new cubeShape(1), // Collision model
1.0f, // Density
pose( // Pose it:-
Vector3(-3,0.5,3), // Put it at -3, 0.5, 3
Quaternion(Radian(Degree(45)),Vector3::UNIT_Y) // Rotate it 45 degrees on the Y axis
)
);


*/
// That's it!
}

//////////////////////////////////////////////////////////////////////////////////////////////////
void stop() {
// Time to go, better tell NxOgre we are leaving.

delete mWorld;
}

//////////////////////////////////////////////////////////////////////////////////////////////////
void newFrame(float _time) {

if (targetBody == 0)
return;
if (isKeyDown(Z)) {
targetBody->addTorque(Ogre::Vector3(0,0,150));
}
if (isKeyDown(NEG_Z)) {
targetBody->addTorque(Ogre::Vector3(0,0,-150));
}
if (isKeyDown(X)) {
targetBody->addTorque(Ogre::Vector3(150,0,0));
}
if (isKeyDown(NEG_X)) {
targetBody->addTorque(Ogre::Vector3(-150,0,0));
}

if (isKeyDown(Y)) {
targetBody->addTorque(Ogre::Vector3(0,150,0));
}

if (isKeyDown(NEG_Y)) {
targetBody->addTorque(Ogre::Vector3(0,-150,0));
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////

void getTutorialSettings() {
mTutorialName = "102";
mTutorialDescription = "Sphere and Torque";
}

//////////////////////////////////////////////////////////////////////////////////////////////////

void prestart() {}
void prestop() {}
void GUIbuttonPressed(BetaGUI::Button *ref) {}

//////////////////////////////////////////////////////////////////////////////////////////////////

};


TUTORIAL_VOIDMAIN



As far as I can tell I switched everything to the new format. :?

ncomputerm4

18-06-2007 16:28:55

You had talked about releasing your demo app (the one where you could right click to make blocks and change sizes), would it be possible to have that so I have something working to look at. Trying to learn by code that does not work is very confusing.

Or is there any other working code I can look at?

asafdav2

14-07-2007 12:14:06

It's just an example.


do you mean that i should still use the regular tutorialApplicationEihort.h? because it appears to be outdated (wrong class names, nxOgre::world::getSingleton(), etc'). if not this one, what tutorial header file should i use?

ncomputerm4

14-07-2007 18:32:10

I think your best off waiting for him to release he's code, there was some kind of big change that makes most of the code in the old header not work.
At least thats what I'm doing :-/

betajaen

14-07-2007 19:52:14

Your post persuaded me to finally release this. :D