本文整理汇总了C++中state::smooth方法的典型用法代码示例。如果您正苦于以下问题:C++ state::smooth方法的具体用法?C++ state::smooth怎么用?C++ state::smooth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state
的用法示例。
在下文中一共展示了state::smooth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
D3DXMATRIX world, view, proj;
D3DXMATRIX skyworld, viewproj;
D3DXVECTOR3 eye(0, 0, -5);
D3DXVECTOR3 look(0, 0, 0);
D3DXVECTOR3 up(0, 1, 0);
D3DXVECTOR2 orient = cameraangle.smooth(alpha);
D3DXMatrixRotationYawPitchRoll(&view, orient.x, orient.y, 0);
D3DXVec3TransformCoord(&eye, &eye, &view);
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, (float)screenwidth / (float)screenheight, 0.1f, 50);
D3DXMatrixLookAtLH(&view, &eye, &look, &up);
D3DXMatrixMultiply(&viewproj, &view, &proj);
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
device->SetTransform(D3DTS_VIEW, &view);
device->SetTransform(D3DTS_PROJECTION, &proj);
for( int i = 0; i < NUM_DWARFS; ++i )
dwarfs[i].Update(elapsedtime, &dwarfmatrices[i]);
effect->SetMatrix("matViewProj", &viewproj);
if( SUCCEEDED(device->BeginScene()) )
{
// render sky
device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
D3DXMatrixScaling(&skyworld, 20, 20, 20);
skyeffect->SetMatrix("matWorld", &skyworld);
D3DXMatrixIdentity(&skyworld);
skyeffect->SetMatrix("matWorldSky", &skyworld);
skyeffect->SetMatrix("matViewProj", &viewproj);
skyeffect->SetVector("eyePos", (D3DXVECTOR4*)&eye);
skyeffect->Begin(0, 0);
skyeffect->BeginPass(0);
{
device->SetTexture(0, skytex);
skymesh->DrawSubset(0);
}
skyeffect->EndPass();
skyeffect->End();
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
// render ground
D3DXMatrixScaling(&world, 5, 0.1f, 5);
world._42 = -0.05f;
device->SetTransform(D3DTS_WORLD, &world);
device->SetTexture(0, texture2);
mesh->DrawSubset(0);
// dwarfs
for( int i = 0; i < NUM_DWARFS; ++i )
dwarfs[i].Draw();
// fire
D3DXMatrixTranslation(&world, 0, 0.25f, 0);
device->SetTransform(D3DTS_WORLD, &world);
system1.Draw(world, view);
// render text
device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
device->SetTexture(0, text);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float));
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_ZENABLE, TRUE);
device->EndScene();
}
device->Present(NULL, NULL, NULL, NULL);
}
示例2: Render
void Render(float alpha, float elapsedtime)
{
static float time = 0;
LPDIRECT3DSURFACE9 backbuffer = 0;
D3DXMATRIX view, proj, viewproj;
D3DXMATRIX world, inv;
D3DXVECTOR4 texelsize;
D3DXVECTOR4 lightpos(-600, 350, 1000, 1);
D3DXVECTOR4 refllight;
D3DXVECTOR3 eye(0, 0, -5.0f);
D3DXVECTOR3 look(0, 1.2f, 0);
D3DXVECTOR3 refleye, refllook;
D3DXVECTOR3 up(0, 1, 0);
D3DXVECTOR2 orient = cameraangle.smooth(alpha);
D3DXMatrixRotationYawPitchRoll(&view, orient.x, orient.y, 0);
D3DXVec3TransformCoord(&eye, &eye, &view);
eye.y += 1.2f;
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 2, (float)screenwidth / (float)screenheight, 0.1f, 30);
time += elapsedtime;
if( SUCCEEDED(device->BeginScene()) )
{
device->GetRenderTarget(0, &backbuffer);
// STEP 1: render reflection texture
device->SetRenderTarget(0, reflectsurf);
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
D3DXPLANE plane(0, 1, 0, 1);
refleye = eye - 2 * D3DXPlaneDotCoord(&plane, &eye) * (D3DXVECTOR3&)plane;
refllook = look - 2 * D3DXPlaneDotCoord(&plane, &look) * (D3DXVECTOR3&)plane;
refllight = lightpos - 2 * D3DXPlaneDot(&plane, &lightpos) * (D3DXVECTOR4&)plane;
refllight.w = 1;
D3DXMatrixLookAtLH(&view, &refleye, &refllook, &up);
D3DXMatrixMultiply(&viewproj, &view, &proj);
D3DXMatrixInverse(&inv, 0, &viewproj);
D3DXMatrixTranspose(&inv, &inv);
D3DXPlaneTransform(&plane, &plane, &inv);
device->SetClipPlane(0, &plane.a);
RenderScene(viewproj, refleye, refllight, true);
// STEP 2: render scene (later used for refraction)
D3DXMatrixLookAtLH(&view, &eye, &look, &up);
D3DXMatrixMultiply(&viewproj, &view, &proj);
device->SetRenderTarget(0, refractsurf);
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
RenderScene(viewproj, eye, lightpos, false);
// render water surface into alpha channel for masking
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
D3DXMatrixTranslation(&world, 0, -1, 0);
device->SetTransform(D3DTS_WORLD, &world);
device->SetTransform(D3DTS_VIEW, &view);
device->SetTransform(D3DTS_PROJECTION, &proj);
waterplane->DrawSubset(0, DXObject::Opaque);
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0f);
// STEP 3: light shafts
quadvertices[6] = quadvertices[24] = quadvertices[30] = (float)screenwidth - 0.5f;
quadvertices[13] = quadvertices[19] = quadvertices[31] = (float)screenheight - 0.5f;
RenderLightShafts(view, proj, eye, lightpos);
// STEP 4: gamma correct
device->SetRenderTarget(0, sceneldrsurf);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetVertexDeclaration(quaddecl);
bloom->SetTechnique("gammacorrect");
bloom->Begin(0, 0);
bloom->BeginPass(0);
{
device->SetTexture(0, refraction);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
}
bloom->EndPass();
bloom->End();
device->SetRenderState(D3DRS_ZENABLE, TRUE);
// STEP 5: water surface
//.........这里部分代码省略.........
示例3: Render
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
LPDIRECT3DSURFACE9 oldtarget = NULL;
D3DXMATRIX vp, inv, tmp1, tmp2;
D3DXVECTOR3 axis(0, 1, 0);
D3DXVECTOR3 eye(0, 0, -5);
D3DXVECTOR3 look(0, 0, 0);
D3DXVECTOR3 up(0, 1, 0);
D3DXVECTOR2 cangle = cameraangle.smooth(alpha);
D3DXVECTOR2 oangle = objectangle.smooth(alpha);
float expo = exposure.smooth(alpha);
D3DXMatrixRotationYawPitchRoll(&world, cangle.x, cangle.y, 0);
D3DXVec3TransformCoord(&eye, &eye, &world);
D3DXMatrixLookAtLH(&view, &eye, &look, &up);
D3DXMatrixMultiply(&vp, &view, &proj);
D3DXMatrixInverse(&inv, NULL, &view);
memcpy(&eye, inv.m[3], 3 * sizeof(float));
if( mesh == mesh1 )
{
// skullocc
D3DXMatrixScaling(&world, 0.4f, 0.4f, 0.4f);
world._42 = -1.5f;
}
else if( mesh == mesh2 )
{
// knot
D3DXMatrixScaling(&world, 0.8f, 0.8f, 0.8f);
}
else
{
// teapot
D3DXMatrixScaling(&world, 1.5f, 1.5f, 1.5f);
}
D3DXMatrixRotationYawPitchRoll(&tmp1, oangle.x, oangle.y, 0);
D3DXMatrixMultiply(&world, &world, &tmp1);
D3DXMatrixInverse(&inv, NULL, &world);
fresnel->SetVector("eyePos", (D3DXVECTOR4*)&eye);
fresnel->SetMatrix("matWorld", &world);
fresnel->SetMatrix("matWorldInv", &inv);
fresnel->SetMatrix("matViewProj", &vp);
D3DXMatrixScaling(&world, 20, 20, 20);
skyeffect->SetMatrix("matWorld", &world);
D3DXMatrixIdentity(&world);
skyeffect->SetMatrix("matWorldSky", &world);
skyeffect->SetMatrix("matViewProj", &vp);
memcpy(tmpvert, quadvertices, 36 * sizeof(float));
if( SUCCEEDED(device->BeginScene()) )
{
device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
// STEP 1: render sky
device->GetRenderTarget(0, &oldtarget);
if( firstframe )
{
device->SetRenderTarget(0, aftersurfaces[0]);
device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
device->SetRenderTarget(0, aftersurfaces[1]);
device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
device->SetRenderTarget(0, avglumsurfaces[4]);
device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0);
device->SetRenderTarget(0, avglumsurfaces[5]);
device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0);
firstframe = false;
}
device->SetRenderTarget(0, scenesurface);
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetTexture(0, skytexture);
skyeffect->Begin(NULL, 0);
skyeffect->BeginPass(0);
{
skymesh->DrawSubset(0);
}
skyeffect->EndPass();
skyeffect->End();
device->SetRenderState(D3DRS_ZENABLE, TRUE);
//.........这里部分代码省略.........