• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ dx::StepTimer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dx::StepTimer的典型用法代码示例。如果您正苦于以下问题:C++ StepTimer类的具体用法?C++ StepTimer怎么用?C++ StepTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StepTimer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
    );
}
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:32,代码来源:DynamicCubemapRenderer.cpp


示例2: 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
        );
}
开发者ID:AmazingJaze,项目名称:Windows-universal-samples,代码行数:37,代码来源:SpinningCubeRenderer.cpp


示例3: 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);
    }
}
开发者ID:walbourn,项目名称:directxtk-samples,代码行数:53,代码来源:Game.cpp


示例4: 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();
        }
    }
}
开发者ID:dbremner,项目名称:old-Windows8-samples,代码行数:29,代码来源:ShadowSceneRenderer.cpp


示例5: 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;
	}
}
开发者ID:AlanWills,项目名称:UnderSiege_DirectX,代码行数:35,代码来源:Camera.cpp


示例6: 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();
}
开发者ID:facybenbook,项目名称:xbox-live-samples,代码行数:31,代码来源:Leaderboards.cpp


示例7: 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();
}
开发者ID:heatha7979,项目名称:xbox-live-api,代码行数:27,代码来源:Game.cpp


示例8: Update

// Updates the text to be displayed.
void SampleFpsTextRenderer::Update(DX::StepTimer const& timer)
{
	// Update display text.
	uint32 fps = timer.GetFramesPerSecond();

	m_text = (fps > 0) ? std::to_wstring(fps) + L" FPS" : L" - FPS";

	ComPtr<IDWriteTextLayout> textLayout;
	DX::ThrowIfFailed(
		m_deviceResources->GetDWriteFactory()->CreateTextLayout(
			m_text.c_str(),
			(uint32) m_text.length(),
			m_textFormat.Get(),
			240.0f, // Max width of the input text.
			50.0f, // Max height of the input text.
			&textLayout
			)
		);

	DX::ThrowIfFailed(
		textLayout.As(&m_textLayout)
		);

	DX::ThrowIfFailed(
		m_textLayout->GetMetrics(&m_textMetrics)
		);
}
开发者ID:terriblememory,项目名称:imgui,代码行数:28,代码来源:SampleFpsTextRenderer.cpp


示例9: 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));
	}
}
开发者ID:AlanWills,项目名称:UnderSiege_DirectX,代码行数:17,代码来源:Button.cpp


示例10: 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;
}
开发者ID:OmegaSyrus,项目名称:COMP3501-Final-Project,代码行数:9,代码来源:SampleVirtualControllerRenderer.cpp


示例11: 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);
	}
}
开发者ID:Mixone-FinallyHere,项目名称:MixSecond,代码行数:17,代码来源:Game.cpp


示例12: Update

// Updates the world.
void Game::Update(DX::StepTimer const& timer)
{
    float elapsedTime = float(timer.GetElapsedSeconds());

    // TODO: Add your game logic here.
    elapsedTime;
}
开发者ID:zhiangf,项目名称:sobriquet,代码行数:8,代码来源:Game.cpp


示例13: 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();
}
开发者ID:ka-s,项目名称:DTK_test,代码行数:9,代码来源:Game.cpp


示例14: 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);
}
开发者ID:AlanWills,项目名称:SpinOut_Source,代码行数:9,代码来源:Game.cpp


示例15: 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;
}
开发者ID:fixedFTGJ,项目名称:Coursework,代码行数:11,代码来源:Game.cpp


示例16: 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();
}
开发者ID:pirlonms,项目名称:Xbox-ATG-Samples,代码行数:56,代码来源:SimpleLightingUWP12.cpp


示例17: 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;
    }
}
开发者ID:AlvisDEV,项目名称:directxtk-samples,代码行数:42,代码来源:DirectXTK3DSceneRenderer.cpp


示例18: 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;
		}
	}
}
开发者ID:prithiraj2005,项目名称:CrossPlatformRenderingEngine,代码行数:41,代码来源:PointLightRenderer.cpp


示例19: 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();
	}
}
开发者ID:AlanWills,项目名称:UnderSiege_DirectX,代码行数:13,代码来源:UIObject.cpp


示例20: 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();
    }
}
开发者ID:TsubameDono,项目名称:CCDK,代码行数:13,代码来源:Game.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dxf::LineReader类代码示例发布时间:2022-05-31
下一篇:
C++ dune::CpGrid类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap