IrrToNewton

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mrsquare
Posts: 2
Joined: Wed Feb 08, 2006 12:15 am

IrrToNewton

Post by mrsquare »

Hi all - new member here, got a couple of questions for you clever people :)

I'm trying to integrate Newton physics together with a terrain heightmap. Its nothing too fancy - at the moment I'm just ripping out the terrain from the terrain tutorial and adding the physics from the Newton tutorial to a model.

The gravity works fine on the model, but it doesn't collide with the terrain at all - just falls into nothingness. Reading through lots of threads about this topic on here has given me some pointers, and it looks like the collision map isn't being built correctly. At the moment my code looks like:

Code: Select all

pxMesh = mpxLevel_TerrainNode->getMesh();

// Now create a collision tree using all the triangles in our mesh
mpxLevel_NewtonCollisionMap = NewtonCreateTreeCollision( mpxLevel_NewtonWorld, NULL );

NewtonTreeCollisionBeginBuild( mpxLevel_NewtonCollisionMap );

nMeshBufferCount = pxMesh->getMeshBufferCount();

for( nLoop = 0; nLoop < nMeshBufferCount; nLoop++)
{	
//etc etc
The problem seems to be that nMeshBufferCount always comes out as zero, so nothing is ever actually added to the collision map by the loop :? One thread (http://irrlicht.sourceforge.net/phpBB2/ ... rrtonewton) I found mentioned something about using getMeshBufferForLOD instead - if correct I don't really get how that would work - do you then use the resulting SMeshBufferLightMap in place of the terrain mesh buffer?


Also... in loads of Newton threads I keep seeing references to some mysterious variable called 'IrrToNewton'. This doesn't seem to be defined anywhere that I can see - what is its value and where (if anywhere) can it be found? Am I missing some important #include file?
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

I can't tell you why it isn't working, I've never got Newton integrated into any of my apps.

But, the irrtonewton is: a convertor.

Code: Select all

// use scale factor between Newton and IRR
const float NewtonToIrr = 32.0f;
const float IrrToNewton = (1.0f / NewtonToIrr);
Hope that helps a bit at least.

Edit to add: It's found in the global.h files in the demos.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

The problem seems to be that nMeshBufferCount always comes out as zero, so nothing is ever actually added to the collision map by the loop
That's strange, there should be at least 1 mesh in there. The terrain is loading properly (apart from collision)? Yeah, you could also use getMeshBufferForLOD, you are correct in that you use that in place of the mesh buffer (actually, an SMeshBufferLightMap is very similar to a mesh buffer).
Also... in loads of Newton threads I keep seeing references to some mysterious variable called 'IrrToNewton'. This doesn't seem to be defined anywhere that I can see - what is its value and where (if anywhere) can it be found?
It's a scaling constant that some people apply. I don't understand why, some people think it gets better results w/ Newton. You are not required to use it, in my opinion if my units in my graphics and physics engines were of different sizes for the same object, I'd probably go insane.
Guest

Post by Guest »

mrsquare how do you get the gravity thing working for the terrain.......

can u pls show the code to me

thxs alot for helping me :wink:
Post Reply