newton collision materials

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

newton collision materials

Postby JernejL » Thu Dec 10, 2009 6:48 pm

I know this was discussed a long time ago, that in newton 2.0 there is a way to attach materials directly to the collisions and build a compound with collision pieces of different materials.

I just came in situation when i need a compound collision box made of two pieces and 2 different materials, where one specific material would not collide with another particular material, but i cannot find out how to assign a material to collision directly, there is no "NewtonCollisionSetMaterialGroupID" or anything similar, so how does it work?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby Julio Jerez » Thu Dec 10, 2009 7:38 pm

it uses the Shape ID,
the advance material in the wiki tutorial show how to dod it.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton collision materials

Postby JernejL » Fri Dec 11, 2009 5:02 am

I was looking at that, and i couldn't see it be used, so shapeid is effectively the newton material number?

Also: how do i get a collision shapeid? is it the "int m_collisionUserID;" in the newtoncollisiongetinfo structure?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby JernejL » Sat Dec 12, 2009 12:56 pm

Ok, i tried and set the groupid to my a material i created earlier, i tried this on NewtonCreateConvexHull but the created objects don't behave as if they had the proper material, should this work like this or did i do something wrong?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby Julio Jerez » Sat Dec 12, 2009 2:10 pm

Basically you need to implement a Material manager the unify shape and sub shape.
the shape ID was added to solb ther problem of determine what subshape was colliding with another subshape.

give me a day only I am done with the memory manager thing, and i will explain how to do it.
do you have the facility to compile C++ program?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton collision materials

Postby JernejL » Sat Dec 12, 2009 4:37 pm

No i don't have any c++ tools.

I looked at the tutorial more in-depth now, i think i understand how it's supposed to work, i am supposed to use NewtonMaterialGetBodyCollisionID to get the GroupID, which i can then process.
And because i only need to make the specific collision parts non-collideable this shouldn't be hard to implement.

But i would suggest renaming the shapeid to CollisionID, this way it would clear up a lot of things.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby JernejL » Sat Dec 12, 2009 8:36 pm

Awesome, i got it to function and it works PERFECT for my needs but i have a few suggestions:

- Rename shapeid parameters to CollisionID, this way it would clear up a lot of misunderstanding of what is used for what purpose.

- Add a function like NewtonMaterialUseGroup(const contactJoint: PNewtonJoint; materialgroupid1, materialgroupid2: integer)
This could be used inside a material callback to instead of overwriting values with several NewtonMaterialSetDefaultSoftness, NewtonMaterialSetDefaultElasticity, etc.. functions could just apply parameters of a particular existing created material pair, this can be useful when you don't want to implement a completely new material system, but just want to apply ordinary newton materials to separate pieces of a compound collision.

I still have that question: how do i get a collision's shapeid outside of collision callback? is it the "int m_collisionUserID;" in the NewtonCollisionGetInfo structure?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby Julio Jerez » Sat Dec 12, 2009 8:56 pm

Delfi wrote:I still have that question: how do i get a collision's shapeid outside of collision callback? is it the "int m_collisionUserID;" in the NewtonCollisionGetInfo structure?


This is correct, but you can also call
unsigned NewtonCollisionGetUserID(const NewtonCollision* collision)
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton collision materials

Postby JernejL » Sun Dec 13, 2009 9:53 am

At least it works good, althru it's a mess :D

The same parameter is called UserID twice (NewtonCollisionGetUserID, m_collisionUserID)
"shapeid": once (newtoncreate calls), and CollisionID 1 times in NewtonMaterialGetBodyCollisionID

Should be unified to use 1 single name (i would suggest CollisionID), no wonder i had trouble figuring it out :S
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby Julio Jerez » Sun Dec 13, 2009 11:42 am

where should it be renamed?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton collision materials

Postby JernejL » Sun Dec 13, 2009 12:52 pm

NewtonCollisionGetUserID -> NewtonCollisionGetCollisionID
collision info record - m_collisionUserID -> m_UserCollisionID
And all the newtoncreatexx calls - shapeid rename to -> CollisionID
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newton collision materials

Postby Aphex » Sat Mar 06, 2010 12:32 pm

Hmm. Makes more sense to me the way it is.
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 625 guests