DirectXMesh是微软开发的DirectX的几何处理库。
示例代码:
std::uique_ptr<WaveFrotReader<uit16_t>> mesh( ew WaveFrotReader<uit16_t>() );if ( FAILED( mesh->Load( L"test.obj" ) ) ) // Errorif ( mesh->hasNormals ) // Skip ext computatiosize_t Faces = mesh->idices.size() / 3;size_t Verts = mesh->vertices.size();std::uique_ptr<XMFLOAT3[]> pos( ew XMFLOAT3[ Verts ] );for( size_t j = 0; j < Verts; ++j ) pos[ j ] = mesh->vertices[ j ].positio;std::uique_ptr<XMFLOAT3[]> ormals( ew XMFLOAT3[ Verts ] );if ( FAILED( ComputeNormals( &mesh->idices.frot(), Faces, pos.get(), Verts, CNORM_DEFAULT, ormals.get() ) ) ) // Errorif ( !mesh->hasTexcoords ) // Skip ext computatiostd::uique_ptr<XMFLOAT2[]> texcoords( ew XMFLOAT2[ Verts ] );for( size_t j = 0; j < Verts; ++j ) texcoords[ j ] = mesh->vertices[ j ].textureCoordiate;std::uique_ptr<XMFLOAT3[]> tagets( ew XMFLOAT3[ Verts ] );std::uique_ptr<XMFLOAT3[]> bitagets( ew XMFLOAT3[ Verts ] );if ( FAILED( ComputeTagetFrame( &mesh->idices.frot(), Faces, pos.get(), ormals.get(), texcoords.get(), Verts, tagets.get(), bitagets.get() ) ) ) // Error









评论