本文整理汇总了C++中Waves::Depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Waves::Depth方法的具体用法?C++ Waves::Depth怎么用?C++ Waves::Depth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Waves
的用法示例。
在下文中一共展示了Waves::Depth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateScene
void BlendApp::UpdateScene(float dt)
{
// Convert Spherical to Cartesian coordinates.
float x = mRadius*sinf(mPhi)*cosf(mTheta);
float z = mRadius*sinf(mPhi)*sinf(mTheta);
float y = mRadius*cosf(mPhi);
mEyePosW = XMFLOAT3(x, y, z);
// Build the view matrix.
XMVECTOR pos = XMVectorSet(x, y, z, 1.0f);
XMVECTOR target = XMVectorZero();
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
XMMATRIX V = XMMatrixLookAtLH(pos, target, up);
XMStoreFloat4x4(&mView, V);
//
// Every quarter second, generate a random wave.
//
static float t_base = 0.0f;
if( (mTimer.TotalTime() - t_base) >= 0.1f )
{
t_base += 0.1f;
DWORD i = 5 + rand() % (mWaves.RowCount()-10);
DWORD j = 5 + rand() % (mWaves.ColumnCount()-10);
float r = MathHelper::RandF(0.5f, 1.0f);
mWaves.Disturb(i, j, r);
}
mWaves.Update(dt);
//
// Update the wave vertex buffer with the new solution.
//
D3D11_MAPPED_SUBRESOURCE mappedData;
HR(md3dImmediateContext->Map(mWavesVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedData));
Vertex* v = reinterpret_cast<Vertex*>(mappedData.pData);
for(UINT i = 0; i < mWaves.VertexCount(); ++i)
{
v[i].Pos = mWaves[i];
v[i].Normal = mWaves.Normal(i);
// Derive tex-coords in [0,1] from position.
v[i].Tex.x = 0.5f + mWaves[i].x / mWaves.Width();
v[i].Tex.y = 0.5f - mWaves[i].z / mWaves.Depth();
}
md3dImmediateContext->Unmap(mWavesVB, 0);
//
// Animate water texture coordinates.
//
// Tile water texture.
XMMATRIX wavesScale = XMMatrixScaling(5.0f, 5.0f, 0.0f);
// Translate texture over time.
mWaterTexOffset.y += 0.05f*dt;
mWaterTexOffset.x += 0.1f*dt;
XMMATRIX wavesOffset = XMMatrixTranslation(mWaterTexOffset.x, mWaterTexOffset.y, 0.0f);
// Combine scale and translation.
XMStoreFloat4x4(&mWaterTexTransform, wavesScale*wavesOffset);
//
// Switch the render mode based in key input.
//
if( GetAsyncKeyState('1') & 0x8000 )
mRenderOptions = RenderOptions::Lighting;
if( GetAsyncKeyState('2') & 0x8000 )
mRenderOptions = RenderOptions::Textures;
if( GetAsyncKeyState('3') & 0x8000 )
mRenderOptions = RenderOptions::TexturesAndFog;
}
示例2: UpdateScene
void TreeBillboardApp::UpdateScene(float dt)
{
DemoApp::UpdateScene(dt);
// Every quarter second, generate a random wave.
static float t_base = 0.0f;
if( (m_timer.TotalTime() - t_base) >= 0.1f )
{
t_base += 0.1f;
uint32 i = 5 + rand() % (m_waves.RowCount()-10);
uint32 j = 5 + rand() % (m_waves.ColumnCount()-10);
float r = MathHelper::RandF(0.5f, 1.0f);
m_waves.Disturb(i, j, r);
}
m_waves.Update(dt);
// Update the wave vertex buffer with the new solution.
D3D11_MAPPED_SUBRESOURCE mappedData;
HR(m_dxImmediateContext->Map(m_wavesVB.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedData));
Vertex::Basic32* v = reinterpret_cast<Vertex::Basic32*>(mappedData.pData);
for(UINT i = 0; i < m_waves.VertexCount(); ++i)
{
v[i].Pos = m_waves[i];
v[i].Normal = m_waves.Normal(i);
// Derive tex-coords in [0,1] from position.
v[i].Tex.x = 0.5f + m_waves[i].x / m_waves.Width();
v[i].Tex.y = 0.5f - m_waves[i].z / m_waves.Depth();
}
m_dxImmediateContext->Unmap(m_wavesVB.Get(), 0);
// Animate water texture coordinates.
// Tile water texture.
XMMATRIX wavesScale = XMMatrixScaling(5.0f, 5.0f, 0.0f);
// Translate texture over time (this animate the texture)
m_waterTexOffset.y += 0.05f*dt;
m_waterTexOffset.x += 0.1f*dt;
XMMATRIX wavesOffset = XMMatrixTranslation(m_waterTexOffset.x, m_waterTexOffset.y, 0.0f);
// Combine scale and translation.
XMStoreFloat4x4(&m_waterTexTransform, wavesScale*wavesOffset);
// Switch the render mode based in key input.
if( GetAsyncKeyState('1') & 0x8000 )
m_renderOptions = RenderOptions::Lighting;
if( GetAsyncKeyState('2') & 0x8000 )
m_renderOptions = RenderOptions::Textures;
if( GetAsyncKeyState('3') & 0x8000 )
m_renderOptions = RenderOptions::TexturesAndFog;
if( GetAsyncKeyState('R') & 0x8000 )
m_alphaToCoverageOn = true;
if( GetAsyncKeyState('T') & 0x8000 )
m_alphaToCoverageOn = false;
}