本文整理汇总了C++中GeometryGenerator::CreateLightVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryGenerator::CreateLightVolume方法的具体用法?C++ GeometryGenerator::CreateLightVolume怎么用?C++ GeometryGenerator::CreateLightVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryGenerator
的用法示例。
在下文中一共展示了GeometryGenerator::CreateLightVolume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCullingVolume
void SDFShadow::GetCullingVolume(D3DXVECTOR3¢er, D3DXVECTOR3& extend,
D3DXVECTOR3& lightDir,D3DXMATRIX& worldMat)
{
if(mCullingVolumeIB) mCullingVolumeIB->Release();
if(mCullingVolumeVB) mCullingVolumeVB->Release();
static D3DXVECTOR3 vt[8] =
{
D3DXVECTOR3(1, -1, -1),
D3DXVECTOR3(1, 1, -1),
D3DXVECTOR3(-1, 1, -1),
D3DXVECTOR3(-1, -1, -1),
D3DXVECTOR3(1, -1, 1),
D3DXVECTOR3(1, 1, 1),
D3DXVECTOR3(-1, 1, 1),
D3DXVECTOR3(-1, -1, 1),
};
GeometryGenerator geoGen;
D3DXVECTOR3 vert[8];
for (int i = 0; i < 8; i++){
vert[i] = center;
for(int j = 0; j < 3; j++)
vert[i][j] += vt[i][j] * extend[j];
D3DXVECTOR4 tmpout;
D3DXVec3Transform(&tmpout, &vert[i], &worldMat);
for(int j = 0; j < 3; j ++) vert[i][j] = tmpout[j];
}
std::vector<D3DXVECTOR3> vertices;
std::vector<USHORT> indices16;
geoGen.CreateLightVolume(vertices, indices16, vert, lightDir);
void *tvb, *tib;
mVertexCount = vertices.size();
HR(gd3dDevice->CreateVertexBuffer(
mVertexCount * sizeof(VertexPos)
,0
,D3DFVF_XYZ
,D3DPOOL_MANAGED
,&mCullingVolumeVB
,NULL));
HR(mCullingVolumeVB->Lock(0, sizeof(VertexPos) * mVertexCount, & tvb, 0));
memcpy(tvb, &vertices[0], sizeof(VertexPos) * mVertexCount);
HR(mCullingVolumeVB->Unlock());
mIndexCount = indices16.size();
HR(gd3dDevice->CreateIndexBuffer(
mIndexCount * sizeof(USHORT)
,0
,D3DFMT_INDEX16
,D3DPOOL_MANAGED
,&mCullingVolumeIB
,NULL
));
HR(mCullingVolumeIB->Lock(0, sizeof(USHORT) * mIndexCount, & tib, 0));
memcpy(tib, &indices16[0], sizeof(USHORT) * mIndexCount);
HR(mCullingVolumeIB->Unlock());
}