本文整理汇总了C++中IPhysicsObject::GetInertia方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicsObject::GetInertia方法的具体用法?C++ IPhysicsObject::GetInertia怎么用?C++ IPhysicsObject::GetInertia使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicsObject
的用法示例。
在下文中一共展示了IPhysicsObject::GetInertia方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Activate
void CPhysMotor::Activate( void )
{
BaseClass::Activate();
// This gets called after all objects spawn and after all objects restore
if ( m_attachedObject == NULL )
{
CBaseEntity *pAttach = gEntList.FindEntityByName( NULL, m_nameAttach, NULL );
if ( pAttach && pAttach->GetMoveType() == MOVETYPE_VPHYSICS )
{
m_attachedObject = pAttach;
IPhysicsObject *pPhys = m_attachedObject->VPhysicsGetObject();
CalculateAcceleration();
matrix3x4_t matrix;
pPhys->GetPositionMatrix( matrix );
Vector motorAxis_ls;
VectorIRotate( m_motor.m_axis, matrix, motorAxis_ls );
float inertia = DotProductAbs( pPhys->GetInertia(), motorAxis_ls );
m_motor.m_maxTorque = inertia * m_motor.m_inertiaFactor * (m_angularAcceleration + m_additionalAcceleration);
m_motor.m_restistanceDamping = 1.0f;
}
}
if ( m_attachedObject )
{
IPhysicsObject *pPhys = m_attachedObject->VPhysicsGetObject();
// create a hinge constraint for this object?
if ( m_spawnflags & SF_MOTOR_HINGE )
{
// UNDONE: Don't do this on restore?
if ( !m_pHinge )
{
constraint_hingeparams_t hingeParams;
hingeParams.Defaults();
hingeParams.worldAxisDirection = m_motor.m_axis;
hingeParams.worldPosition = GetLocalOrigin();
m_pHinge = physenv->CreateHingeConstraint( g_PhysWorldObject, pPhys, NULL, hingeParams );
m_pHinge->SetGameData( (void *)this );
}
if ( m_spawnflags & SF_MOTOR_NOCOLLIDE )
{
physenv->DisableCollisions( pPhys, g_PhysWorldObject );
}
}
else
{
m_pHinge = NULL;
}
// NOTE: On restore, this path isn't run because m_pController will not be NULL
if ( !m_pController )
{
m_pController = physenv->CreateMotionController( &m_motor );
m_pController->AttachObject( m_attachedObject->VPhysicsGetObject() );
if ( m_spawnflags & SF_MOTOR_START_ON )
{
TurnOn();
}
}
}
// Need to do this on restore since there's no good way to save this
if ( m_pController )
{
m_pController->SetEventHandler( &m_motor );
}
}