A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by belfegor » Wed Jan 16, 2013 4:04 pm
I am using Newton 2.3. Is there a way to get face attribute id with convex cast?
Looks like NewtonWorldConvexCastReturnInfo::m_contactID is not that.
Thank you for your time.
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Wed Jan 16, 2013 4:32 pm
I do not remember how is done in core 2.xx but
I believe that you will have to enumate the faces with a unique ID, so tha each face have that information.
what are you using this for?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by belfegor » Wed Jan 16, 2013 4:51 pm
I am using modified Marc character controller, and i have static tree collison loaded from one serialization file representing my world (about 2000 objects - ~1.5 milon faces) , and when i build it i have set their "face attribute" according what they represent concrete, grass, metal, wood... So now i need to know on what type of surface i am standing on so i can know witch "step" sound to play.
Any help is appreciated. Thank you for your time.
PS. Marc's "character" is hovering above ground and he is using convex cast so i can't use NewtonMaterialGetContactFaceAttribute in contactProcess callback.
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Wed Jan 16, 2013 7:06 pm
I thought you needed the face, but your are refering to the face materail ID, I beleive the contact structure report the materail ID thar you pass to the face when you make teh collision tree.
take a look at the toturiall
- Code: Select all
http://newtondynamics.com/wiki/index.php5?title=Tutorial_201:_-_Advanced_Custom_Material_System
It has a matrail system with per collsion tree face id, and even plays a sound
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by belfegor » Wed Jan 16, 2013 7:22 pm
I have already using that MtrlManager class from that tutorial. The problem is that Marc's character controller body is hovering above ground so it doesn't generate contact so "ContactProcess" function is not called (unless i hit something like a hight wall). He is using collision object not in relation to that body for convex cast.
Can i switch to Newton 3.0 or there is some features unimplemented?
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Wed Jan 16, 2013 8:52 pm
belfegor wrote:Can i switch to Newton 3.0 or there is some features unimplemented?
yes, If you wtich to version 3.0 it will be easser to work it out. Plsu tehr are lot many bug fixest that, optimization and newer featire that are not in core 2.xx
There is also a player controller that is very similar to Marc's player controller.
That controller is build using the convex cast. Plus is use a new powefull feature name Pre and Post listener
that make it possible to do the kind of stuff that you want more closetly to what a Game Engine does.
you can simple download or synk to svn and play the player controller. so that you can see what is does.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by belfegor » Wed Jan 16, 2013 9:08 pm
Downloaded latest Newton SVN.
Looks like there is no "NewtonCreateXXX" interface exposed for creating character controller, it is tightly coupled with "packages" dependencies. It will be chaos and lot of hair ripped until i find out witch headers & folders to setup and what not.

BTW. Why do you like inverted mouse look for demos? This is crazy.
Also text is messed up and playing with options menu gives wierd results.

-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by belfegor » Thu Jan 17, 2013 12:58 pm
After couple of hours i have successfully "extracted" code from "BasicPlayer" demo into my test project.
Looks like "player" can't push other dynamic bodies by default? Maybie i need to manually add forces to bodies from "contacts info" in ProcessContacts function of CustomPlayerControllerManager for this behavior?
I still don't see how i can get face attribute ID from tree collision when player is in contact?
Thank you for your time.
EDIT:
Some unrelated questions
1.
- Code: Select all
dMatrix playerAxis;
playerAxis[0] = dVector (0.0f, 1.0f, 0.0f, 0.0f); // the y axis is the character up vector
playerAxis[1] = dVector (1.0f, 0.0f, 0.0f, 0.0f); // the x axis is the character front direction
playerAxis[2] = playerAxis[0] * playerAxis[1];
playerAxis[3] = dVector (0.0f, 0.0f, 0.0f, 1.0f);
Why do you choose positive x to be front axis for player, isn't -z front for OpenGl?
2.
- Code: Select all
class DemoEntity...
dVector m_curPosition; // position one physics simulation step in the future
dVector m_nextPosition; // position at the current physics simulation step
dQuaternion m_curRotation; // rotation one physics simulation step in the future
dQuaternion m_nextRotation; // rotation at the current physics simulation step
Comments don't match variable names, intentional?
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Thu Jan 17, 2013 2:43 pm
-the player do no push bodies, that was my next task fo rteh controller. It will be don by teh plasye applyin impulse to the body that it collide with.
-I use the x direction because It feel more natural to me, but you can select any othe directions
dMatrix playerAxis;
playerAxis[0] = dVector (0.0f, 1.0f, 0.0f, 0.0f); // the y axis is the character up vector
playerAxis[1] = dVector (0.0f, 0.0f, 1.0f, 0.0f); // the x axis is the character front direction
playerAxis[2] = playerAxis[0] * playerAxis[1];
playerAxis[3] = dVector (0.0f, 0.0f, 0.0f, 1.0f);
as for the gettting the face from the collision I will look into that, and post how to get it, but you sould be able to get the face it that is assigned to the material.
and yes it looks like teh commnet at trasnposed. next is one step in teh future.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by belfegor » Thu Jan 17, 2013 2:57 pm
Thank you for considering my noob problems.
I have added this to be able to push boxes around with player:
- Code: Select all
virtual int ProcessContacts (const CustomPlayerController* const controller, NewtonWorldConvexCastReturnInfo* const contacts, int count) const
{
for(int i = 0; i < count; ++i)
{
const NewtonBody* cBody = contacts[i].m_hitBody;
float mass, iix, iiy, iiz;
NewtonBodyGetMassMatrix(cBody, &mass, &iix, &iiy, &iiz);
if(mass > 0.0f)
{
D3DXVECTOR3 nrm(contacts[i].m_normal);
D3DXVec3Normalize(&nrm, &-nrm);
NewtonBodyAddImpulse(cBody, nrm * 0.2f, contacts[i].m_point);
}
}
count = CustomPlayerControllerManager::ProcessContacts (controller, contacts, count);
return count;
}
although i don't know how to calculate "correct" impulse force so now it is hard-coded.
as for the gettting the face from the collision I will look into that, and post how to get it...
Yes, please.
Thank you for your time.
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by belfegor » Wed Jan 23, 2013 12:05 pm
Julio wrote:as for the gettting the face from the collision I will look into that, and post how to get it...
Bump.
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Wed Jan 23, 2013 12:37 pm
Oh yes I added teh convex cast and I forgot wh athe problem was.
can you post a copde fragment of of you code wher you try top read teh face IF.
In the sand Box there is a basic player controller demo tha uses a collsion tree mesh. Maybe I can modufi that to play soem sound by detecting the face that the player is at.
But it will be best of you post a code frament of how you are using it. maybe I can add that to one of teh demos.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by belfegor » Wed Jan 23, 2013 1:09 pm
OK. How to explain?
I have about 3000 static objects in my scene, then i make
one tree collision from them and assign "face attribute id" with NewtonTreeCollisionAddFace depending on what "material" current object represent.
Half pseudo:
- Code: Select all
enum EMATERIAL
{
WOOD,
METAL,
GRAVEL,
WATER,
GLASS,
...
};
NewtonCollision* TreeCol = NewtonCreateTreeCollision(newtonWorld, 0);
NewtonTreeCollisionBeginBuild(TreeCol);
for each mesh
EMATERIAL matID = mesh->getMaterialType();
byte* verts;
mesh->lockVB(&verts);
for each face
NewtonTreeCollisionAddFace(TreeCol, 3, reinterpret_cast<const float*>(&Tri[0]), sizeof(vec3), matID);
mesh->unlockVB();
...
NewtonTreeCollisionEndBuild(TreeCol, FALSE);
//serialize
NewtonCollisionSerialize(newtonWorld, TreeCol, SerializeTree, file);
The only function that i saw that can read that face attribute is NewtonMaterialGetContactFaceAttribute but this can be only called from material callback event handler.
I need to know what is a material (face attribute) of a surface that i am "standing" on so that i can know witch "walk" sound to play depending on that.
Any tips how to obtain this since Character controller is using convex cast and this info is not avilable.
Thank you for your time.
EDIT:
In the sand Box there is a basic player controller demo tha uses a collsion tree mesh. Maybe I can modufi that to play soem sound by detecting the face that the player is at.
Example would be nice. Please do. Appreciate your help and time. Thanks
Last edited by
belfegor on Wed Jan 23, 2013 1:13 pm, edited 1 time in total.
-

belfegor
-
- Posts: 53
- Joined: Mon Sep 18, 2006 4:42 pm
- Location: Serbia
by Julio Jerez » Wed Jan 23, 2013 1:12 pm
I may have ot add some functionaty to the collsion functions so that it can collect the faces, I have to leave for work now I see if I do it tonoght.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Thu Jan 24, 2013 12:20 pm
Ok I strt to look at thsi now and examinin the structure of the contacts returned bu the conevx cast I see thgis
- Code: Select all
struct NewtonWorldConvexCastReturnInfo
{
dFloat m_point[4]; // collision point in global space
dFloat m_normal[4]; // surface normal at collision point in global space
dFloat m_normalOnHitPoint[4]; // surface normal at the surface of the hit body,
// is the same as the normal calculated by a ray cast hitting the body at the hit point
dFloat m_penetration; // contact penetration at collision point
int m_contactID; // collision ID at contact point
const NewtonBody* m_hitBody; // body hit at contact point
};
It has normal, contat point, penetration, contaID and hit body.
isn't the m_contactID what you look for? or am I wrong?
I can see hwo teh retyurn infomation per contact can be improve, to also return the collision sub shape that was hit, since there are collision with multiple shape
plus the a void* pointe repsenting some infomation to get the face ID when i apply for example the for a collsion tree it will
however I like to know if you read m_contactID is reporting a wrong value, a Bug?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest