Collision questions in regard to newton.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Collision questions in regard to newton.

Postby Zetamun » Thu Jan 26, 2017 12:42 pm

The Newton I am using is GMNewton from 2011. I am not sure what version of Newton this is, I assume it is Newton 2.0 because it has a function called GmnCollisionGetContactCount(). GMNewton has no documetation, only a couple comments on the scripts. The closest thing I could find to this in the official documentation is NewtonContactJointGetContactCount() which is only in GMNewton2.0. Thus through deductive reasoning I assume GMNewton uses Newton 2.0.

So what I am trying to do is exclude collisions from their own body. For example, I want each car of a wheel to return if it is touching an object, but not to return a collision with the chassis of the car it is touching. I have tried everything, from assigning the chassis and wheel to two different materials, and disabling collision between the materials, and disabling collision between joints, and it still returns a collision when it touches it's own chassis. So I am left with the functions GmnCollisionGet(), GmnCollisionGetNext(), GmnCollisionGetContactCount () and GmnCollisionGetObject(). They are poorly documented and so far I have not been having any luck. But I have read the documentation again and this time I will try putting joint ids in the functions. I will keep you posted.

(I cannot use raytracing either, because it would be too long to explain, I need the actual contacts of the wheels. But even if, hypothetically, if I could use raytracing, it would still not work because I can't disable the ray from detecting certain objects or materials. In any case, just forget about the whole raytracing thing, I mainly need help with the non-raytracing collision functions.)

Also, there seems to be no function of NewtonMaterialGetContactPositionAndNormal() in GMNewton.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm

Re: Collision questions in regard to newton.

Postby JoeJ » Thu Jan 26, 2017 1:13 pm

Strange is, by default Newton disables collisions between bodies if they are connected by a joint.
Maybe the creator of GMN changed that, but he may have added somthing where you can change this at setup. Maybe you can do this when creating the joints.

At runtime we can use Callbacks to reject contacts for further processing.
There is a broadphase callback if bounding boxes (AABB) if two objects overlap,
and a narrow phase callback for each individual contact.
Both could be used to reject contacts, so maybe you have interface for them which works somehow like this:

c = GmnCollisionGet()
while (c)
{
c.DisableSomehow()
c = GmnCollisionGetNext(c);
}

but that's pure guessing, so unlikely.
'Collision' in Newton means the shape of an object, so 'Contact' seems the better term to look for.
But if all you have is NewtonContactJointGetContactCount() and the author uses the same terminology you may be out of luck.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collision questions in regard to newton.

Postby Zetamun » Fri Jan 27, 2017 2:03 pm

c = GmnCollisionGet()
while (c)
{
c.DisableSomehow()
c = GmnCollisionGetNext(c);
}

CollisionGet returns a value around 1 million, and there is no function called DisableSomehow lol. But I will try your code and see if it works, probably won't but worth a shot.

'Collision' in Newton means the shape of an object, so 'Contact' seems the better term to look for.

It was a typo, I think the function is called ContactGet in GM Newton. I probably have made several of these typos lol.

But if all you have is NewtonContactJointGetContactCount() and the author uses the same terminology you may be out of luck.

Hmm. Upon further inspection I don't think it is the joint function, plugging in joint values crashed and froze the engine. Upon experimentation of plugging in all possible values (body ids, joint ids, game maker object ids) I got the function GmnGetContactCount() to return a non-zero value. But the funny thing is, it seemed to return a high value, like over 1 million. So I'm guessing that this returns the amount of per-pixel vertex contacts on the entire mesh.

The GM Newton has no helpfile, and it's mostly undocumented except for a few vague comments on the scripts. In GM Newton he put a function called GmnGetContactObject() but I can find no corresponding function to this in the official Newton Wiki page. Its parameters are dCollision and index, that is the only help GM Newton has availiable for me. It doesn't tell me what dCollision is, and it doesn't say what type of index index is. I tried to put the function GmnGetContact() for dCollision but it crashed the game, so then I tried to put the GM Newton equivalent of NewtonMaterialGetBodyCollisionID as the parameter, still crashed it.

I tried to outsmart the conundrum by assigning each object to use a different material, and thinking that by calling GmnCollisionGet() in each object, I could individualize the collisions, but GmnCollisionGet() returns all collisions of all materials, so even if an object isn't touching anything, if a random object touches something GmnCollisionGet() will return true. So I am searching for a way to instanciate the collisions but I can't figure out what to put in GmnGetContactObject and I have no idea what function GmnGetContactObject is equivalent to in the official newton. I am guessing dCollision must refer to a collision shape itself, and index refers to a body, but I have sinking feeling that it won't work and it will crash the game. So I am now focusing my attention on GmnGetContactNext(), but I have no idea what it does because I can't find an equivalent function in the documentation.

Also, he wrote //Newton v1.00
in the documentation, but the file is listed as GM_Newton 2, so it may be Newton 1.00 I'm not sure. It was made in 2011.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm

Re: Collision questions in regard to newton.

Postby JoeJ » Sat Jan 28, 2017 3:38 am

I was looking up https://github.com/RobQuistNL/GMNewton/blob/master/DLL/Source/j_bs.cpp

There is GmnJointSetCollisionState(double dJoint, double state), and i guess you can disable collisions there by setting state to either 0 or 1.
Yep, should work, see: http://newtondynamics.com/wiki/index.php5?title=NewtonJointSetCollisionState

Further i found some interface refering to rotations, which are given by euler angles.
You have some local / global problem with this?
Probably you can solve it by converting between euler and matrix/quaternion on your own.
You'd need to tell me what you want to do and see if you have access to some math library dealing with matrices or quats.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collision questions in regard to newton.

Postby Zetamun » Sat Jan 28, 2017 3:54 pm

Figured out the rotation thing, but the problem is GmnContactGet() returns true when any object (not just the object calling GmnContactGet()) collides. So I am trying to figure out how to instanciate the collisions, but GmnContactGetObject() has no documentation, it's paramters are dCollision and index but when I put the parameters in it crashes the game.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm

Re: Collision questions in regard to newton.

Postby JoeJ » Sat Jan 28, 2017 4:25 pm

What do you want to do with GmnContactGet()?
(I need some background so i can look for an alternatives)

To disable collisions between wheels and car GmnJointSetCollisionState is the best option, does it work?
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collision questions in regard to newton.

Postby Zetamun » Mon Jan 30, 2017 12:34 pm

Need it to return the individualized collisions of the wheels. For instance, if wheel A is touching but wheel D is not touching, it tells me wheel A's collision is true and wheel D's collision is false.

How it is setup currently, if wheel D touches, both wheel a and wheel d return true. I don't know how to get out of this and get individualized collisions.

Also, I need this functionality for other areas of the game. So suggesting having 4 raytrace checks may solve the car problem, but in other areas of the game I can't use raytracing and need the actual physical contact collisions.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm

Re: Collision questions in regard to newton.

Postby JoeJ » Tue Jan 31, 2017 3:04 am

https://github.com/RobQuistNL/GMNewton/blob/master/DLL/Source/materials.cpp
https://github.com/RobQuistNL/GMNewton/blob/c7f3cc86fbfdb7c3030e39d714d69ee32f50d94d/GM/DefaultBoxDemo.gmx/scripts/handle_collisions.gml

Unfortunately this does not make much sense to me.
Maybe he processes all callbacks/contacts internally and exposes a list for all of them you can interate over. But don't know how. I'm lost there.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collision questions in regard to newton.

Postby Zetamun » Wed Feb 01, 2017 2:27 pm

Hmm thanks.

I'm gonna try that code and see if it works.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm

Re: Collision questions in regard to newton.

Postby Zetamun » Fri Feb 03, 2017 11:34 am

Good jubes.

I ran a modified version of the code, and lo and behold it worked! Thanks very much. Good jubes.
User avatar
Zetamun
 
Posts: 18
Joined: Tue Jan 03, 2017 1:19 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 27 guests

cron