本文整理汇总了C++中Matrix::BuildScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::BuildScale方法的具体用法?C++ Matrix::BuildScale怎么用?C++ Matrix::BuildScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::BuildScale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VOnMouseWheel
bool ScrollCamera::VOnMouseWheel( const Vector3& vPosition, const Vector3& vDelta )
{
Matrix matScale;
if ( vDelta.y > 0.0f )
{
matScale.BuildScale( 2.0f, 2.0f, 2.0f );
m_fZoomModifier *= 0.5f;
}
else
{
m_fZoomModifier *= 2.0f;
matScale.BuildScale( 0.5f, 0.5f, 0.5f );
}
SetProjection( GetProjection() * matScale );
return false;
}
示例2: VOnMouseButtonUp
bool GameProcess::VOnMouseButtonUp( const int iButtonIndex, const Vector3& vPosition )
{
Vector3 vResolution( IRenderer::Get()->VGetScreenWidth(), IRenderer::Get()->VGetScreenHeight(), 1.0f );
Vector3 vRayPos, vRayDir;
Matrix::Unproject( vPosition, vResolution, m_pCamera->GetProjection(), m_pCamera->GetView(), vRayPos, vRayDir );
float fDistance = 0.0f;
if ( iButtonIndex == 0 )
{
if ( m_pHeightMapEntity->VPick( vRayPos, vRayDir, &fDistance ) )
{
if ( fDistance < 0.0f )
fDistance = -fDistance;
Transform& transform = m_pMrBitey->GetTransform();
if ( InputManager::Get()->GetKeyState( KEY_T ) == HELD_KEYSTATE )
{
transform.SetPosition( vRayPos + vRayDir * fDistance + Vector3::UP );
}
else
{
Vector4 vTarget = vRayPos + vRayDir * fDistance + Vector3( 0.0f, 1.0f, 0.0f );
m_pSteering->SetTargetPosition( vTarget );
}
return false;
}
}
else if ( iButtonIndex == 1 )
{
SceneNode* pSceneNode = SceneManager::Get()->VPickAndReturnClosest( vRayPos, vRayDir, &fDistance );
if ( pSceneNode )
{
Entity* pEntity = pSceneNode->VGetEntity();
if ( pEntity )
{
if ( pEntity != m_pHeightMapEntity->GetOwner() )
{
Transform& matTransform = m_pMrBitey->GetTransform();
Vector4 vPosition( pEntity->GetTransform().GetPosition() - Vector4( Vector4( 0.0f, 0.0f, -20.0f ) ) );
m_pHeightMapEntity->GetHeight( vPosition.x, vPosition.z, vPosition.y );
matTransform.SetPosition( vPosition );
InteractableComponent* pInteractable = (InteractableComponent*)pEntity->GetComponent( InteractableComponent::g_hID );
if ( pInteractable )
{
pInteractable->VOnInteract( m_pMrBitey );
}
Combat::InitiateCombat( m_pCamera, m_pMrBitey, pEntity );
}
else
{
Matrix matTransform;
matTransform.BuildScale( Vector4::ONE * 2.0f );
vRayDir.Normalize();
matTransform.SetPosition( vRayPos + vRayDir * fDistance + Vector4( 0.0f, 1.0f, 0.0f ) );
Entity* pEntity = Game::CreateEntity( matTransform );
MeshComponent* pMeshComponent = new MeshComponent();
pEntity->AddComponent( pMeshComponent );
Mesh* pMesh = Mesh::CreateBox();
pMeshComponent->SetMesh( pMesh );
pMesh->Release();
pMeshComponent->Start();
pMeshComponent->Release();
TalkerComponent* pTalker = new TalkerComponent( "Dialogue.xml" );
pEntity->AddComponent( pTalker );
pTalker->Start();
pTalker->Release();
StateMachineComponent* pStateMachine = new StateMachineComponent();
pEntity->AddComponent( pStateMachine );
//pStateMachine->Start();
pStateMachine->Release();
Character* pCharacter = new Character();
XmlResource* pResource = AssetManager::Get().GetAsset<XmlResource>( "CombatAbilities.xml" );
if ( pResource )
{
auto pElement = pResource->GetRoot()->FirstChildElement();
while ( pElement )
{
CombatAbility ability;
ability.VFromXML( pElement );
pCharacter->AddAbility( ability );
pElement = pElement->NextSiblingElement( "Ability" );
}
}
pEntity->AddComponent( pCharacter );
pCharacter->Release();
//.........这里部分代码省略.........
示例3: VOnUpdate
void GameProcess::VOnUpdate( const float fDeltaSeconds )
{
const Transform& matTransform = m_pMrBitey->GetTransform();
Vector4 vPosition = matTransform.GetPosition();
Vector4 vForward = matTransform.GetDirection().Normalize();
Vector4 vCameraPosition = vPosition - vForward * 10.0f + Vector4( 0.0f, 5.0f, 0.0f );
// m_pCamera->SetPosition( vCameraPosition );
// m_pCamera->SetDirection( vForward );
Vector3 vResolution( (float)IRenderer::Get()->VGetScreenWidth(), (float)IRenderer::Get()->VGetScreenHeight(), 1.0f );
Vector3 vRayPos, vRayDir;
Matrix::Unproject( InputManager::Get()->GetMousePos(), vResolution, m_pCamera->GetProjection(), m_pCamera->GetView(), vRayPos, vRayDir );
float fDistance = 0.0f;
if ( m_pHeightMapEntity->VPick( vRayPos, vRayDir, &fDistance ) )
{
Matrix matTransform;
matTransform.BuildScale( Vector4::ONE * 2.0f );
vRayDir.Normalize();
matTransform.SetPosition( vRayPos + vRayDir * fDistance + Vector4( 0.0f, 0.0f, 0.0f ) );
//m_pMrBitey->SetTransform( matTransform );
}
((StructuredMaterial<Vector4>*)m_pHeightMapEntity->GetMaterial())->GetData() = m_pAtmosphere->GetAtmosphericSettings().v3LightPos;
m_pCamera->SetTarget( m_pMrBitey->GetTransform().GetPosition() );
Vector4 vAngles;
if ( InputManager::Get()->GetKeyState( KEY_D ) != NONE_KEYSTATE )
{
vAngles.y -= 1.0f;
}
if ( InputManager::Get()->GetKeyState( KEY_A ) != NONE_KEYSTATE )
{
vAngles.y += 1.0f;
}
if ( InputManager::Get()->GetKeyState( KEY_W ) != NONE_KEYSTATE )
{
vAngles.x += 1.0f;
}
if ( InputManager::Get()->GetKeyState( KEY_S ) != NONE_KEYSTATE )
{
vAngles.x -= 1.0f;
}
m_pCamera->SetAngleDelta( vAngles * fDeltaSeconds );
m_pCamera->SetDistanceDelta(- InputManager::Get()->GetMouseWheelDelta().y );
static const float speed = 1000.0f;
if (InputManager::Get()->GetKeyState( KEY_UPARROW ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(Vector3::FORWARD * fDeltaSeconds * speed);
}
if (InputManager::Get()->GetKeyState( KEY_RIGHTARROW ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(Vector3::RIGHT * fDeltaSeconds * speed);
}
if (InputManager::Get()->GetKeyState( KEY_DOWNARROW ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(-Vector3::FORWARD * fDeltaSeconds * speed);
}
if (InputManager::Get()->GetKeyState( KEY_LEFTARROW ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(-Vector3::RIGHT * fDeltaSeconds * speed);
}
if (InputManager::Get()->GetKeyState( KEY_SPACE ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(Vector3::UP * fDeltaSeconds * speed);
}
if (InputManager::Get()->GetKeyState( KEY_X ) != NONE_KEYSTATE )
{
m_pMrBitey->GetTransform().Move(-Vector3::UP * fDeltaSeconds * speed);
}
}
示例4: VOnInit
//.........这里部分代码省略.........
pSplattingMaterial->AddTextureRegister( "BlendMap" );
ITexture* pTexture = AssetManager::Get().GetAsset<ITexture>( "Desert.png" );
pSplattingMaterial->SetTexture( 0, pTexture );
pTexture = AssetManager::Get().GetAsset<ITexture>( "Grass.png" );
pSplattingMaterial->SetTexture( 1, pTexture );
pTexture = AssetManager::Get().GetAsset<ITexture>( "Water.png" );
pSplattingMaterial->SetTexture( 2, pTexture );
pTexture = AssetManager::Get().GetAsset<ITexture>( "Snow.png" );
pSplattingMaterial->SetTexture( 3, pTexture );
pTexture = AssetManager::Get().GetAsset<ITexture>( "Rock.png" );
pSplattingMaterial->SetTexture( 4, pTexture );
pSplattingMaterial->SetTexture( 5, pBlendMapTexture );
m_pHeightMapEntity->SetMaterial( pSplattingMaterial );
pSplattingMaterial->Release();
pProgram->Release();
pPixelShader->Release();
pVertexShader->Release();
pBlendMapTexture->Release();
/*pEntity = Game::CreateEntity();
SkyBox* pSkyBox = new SkyBox();
pEntity->AddComponent( pSkyBox );
pSkyBox->Start();
pSkyBox->Release();*/
Matrix mat;
MeshComponent* pMeshComponent = NULL;
Mesh* pMesh = NULL;
pMesh = Mesh::CreateBox();
mat.BuildScale( Vector4::ONE * 2.0f );
mat.SetPosition( Vector4( 1900.0f, 0.0f, 1900.0f ) );
mat.SetPosition( Vector4( 0.0f, 0.0f, 0.0f ) );
pEntity = Game::CreateEntity( mat );
pMeshComponent = new MeshComponent();
// pEntity->AddComponent( pMeshComponent );
pMeshComponent->SetMesh( pMesh );
pMesh->Release();
pMeshComponent->Start();
pMeshComponent->Release();
m_pSteering = new SteeringComponent();
pEntity->AddComponent( m_pSteering );
m_pSteering->SetSpeed( 15.0f );
m_pSteering->SetHeightOffset( 1.0f );
m_pSteering->Start();
m_pSteering->Release();
Character* pCharacter = new Character();
XmlResource* pResource = AssetManager::Get().GetAsset<XmlResource>( "CombatAbilities.xml" );
if ( pResource )
{
auto pElement = pResource->GetRoot()->FirstChildElement();
while ( pElement )
{
CombatAbility ability;
ability.VFromXML( pElement );
pCharacter->AddAbility( ability );
pElement = pElement->NextSiblingElement( "Ability" );
}
}
pEntity->AddComponent( pCharacter );
pCharacter->Release();
GameHUDComponent* pGameHud = new GameHUDComponent();
pEntity->AddComponent( pGameHud );
pGameHud->Start();
pGameHud->Release();
m_pMrBitey = pEntity;
pEntity = Game::CreateEntity();
m_pAtmosphere = new AtmosphericScattering();
pEntity->AddComponent( m_pAtmosphere );
m_pAtmosphere->Start();
m_pAtmosphere->Release();
Transform waterPosition;
waterPosition.SetPosition( 0.0f, 5.0f, 0.0f );
pEntity = Game::CreateEntity( waterPosition );
WaterPlane* pWater = new WaterPlane();
pEntity->AddComponent( pWater );
pWater->Start();
pWater->Release();
}