Making Kinematic Bodies

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Making Kinematic Bodies

Postby Bird » Wed Apr 24, 2013 5:03 pm

Hi Julio,

I'm using NewtonCreateKinematicBody() to create a NewtonBody in my scene but Dynamic bodies pass right through it during the simulation. Is there something else that needs to be done to make Dynamics bodies interact with Kinematics?

I'm using the latest SVN version of Newton.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Making Kinematic Bodies

Postby Julio Jerez » Fri Apr 26, 2013 1:46 pm

Bird kenematic bodies do not collide, the can make to generate contacts, bu tsheo conat are no send to the solver for collision reaction

If you look at eth trigger controller manage
this fintion here
Code: Select all
void CustomTriggerController::Init (NewtonCollision* const convexShape, const dMatrix& matrix, void* const userData)
{
   NewtonWorld* const world = GetManager()->GetWorld();

   // create a trigger body and place in the scene
   NewtonBody* const body = NewtonCreateKinematicBody(world, convexShape, &matrix[0][0]);
   SetBody (body);
   
   // set this shape do not collide with other bodies
   NewtonCollision* const collision = NewtonBodyGetCollision (body);
   NewtonCollisionSetCollisonMode(collision, 0);
}


I set the collision shape to not generate contact. if yo uwna all contact to be generated the yo umust overide the
NewtonCollisionSetCollisonMode(collision, 1);
but they will still not collide with dynamics bodies, that whole idea of kinematic bodies is that they only run the collsion phase but not the dynamic phase.


The still generate the closest point, which is act and for triggers in most likelly what is needed.
This function here can be use to check in a body is in teh trigger regin

Code: Select all
void CustomTriggerController::PreUpdate(dFloat timestep, int threadIndex)
{
   CustomTriggerManager* const manager = (CustomTriggerManager*)GetManager();

   unsigned lru = manager->m_lru;

   NewtonBody* const triggerBody = GetBody();
   for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint (triggerBody); joint; joint = NewtonBodyGetNextContactJoint (triggerBody, joint)) {
      NewtonBody* const body0 = NewtonJointGetBody0(joint);
      NewtonBody* const body1 = NewtonJointGetBody1(joint);
      NewtonBody* const passangerBody = (body0 != triggerBody) ? body0 : body1;
      PassangerManifest::dTreeNode* node = m_manifest.Find (passangerBody);
      if (!node) {
         node = m_manifest.Insert (passangerBody);
         manager->EventCallback (this, CustomTriggerManager::m_enterTrigger, passangerBody);
      } else {
         manager->EventCallback (this, CustomTriggerManager::m_inTrigger, passangerBody);
      }
      node->GetInfo() = lru;
   }
   
   PassangerManifest::Iterator iter (m_manifest);
   for (iter.Begin(); iter; ) {
      PassangerManifest::dTreeNode* const node = iter.GetNode();
      iter ++;
      if (node->GetInfo() != lru) {
         manager->EventCallback (this, CustomTriggerManager::m_exitTrigger, node->GetKey());         
         m_manifest.Remove(node);
      }
   }
}
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Bird » Mon Apr 29, 2013 11:49 am

Ok, I was expecting Kinematic bodies to act like Static bodies that could be moved manually during the course of the simulation like they are in PhysX and Bullet.

If you can find the time, it would be helpful if you could finish the KinematicBodies demo, so we could learn more about how to use them.

Thanks for the explanation and code.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Making Kinematic Bodies

Postby Julio Jerez » Mon Apr 29, 2013 2:57 pm

Bird wrote:Ok, I was expecting Kinematic bodies to act like Static bodies that could be moved manually during the course of the simulation like they are in PhysX and Bullet.

Would not that be a distintion without a difference? :)

The concept of a kinematic body in Newton is this:
It is body that operates strictly on the collision phase engine, the can collect contact and all of the other functionality the collision system has to offer buy they do not interact physically with other bodies (kinematic, static or dynamics)
However the functionality you are looking for is also supported by the engine by using the scene collision.
Te Scene collision is a static compound collision, you can make one as add nodes that can be collidable and non collidable and you can move the around at will.
Bird wrote: If you can find the time, it would be helpful if you could finish the KinematicBodies demo, so we could learn more about how to use them.

Yes I have to do that I will finish that when I complete the Mac project. It is almost completed now, al the libraries compile, but I have no set the path in cxcode yet. I am guessing that in tow more day I will upload the new build with Mac CoCoa project for OSX 10.8
I finally switch back to wxWidget, in the new version 2.9.4 they actually fix all of the nonsence they had to make a build on version 2.8.xx
The I will complete the Kenematic demo, yes.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Bird » Tue Apr 30, 2013 8:42 am

Excellent news about the Mac! I'm looking forward to testing it.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Making Kinematic Bodies

Postby Julio Jerez » Fri May 03, 2013 12:18 pm

I have the mac project going now.

I also fixed the multithreaded bug that force people to set the engine to thread emulation on MAC platform.
I turn out that OSX does no allow for Anonymous Semaphores, on windows it is jus the opposite it doe no allowed named semaphores.
after I fixed that with #ifdef/#end the engine now run perfectly on OSX, 10.8 xcode 4.5

There are tow problems I nee to fix.
The first is easy, I nee to implement the equivalent of wglSwapIntervalEXT(0) for OSX
for Linux and unit this is glXSwapIntervalSGI, but for some reason it does no works for OSX.
it look that apple make its own opneGL layer called AGL
this is important because without that OpenGL run in Vsink, an dthat blocks all the other thread to 60 hearth.

The second is a bigger bug, I do not know how to make MenuBar to show up in the Mac main menu.
apparently this is a resource setting on the project but I do not know how. If you know please let me know, I can no get an answer form WxWidget forum, and no one on the Apple forum seem to know.
with out that the application does no get keyboard or menu messages.

If you sync to SVN you soudl get it.
I dis no check the compile libraries, yo uhave to open the xcode project and build the libraries one at a time.
(that another issue, I do not know why xcode 4.5 does not recognize subproject dependencies, or at least I do not know how to set that up)
then you build the sandbox demo and it should runs.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Julio Jerez » Mon May 06, 2013 3:04 am

I am having a very strange problem wit the mac. I had not idea that xcode 4.xs was so buggy.
It is one bug after the other, and one point it simple crashes a few seconds after I launched.
I was using 4.5 so I upgrade to 4.6

now with 4.6 I have a very strange bug, I have one back archive in my user fodder. That project build and runs fine

but if I copy the same archove to eh destop, I get this error

/Users/juliojerez/Desktop/newton-dynamics/applications/demosSandbox/projects/mac/osx-10.8-xcode-4.5/DerivedData/demosSandbox/Build/Intermediates/wxcocoaStatic.build/Debug/wxWidget.build/Script-94E713C89B403F568A694F9B.sh: line 2: /Users/juliojerez/Desktop/newton-dynamics/packages/thirdParty/wxWidgets/wxWidgets-2.9.4/build/osx/../../distrib/mac/pbsetup-sh: Permission denied


I can not even post that in google because it come empty. It look like a script try to create a file name pbsetup-sh but it get access denied
do yo know how to solve this?
this same project on my user folder compile fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Bird » Mon May 06, 2013 8:49 am

Sorry, I've been busy on other stuff and haven't been able to get to the Mac yet. I'll try it this week and let you know how it goes.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Making Kinematic Bodies

Postby Julio Jerez » Mon May 06, 2013 10:27 am

Oh it is ok. I think I figure out.

I appear that xcode 4.xx only create project connected to SVN. or at least that is the default behavior.
It may be that at some point in the pass I set that as a default but I do no remember how to turn that off now.
Anyway what happen is that every project I create or I add to the root demosSanbox as a dependence project, get a file by the same scm.plist
this is if I use the project on that directory only, but as soon as I copy of move to another folder, all of the of the source files become red, and I can not compile wxWidget anymore.
The reason wxWidget does no compile is because the project has some preprocessor scripts that copy configuration files form one fodder to another, and those get Permission denied error.
to fix that I have to open the project in a windows PC and delete all those scm.plist form SVN.
after now the project build out of the Box form source control.

there are still tow problems
1- I can not get the main menu in OSx to show up. I poste the question on the wx forum, but no one seem to know the answer to that.
I already follow the rule for making OSX menus, but it seem there are some other resource files I nee to add to the project, but I do not know how.

2- the fps is locked to vsync, this is a problem for real time engine because it blocks the app no letting oteh thread to run concurrently. The problem is that the method for setting vsync in opengl is no standard
for different platforms, and in make in particular there are several OpenGL layers (CGL, AGL) and I can no figure for to get the context form wxwidget.
I think that stepping in debug I can see what API is using so that I can do that.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Julio Jerez » Mon May 06, 2013 10:44 am

actually I take that back. I just delete the project form the desktop and I get it form source control
it compile and link fine, bu I can not open and of the source file by clicking on the xcode explorer.

it like all the file are read and write projected. I do not know how to resolve this because without that I can no edit the source file to fix the issue with OSX.

I despise xcode 4.xx they try to make the s\thing more like visual studio and what the got is a piece of garbage now. xcode 4 is terrible.

when you have time, after to get it form svn please see if you can figure out why all the files are read and write protected.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Julio Jerez » Mon May 06, 2013 11:15 am

The other problem is that if a file is read in the explore I can no step in debug mode either.
I do no know what apple is thinking with this security nonsence. what good those that do if you can no read you own files.
This prevent me for continuing on the Mac, maybe some one with more experience in xcode can figure out what is wrong.

The code compile and runs, but xcode do no let me do any editing to any file. even worse the fiel on the main project are black but if I double click on then, they become red too.

I have no idea what cause this.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Bird » Mon May 06, 2013 12:06 pm

Julio Jerez wrote:actually I take that back. I just delete the project form the desktop and I get it form source control
it compile and link fine, bu I can not open and of the source file by clicking on the xcode explorer.

it like all the file are read and write projected. I do not know how to resolve this because without that I can no edit the source file to fix the issue with OSX.

I despise xcode 4.xx they try to make the s\thing more like visual studio and what the got is a piece of garbage now. xcode 4 is terrible.

when you have time, after to get it form svn please see if you can figure out why all the files are read and write protected.


Yes, I don't like XCode either and we're not alone. :) http://amplicate.com/hate/xcode

I use Versions for source control on the Mac and found a way to disable XCode built in Svn control here:
http://stackoverflow.com/questions/5280446/how-can-i-turn-off-the-built-in-subversion-repository-in-xcode-4

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Making Kinematic Bodies

Postby Julio Jerez » Sat May 11, 2013 3:50 pm

Ok I think IO figure out why s code fail at looking for the dependencies.

Basically xcode 4.xx S-U-C-K-S
because it when you make a product you cousl set the targetName
for example the debug could be name_d
and release Name

now you still can do that however if you do the the dependecid manage will no let you add the file as depended to another project, because et only target the Target Name.
you can no added as library depend lei I did because they the is no option exclude one of the tow library generated by each target.
If you assign different name to the product name, the only way to link that library is by adding ot to the explores as part of the project, by you can only add one.
this is wrong.

The reason it only link one library was because build those project with xcode 3.xx and there you can combine the decencies anyway you want.

the only way to have a library as a depencies to anoeth project in xcode 4.xx is by having debug and release configuration generation the same product name.
That way the the linker will search for the same file name in the Debug and Release folders for that projectname.


I also think I know why my project does no show the menu, some how my project generate the binary executable only, it is no making a bundle
for some reason OSX 10.8 will only show the many of the application has a specific project structure.
It also look like that the only way to make a bundle in but having the XCode script to make one for you, by creation a new target, what this mean is that I will have to recreate the demo project again

Apple is no the user friendly software and hardware manufacturer that the were. Applet is getting too big.
Some body have a reel them in the can no play we the use that way the do, for one release to the next the change everything the want, regardless of the cost to the user.
the should be hit with an antitrust law sue.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Julio Jerez » Sat May 11, 2013 11:51 pm

Hurray I finally have the xcode project for the sand demos as it should be. It is a legitimate xcode 4.5 Cocoa OSX project.

There are tree things still pending.
1- unlock the OpenG: V sync
2- Change the GetFullPath function so that I read the assets form the Bundle, not form the media folder, that way the executable can be copy anywhere in the machine and will still run.
3-See why the Font, it is failing and non of the debug is reading
4-Debug the ray cast picking, I believe it is failing because eth Point To Screen function on Mac OpenGl is in a different coordinate system.

Everything else seem to be working, and should build out of the Box.
any of the stuff above is not really critical, so I can delay that until I made the Linux.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Making Kinematic Bodies

Postby Bird » Sun May 12, 2013 9:59 am

I just tried with the latest svn version and the demosSandbox.xcodeproj won't compile.

Error in newton_Prefix.pch ----'Carbon/Carbon.h' file not found

I'm using Xcode 4.6 and running OSX 10.7.5

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron