void dVehicleSingleBody::StatesToRigidBody(dFloat timestep) { dComplementaritySolver::dBodyState* const chassisBody = GetBody(); dVector force(chassisBody->GetForce()); dVector torque(chassisBody->GetTorque()); NewtonBodySetForce(m_newtonBody, &force[0]); NewtonBodySetTorque(m_newtonBody, &torque[0]); dVehicleInterface::StatesToRigidBody(timestep); }
void LaunchPuck() { if (!m_launched) { m_launched = true; NewtonInvalidateCache (NewtonBodyGetWorld(m_puckBody)); dVector zeros(0.0f, 0.0f, 0.0f, 0.0f); NewtonBodySetVelocity(m_puckBody, &zeros.m_x); NewtonBodySetOmega(m_puckBody, &zeros.m_x); NewtonBodySetForce(m_puckBody, &zeros.m_x); NewtonBodySetTorque(m_puckBody, &zeros.m_x); dVector vel(171.299469f, 0.0f, 0.0f); NewtonBodySetVelocity(m_puckBody, &vel.m_x); } }
static void MagneticFieldNoForce (const NewtonBody* body, dFloat timestep, int threadIndex) { dMatrix matrix; dVector zero (0.0f, 0.0f, 0.0f, 0.0f); NewtonBodySetForce (body, &zero[0]); NewtonBodySetTorque (body, &zero[0]); NewtonBodySetOmega (body, &zero[0]); NewtonBodySetVelocity (body, &zero[0]); // telepor the magnetic field trigger to the center of the core Magnet* magnet; magnet = (Magnet*)NewtonBodyGetUserData(body); NewtonBodyGetMatrix (magnet->m_magneticCore, &matrix[0][0]); dMatrix posit (GetIdentityMatrix()); posit.m_posit = matrix.m_posit; NewtonBodySetMatrix (body, &posit[0][0]); }
void NzPhysObject::ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex) { NazaraUnused(timeStep); NazaraUnused(threadIndex); NzPhysObject* me = static_cast<NzPhysObject*>(NewtonBodyGetUserData(body)); if (!NzNumberEquals(me->m_gravityFactor, 0.f)) me->m_forceAccumulator += me->m_world->GetGravity() * me->m_gravityFactor * me->m_mass; /*for (std::set<PhysObjectListener*>::iterator it = me->m_listeners.begin(); it != me->m_listeners.end(); ++it) (*it)->PhysObjectApplyForce(me);*/ NewtonBodySetForce(body, me->m_forceAccumulator); NewtonBodySetTorque(body, me->m_torqueAccumulator); me->m_torqueAccumulator.Set(0.f); me->m_forceAccumulator.Set(0.f); ///TODO: Implanter la force gyroscopique? }
void dNewtonDynamicBody::OnForceAndTorque(dFloat timestep, int threadIndex) { NewtonBodySetForce(m_body, &m_externalForce[0]); NewtonBodySetTorque(m_body, &m_externalTorque[0]); }
void iPhysics::setTorque(void* newtonBody, const iaVector3f& torque) { NewtonBodySetTorque(static_cast<const NewtonBody*>(newtonBody), torque.getData()); }