[BloodyMess]Simple collison dectection with terrain

westpointer

29-04-2009 10:27:02

I am a newcomer to NxOgre, and I just setup NxOgre using BloodyMess 1.5.3 and PhysX SDK 2.8.1.
Here is what I want to do using NxOgre:
I have a terrain mesh and a tank mesh, I simply what to make the tank move on the terrain,
I have read the BloodyMess tutorials but I have no idea how to do this?

betajaen

29-04-2009 10:43:15

In the next release you should be able to use spheres to act as wheels and joints to act as motors to your tank, the release after that will have proper wheels to drive your tank with.

For now, I would just experiment with forces to move the tank; for example;

tank->addForce(0,0,10); // move forward
tank->addTorque(0, 3, 0); // turn


And so on.

westpointer

29-04-2009 11:28:06

Thanks for your rely, but I don't know how to setup the terrain mesh and tank mess for NxOgre.
Is it like this:

OGRE3DBody* tank = mRenderSystem->createBody(new NxOgre_Namespace::Box(1, 1, 1), NxOgre_Namespace::Real3(0, 40, 0), "tank.mesh");
OGRE3DBody* terrain = mRenderSystem->createBody(new NxOgre_Namespace::Box(1, 1, 1), NxOgre_Namespace::Real3(20, 45, 0), "terrain.mesh");

The shape of tank should be a "Box" with the size of tank's boundingbox, right? But I am not sure about the shape of terrain I should use.

betajaen

29-04-2009 11:36:06

Use a TriangleGeometry inside a StaticGeometry (mScene->createStaticGeometry) to create your terrain, for your tank just make the box bigger.

westpointer

29-04-2009 13:10:30

TriangleGeometry requires NxOgre mesh, I don't know how to convert my Ogre mesh to NxOgre mesh.
Sorry for my silly question :oops:

betajaen

29-04-2009 13:29:07

Check out flour.

westpointer

29-04-2009 14:07:56

When I complie the floor source, but get the following error:

1>d:\program files\flour-src\include\flourparams.h(7) : error C2039: 'Params': is not a member of 'NxOgre'
...
1>d:\program files\flour-src\source\flour.cpp(27) : error C2039: 'process': is not a member of 'FlourParams'
....


Does floor not work with 1.5.3?

betajaen

29-04-2009 14:31:23

You don't compile flour, You install it.

westpointer

30-04-2009 02:48:51

Thanks betajaen, with your help, I finally make it works. But I still have some questions to ask:

1. The FPS difference betweem using PlaneGeometry and TriangleGeometry is quite big, when using PlaneGeometry, FPS is about 500
while TriangleGeometry is about 50.
http://img207.imageshack.us/img207/9117/screenshot1p.jpg
http://img527.imageshack.us/img527/4961/screenshot2etw.jpg

2. My tank seems hard to move on TriangleGeometry, I guess is it becaues the tank is just a box with no wheels?
In the next release you should be able to use spheres to act as wheels and joints to act as motors to your tank, the release after that will have proper wheels to drive your tank with.
I don't know when the next version will be released, and I am in a hurry to implement driving tank. so I think have back to use 1.0 if I want to use full featured NxOgre.
(I want to use 0.9, but get lots of error compiling with PhysX 2.8.1)

3. How to hide VisualDebugger? I tried this, but doesn't work:

bool frameStarted(const FrameEvent& evt)
{
mTimeController->advance(evt.timeSinceLastFrame);

if (mShowVisualDebugger)
{
mVisualDebugger->draw();
mVisualDebuggerNode->needUpdate();
}
return ExampleFrameListener::frameStarted(evt);
}
...
if(mKeyboard->isKeyDown(OIS::KC_P) && mTimeUntilNextToggle <= 0)
{
mShowVisualDebugger = !mShowVisualDebugger;
if (mShowVisualDebugger)
mVisualDebugger->setVisualisationMode(NxOgre_Namespace::Enums::VisualDebugger_ShowAll);
else
mVisualDebugger->setVisualisationMode(NxOgre_Namespace::Enums::VisualDebugger_ShowNone);

mTimeUntilNextToggle = 1;
}

When I press "P" key, but the VisualDebugger is not hidden, only just doesn't update with the change of tank

kaneyxt

30-04-2009 04:12:18

How about using Vehicle Controller or Character Controller for your tank? I know PhysX engine has these two features, but I am not sure if NxOgre has already supported them. If not, maybe you can combine PhysX and NxOgre together:
(1) create Vehicle Controller in pure PhysX scene and use Keyboad to control its movement;
(2) create tank model in Ogre and render it.
(3) set the postion and rotation of Vehicle Controller to your tank model every frame.

Or can you help betajaen to implement Vehicle Controller in NxOgre? :D

betajaen

30-04-2009 09:49:52

Character Controller is a bad idea; It doesn't support things like acceleration (so you would have to work it in), and has no concept of direction. The reason why it's going so slow with your triangle mesh, is because of the triangle mesh being rendered in the visual debugger, so just remove the code related to the Visual Debugger.

It's up to you to go back to 1.0.22Tx, but in the next few releases of BloodyMess, I will no longer be supporting it anymore.

westpointer

30-04-2009 11:22:47

When I am about to use 1.0.22 Tx, I read from a post of the forum saying that "The BleedingVersions (1.x) were only a filler between the old stable one (0.9) and the new (1.5.x)",
so I decide not to use 1.0.22 Tx, instead, I use the "most stable and the one with the most features" version--0.9, and compile it successfully against PhysX 2.7.3. :)
Unfortunately, I can't find tuturials about 0.9, any guy knows where to get the resources?

betajaen

30-04-2009 11:48:24

1.0.22T5 is vastly superior and stabler than 0.9

westpointer

30-04-2009 15:59:51

1.0.22T5 is vastly superior and stabler than 0.9
But in this thread: viewtopic.php?f=6&t=9354&3
The FAQ says that you should use 1.0, but afaik it has less features than 0.9 as it was never finished and dropped in favour of the complete rewrite (1.5.x).


Anyway I have successfully setup NxOgre using NxOgre.1.0.22T5 + cake.4.0T1 + PhysX SDK 2.8.1 + Ogre 1.6.2 :D
Unfortunately, there is still a small problem with cake, cake runs ok, but when I quit the program an error comes,
and Ogre.log says "OverlayElement with name BetaGUI2.MousePointer not found"!
I think it is caused by BetaGUI, right?
In ogreoverlay.cpp

Overlay::~Overlay()
{
// remove children

OGRE_DELETE mRootNode;

for (OverlayContainerList::iterator i = m2DElements.begin();
i != m2DElements.end(); ++i)
{
(*i)->_notifyParent(0, 0); // ******access violation happens here when press ESC********
}

betajaen

30-04-2009 16:22:59

Spacegaier must of been confused in that thread.

No idea how to fix that error but you know you don't have to use Cake with NxOgre. You can write your own application from scratch or based upon the Ogre tutorials, it isn't hard.

kaneyxt

04-05-2009 07:21:04

There is a sample called "SampleRaycastCar" in PhysX SDK, maybe you can take a look at that. It seems similar to what you want to implement. :)

westpointer

05-05-2009 09:24:15

There is a sample called "SampleRaycastCar" in PhysX SDK, maybe you can take a look at that. It seems similar to what you want to implement. :)
Thanks for your suggestion, I'll look into it.

westpointer

07-05-2009 11:15:10

Previously, I use Box as the shape of my tank, I am trying to use convex as the shape of it hoping that it will make my tank move/slide smoothly on
my terrain mesh. First I convert Tank.mesh to convex type Tank.nxs, then I do it like this:

NxOgre_Namespace::ResourceSystem::getSingleton()->openArchive("media","file:E:/Ogre Projects/BloodyMess_Tutorials/media");
NxOgre_Namespace::Mesh* tankMesh = NxOgre_Namespace::MeshManager::getSingleton()->load("media:Tank.nxs");
mTank = mRenderSystem->createBody(new NxOgre_Namespace::Convex(tankMesh), NxOgre_Namespace::Real3(0, 50, 0), "Tank.mesh");

When I run it, access violation happens at line createBody and in nxogrememory.cpp. Why?

PS: Still using bloodymess 1.5.3

westpointer

11-05-2009 04:04:28

Previously, I use Box as the shape of my tank, I am trying to use convex as the shape of it hoping that it will make my tank move/slide smoothly on
my terrain mesh. First I convert Tank.mesh to convex type Tank.nxs, then I do it like this:

NxOgre_Namespace::ResourceSystem::getSingleton()->openArchive("media","file:E:/Ogre Projects/BloodyMess_Tutorials/media");
NxOgre_Namespace::Mesh* tankMesh = NxOgre_Namespace::MeshManager::getSingleton()->load("media:Tank.nxs");
mTank = mRenderSystem->createBody(new NxOgre_Namespace::Convex(tankMesh), NxOgre_Namespace::Real3(0, 50, 0), "Tank.mesh");

When I run it, access violation happens at line createBody and in nxogrememory.cpp. Why?

PS: Still using bloodymess 1.5.3


After using the latest version 1.5.4, the code above runs OK now.
And the problem in Bloodymess tutorial 4 talked about in this threadhttp://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=9905 is solved.
GOOD WORK betajaen :)

kaneyxt

20-05-2009 10:44:10


After using the latest version 1.5.4, the code above runs OK now.
And the problem in Bloodymess tutorial 4 talked about in this threadhttp://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=9905 is solved.
GOOD WORK betajaen :)


I also try to create convex but still fails with 1.5.4. It crashes at line 52 of ogre3dbody.cpp:
create(prototype, rendersystem->getScene());
According to the call stack, it crashes inside the PhysXCore.dll. Do I miss something? Such as the cooking initialization? Do I have to initialize the PhysX cooking manually if I want to use convex/triangle mesh?

I use flour to convert cube.1m.mesh to a convex mesh then load it to NxOgre. The code is as follows:

NxOgre_Namespace::ResourceSystem::getSingleton()->openArchive("media","file:E:\SourceSafe\BloodyCake\application\Media");
NxOgre_Namespace::Mesh* testMesh = NxOgre_Namespace::MeshManager::getSingleton()->load("media:cube.convex.nxs");
OGRE3DBody* mTank = mRenderSystem->createBody(new NxOgre_Namespace::Convex(testMesh), NxOgre_Namespace::Real3(0, 50, 0), "cube.1m.mesh");


Any help or suggestion is really appreciated!

betajaen

20-05-2009 11:05:38

NxOgre automatically initialises PhysX for cooking for you.

But If PhysX crashes, NxOgre tries to capture the error and dump it into the windows console, if you run in Console mode, you should see a copy of the error message when it crashes.

kaneyxt

20-05-2009 12:35:47

I've found out reason, the media folder should be written like:
"file:E:\\SourceSafe\\BloodyCake\\application\\Media"
Or the file cannot be found... Really a silly error... :?

spacegaier

20-05-2009 12:54:20

Either this:
"file:E:\\SourceSafe\\BloodyCake\\application\\Media"
or this"file:E:/SourceSafe/BloodyCake/application/Media"

Keyword: Character Escaping.