本文整理汇总了C++中BoxCollider::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxCollider::SetSize方法的具体用法?C++ BoxCollider::SetSize怎么用?C++ BoxCollider::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxCollider
的用法示例。
在下文中一共展示了BoxCollider::SetSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePlayer
// Creates a player
GameObject* GameManager::CreatePlayer( uint32_t index, const XMFLOAT3& position, const XMFLOAT3& scale )
{
Scene* scene = Scene::GetInstance();
GameObject* player = scene->AddGameObject( "Player_" + std::to_string( index ) );
ID3D11Device* device = player->GetDevice();
ID3D11DeviceContext* deviceContext = player->GetDeviceContext();
// Set the player's transform info
Transform* transform = player->GetTransform();
transform->SetPosition( position );
transform->SetScale( scale );
// Add the collider to the player
BoxCollider* collider = player->AddComponent<BoxCollider>();
collider->SetSize( XMFLOAT3( 1, 1, 1 ) );
// Add the rigid body to the player
Rigidbody* rigidbody = player->AddComponent<Rigidbody>();
rigidbody->SetMass( 0 );
// Add the default material to the player
DefaultMaterial* material = player->AddComponent<DefaultMaterial>();
material->LoadDiffuseMap( "Textures\\Rocks2.jpg" );
material->LoadNormalMap( "Textures\\Rocks2Normals.jpg" );
material->SetDirectionalLight( StageLight );
// Add the mesh renderer to the player
MeshRenderer* meshRenderer = player->AddComponent<MeshRenderer>();
meshRenderer->SetMaterial( material );
meshRenderer->SetMesh( MeshLoader::Load( "Models\\cube.obj", device, deviceContext ) );
return player;
}
示例2: CreateArrow
// Creates an arrow game object
GameObject* GameManager::CreateArrow( const XMFLOAT3& position, const XMFLOAT3& force )
{
static const XMFLOAT3 ArrowSize = { 1, 0.1f, 1.0f };
Scene* scene = Scene::GetInstance();
ID3D11Device* device = _gameObject->GetDevice();
ID3D11DeviceContext* deviceContext = _gameObject->GetDeviceContext();
// Create the arrow object
GameObject* arrow = scene->AddGameObject( _gameObject->GetName() + "_Arrow_" + std::to_string( _arrowCount++ ) );
// Set some transform info
Transform* transform = arrow->GetTransform();
transform->SetPosition( position );
// Add the arrow's collider
BoxCollider* collider = arrow->AddComponent<BoxCollider>();
collider->SetSize( ArrowSize );
// Add the arrow's rigidbody
Rigidbody* rigidbody = arrow->AddComponent<Rigidbody>();
rigidbody->SetMass( 1.0f );
// Set the arrow's collision callback
GameObject::CollisionCallback callback = std::bind( &GameManager::OnArrowCollide, this, _1 );
arrow->AddEventListener( "OnArrowCollide", callback );
// Add a default material
DefaultMaterial* material = arrow->AddComponent<DefaultMaterial>();
material->LoadDiffuseMap( "Textures\\SolidWhite.png" );
material->SetDirectionalLight( StageLight );
// Add a mesh renderer
MeshRenderer* meshRenderer = arrow->AddComponent<MeshRenderer>();
meshRenderer->SetMaterial( material );
meshRenderer->SetMesh( MeshLoader::Load( "Models\\arrow.obj", device, deviceContext ) );
return arrow;
}