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


C++ Box::BoxToAABB方法代码示例

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


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

示例1: CheckDynamicCollisions


//.........这里部分代码省略.........
				{
					if(boxItemCmp->GetTarget() == m_pParent || boxItemCmp->GetAttached())
					{
						//we are pulling the box so don't check collision with it
						return;
					}
				}

				switch( pCurCollision->GetParent()->GetType() )
				{
				case OBJ_GOO:
					{
						return;
					}
				case OBJ_PLUG:
					{
						if( ((CComponent_PlugCollision*)pCurCollision)->GetPlugged() )
						{
							return;
						}
						break;
					}
				case OBJ_CORK:
					{
						if( ((CComponent_CorkCollision*)pCurCollision)->GetCorked() )
						{
							return;
						}
						break;
					}
				};

				// make sure there is a collision component and that it is not us, also make sure that the object we 
				// are checking against is a box.
				// get a pointer to that box
				Box* crate = (Box*)( pCurCollision->GetParent()->GetCollidableObject() );

				CComponent_Item* pCurItem = (CComponent_Item*)pCurCollision->GetParent()->GetComponent( ECOMP_ITEM );
				if( pCurItem )
				{
					if( pCurItem->GetTarget() )
						return;
				}

				// check the players aabb against the crate or cork
				if (crate->BoxToAABB ( *m_pPlayerCollisionVolume, vec2f( CP.x, CP.y ) , Direction))
				{
					m_fLastOffset = vec3f( Direction.x, Direction.y, 0.0f );
					vec3f MoveDirection = vec3f (Direction.x, Direction.y, 0.0f).normalize();

					float fTimePercentage = 1.0f - ( pCurCollision->GetTimeLeft() / 0.5f );
					if( fTimePercentage > 1.0f ) fTimePercentage = 1.0f;
					if( fTimePercentage < 0.0f ) fTimePercentage = 0.0f;

					float fDirection = dot_product( MoveDirection, vec3f( 0.0f, -1.0f, 0.0f ) );
					if( fDirection > 0.5f )
					{
						CleanOffset( vec2f( Direction.x, Direction.y ) * -1.0f * fTimePercentage );
						if( !( pCurCollision->GetTimeLeft() > 0.0f ) )
							CleanForce( vec2f( Direction.x, Direction.y ) * -1.0f );
						if( pCurCollision->CollidingGround() )
							m_bCollidingGround = true;
					}
					else if( fDirection < -0.5f )
					{
						float fSided = pCurCollision->GetPos2DClean().x - GetPos2DClean().x;
						// Normalize the float.
						if( fSided > 0.0f )
							fSided = 1.0f;
						else
							fSided = -1.0f;

						pCurCollision->CleanOffset( vec2f( Direction.x + fSided * 4.0f, Direction.y ) * 0.75f * fTimePercentage );
						pCurCollision->CleanForce( vec2f( Direction.x + fSided * 2.0f, Direction.y ) * 0.25f * fTimePercentage );
					}
					else
					{
						pCurCollision->CleanOffset( vec2f( Direction.x, Direction.y ) * 0.5f * fTimePercentage );
						pCurCollision->CleanForce( vec2f( Direction.x, Direction.y ) * 0.5f * fTimePercentage );
						CleanOffset( vec2f( Direction.x, Direction.y ) * -0.5f * fTimePercentage );
						CleanForce( vec2f( Direction.x, Direction.y ) * -0.5f * fTimePercentage );
					}
				}
				break;
			}
		case VMT_SPHERE:
			{
				break;
			}
		default:
			break;
		};

	}
	if( m_pParent->GetWorldPos().x > 5000 )
	{
		// Do stuff
		int x = 50;
	}
}
开发者ID:Ethanthecrazy,项目名称:PudgeNSludge,代码行数:101,代码来源:CComponent_PlayerCollision.cpp


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