My Scene Are static ,body not moving,:o

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

My Scene Are static ,body not moving,:o

Postby allked » Thu Apr 09, 2009 4:28 pm

I'v already check the Wiki but it didn't sove my problem,
here is my code:
this is the initalize part:
Code: Select all
 
static  NewtonWorld*      ntWorld;
   static   NewtonBody* ribidBodyBox;

ntWorld=NewtonCreate(NULL, NULL);

   
     NewtonCollision* collision;

 boxSize=1.0f;
   collision = NewtonCreateBox (ntWorld, boxSize,boxSize ,boxSize , NULL);
   ribidBodyBox=NewtonCreateBody(ntWorld,collision);
   NewtonBodySetUserData(ribidBodyBox,bx);

NewtonBodySetAutoFreeze (ribidBodyBox, 0);

   NewtonWorldUnfreezeBody (ntWorld, ribidBodyBox);

   //NewtonBodySetTransformCallback(
   
   NewtonBodySetForceAndTorqueCallback (ribidBodyBox, PhysicsApplyForceAndTorque);
   
   NewtonReleaseCollision (ntWorld, collision);


the PhysicsApplyForceAndTorque callback
Code: Select all
void  PhysicsApplyForceAndTorque (const NewtonBody* body)
{
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dFloat mass;

   NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
   Vector3 force (0.0f, -mass * 9.8f, 0.0f);
   NewtonBodySetForce (body, &force.y);
   
}


and i already have a NewtonUpdate(ntWorld,a); function added in the code at the drawscene loop,

I use this code to test X,Y,Z Pos
NewtonBodyGetMatrix(ribidBodyBox,&bxMatrix[0][0]);
Vector3 pos(bxMatrix[0][3],bxMatrix[1][3],bxMatrix[2][3]);

after i saw printf list ,the value list are just 0,0,0, what is going on? am i doing something wrong?
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby Stucuk » Thu Apr 09, 2009 8:28 pm

your not setting the massmatrix so the objects mass will be 0. No mass = no movement.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: My Scene Are static ,body not moving,:o

Postby allked » Fri Apr 10, 2009 3:24 am

thank you for your reply

OK ,now i add setMassMatrix line in the inalize code ,another problem come out,

the body only affect by this:

float omega[3] = {1.0f, 1.0f, 1.0f};
NewtonBodySetOmega (ribidBodyBox, &omega[0]);

and it will automaticlly stop in a few seconds , what happened ? thanks again,
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby allked » Fri Apr 10, 2009 5:36 am

this is so wierd , I was wondering what will cause the NewtonBodySetOmega stop it self after a few seconds, also there is no gravity too
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby Stucuk » Fri Apr 10, 2009 6:10 am

Body going outside the worlds bounds? If so it will be frozen.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: My Scene Are static ,body not moving,:o

Postby agi_shi » Fri Apr 10, 2009 7:13 am

NewtonBodySetAngularDamping() and NewtonBodySetLinearDamping()

By default, angular and linear velocities are slightly damped every step, just use the above functions and pass "0" as the damping parameter.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: My Scene Are static ,body not moving,:o

Postby allked » Fri Apr 10, 2009 8:53 am

thanks , it rotating without automatic stop, but my scene without gravity ,what is going on ? my callback are here:

Code: Select all
float force[3];
   float mass;
   float inertia[3];
               
   NewtonBodyGetMassMatrix( nBodyBox, &mass, &inertia[0],&inertia[1],&inertia[2] );

   force[0] = 0.0f;
   force[1] = -9.8f * mass;
   force[2] = 0.0f;

   NewtonBodyAddForce( nBodyBox, &force[0] );
   


ive change my world size to
Code: Select all
float min[3];
   float max[3];
   min[0] = -70000.0;min[1] = -70000.0;min[2] = -70000.0;
   max[0] = 70000.0;max[1] = 70000.0;max[2] = 70000.0;
   NewtonSetWorldSize( nWorld, min, max );


it's still no gravity
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby allked » Fri Apr 10, 2009 9:28 am

I change NewtonBodyAddForce to NewtonBodySetForce , also with no luck,nomatter how I edit the code ,it just looks like the copy from tutorial01 , no gravity :shock:
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby allked » Fri Apr 10, 2009 12:15 pm

I've Checked the Translate value at the matrix that come out from NewtonBodyGetMatrix() they are always 0,0,0 why is that? :roll:
allked
 
Posts: 8
Joined: Thu Apr 09, 2009 2:21 pm

Re: My Scene Are static ,body not moving,:o

Postby agi_shi » Fri Apr 10, 2009 5:03 pm

How do you call NewtonUpdate()?
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: My Scene Are static ,body not moving,:o

Postby mfdesigner » Sat Apr 11, 2009 4:02 am

you need to implement tranformcallback within which to move the body and its collision object.
mfdesigner
 
Posts: 7
Joined: Sun Feb 08, 2009 7:07 pm

Re: My Scene Are static ,body not moving,:o

Postby Manawenuz » Fri Jan 08, 2010 11:26 am

Plz, UP
I have the same problem and I still haven't solved it!!!
Manawenuz
 

Re: My Scene Are static ,body not moving,:o

Postby JernejL » Fri Jan 08, 2010 1:48 pm

Manawenuz wrote:Plz, UP
I have the same problem and I still haven't solved it!!!


Please give us information on what problem and how and what you tried to solve it.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron