本文整理汇总了C++中dx::StepTimer::GetElapsedSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ StepTimer::GetElapsedSeconds方法的具体用法?C++ StepTimer::GetElapsedSeconds怎么用?C++ StepTimer::GetElapsedSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dx::StepTimer
的用法示例。
在下文中一共展示了StepTimer::GetElapsedSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//-----------------------------------------------------------------------------------------------------------------------------------
void Camera::Update(DX::StepTimer const& timer)
{
// If the camera is fixed we should not do any more updating
if (m_cameraMode == CameraMode::kFixed)
{
return;
}
KeyboardInput& keyboard = ScreenManager::GetKeyboardInput();
Vector2 diff = Vector2::Zero;
if (keyboard.IsKeyDown(Keyboard::Keys::Left))
{
diff.x = -1;
}
if (keyboard.IsKeyDown(Keyboard::Keys::Right))
{
diff.x = 1;
}
if (keyboard.IsKeyDown(Keyboard::Keys::Up))
{
diff.y = -1;
}
if (keyboard.IsKeyDown(Keyboard::Keys::Down))
{
diff.y = 1;
}
if (diff != Vector2::Zero)
{
diff.Normalize();
m_position += diff * (float)timer.GetElapsedSeconds() * m_panSpeed;
}
}
示例2: Update
// Updates the world.
void Game::Update(DX::StepTimer const& timer)
{
float elapsedTime = float(timer.GetElapsedSeconds());
// TODO: Add your game logic here.
elapsedTime;
}
示例3: Update
// Called once per frame. Rotates the cube, and calculates and sets the model matrix
// relative to the position transform indicated by hologramPositionTransform.
void SpinningCubeRenderer::Update(const DX::StepTimer& timer)
{
float const deltaTime = static_cast<float>(timer.GetElapsedSeconds());
float const lerpDeltaTime = deltaTime * c_lerpRate;
float3 const prevPosition = m_position;
m_position = lerp(m_position, m_targetPosition, lerpDeltaTime);
m_velocity = (prevPosition - m_position) / deltaTime;
// Rotate the cube.
// Convert degrees to radians, then convert seconds to rotation angle.
float const radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
float const totalRotation = static_cast<float>(timer.GetTotalSeconds()) * radiansPerSecond;
// Scale the cube down to 10cm
float4x4 const modelScale = make_float4x4_scale({ 0.1f });
float4x4 const modelRotation = make_float4x4_rotation_y(totalRotation);
float4x4 const modelTranslation = make_float4x4_translation(m_position);
m_modelConstantBufferData.model = modelScale * modelRotation * modelTranslation;
// Use the D3D device context to update Direct3D device-based resources.
const auto context = m_deviceResources->GetD3DDeviceContext();
// Update the model transform buffer for the hologram.
context->UpdateSubresource(
m_modelConstantBuffer.Get(),
0,
nullptr,
&m_modelConstantBufferData,
0,
0
);
}
示例4: Update
// Updates the world.
void Game::Update(DX::StepTimer const& timer)
{
PIXBeginEvent(PIX_COLOR_DEFAULT, L"Update");
float elapsedTime = float(timer.GetElapsedSeconds());
UNREFERENCED_PARAMETER(elapsedTime);
auto pad = m_gamePad->GetState(0);
if (pad.IsConnected())
{
m_gamePadButtons.Update(pad);
if (pad.IsViewPressed())
{
Windows::ApplicationModel::Core::CoreApplication::Exit();
}
}
else
{
m_gamePadButtons.Reset();
}
UpdateGame();
PIXEndEvent();
}
示例5: Update
// Updates any time-based rendering resources (currently none).
// This method must be implemented for the Overlay class.
void SampleVirtualControllerRenderer::Update(DX::StepTimer const& timer)
{
// Update the timers for fading out unused touch inputs.
float frameTime = static_cast<float>(timer.GetElapsedSeconds());
if (m_stickFadeTimer > 0) m_stickFadeTimer -= frameTime;
if (m_buttonFadeTimer > 0) m_buttonFadeTimer -= frameTime;
}
示例6: Update
//-----------------------------------------------------------------------------------------------------------------------------------
void Button::Update(DX::StepTimer const& timer)
{
UIObject::Update(timer);
if (IsActive())
{
m_clickResetTimer += (float)timer.GetElapsedSeconds();
if (m_clickResetTimer >= m_resetTime)
{
m_buttonState = ButtonState::kIdle;
}
// Lerp our current colour to the default one to create effect when mouse over button
SetColour(Color::Lerp(GetColour(), m_defaultColour, (float)timer.GetElapsedSeconds() * 3));
}
}
示例7: Update
// Updates the world.
void Sample::Update(DX::StepTimer const& timer)
{
PIXBeginEvent(PIX_COLOR_DEFAULT, L"Update");
float elapsedTime = float(timer.GetElapsedSeconds());
auto pad = m_gamePad->GetState(0);
if (pad.IsConnected())
{
m_gamePadButtons.Update(pad);
if (!m_ui->Update(elapsedTime, pad))
{
if (pad.IsViewPressed())
{
Windows::ApplicationModel::Core::CoreApplication::Exit();
}
if (pad.IsMenuPressed())
{
Windows::Xbox::UI::SystemUI::ShowAccountPickerAsync(nullptr,Windows::Xbox::UI::AccountPickerOptions::None);
}
}
}
else
{
m_gamePadButtons.Reset();
}
PIXEndEvent();
}
示例8: Update
// Updates the world
void Game::Update(DX::StepTimer const& timer)
{
float elapsedTime = float(timer.GetElapsedSeconds());
// TODO: Add your game logic here
elapsedTime;
i_render_manager->update();
}
示例9: Update
// Updates the world
void Game::Update(DX::StepTimer const& timer)
{
float elapsedTime = float(timer.GetElapsedSeconds());
// TODO: Add your game logic here
m_screenManager->Update(elapsedTime);
m_screenManager->HandleInput(elapsedTime);
}
示例10: Update
// Updates the world
void Game::Update(DX::StepTimer const& timer)
{
float elapsedTime = float(timer.GetElapsedSeconds());
// TODO: Add your game logic here
XMMATRIX m = XMMatrixIdentity();
m = XMMatrixMultiply(m, XMMatrixTranslation(0.0f, 0.0f, 0.0f));
XMStoreFloat4x4(&m_constantBufferData.model, m);
elapsedTime;
}
示例11: Update
// Updates the world.
void Sample::Update(DX::StepTimer const& timer)
{
PIXBeginEvent(PIX_COLOR_DEFAULT, L"Update");
float elapsedTime = float(timer.GetElapsedSeconds());
// Update the rotation constant
m_curRotationAngleRad += elapsedTime / 3.f;
if (m_curRotationAngleRad >= XM_2PI)
{
m_curRotationAngleRad -= XM_2PI;
}
// Rotate the cube around the origin
XMStoreFloat4x4(&m_worldMatrix, XMMatrixRotationY(m_curRotationAngleRad));
// Setup our lighting parameters
m_lightDirs[0] = XMFLOAT4(-0.577f, 0.577f, -0.577f, 1.0f);
m_lightDirs[1] = XMFLOAT4(0.0f, 0.0f, -1.0f, 1.0f);
m_lightColors[0] = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
m_lightColors[1] = XMFLOAT4(0.5f, 0.0f, 0.0f, 1.0f);
// Rotate the second light around the origin
XMMATRIX rotate = XMMatrixRotationY(-2.0f * m_curRotationAngleRad);
XMVECTOR lightDir = XMLoadFloat4(&m_lightDirs[1]);
lightDir = XMVector3Transform(lightDir, rotate);
XMStoreFloat4(&m_lightDirs[1], lightDir);
// Handle controller input for exit
auto pad = m_gamePad->GetState(0);
if (pad.IsConnected())
{
m_gamePadButtons.Update(pad);
if (pad.IsViewPressed())
{
Windows::ApplicationModel::Core::CoreApplication::Exit();
}
}
else
{
m_gamePadButtons.Reset();
}
auto kb = m_keyboard->GetState();
m_keyboardButtons.Update(kb);
if (kb.Escape)
{
Windows::ApplicationModel::Core::CoreApplication::Exit();
}
PIXEndEvent();
}
示例12: UpdateSpecularLight
void PointLightRenderer::UpdateSpecularLight(const DX::StepTimer& gameTime)
{
static float specularIntensity = 1.0f;
GamePad::State gamePadState = mGamePad->CurrentState();
if (gamePadState.IsConnected())
{
if (gamePadState.IsLeftTriggerPressed() && specularIntensity <= 1.0f)
{
specularIntensity += static_cast<float>(gameTime.GetElapsedSeconds());
specularIntensity = min(specularIntensity, 1.0f);
mPixelCBufferPerObjectData.SpecularColor = XMFLOAT3(specularIntensity, specularIntensity, specularIntensity);
}
if (gamePadState.IsRightTriggerPressed() && specularIntensity >= 0.0f)
{
specularIntensity -= (float)gameTime.GetElapsedSeconds();
specularIntensity = max(specularIntensity, 0.0f);
mPixelCBufferPerObjectData.SpecularColor = XMFLOAT3(specularIntensity, specularIntensity, specularIntensity);
}
static float specularPower = mPixelCBufferPerObjectData.SpecularPower;
if (mGamePad->IsButtonDown(GamePadButton::DPadUp) && specularPower < UCHAR_MAX)
{
specularPower += LightModulationRate * static_cast<float>(gameTime.GetElapsedSeconds());
specularPower = min(specularPower, static_cast<float>(UCHAR_MAX));
mPixelCBufferPerObjectData.SpecularPower = specularPower;
}
if (mGamePad->IsButtonDown(GamePadButton::DPadDown) && specularPower > 1.0f)
{
specularPower -= LightModulationRate * static_cast<float>(gameTime.GetElapsedSeconds());
specularPower = max(specularPower, 1.0f);
mPixelCBufferPerObjectData.SpecularPower = specularPower;
}
}
}
示例13: Update
//-----------------------------------------------------------------------------------------------------------------------------------
void RigidBody::Update(DX::StepTimer const& timer)
{
float elapsedSeconds = (float)timer.GetElapsedSeconds();
// Update the rotation and angular components
m_angularVelocity += m_angularAcceleration * elapsedSeconds;
m_parent->SetLocalRotation(m_angularVelocity * elapsedSeconds + m_parent->GetLocalRotation());
// Update the position and linear components (it IS minus because of the screen coords
m_linearVelocity += m_linearAcceleration * elapsedSeconds;
m_parent->SetLocalPosition(m_parent->GetLocalPosition() - Vector2::Transform(m_linearVelocity, Matrix::CreateRotationZ(m_parent->GetLocalRotation())) * elapsedSeconds);
}
示例14: Update
//-----------------------------------------------------------------------------------------------------------------------------------
void UIObject::Update(DX::StepTimer const& timer)
{
BaseObject::Update(timer);
m_currentLifeTime += (float)timer.GetElapsedSeconds();
if (m_currentLifeTime > m_lifeTime)
{
// This UIObject has been alive for longer than its lifetime so it dies
// and will be cleared up by whatever manager is in charge of it
Die();
}
}
示例15: Update
// Updates the world
void Game::Update(DX::StepTimer const& timer)
{
float elapsedTime = float(timer.GetElapsedSeconds());
// TODO: Add your game logic here
elapsedTime;
for(auto & player: m_players)
{
player->Update();
}
}