当前位置: 首页>>代码示例>>C++>>正文


C++ Mat4x4::GetUp方法代码示例

本文整理汇总了C++中Mat4x4::GetUp方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::GetUp方法的具体用法?C++ Mat4x4::GetUp怎么用?C++ Mat4x4::GetUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mat4x4的用法示例。


在下文中一共展示了Mat4x4::GetUp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VUpdate

void PhysicsComponent::VUpdate(int deltaMs)
{
    // get the transform component
    shared_ptr<TransformComponent> pTransformComponent = MakeStrongPtr(m_pOwner->GetComponent<TransformComponent>(TransformComponent::g_Name));
    if (!pTransformComponent)
    {
        GCC_ERROR("No transform component!");
        return;
    }

    // get the direction the object is facing
    Mat4x4 transform = pTransformComponent->GetTransform();

	if (m_acceleration != 0)
    {
        // calculate the acceleration this frame

        float accelerationToApplyThisFrame = m_acceleration / 1000.f * (float)deltaMs;

        // Get the current velocity vector and convert to a scalar.  The velocity vector is a combination of 
        // the direction this actor is going in and the speed of the actor.  The scalar is just the speed 
        // component.
        Vec3 velocity(m_pGamePhysics->VGetVelocity(m_pOwner->GetId()));
        float velocityScalar = velocity.Length();

		Vec3 direction(transform.GetDirection());
		m_pGamePhysics->VApplyForce(direction, accelerationToApplyThisFrame, m_pOwner->GetId());

        // logging
        // [rez] Comment this back in if you want to debug the physics thrust & rotation stuff.  It spams quite 
        // a bit of info the output window so I'm commenting it out for now.
/*
        GCC_LOG("Actor", "Acceleration: " + ToStr(accelerationToApplyThisFrame) + "; velocityScalar: " + ToStr(velocityScalar) + \
                "; direction: " + ToStr(direction) + "; direction.Length(): " + ToStr(direction.Length()) + \
                "; velocity: " + ToStr(velocity) + "; velocity.Length(): " + ToStr(velocity.Length()));
*/
    }

    if (m_angularAcceleration != 0)
    {
        // calculate the acceleration this frame
        float angularAccelerationToApplyThisFrame = m_angularAcceleration / 1000.f * (float)deltaMs;
		m_pGamePhysics->VApplyTorque(transform.GetUp(), angularAccelerationToApplyThisFrame, m_pOwner->GetId());

        // logging
        // [rez] Comment this back in if you want to debug the physics thrust & rotation stuff.  It spams quite 
        // a bit of info the output window so I'm commenting it out for now.
        //GCC_LOG("Actor", "Angular Acceleration: " + ToStr(angularAccelerationToApplyThisFrame) );
    }
}
开发者ID:AsbjoernS,项目名称:gamecode4,代码行数:50,代码来源:PhysicsComponent.cpp


注:本文中的Mat4x4::GetUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。