本文整理汇总了C++中LPD3DXCONSTANTTABLE::SetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXCONSTANTTABLE::SetMatrix方法的具体用法?C++ LPD3DXCONSTANTTABLE::SetMatrix怎么用?C++ LPD3DXCONSTANTTABLE::SetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXCONSTANTTABLE
的用法示例。
在下文中一共展示了LPD3DXCONSTANTTABLE::SetMatrix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VS_XFormFn
// Pass the world matrix and view/projection matrix to the vertex shader
void VS_XFormFn( int method, CMatrix4x4* worldMatrix, CCamera* camera )
{
LPD3DXCONSTANTTABLE shaderConsts = renderMethods[method].vertexConsts;
D3DXMATRIXA16 matViewProj = ToD3DXMATRIX( camera->GetViewProjMatrix() );
shaderConsts->SetMatrix( g_pd3dDevice, "ViewProjMatrix", &matViewProj );
D3DXMATRIX* matWorld = ToD3DXMATRIXPtr( worldMatrix );
shaderConsts->SetMatrix( g_pd3dDevice, "WorldMatrix", matWorld );
}
示例2: modelShaderApply
//-----------------------------------------------------------------------
void CEnvironmentMap::modelShaderApply(OwnMatrix4x4 *pModelMtx /*= NULL*/, bool bRenderEnvMappedMesh)
{
LPD3DXCONSTANTTABLE constable = mVtxConstTable;
OwnMatrix4x4 modelMtx, viewProjMtx, modelViewProjMtx;
if (NULL == pModelMtx)
modelMtx.setIdentity();
else
modelMtx = *pModelMtx;
viewProjMtx.setMultiply(mCamera->mViewTrans, mCamera->mProjectionTrans);
modelViewProjMtx.setMultiply(modelMtx, viewProjMtx);
HRESULT hr;
D3DXHANDLE handle;
D3DXHANDLE modelViewProj = mVtxConstTable->GetConstantByName(0, "u_ModelViewProjMatrix");
hr = mVtxConstTable->SetMatrix(mD3DDevice, modelViewProj, (D3DXMATRIX*)&modelViewProjMtx);
D3DXHANDLE u_ModelMatrix = constable->GetConstantByName(0, "u_ModelToWorld");
hr = constable->SetMatrix(mD3DDevice, u_ModelMatrix, (D3DXMATRIX*)&modelMtx);
LPD3DXCONSTANTTABLE pixConstable = mPxlConstTable;
float value = bRenderEnvMappedMesh ? 0.5f : 0;
D3DXHANDLE reflectivity = pixConstable->GetConstantByName(0, "$reflectivity");
hr = pixConstable->SetFloat(mD3DDevice, reflectivity, value);
}
示例3: draw
// draw draws the set of graphics primitives using the object's world
// transformation and reflected colour
//
void Graphic::draw(const iObject* object, int i) {
// if graphic is not setup, set it up
if (!isSetup) setup(object);
if (isSetup) {
#if PIPELINE == FIXED_FUNCTION
#elif PIPELINE == PROGRAMMABLE || PIPELINE == PROGRAMMABLE_EFFECT
Display* disp = reinterpret_cast<Display*>(display);
Matrix worldView = object->world() * disp->viewMatrix();
Matrix worldViewProjection = worldView * disp->projectionMatrix();
#endif
#if PIPELINE == FIXED_FUNCTION
d3dd->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)(&object->world()));
d3dd->SetMaterial(&mat);
if (!strcmp(technique, "opaque") || !strcmp(technique, "skybox"))
d3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
else if (!strcmp(technique, "translucent"))
d3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
vertexList->draw(i);
#elif PIPELINE == PROGRAMMABLE
LPD3DXCONSTANTTABLE vertexTable = (LPD3DXCONSTANTTABLE)uniformVS;
LPD3DXCONSTANTTABLE fragmentTable = (LPD3DXCONSTANTTABLE)uniformFS;
vertexTable->SetMatrix(d3dd, "world", (D3DXMATRIX*)&object->world());
fragmentTable->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&ambient, 4);
fragmentTable->SetFloatArray(d3dd, "material.diffuse", (FLOAT*)&diffuse, 4);
fragmentTable->SetFloatArray(d3dd, "material.specular", (FLOAT*)&specular, 4);
fragmentTable->SetFloat(d3dd, "material.power", (FLOAT)power);
if (!strcmp(technique, "opaque") || !strcmp(technique, "skybox"))
d3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
else if (!strcmp(technique, "translucent"))
d3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
#elif PIPELINE == PROGRAMMABLE_EFFECT
effect->SetInt(stagesHandle, nStages);
effect->SetMatrix(worldHandle, (D3DXMATRIX*)&object->world());
effect->SetVector(ambientHandle, (D3DXVECTOR4*)&ambient);
effect->SetVector(diffuseHandle, (D3DXVECTOR4*)&diffuse);
effect->SetVector(specularHandle, (D3DXVECTOR4*)&specular);
effect->SetFloat(powerHandle, power);
effect->SetFloat(roughnessHandle, object->getRoughness());
effect->SetFloat(refractionHandle,object->getIndexOfRefraction());
effect->SetInt(algorithmHandle, object->getAlgorithm());
effect->SetMatrix(worldViewHandle, (D3DXMATRIX*)&worldView);
effect->SetMatrix(clipMatrixHandle, (D3DXMATRIX*)&worldViewProjection);
effect->CommitChanges();
Matrix viewProjectionBak;
effect->GetMatrix("viewProjection", (D3DXMATRIX*)&viewProjectionBak);
effect->SetTechnique(techniqueHandle);
unsigned nPasses;
effect->Begin(&nPasses, 0);
for (unsigned iPass = 0; iPass < nPasses; iPass++) {
effect->BeginPass(iPass);
vertexList->draw(i);
effect->EndPass();
}
effect->End();
#endif
}
}
示例4: VS_VertLit1Fn
// Pass data to vertex shaders that perform vertex lighting (1 point light)
// Passes full range of data - some shaders don't need all of it. This
// reduces the number of these functions at the expense of redundancy
void VS_VertLit1Fn( int method, CMatrix4x4* worldMatrix, CCamera* camera )
{
LPD3DXCONSTANTTABLE shaderConsts = renderMethods[method].vertexConsts;
D3DXMATRIXA16 matViewProj = ToD3DXMATRIX( camera->GetViewProjMatrix() );
shaderConsts->SetMatrix( g_pd3dDevice, "ViewProjMatrix", &matViewProj );
D3DXMATRIX* matWorld = ToD3DXMATRIXPtr( worldMatrix );
shaderConsts->SetMatrix( g_pd3dDevice, "WorldMatrix", matWorld );
D3DXVECTOR3 cameraPos = ToD3DXVECTOR( camera->Position() );
shaderConsts->SetFloatArray( g_pd3dDevice, "CameraPosition", (FLOAT*)&cameraPos, 3 ); // If needed
shaderConsts->SetFloatArray( g_pd3dDevice, "AmbientLight", (FLOAT*)&m_AmbientLight, 3 );
shaderConsts->SetFloatArray( g_pd3dDevice, "LightPosition", (FLOAT*)&m_Lights[0]->GetPosition(), 3 );
shaderConsts->SetFloatArray( g_pd3dDevice, "LightColour", (FLOAT*)&m_Lights[0]->GetColour(), 3 );
shaderConsts->SetFloat( g_pd3dDevice, "LightBrightness", m_Lights[0]->GetBrightness() );
shaderConsts->SetFloatArray( g_pd3dDevice, "MaterialColour", (FLOAT*)&m_DiffuseColour, 3 ); // If needed
shaderConsts->SetFloatArray( g_pd3dDevice, "SpecularStrength", (FLOAT*)&m_SpecularColour, 3 ); // If needed
shaderConsts->SetFloat( g_pd3dDevice, "SpecularPower", m_SpecularPower ); // If needed
}
示例5: SetConstantTableMatrix
void Renderer::SetConstantTableMatrix( LPD3DXCONSTANTTABLE pConstantTable, char* pConstantName, D3DXMATRIX* pMatrix )
{
pConstantTable->SetMatrix( m_pD3DDevice, pConstantName, pMatrix );
}