strange behaviour of my cuboids

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

strange behaviour of my cuboids

Postby Yustme » Thu Aug 14, 2008 1:51 pm

Hi,

When i create a few cuboids stacked on each other, they suddenly fly like crazy around and act really strange.

I adjusted its size and then this happened. How can i calculate realistic mass for the objects? I think thats where the problem lies.

Here is the code i use:

Code: Select all
dVector inertia;
dVector origin;
   
NewtonConvexCollisionCalculateInertialMatrix(collision, &inertia[0], &origin[0]);   

// Set body mass & inertia matrix
float mass = 50.0f;
float Ixx = mass * inertia[0];
float Iyy = mass * inertia[1];
float Izz = mass * inertia[2];
   
// set the correct center of gravity for this body
NewtonBodySetCentreOfMass (body, &origin[0]);

NewtonBodySetMassMatrix(body, mass, Ixx, Iyy, Izz);


Size of the cuboid is: 50.0, 10.0, 20.0 (XYZ).

What am i doing wrong?
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Firefly » Fri Aug 15, 2008 2:08 am

Try setting set the massmatrix/bodymatrix/centreofmass after you release the collision mesh.

I had a problem with objects going all crazy if I set the bodymatrix before releasing the collision.
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: strange behaviour of my cuboids

Postby Yustme » Fri Aug 15, 2008 4:18 am

Hi Firefly,

Didn't work. It keeps suddenly jumping from the ground when it was down on the floor and rotates like crazy in the air.
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Julio Jerez » Fri Aug 15, 2008 7:30 am

My guess is teh you trasform matrix of teh body is incorrect.
I do not know why by this seems to be a pathogical thing with Irrlitch users, 9 out of 10 make the same mistake.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: strange behaviour of my cuboids

Postby Yustme » Fri Aug 15, 2008 7:49 am

Hi Julio,

Do you mean the transform callback function?

Code: Select all
void CNewton::PhysicsSetTransform(const NewtonBody* body, const float* matrix, int threadIndex)
{
   matrix4 mat;
   memcpy(mat.pointer(), matrix, sizeof(float) * 16);
   
   IMeshSceneNode* mesh = (IMeshSceneNode*)NewtonBodyGetUserData(body);
   
   if(mesh)
   {
      mesh->setPosition(mat.getTranslation());      
      mesh->setRotation(mat.getRotationDegrees());
   }
}
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Julio Jerez » Fri Aug 15, 2008 8:34 am

no, IO mean teh matrix you set into teh collision shape if you are using it or into teh body.
the matrix sopudl have the form

unitVectorX 0.0
unitVectorY 0.0
unitVectorZ 0.0
pointion 1.0

where UnitVector is (x, y, z) no scaling
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: strange behaviour of my cuboids

Postby Yustme » Fri Aug 15, 2008 10:20 am

Hi,

This is the collision shape:

NewtonCollision *collision = NewtonCreateConvexHull(world, nVertices, vertices, sizeof(float) * 3, 0.01f, NULL);

It's a collision shape i create from a mesh file. The only matrix keyword in that function is an offsetMatrix.

But i don't think you mean that one.
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Julio Jerez » Fri Aug 15, 2008 11:20 am

then is most be the matrix you are setting on the body when you initialize it.
Make sure it is a correct matrix, and if still malfuntion send me a test demo
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: strange behaviour of my cuboids

Postby Yustme » Fri Aug 15, 2008 11:45 am

Hi Julio,

After creating the collision and releasing it, i use the irrlicht matrix class to position the body in the world like this:

Code: Select all
// Set the position of the body
matrix4 mat;
mat.setTranslation(node->getPosition());
NewtonBodySetMatrix(body, mat.pointer());
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Julio Jerez » Sat Aug 16, 2008 8:34 am

I run you test and I do nto see the bodies flying around. what is the problem?
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: strange behaviour of my cuboids

Postby Yustme » Sat Aug 16, 2008 8:45 am

Hi,

It only happens if you shoot a sphere to the cuboids which are in the pyramid form.

I don't know how to explain the behavior, but it suddenly rotates when it lands on the floor and than its flying up and coming down again.

Try using less cuboids, i get this behavior with this config:

newtonPtr->CreatePyramideStack(-500.0f, 3.0f, 1.0f, 80.0f);
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Julio Jerez » Sat Aug 16, 2008 8:57 am

something is very wrong somewhere, when the cube touch teh floor they explode sometime becaus ethe boune on the wrong direction,
can you set teh debug dispplay to se the collison ?

you using are really big, try plaing a 120 fps and see if it is better, if it is then maybe converion to metter will be a good idea.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: strange behaviour of my cuboids

Postby Yustme » Sat Aug 16, 2008 10:08 am

Hi,

Im having a hard time implementing debug display. What did you mean with "converting to metter" and "you using are really big" ?
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby Yustme » Sat Aug 16, 2008 3:40 pm

Hi,

A screenshot of the spheres. Looks like the collision is hanging in the air while the graphics object of the sphere is on the floor:

http://yustme.g0dsoft.com/Projects/newtonCollisionDisplayDebug.JPG
Yustme
 
Posts: 37
Joined: Sat Dec 08, 2007 2:06 pm

Re: strange behaviour of my cuboids

Postby JernejL » Sat Aug 16, 2008 5:10 pm

It looks as if your newton body scale doesn't match the graphical scale, if you are sending scaled matrices to newton then that is one of possible problems, newton currently doesn't support scaling bodies except convex hulls, for which it uses the convex hull modifier.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Next

Return to General Discussion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests

cron