I serve a ball with velocity {0.0, 2.1, 4.0}, it looks good, the ball hit the ground and bounce good.
but when change the velocity to {0.0, 2.2, 4.0}, the ball bounce much lower.
and change the velocity to {0.0, 2.3, 4.0}, it looks good again.
And I compare the velocity before ball hit ground and the velocity after ball bounce:
-----------------------before ---------------------after
vY :2.1------vY:-2.42,vZ:3.32-----------vY:2.13,vZ:3.31
vY :2.2------vY:-2.47,vZ:3.30 ----------vY:1.74,vZ:3.29
vY :2.3------vY:-2.56,vZ:3.27-----------vY:2.27,vZ:3.27
so, what cause the vY reduce so much in this case?
the parameter is below:
PHYSICS_UPDATE_FPS 200.0f
Softness 0.9
Elasticity 0.9
Static friction 0.4
Dynamic friction 0.3
serve position {0.0, 0.14, 0.0}
create ball code
- Code: Select all
NewtonCollision* Collision;
m_fBallRadius = 0.020f;
Collision = NewtonCreateSphere(m_pPhysWorld, m_fBallRadius, m_fBallRadius, m_fBallRadius, m_iPhysBallID, NULL);
World = GetIdentityMatrix();
World.m_posit.m_x = 0.0f;
World.m_posit.m_y = 2.00f;
World.m_posit.m_z = 1.0f;
m_pPhysBall = NewtonCreateBody(m_pPhysWorld, Collision, &World[0][0]);
NewtonBodySetAutoSleep(m_pPhysBall,1);
// keep the player always active
NewtonBodySetFreezeState(m_pPhysBall, 0); // 0 unfreeze
NewtonBodySetMaterialGroupID (m_pPhysBall, m_iPhysBallID);
NewtonConvexCollisionCalculateInertialMatrix(Collision, &Inertia.m_x, &Origin.m_x);
//We're done with the collision object, release it
NewtonReleaseCollision(m_pPhysWorld, Collision);
//Set the callback to handle gravity
NewtonBodySetForceAndTorqueCallback (m_pPhysBall, physicsApplyForceAndTorque);
//Set mass
float Mass = 50.00f;
NewtonBodySetMassMatrix(m_pPhysBall, Mass, Mass*Inertia.m_x, Mass*Inertia.m_y, Mass*Inertia.m_z);
NewtonBodySetCentreOfMass(m_pPhysBall, &Origin.m_x);
NewtonBodySetFreezeState(m_pPhysBall, 1);