NewtonHeightFieldCollisionCallback

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Sat Dec 18, 2010 3:28 pm

Ok it is done, you can get SDK 2.27
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Chooka » Sat Dec 18, 2010 9:27 pm

thankyou julio. i will download it tonight and give it a try.

Edit: works perfectly :)
Chooka
 
Posts: 10
Joined: Fri Dec 10, 2010 8:48 pm

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Sat Jan 08, 2011 8:31 am

Hi julio,

I come from the ogre-forum and I'm testing the heightfieldraycast.
I added everything necessary to OgreNewt.
After long testing it is for me obvious, that the heighfieldraycast is faulty!! When I add my Debuglabels to show the player height from the terrain, then It works, when I remove them, It doesnt work. When I rename the function that calulates the ray and remove the debuglabels --> It works. When I'm directed in the Ogre::Vector3::NEGATIVE_UNIT_Z direction (north) then it doesn't work. When vsync is enabled It doesn't work. This is sooo frustrating. I first thought, that I made an error somehow. But now I see that It is purely arbitrary!

Or have I done something wrong in OgreNewt. I did the same thing that was done with the Treecollisionraycast with the Heightfieldraycast.

But raycast on all other collisiontypes works!

I'm testing this for weeks

Please can you check in newton physics that there is no error.
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Sat Jan 08, 2011 10:32 am

It should alway hit one treein cell as long as one ray cross that tile.
do you have a test? that I can chek out?

Is OgreNewt uptodate?
Terrian Raycast is a feature of 2.29, can you request that It is updated, the last newton SDK added that functionality and now the current OgreNewt does not deal with it.
plus I also added new changes for OgreNewt to handle asycronous updates, I submited a Patch but no one took it seriuslly.

once OgreNewt is upto date then I can check any test you migh have. It should be eassy to see what is wrong.
right now it does not even deal with terrain ray cast callback
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Sun Jan 09, 2011 11:55 am

Ok I see now that the new newton version is 2.29 I try to test everything with this version.
I see that: NewtonCreateBody(...) needs a matrix. I read that this is for forwardcompatibility for version 3. I let the matrix NULL and when I start my project, then It crashes by creating bodies. I don't know with what values to fill the matrix.

Besides have you something changed with the heighfieldraycast during the version 2.27?
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Sun Jan 09, 2011 11:59 am

you can not just pass a NULL pointer as a matrix, that will lead to a sure crash. Pass an identity matrix if you do not have the final matrix.

Nothing has changed in the ray cast function. only the interface of the call back were separated. one for collision tree, and one for hightfield to pass the apropriate parameters
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Sun Jan 09, 2011 6:11 pm

Ok crash solved thanks! Now I have It compiled with Newton2.29. But the heightfieldraycast does only work in strange circumstances like I wrote 2 posts before. When I undocument my labels which shows the height from the player and the terrain, object etc. then the raycast for the terrain doesn't work, but for all other collisiontypes. When I document the labels then It works. This is soo strange. It must say it works randomly.
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Sun Jan 09, 2011 7:35 pm

It is not random, you must have a bug somewhere.

do you have a test that I can check?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Mon Jan 10, 2011 12:55 pm

here: http://www.megaupload.com/?d=T7M6CBNT I've uploaded a test.
Go to the folder release and delete the file ogre.cfg, then start the OgreBaseArchitecture.exe. I've an error should appear, It could be that you need to install OpenAL.
You can move the player with the wasd keys and jump with space. You see in the right-bottom corner debuglabels which shows the raydistance from the player and an object. The error is, that the height is zero, because there is no rayhit with the terrain and therefore if you hold the jump button to long you get catapultated in the air, but If you jump on a box or other object, then everything works.
Here is the function which calculates the ray:

Code: Select all
void Character::checkObjectsBelow(void)
{
   Ogre::Vector3 charPoint = Ogre::Vector3(this->getPosition().x, this->getPosition().y + 0.4f, this->getPosition().z);
   OgreNewt::BasicRaycast ray(this->pOgreNewt, charPoint, charPoint + Ogre::Vector3::NEGATIVE_UNIT_Y * 500.0f, true);
   OgreNewt::BasicRaycast::BasicRaycastInfo contact = ray.getFirstHit();
   //AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("no contact:");
   if (contact.getBody())
   {
      //AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("contact with: " + contact.getBody()->getOgreNode()->getName());
      this->height = contact.mDistance  * 500.0f;
      if (contact.mBody->getType() == AdvancedOgreFramework::getSingletonPtr()->TERRAINTYPE)
      {
         
         Ogre::Vector3 vec = Ogre::Vector3::UNIT_Y;
         Ogre::Vector3 normal = contact.mNormal;
         
         this->rise = Ogre::Math::ACos(vec.dotProduct(normal) / (vec.length() * normal.length())).valueDegrees();
         //AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("rise: " + Ogre::StringConverter::toString(rise));
      }
   }
}

Now the strange thing: The pDebugLabel3's are undocumentated and because of that, there is no hit with the terrain! When I document them, the heightfieldraycast works in special circumstances like I posted before.
This function is called in a gameloop
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Mon Jan 10, 2011 1:00 pm

Ok I will teat it tonight and see what is the problem.

was OgreNewt updated to the latest newton 2.29? can I update from SVN?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Mon Jan 10, 2011 2:37 pm

Ok thanks for the time!
Ogrenewt was compiled with the newest newton version. But It is not in the svn because I'm not the maintainer of OgreNewt. But I will arrange that, when everything works.
here: http://www.megaupload.com/?d=EYMBK301 my uploaded version. I compiled It with vsstudio10.
Besides here the topic in the ogre forum: http://www.ogre3d.org/addonforums/viewtopic.php?f=4&t=13768
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Thu Jan 13, 2011 1:34 pm

I had not tested this yet, because I am bussy at work this week.
I will do this saturday, I am sure it has to be a very simple problem, but I had not had the time to check it out.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Fri Jan 14, 2011 9:25 am

Ok no problem.
I've got a question concerning: NewtonDestroy(...)
when I create a Material like:
this->pMaterial = new OgreNewt::MaterialID(this->pOgreNewt);

does newton destroy the materials too?
I read that It destroys bodies, joints, ...
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: NewtonHeightFieldCollisionCallback

Postby Julio Jerez » Sun Jan 23, 2011 10:39 am

Lax wrote:here: http://www.megaupload.com/?d=T7M6CBNT I've uploaded a test.
Go to the folder release and delete the file ogre.cfg, then start the OgreBaseArchitecture.exe. I've an error should appear, It could be that you need to install OpenAL.
You can move the player with the wasd keys and jump with space. You see in the right-bottom corner debuglabels which shows the raydistance from the player and an object. The error is, that the height is zero, because there is no rayhit with the terrain and therefore if you hold the jump button to long you get catapultated in the air, but If you jump on a box or other object, then everything works.
Here is the function which calculates the ray:


Ok I downloaded this demo, dlete Ogre.cfg, and I am playing it.
I am moving around wi the wasd key and I hold the space key to jump.
I in lower right corner I never see the high becoming zero, it is about 0.3860 in a flat tarrain and goes hiher when I climb hills.

It is some special I have to do to reproduce the bug?

Note:
I can only run the demo, because you are using a version of Netwon older that 2.29 (which has the new CreateBody which take a matrix as argument)
If copy newton 2.29 the game crashes therfore I can no debug teh demog to see if teh Ray Cast ever fail on teh hieghtfield objects.

In Fact Newton 2.29 now comes with two version of the dll and libraries, newton.dll and newton_d.dll
you can link the debug version of you program to the newton_d.dll an dteh relase to Newton,ll and see where teh game crash yourself.
or at least if OgretNewt is updated to 2.29, debugging will be easier for everyone.


if you link teh Game to 2.29 you can use
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonHeightFieldCollisionCallback

Postby Lax » Mon Jan 24, 2011 1:45 pm

Oh, I did net realize, that there is a newton debug file^^. I will test everything from the beginning, thanks.
In the meantime, since your last post. I tried the following. I moved the raycast function to a thread. Now the suprise was big, as I saw, that the raycast worked.
What do you think, is this an optionen to let a seperate thread do the raycast?
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 383 guests