Almost there with Irrlicht/Newton terrain

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Nick_Japan
Posts: 98
Joined: Mon Dec 13, 2004 11:47 am
Location: Japan

Almost there with Irrlicht/Newton terrain

Post by Nick_Japan »

Heya all,

I've nearly cracked getting a heightmap terrain into a Newton body. In my code I'm definitely getting a physics hull of some kind, but it doesn't match up with the graphical equivalent. Now, a bit of poking around has lead me to believe that the call to getMeshBufferForLOD() doesn't return a correctly scaled mesh buffer, in fact whatever terrain scale values I throw at the addTerrainSceneNode() call, I still seem to get the same values in my SMeshBufferLightMap. Now, this isn't necessarily a problem, as I can just multiply the vertices by the scale values, but a combination of that and also any IrrToNewton scale values hasn't even got me close. Have I got the right end of the stick regarding what vertices I'm getting out of getMeshBufferForLOD()? How have other people done it? I'm thinking maybe Spintz or pfo might know something about this... onegai shimasu!
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

NO problem is probably the position of the newto mesh. Just for exampel i tried the vertice part of the newton exampel (in the irrlicht tutorial section) and it was way of the real orientation and position. So i tried to play with it a little bit and got it to work by setting an offset matrix to the newton body. i used the center of the bounding box of the irrlicht body and applyed it as offset to the newton body...
But all this only applies when u use collision primitives and u are probably using collision trees to discribe the terrain but that works perfectly......at least in my case. so some more information about the problem would be good
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
zenoid
Posts: 40
Joined: Wed Jul 20, 2005 1:16 pm
Location: france
Contact:

Post by zenoid »

Are you using irr 0.14, if so you certainly encountered the pb I'am facing actualy, just find my recent post on the subject.
It works perfectly using irr 0.12 and early versions (my heighmap is sized 400 times) and I run vehicle upon.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Nick: you're right, the scale of the node is not returned with getMeshBufferForLOD() or getMesh(). You do need to get the scale from the node and apply it to all positions. I say this everytime: do not use IrrToNewton, that is not the correct way to apply scale in Newton. The only scale you should use is the scale of the terrain node, it should match up 100% all the time after that.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I should add a getTransformedMeshBufferForLOD function...
Image
ProSoft
Posts: 59
Joined: Thu Sep 08, 2005 10:55 am
Location: Brasil

Post by ProSoft »

pfo: I really dont know if Newton will work well without IrrToNewton scale...
for myself, i have made a lot of tryouts to make a working vehicle, and only got it to work with this scale... If i understood well, its planned to be added on Newton API, and is described in NewtonGetGlobalScale section, on Newton docs. I guess it dependent on scale of your models/world. Ill look on forum for other comments about this.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

pfo: I really dont know if Newton will work well without IrrToNewton scale
I think it works great... Last I checked more projects using Newton were not using some arbitrary scaling constant on all objects, and many of them look pretty good.
I guess it dependent on scale of your models/world
It is, Newton likes working with meters / kilograms / seconds. Getting objects sizes and masses to more closely resembly objects we would observe in real life will get better results.
ProSoft
Posts: 59
Joined: Thu Sep 08, 2005 10:55 am
Location: Brasil

Post by ProSoft »

Newton likes working with meters / kilograms / seconds. Getting objects sizes and masses to more closely resembly objects we would observe in real life will get better results.
Yes, then we can say if your objects are larger or smaller in relation to real world, i believe you can use this scale factor to keep precision on results. I guess scalling isnt necessary if your models are sized correctly. Its specially true to vehicles. In my tests, i get weird results with my car before using scale factor ( IrrToNewton ). If i change this to 1.0f ( no scale at all ) my vehicle gets crazy, transform to a gynast, take a jump in the air and lands upside down :lol: .
Nick_Japan
Posts: 98
Joined: Mon Dec 13, 2004 11:47 am
Location: Japan

Post by Nick_Japan »

This is slightly off-topic but wasn't quite worth a whole new thread:

I've found a couple of things that may help people who are using Newton and Irrlicht in Visual Studio 2005 EE. I mentioned a while ago, just before 0.14 was released, that I was having some sort of weird crash when creating a collision tree using getMeshBufferForLOD(). If you bring up the project settings (project right click -> properties) and go into Configuration Properties > C/C++ > Code Generation, and set the runtime library to Multi-Threaded /MT, you get rid of that crash and also another nasty one where my program would crash on exit.

In the same menu, I've also had to set Enable C++ exceptions and Buffer Security Check to No, and also Basic Runtime Checks to default just to get it to compile and not complain about RTC calls. Does any of that sound scarily hacky to anyone or is part of programming these days just working out what to turn off?
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

You'll probably find that those crashes are in relation to memory management. More precisely, where the memory is freed (in the Newton or Irrlicht DLL's or the application EXE).

This is a big gotcha when you are creating things in you own application... that are usually created in the DLL.

--EK
Post Reply