本文整理汇总了C++中dx::StepTimer::GetTotalSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ StepTimer::GetTotalSeconds方法的具体用法?C++ StepTimer::GetTotalSeconds怎么用?C++ StepTimer::GetTotalSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dx::StepTimer
的用法示例。
在下文中一共展示了StepTimer::GetTotalSeconds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
// Called once per frame.
void DynamicCubemapRenderer::Update(DX::StepTimer const& timer)
{
m_controller->Update();
// Update the view matrix based on the camera position.
m_camera->SetViewParameters(
m_controller->get_Position(), // The point the camera is at.
m_controller->get_LookPoint(), // The point to look towards.
float3(0, 1, 0) // The up-vector (+Y).
);
// Update the position of the cube and sphere objects.
XMStoreFloat4x4(
&m_cubeRotation,
XMMatrixTranspose(
XMMatrixRotationY(static_cast<float>(timer.GetTotalSeconds()) / 4 * XM_PIDIV4)
)
);
XMStoreFloat4x4(
&m_cube2Rotation,
XMMatrixTranspose(
XMMatrixRotationX(static_cast<float>(timer.GetTotalSeconds()) / 4 * XM_PIDIV4)
)
);
XMStoreFloat4x4(
&m_sphereRotation,
XMMatrixTranspose(XMMatrixTranslation(0.0f, 0.0f, 0.0f))
);
}
示例2: Update
// Called once per frame, creates a Y rotation based on elapsed time.
void ShadowSceneRenderer::Update(DX::StepTimer const& timer)
{
// Convert degrees to radians, then convert seconds to rotation angle.
float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
double totalRotation = timer.GetTotalSeconds() * radiansPerSecond;
// Uncomment the following line of code to oscillate the cube instead of
// rotating it. Useful for testing different margin coefficients in the
// pixel shader.
//totalRotation = 9.f + cos(totalRotation) *.2;
float animRadians = (float)fmod(totalRotation, XM_2PI);
// Prepare to pass the view matrix, and updated model matrix, to the shader.
XMStoreFloat4x4(&m_rotatedModelBufferData.model, XMMatrixTranspose(XMMatrixRotationY(animRadians)));
// If the shadow dimension has changed, recreate it.
D3D11_TEXTURE2D_DESC desc = { 0 };
if (m_shadowMap != nullptr)
{
m_shadowMap->GetDesc(&desc);
if (m_shadowMapDimension != desc.Height)
{
InitShadowMap();
}
}
}
示例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: XMConvertToRadians
// Called once per frame, rotates the cube and calculates the model and view matrices.
void Sample3DSceneRenderer::Update(DX::StepTimer const& timer)
{
if (!m_tracking)
{
// Convert degrees to radians, then convert seconds to rotation angle
float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
double totalRotation = timer.GetTotalSeconds() * radiansPerSecond;
float radians = static_cast<float>(fmod(totalRotation, XM_2PI));
Rotate(radians);
}
}
示例5: Update
// Updates the world.
void Game::Update(DX::StepTimer const& timer)
{
Vector3 eye(0.0f, 0.7f, 1.5f);
Vector3 at(0.0f, -0.1f, 0.0f);
m_view = Matrix::CreateLookAt(eye, at, Vector3::UnitY);
m_world = Matrix::CreateRotationY(float(timer.GetTotalSeconds() * XM_PIDIV4));
m_batchEffect->SetView(m_view);
m_batchEffect->SetWorld(Matrix::Identity);
#ifdef DXTK_AUDIO
m_audioTimerAcc -= (float)timer.GetElapsedSeconds();
if (m_audioTimerAcc < 0)
{
if (m_retryDefault)
{
m_retryDefault = false;
if (m_audEngine->Reset())
{
// Restart looping audio
m_effect1->Play(true);
}
}
else
{
m_audioTimerAcc = 4.f;
m_waveBank->Play(m_audioEvent++);
if (m_audioEvent >= 11)
m_audioEvent = 0;
}
}
#endif
auto pad = m_gamePad->GetState(0);
if (pad.IsConnected())
{
if (pad.IsViewPressed())
{
PostQuitMessage(0);
}
}
auto kb = m_keyboard->GetState();
if (kb.Escape)
{
PostQuitMessage(0);
}
}
示例6: Update
// Called once per frame, updates the scene state.
void Game::Update(DX::StepTimer const& timer)
{
auto timeDelta = static_cast<float>(timer.GetElapsedSeconds());
// Update animated models.
m_skinnedMeshRenderer.UpdateAnimation(timeDelta, m_meshModels);
// Rotate scene.
m_rotation = static_cast<float>(timer.GetTotalSeconds()) * 0.5f;
// Update the "time" variable for the glow effect.
for (float &time : m_time)
{
time = std::max<float>(0.0f, time - timeDelta);
}
}
示例7: eye
void DirectXTK3DSceneRenderer::Update(DX::StepTimer const& timer)
{
Vector3 eye(0.0f, 0.7f, 1.5f);
Vector3 at(0.0f, -0.1f, 0.0f);
m_view = Matrix::CreateLookAt(eye, at, Vector3::UnitY);
m_world = Matrix::CreateRotationY( float(timer.GetTotalSeconds() * XM_PIDIV4) );
m_batchEffect->SetView(m_view);
m_batchEffect->SetWorld(Matrix::Identity);
m_audioTimerAcc -= (float)timer.GetElapsedSeconds();
if (m_audioTimerAcc < 0)
{
if (m_retryDefault)
{
m_retryDefault = false;
if (m_audEngine->Reset())
{
// Restart looping audio
m_effect1->Play(true);
}
}
else
{
m_audioTimerAcc = 4.f;
m_waveBank->Play(m_audioEvent++);
if (m_audioEvent >= 11)
m_audioEvent = 0;
}
}
if (!m_audEngine->IsCriticalError() && m_audEngine->Update())
{
// Setup a retry in 1 second
m_audioTimerAcc = 1.f;
m_retryDefault = true;
}
}
示例8: 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(DX::StepTimer const& timer)
{
// Rotate the cube.
// Convert degrees to radians, then convert seconds to rotation angle.
const float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
const double totalRotation = timer.GetTotalSeconds() * radiansPerSecond;
const float radians = static_cast<float>(fmod(totalRotation, XM_2PI));
const XMMATRIX modelRotation = XMMatrixRotationY(-radians);
// Position the cube.
const XMMATRIX modelTranslation = XMMatrixTranslationFromVector(XMLoadFloat3(&m_position));
// Multiply to get the transform matrix.
// Note that this transform does not enforce a particular coordinate system. The calling
// class is responsible for rendering this content in a consistent manner.
const XMMATRIX modelTransform = XMMatrixMultiply(modelRotation, modelTranslation);
// The view and projection matrices are provided by the system; they are associated
// with holographic cameras, and updated on a per-camera basis.
// Here, we provide the model transform for the sample hologram. The model transform
// matrix is transposed to prepare it for the shader.
XMStoreFloat4x4(&m_modelConstantBufferData.model, XMMatrixTranspose(modelTransform));
// Loading is asynchronous. Resources must be created before they can be updated.
if (!m_loadingComplete)
{
return;
}
// 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
);
}