本文整理汇总了C++中LPD3DXMESH::SetAttributeTable方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXMESH::SetAttributeTable方法的具体用法?C++ LPD3DXMESH::SetAttributeTable怎么用?C++ LPD3DXMESH::SetAttributeTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXMESH
的用法示例。
在下文中一共展示了LPD3DXMESH::SetAttributeTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnGenerateAtlas
//.........这里部分代码省略.........
}
for( int i = 0; i < (int)numFaces; i++ )
{
unsigned short * index = (unsigned short*)indexData;
index[0] = ( unsigned short )(*m_Faces)[ i ].index[ 0 ];
index[1] = ( unsigned short )(*m_Faces)[ i ].index[ 1 ];
index[2] = ( unsigned short )(*m_Faces)[ i ].index[ 2 ];
indexData += sizeof( unsigned short )*3;//32 bit indices triangles
}
LPD3DXBUFFER imt;
hr = D3DXComputeIMTFromPerVertexSignal( mesh, (const float*)pVertOriginal + 3*sizeof(float), 3, sizeof(paramVertex),
0L, 0, 0, &imt );
mesh->UnlockIndexBuffer();
mesh->UnlockVertexBuffer();
//tensors
float * tensors = new float[ 3*numFaces ];
for( int i = 0; i < 3*(int)numFaces; i += 3 )
{
tensors[ i ] = 4.f;
tensors[ i + 1 ] = 0.f;
tensors[ i + 2 ] = 4.f;
}
//some checks
numVertices = mesh->GetNumVertices();
numFaces = mesh->GetNumFaces();
//create adjacency
DWORD * adjacency = new DWORD[ 3*numFaces ];
memset( adjacency, 0, sizeof(DWORD)*3*numFaces );
hr = mesh->GenerateAdjacency( 0.001f, adjacency );
//hr = mesh->ConvertPointRepsToAdjacency( NULL, adjacency );
if( FAILED( hr ) )
{
curError = GetLastError();
EngineGetToolBox()->Log(LOGERROR, _T("MeshParameterization: Error in generate adjacency\n"));
return MSG_ERROR;
}
/* save to mesh to check model uvs
D3DXMATERIAL mat;
mat.MatD3D.Ambient.r = mat.MatD3D.Ambient.a =mat.MatD3D.Ambient.b =mat.MatD3D.Ambient.g = 0;
mat.MatD3D.Diffuse.r = mat.MatD3D.Diffuse.a =mat.MatD3D.Diffuse.b =mat.MatD3D.Diffuse.g = 1;
mat.pTextureFilename = "tex.dds";
D3DXSaveMeshToX( "mesh.x", mesh, adjacency, &mat, NULL, 0, D3DXF_FILEFORMAT_TEXT );
*/
float * imtTensor = tensors;//(float*)imt->GetBufferPointer();
float stretchout;
unsigned int charts;
LPD3DXMESH meshOut = NULL;
LPD3DXBUFFER remappedData = NULL;
LPD3DXBUFFER faceData = NULL;
D3DXATTRIBUTERANGE Attrib;
memset(&Attrib, 0, sizeof(D3DXATTRIBUTERANGE));
Attrib.FaceCount = numFaces;
Attrib.VertexCount = numVertices;
mesh->SetAttributeTable(&Attrib, 1);
int gutter = m_TexSize / 32;
gutter = min( gutter, 6 );
hr = D3DXUVAtlasCreate( mesh, 0, .5, m_TexSize, m_TexSize,
6, //gutter
0, adjacency, 0,
imtTensor, (LPD3DXUVATLASCB)UVGenCallback, .0001f, 0,
//D3DXUVATLAS_GEODESIC_QUALITY ,
D3DXUVATLAS_GEODESIC_FAST,
&meshOut, &faceData, &remappedData,
&stretchout, &charts );
if( FAILED( hr ) )
{
curError = GetLastError();
EngineGetToolBox()->Log(LOGERROR, _T("MeshParameterization: Error in uv atlas create\n"));
return MSG_ERROR;
}
/* save to mesh to check model uvs
hr = meshOut->ConvertPointRepsToAdjacency( NULL, adjacency );
D3DXSaveMeshToX( "mesh2.x", meshOut, adjacency, &mat, NULL, 0, D3DXF_FILEFORMAT_TEXT );
*/
delete [] adjacency;
delete [] tensors;
//Generate our lightmap cache data for passing on and saving
GenerateCache( meshOut, remappedData );
GenerateTriangleTexelData();
meshOut->Release();
faceData->Release();
remappedData->Release();
mesh->Release();
}
else
if( bUseIncomingTexCoords )
{
GenerateCache();
GenerateTriangleTexelData();
}
return MSG_HANDLED_STOP;
}