Hi,
I made really BIG steps forward in Newton wrapper world.
I made a little demo where over 2000 little cubes are fired versus a wall and all works fine with great physics!
But I saw that my little cubes, after hitting the wall (thx to the gravity force), instead of falling on the ground and stop the movement ,they pierce and surpass the terrain (ground) object.
So finally I decided to make my terrain object as infinite mass object with collision tree too; as if it were a real terrain then I should see my cubes stop their fall when they hitting the terrain object.
Then I add the \"NDB_NewtonCreateTreeCollision\" command to have my terrain object with infinite mass (so unaffected from the force of the little cubes when these little cubes hitting the ground) and a collision system that know that the little cubes are exactly hitting the ground.
Now the DAMN WEIRD problem..:
When I use the \"NDB_NewtonCreateTreeCollision\", ALWAYS!, I get a windows application (APP CRASH) error as you can look at the posted image.
Ok at this point I trying ALL, 1 million of code changes but nothing.. ther error always appear if I using \"NDB_NewtonCreateTreeCollision\"..
So I reduced to maximum my code until I obtain the following really little code:
`this first command initializes the Newton world, and must be called before
`any other Newton commands. to remove newton, use the NDB_NewtonDestroy command.
NDB_NewtonCreate
` Setting physics precision and gravity force
NDB_NewtonSetSolverModel 0
NDB_SetVector 0,-98.0,0
NDB_SetStandardGravity
rem *********************************************************************
rem ***************** MAKING THE PHYSIC WORLD ***************************
rem *********************************************************************
rem Terrain object
make object box 100, 300.0,0.5,300.0
REM FIRST OF THESE 3 FOLLOWING LINES IS THE ONE CAUSING THE CRASH! (collision_terrain =..)
collision_terrain = NDB_NewtonCreateTreeCollision(100,1)
rigid_body_terrain = NDB_NewtonCreateBody(collision_terrain)
NDB_BodySetDBProData rigid_body_terrain, 100
remstart
NDB_NewtonBodySetDestructorCallback rigid_body_terrain
NDB_NewtonReleaseCollision collision_terrain
remend
`We need to set the World limits, this is very important to do otherwise there
`could be some unpredictable results
NDB_SetVector 1, -500.0, -500.0, -500.0
NDB_SetVector 2, 1500.0, 500.0, 1500.0
NDB_NewtonSetWorldSize
rem Newton refresh
NDB_NewtonUpdate 0.1
rem positioning camera
position camera 0,3,0
`okay, that\'s all of the setup we need, let\'s make our main loop!
rem ********************************************************************************
rem ********************************************************************************
rem ******************************** MAIN LOOP *************************************
rem ********************************************************************************
rem ********************************************************************************
do
rem mouse view
if mouseclick()=1 then cf#=1
if mouseclick()=2 then cf#=-1
cx#=wrapvalue(cx#+mousemovey()*0.5)
cy#=wrapvalue(cy#+mousemovex()*0.5)
if cx#<=290 and cx#>180 then cx#=290
if cx#>=70 and cx#<=180 then cx#=70
acx#=curveangle(cx#,acx#,2.1)
acy#=curveangle(cy#,acy#,2.1)
rotate camera acx#,acy#,0
acf#=curvevalue(cf#,acf#,20)
move camera acf#
cf#=0
`gets the amount ot time elapsed since the last call to this function, in seconds.
time# = NDB_GetElapsedTimeInSec()
`then the big command that updates the physics world. you tell it how much
`time has passed, and it updates that much.
NDB_NewtonUpdate time#
loop
Result? Same damn ERROR!!
I trying to read from help files some info about the way to use \"NDB_NewtonCreateTreeCollision\" command so I find that I should to use the \"NDB_NewtonTreeCollisionBeginBuild\" and \"NDB_NewtonTreeCollisionEndBuild\" commands before and after I made my terrain...
So I try to make that code modification as the following:
rem *********************************************************************
rem ***************** MAKING THE PHYSIC WORLD ***************************
rem *********************************************************************
rem Terrain object
make object box 100, 300.0,0.5,300.0
NDB_NewtonTreeCollisionBeginBuild collision_terrain
collision_terrain = NDB_NewtonCreateTreeCollision(100,0)
rigid_body_terrain = NDB_NewtonCreateBody(collision_terrain)
NDB_BodySetDBProData rigid_body_terrain, 100
NDB_NewtonBodySetDestructorCallback rigid_body_terrain
NDB_NewtonReleaseCollision collision_terrain
NDB_NewtonTreeCollisionEndBuild collision_terrain,1
But nothing.. I read from \"NDB_NewtonTreeCollisionBeginBuild\" command info the following :
Quote: "
Comments: This command tells Newton you are about to add faces (polygon data) to an empty Tree Collision object. To use this manual method you must have created an empty TreeCollision object by calling NDB_NewtonCreateTreeCollision with no parameters.
"
Where I have to put this "NDB_NewtonCreateTreeCollision with no parameters" ???.... I think I don't understand this info...
And sincerely, after other many attempts, I got nothing.. same my program crash a bit after I run it (before my terrain is showed)
Please... HELP!!!