当前位置: 首页>>代码示例>>C++>>正文


C++ LPD3DXCONSTANTTABLE::SetMatrix方法代码示例

本文整理汇总了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 );
}
开发者ID:Nixxus,项目名称:GamesDevelopment2,代码行数:11,代码来源:RenderMethod.cpp

示例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);

}
开发者ID:Oswin2014,项目名称:CgTutorials_Practice,代码行数:31,代码来源:EnvironmentMap.cpp

示例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
    }
}
开发者ID:andrei-kopytov,项目名称:Game-Project-Lighting,代码行数:62,代码来源:Graphic.cpp

示例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
}
开发者ID:Nixxus,项目名称:GamesDevelopment2,代码行数:25,代码来源:RenderMethod.cpp

示例5: SetConstantTableMatrix

void Renderer::SetConstantTableMatrix( LPD3DXCONSTANTTABLE pConstantTable, char* pConstantName, D3DXMATRIX* pMatrix )
{
	pConstantTable->SetMatrix( m_pD3DDevice, pConstantName, pMatrix );
}
开发者ID:SHPURDYdBurt,项目名称:https-github.com-xbmc-atv2,代码行数:4,代码来源:Renderer.cpp


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