Strange size of sphere

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Strange size of sphere

Postby Virginie » Tue May 26, 2009 9:19 am

Hello,

I've got a stange problem with sphere.
I set the radius in x, y and z coodinates by the user and when the spher is a real sphere (x=y=z) it's bigger than when it isn't !

I explain.

My sphere is my collision primitive for my camera. The user can set the size of this primitive. I use it only for colision.
I start with a size = 0.5, 0.5, 0.5
For exemple I set with 9.5, 8.5, 8.5 I touch my object for collide but without penetration.
And when I set with 8.5, 8.5, 8.5 they are collision with penetration!

Somebody knows why?
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Julio Jerez » Tue May 26, 2009 9:35 am

you can display the collsion shape and the contacts. It will show what is going on
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Strange size of sphere

Postby Virginie » Tue May 26, 2009 10:47 am

Thanks for your speedy answer Julio.

But I insert the physic engine newton in a software and this sofware don't permit display collision shape with the tool in newton world so I write only coordinates and they seem good. But the contact is somethink bad! It's stange because before to add the function to set the camera size all are good so it's more coherent that it appens by the collision shape. The most strange is that appen only when x=y=z!

I see this in much detail and I say you if I find the problem.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Julio Jerez » Tue May 26, 2009 1:17 pm

I am confused.
are you saying spheres do not works but that ellipsis do?
to make a debug diaply all you need is aline drawing funtion, whic I am sure all graphics engine support.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 4:01 am

Yes with elipsis no problem but when the ellipsis become a sphere it seems that the primitive is much big. The problem must become away, I look for this today.
No I can't use debug function because the sofware screen display and too much change are necessary.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby JernejL » Wed May 27, 2009 5:36 am

Are you sure you didnt specify some dimensions wrong? like radius / diameter, negative radius..??
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 6:38 am

No, look :

size : 2.5,2.5,4.5
position : 0.62,1.08,-2.77
AABB min : -2.18,-2.18,-7.80
AABB max : 3.42,4.35,2.27

At this moment my camera is in touch with a plan

I set size
size : 2.5,2.5,3.5
position : 0.62,1.08,-2.77 the same
AABB min : -2.15,-2.03,-6.81
AABB max : 3.38,4.20,1.28

contactsCallback isn't called
It's good at this moment

I set size
size : 2.5,2.5,2.5
position : 0.62,1.08,-2.77 the same
AABB min : -2.00,-1.54,-5.39
AABB max : 3.24,3.71,-0.14

contactsCallback is called on camera and the plan!
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 6:42 am

I presize the size in the before post is the radius in x,y,z of my ellipsoid collision primitive.
And I only set size in this test.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby JernejL » Wed May 27, 2009 7:09 am

Do you set the other object and camera object positions precisely? please implement the debug geometry system, it will help you a lot with this kind of problems!
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 7:21 am

No I don't move the position of camera, I just set the size of the collision ellipsoid.
But even if I implement debug system, I don't see the box of my camera?
And the other objects are good I am sure because before implement this functionnality all are good, I just add this.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 7:55 am

No in fact it's when the ellipsoid is not a sphere the size don't set, so when there is a sphere the good size is update and collision are make.
I test if I've got the same problem with box.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 8:01 am

No with box there are no problem! So I use box and no ellipsoid.
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Re: Strange size of sphere

Postby Julio Jerez » Wed May 27, 2009 8:27 am

if you are going to use newton, it will help you a lot having a way to see the collision shapes.
Maybe I need to write a visual debugger, but until them you need to implmnet debug display.

what you say sugest that the is a bug some where with a matrix that have some scale build in or some ill constrution like a last element not bing zero.
Newton does not do error checking, it maybe that the sphere code uses that condition and the elipsis does not.

changing to a Box may hide the Bug for now but it may show up later.
please spend time implementing debug display, it shuold not be harder than displaying other kind of geometry in your engine.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Strange size of sphere

Postby JernejL » Wed May 27, 2009 8:55 am

Julio Jerez wrote:if you are going to use newton, it will help you a lot having a way to see the collision shapes.
Maybe I need to write a visual debugger, but until them you need to implmnet debug display.


I was just thinking of the same thing, with a special dll hook / wrapper you could debug any application which uses the external dll (unfortunately linked libs wouldnt work).
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Strange size of sphere

Postby Virginie » Wed May 27, 2009 9:13 am

No, I'm very sorry but I'm in stage in a business and the sofware take many many class (much of 200). My boss says me that I haven't got the time to check all points to permit display debug and do my work because I don't know all classes. That's why I choise the solution to display AABB.
I would like to help you because you engine is very good but I haven't got the time. Sorry.

But if you see it's because the matrix : it's possible it's not a Newton bug but an OgreNewt bug!
This the code of OgreNewt to create ellipsoid :

Ellipsoid( const World* world, const Ogre::Vector3& size, const Ogre::Quaternion& orient, const Ogre::Vector3& pos )
{
float matrix[16];

OgreNewt::Converters::QuatPosToMatrix( orient, pos, &matrix[0] );

m_col = NewtonCreateSphere( m_world->getNewtonWorld(), (float)size.x, (float)size.y, (float)size.z, &matrix[0] );
}

//! Take a Quaternion and Position Matrix and create a Newton float matrix
void QuatPosToMatrix( const Ogre::Quaternion& quat, const Ogre::Vector3 &pos, float* matrix )
{
// this takes a Quaternion and a Vector3 and creates a float array
using namespace Ogre;
Matrix3 rot;
Vector3 xcol, ycol, zcol;

quat.ToRotationMatrix( rot ); // creates a 3x3 rotation matrix from the Quaternion.

xcol = rot.GetColumn(0);
ycol = rot.GetColumn(1);
zcol = rot.GetColumn(2);

// now fill the final matrix with the appropriate data:
matrix[0] = xcol.x;
matrix[1] = xcol.y;
matrix[2] = xcol.z;
matrix[3] = 0.0f;

matrix[4] = ycol.x;
matrix[5] = ycol.y;
matrix[6] = ycol.z;
matrix[7] = 0.0f;

matrix[8] = zcol.x;
matrix[9] = zcol.y;
matrix[10] = zcol.z;
matrix[11] = 0.0f;

matrix[12] = pos.x;
matrix[13] = pos.y;
matrix[14] = pos.z;
matrix[15] = 1.0;
}

Now you can see if it's an OgreNewt or Newton bug.

And very very sorry because I can't spend time to help you
Virginie
 
Posts: 32
Joined: Tue Mar 31, 2009 4:29 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest