Try to "shoot" a box...

ColeZero

02-06-2006 13:54:07

Hi iam try to shoot a box from the camera, like in rocket. But it doesn't seems to work and i get an error, every time i press space to shoot the box, the app crashes.
This is my code:


Keyboard-input from the BaseApplication.

//Shoot the Box
if(mInputDevice->isKeyDown(KC_SPACE) && mTimeUntilNextToggle <=0)
{
Ogre::Vector3 dir, vec;
Ogre::Quaternion orient = mCamera->getWorldOrientation();
vec = Ogre::Vector3(0,0,-1);
dir = orient * vec;

Ogre::String name;
Ogre::Vector3 pos = mCamera->getWorldPosition();

name = "Cube "+Ogre::StringConverter::toString( count++ );
mCube = mScene->createBody(name,"Cube.mesh",new nxOgre::cubeShape(1.0f),1.0f,Vector3(0,10,0));
}



COnstructor from baseApplication:

BaseApplication::BaseApplication(nxOgre::world * world,nxOgre::scene* scene)
: mRoot(0)
{
mWorld = world;
mScene = scene;
}


And this is my Constructor from the GameClass which is from the BaseApplication:

OgreNXApp::OgreNXApp(void): BaseApplication(mWorld,mScene)
{
}


Hoping this will help..^^

betajaen

02-06-2006 14:10:37

Okay, your nearly there.

You forgot to add:


mCube->addForce(dir);

ColeZero

02-06-2006 14:16:17

Yes i got mCube->addForce(dir);
But the problem is, that the app crashes, if press Space, and because NxOgre only works in release mode i cannot debug and find out where the problem is.

ColeZero

02-06-2006 14:25:17

ok i thing it has something todo with:
new nxOgre::cubeShape(1.0f),1.0f,Vector3(0,10,0));
in the line

mCube = mScene->createBody(name,"Cube.mesh",new nxOgre::cubeShape(1.0f),1.0f,Vector3(0,10,0));


Because the debugger says the error has something todo with

if (_shape->mType == shape::SHAPE_CUBE) {
mActorDescription.shapes.push_back(&static_cast<cubeShape*>(_shape)->mShapeDesc);
}

from the nxogre_body.cpp

If i comment out the line:

mCube = mScene->createBody(name,"Cube.mesh",new nxOgre::cubeShape(1.0f),1.0f,Vector3(0,10,0));

The app did'nt crash..

betajaen

02-06-2006 14:28:56

Is count initialised to 0 at the beginning, because it's the name of the body I expect is making it crash.

ColeZero

02-06-2006 14:33:06

yes the counter(int count) is set to 0.
i've checked the name of the cube and it and it is cube1, so the debugger says.

betajaen

02-06-2006 14:35:23

Okay, it is something to do with the name, because the cube and body creation code is very stable.

ColeZero

02-06-2006 14:37:52

This is the debugger output:

  1. + _meshName "Cube.mesh" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
    + _name "Cube 0" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
    [/list:u]
    May be this is interesting:

    + _scene 0x00000000 {mPhysicsSDK=??? mScene=??? mSceneMgr=??? ...} nxOgre::scene *

    Or this:
    _shape->mType 0 int

ColeZero

02-06-2006 14:45:38

I've tried to use an Hard-Coded name:

mCube = mScene->createBody("Box1","Cube.mesh",new nxOgre::cubeShape(1.0f),1.0f,Vector3(0,10,0));

Same error, when i press space


Maybe mScene is empty, so its NULL

ColeZero

02-06-2006 16:36:19

ha jeah, i've fixed it, now it works..i can trow balls now...^^
The Problem was the mScene...so i've recoded the most things, added a method called setPhysics() where i set the scene and the world. and now it works. i thing the error appers because mScene was NULL..how foolish iam ashamed. :D

betajaen

02-06-2006 17:27:23

Ouch. I knew it wasn't the NxOgre code, so it was the name. I was thinking that count wasn't initialised, never occured to me that mScene was null.

Anyway, happy NxOgre programming!

p.s. Be sure to checkout the NxTutorials if you haven't done so already.

ColeZero

02-06-2006 17:32:45

If anyone is interessted: i've created a demo, you can shoot balls into a Pyramid, or a wall. If you want a wall instead of a Pyramid, just take a look into the code and change it.
You can do what ever youo want with the sample..^^
To shoot some balls press Space

Screen:



Sample Src VC8.0

betajaen

02-06-2006 18:21:19

Excellent! I also notice that the FPS is almost 700, which is insane!

p.s. Although I haven't played the demo (can't), how about using a trigger in the centre of the world say 50metres in size, so when those spheres leave the trigger - they disappear, instead of rolling on forever.

ColeZero

02-06-2006 20:24:37

Yeah thats a good idea, but are triggers possible in nxOgre?
If so i try it...Is there an API-Documentation for nxOgre?

So i made some changes to my demo, i'm going to create a simple "rocket" demo, made in Ogre. but my dream were to create something comparably with CellFactor, that would be kewl, i mean a game were you can pick up some crates or boxes and throw them on your opponent.. :lol:

But first the triggers- :wink:

betajaen

02-06-2006 23:00:26

NxOgre and Triggers, are like Fish and water.

Check out NxTutorial 110 - You'll cry because how easy it is. :D

As for your CellFactor clone; go for as it it's been done before in NxOgre

danharibo

02-06-2006 23:33:06

can i get a demo?

betajaen

03-06-2006 09:45:16

Dan he just gave out the source on the previous page.

ColeZero

03-06-2006 10:56:21

This is just a small example, the important thing is to look into the code and see how easy it is, if you wan't to compile it you need to check the include- and library pathes...^^


can i get a demo?


What do you mean, do you mean my sample or do you mean CellFactor?
If so, there is a Demo of Cellfactor, but you need to use a PhysX-Card.
I've heard of people who run the demo without a card using a command(usePhysX = 0, or something), but they told that there FPS goes down to 5 or 4fps...

danharibo

03-06-2006 13:43:37

ok, i mised the link :roll: but that host is wierd i cant even download it

ColeZero

03-06-2006 14:40:43

Sorry bbut i don't have a presonal host to load up files...;)
But i don't have any problems downloading this file, you have to scroll to the end of the page, there is the link..

danharibo

03-06-2006 14:53:39

can you e-mail it to me?
dan_haribo@hotmail.co.uk

ColeZero

03-06-2006 15:16:41

no poblem. i've sent it to your email-adress..