How to detect collisions with setWorldGeometry ???

Buckcherry

03-07-2006 11:34:54

Hello everybody,

Is there any way to create the collisions for a map created using setWorldGeometry ??

Hansel

03-07-2006 21:11:28

I have seen in tutorials that setWorldgeometry is used with TerrainSceneManager in order to get collisions with raycasting. You can use rays to detect collisions with ogrenewt using this:

OgreNewt::BasicRaycast ray(world, position_a, position_b);


Then, if for example you want to detect collisions between one objet and terrain (or another object) you can throw a ray from the object to the terrain and calculate the distance between them to know if there is a collision.

I don't kwow it this is what you are looking for :oops:

Buckcherry

03-07-2006 22:22:32

Well, basicly what I want to do is:

1. Create the bodies and attach them to the entities
2. Create the map using setWorldGeometry
3. Set gravity to the bodies
4. Detect collision of those bodies with the terrain. This means: The character (body) keeps over the terrain, it does not go through it because of the gravity

Buckcherry

05-07-2006 09:50:09

Could anyone help me, please?

Hansel

05-07-2006 10:26:12

I have found 3 topics in this forum using "setWorldGeometry".

- This one looks to be the the most useful to you -> http://www.ogre3d.org/phpBB2addons/view ... ldgeometry

- Using PLSM2 with Newton -> http://www.ogre3d.org/wiki/index.php/Us ... ith_Newton

http://www.ogre3d.org/phpBB2addons/view ... ldgeometry


Good luck :wink:

Buckcherry

05-07-2006 20:52:56

Thanks a lot! :D

It seems we have to use the DotSceneManager to be able to detect collisions using OgreNewt if you want to use the setWorldGeometry, doesn't it?.

I have successfully compiled the Plugin_DotSceneManager.dll but now I do not know how to use it... I have followed the tutorial, but it's not very clear to me...

I do the following:

1. Setup correctly the project with include and lib directories
2. Add the line:
#include <DotSceneManager.h>
3. Add this to the OgreSceneManager.h:
enum SceneType
{
ST_GENERIC = 1,
ST_GENERIC = 8,
ST_EXTERIOR_CLOSE = 2,
ST_EXTERIOR_FAR = 4,
ST_EXTERIOR_REAL_FAR = 8,
ST_INTERIOR = 16,
ST_DOTSCENE = 32
};

4. Choose the DotSceneManager using:
mSceneMgr = mRoot->createSceneManager("DotOctreeSceneManager");
5. Load the map using:
mSceneMgr->setWorldGeometry("map.cfg");

It compiles and links succesfully but when I run the program it crashes saying that it was impossible to find the DotOctreeSceneManager...

What is wrong?

How to use PLSM2, DotSceneManager and OgreNewt at the same time?. Is it possible?.

HexiDave

05-07-2006 23:19:20

DotSceneMgr is only to load a scene saved in a 3D modeler or something. PLSM2 could be overkill (it's also hard as hell to optimize for large terrains with physics - trust me on this one.) You need the vertices, indicies and vert count to pass to a TreeCollision object.

Look into the OgreNewt docs for creating TreeCollision objects and also how to get polygon data from the standard Terrain Manager.

What kind of terrain are you looking to use? Big, small, really detailed or low detail?

Buckcherry

06-07-2006 07:44:08

I want a huge map, so I need to divide it.

The problem is that if I create the map using meshes rather than heightmaps I can not divide it, doesn't it?

But, if I want to detect collisions using OgreNewt I need to create the map using meshes.

So, how should I start?.

As well, I would like to know if there is any way to detect collisions using a BSP map...

OvermindDL1

06-07-2006 13:32:26

Can't you just make a collision material for the world, and use the callbacks to see when you hit it?

Buckcherry

07-07-2006 11:27:00

Yes, I can do that, but in that way I can't set gravity, because all the objetcs and characters would fall because of the terrain has not a body with collisions.

It seems the PLSM2 only works with height maps. But there is not a way to create a body for the terrain if this is created using setWorldGeometry.

Any suggestions?. How to set gravity in a height map and detect collisions with the ground?.

OvermindDL1

07-07-2006 14:18:13

You should be able to do both quite easily, perhaps I am misunderstanding what you are attempting. Perhaps some pseudo-code would help?

Buckcherry

07-07-2006 15:46:23

I am going to try to explain what I want to do more clearly:

First of all, I want to detect collisions between objects, so I decided to use OgreNewt.

Having only the characters and objects if I set the gravity, all the objects and characters are falling all the time, so I need to create a ground.

There are basicly 3 types of floor you can use in Ogre:

A) Height Maps (using setWorldGeometry)
B) BSP Maps (Using the BSP Plug-in)
C) Mesh (Creating the ground as a mesh)

To detect collisions you have to create a collision body. In the case of characters, you can approach this as an ellipsoid or another form...

In the case of ground, you can use the TreeMeshCollision.

So, creating a map using meshes is very easy to detect collisions, and in this way, all the characters and objects of my game would stand over the terrain due to the gravity (rather than falling all the time).

But the problem is: what happens when the map is really big?. In this case, a good solution would be to use the PLSM2. The problem is that the PLSM2 only works with height maps, not with maps generated with meshes.

So, if there were a way to create a collision body for a height map, I could use the PLSM2 to divide the map. But I think that is not possible.

So, how to deal collisions with a huge map?.

A simple solution would be setting the gravity to 0 and placing the character over the terrain manually calculating the distance using rays... But in that way you do not have gravity...

Is it a bit clearer now?.

Any idea?

walaber

07-07-2006 19:15:55

in the wiki there is an explanation on how to use OgreNewt with the PLSM2. it uses the low-LOD versions of the meshes (iirc) and serializes them, and loads them in / unloads them as the pages are loaded/unloaded by the scene manager. you should be able to find this information on this forum if you search for it.

OvermindDL1

07-07-2006 22:41:56

You could also just have plsm2 load the entire terrain at start and let OgreNewt load that up.

hoffhoff

11-07-2006 12:51:20

I´m facing the same problem too.
I want to create collision with a terrain using a height map (It won´t be so big). Should I use plsm2 or that isn´t really needful?
And for the collision I need the DotSceneManager plugin?

And if I use BSP, how can I set the collision?
Thanks!

Buckcherry

11-07-2006 13:44:14

Well, if the map is not very big and the FPS is enough for you, you do not need to use PLSM2. After creating the map using setWorldGeometry you have to create the meshes that fits with the height map. This is explain in any place... (I will check...).

According to BSP maps: I am on it, man, I am on it... :wink:

Hope it helps...

hoffhoff

11-07-2006 16:43:52

I c...
should I create a DotSceneOctree or it can be a TerrainScene?
And how do I create a mesh to fit the heghtmap?

Sorry if my questions are stupid, but I´m just a newbie :oops: