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


C++ PhysicsBody::get_global_transform方法代码示例

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


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

示例1: _update_friction

void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {

	//calculate the impulse, so that the wheels don't move sidewards
	int numWheel = wheels.size();
	if (!numWheel)
		return;

	m_forwardWS.resize(numWheel);
	m_axle.resize(numWheel);
	m_forwardImpulse.resize(numWheel);
	m_sideImpulse.resize(numWheel);

	int numWheelsOnGround = 0;


	//collapse all those loops into one!
	for (int i=0;i<wheels.size();i++)
	{
		VehicleWheel& wheelInfo = *wheels[i];
		if (wheelInfo.m_raycastInfo.m_isInContact)
			numWheelsOnGround++;
		m_sideImpulse[i] = real_t(0.);
		m_forwardImpulse[i] = real_t(0.);

	}

	{

		for (int i=0;i<wheels.size();i++)
		{

			VehicleWheel& wheelInfo = *wheels[i];


			if (wheelInfo.m_raycastInfo.m_isInContact)
			{

				//const btTransform& wheelTrans = getWheelTransformWS( i );

				Matrix3 wheelBasis0 = wheelInfo.m_worldTransform.basis;//get_global_transform().basis;

				m_axle[i] = wheelBasis0.get_axis(Vector3::AXIS_X);
				//m_axle[i] = wheelInfo.m_raycastInfo.m_wheelAxleWS;

				const Vector3& surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS;
				real_t proj = m_axle[i].dot(surfNormalWS);
				m_axle[i] -= surfNormalWS * proj;
				m_axle[i] = m_axle[i].normalized();

				m_forwardWS[i] = surfNormalWS.cross(m_axle[i]);
				m_forwardWS[i].normalize();


				_resolve_single_bilateral(s, wheelInfo.m_raycastInfo.m_contactPointWS,
						       wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS,
							m_axle[i],m_sideImpulse[i]);

				m_sideImpulse[i] *= sideFrictionStiffness2;


			}
		}
	}

	real_t sideFactor = real_t(1.);
	real_t fwdFactor = 0.5;

	bool sliding = false;
	{
		for (int wheel =0;wheel <wheels.size();wheel++)
		{
			VehicleWheel& wheelInfo = *wheels[wheel];


			//class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;

			real_t	rollingFriction = 0.f;

			if (wheelInfo.m_raycastInfo.m_isInContact)
			{
				if (engine_force != 0.f)
				{
					rollingFriction = -engine_force* s->get_step();
				} else
				{
					real_t defaultRollingFrictionImpulse = 0.f;
					float cbrake = MAX(wheelInfo.m_brake,brake);
					real_t maxImpulse = cbrake ? cbrake : defaultRollingFrictionImpulse;
					btVehicleWheelContactPoint contactPt(s,wheelInfo.m_raycastInfo.m_groundObject,wheelInfo.m_raycastInfo.m_contactPointWS,m_forwardWS[wheel],maxImpulse);
					rollingFriction = _calc_rolling_friction(contactPt);
				}
			}

			//switch between active rolling (throttle), braking and non-active rolling friction (no throttle/break)




			m_forwardImpulse[wheel] = real_t(0.);
			wheelInfo.m_skidInfo= real_t(1.);
//.........这里部分代码省略.........
开发者ID:03050903,项目名称:godot,代码行数:101,代码来源:vehicle_body.cpp


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