本文整理汇总了C++中ModelData::polygons方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelData::polygons方法的具体用法?C++ ModelData::polygons怎么用?C++ ModelData::polygons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelData
的用法示例。
在下文中一共展示了ModelData::polygons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildModelData
zenic::ModelData* ExporterBackend::buildModelData(CSLModel* model, Model* modelNode)
{
ModelData* target = zenic_new ModelData;
CSLXSIMesh* mesh = static_cast<CSLXSIMesh*>(model->Primitive());
CSLXSIShape* shape = mesh->XSIShape();
DegenerateMesh degMesh;
degMesh.process(mesh);
TriangleStrip triangleStripper(TriangleStrip::Actc);
const TriangleStrip::StripInfo& stripInfo = triangleStripper.process(°Mesh);
if (stripInfo.remapTable == 0)
{
ZENIC_ERROR("Failed to trianglestrip " << mesh->GetName() << " mesh will be skipped");
zenic_delete target;
return 0;
}
// Set the correct material to the modelData
if (model->GlobalMaterial())
target->setMaterial((opengl::Material*)findMaterial(model->GlobalMaterial()->GetMaterial()));
SkinInfo* skinInfo = 0;
if (model->GetEnvelopeCount() != 0)
{
skinInfo = buildSkinInfo(model, modelNode, stripInfo.remapTable);
target->setType(ModelData::Skinned);
}
static float colors[] =
{
0, 1.0f, 1.0f, 0,
1.0f, 0, 1.0f, 0,
0, 1.0f, 0, 0,
1.0f, 1.0f, 0, 0
};
target->polygons().allocate(u32(stripInfo.stripList.size()));
ModelData::PolygonList* polygonLists = target->polygons().objects();
const std::vector<DegenerateMesh::Vertex>& vertices = degMesh.vertexList();
uint d = 0;
for (std::vector<DataPtr<u32>*>::const_iterator i = stripInfo.stripList.begin(); i != stripInfo.stripList.end(); ++i, ++d)
{
u32 colorSelection = (d & 3) << 2;
DataPtr<u32>* triStripList = (*i);
// process strip
u32* stripList = triStripList->objects();
u32 stripCount = triStripList->count();
ModelData::PolygonList& polygonList = polygonLists[d];
polygonList.setPolygonType(ModelData::TriStrips);
if (skinInfo)
polygonList.setVertexFormat(ModelData::Postion | ModelData::Color | ModelData::Weight);
else
polygonList.setVertexFormat(ModelData::Postion | ModelData::Color | ModelData::Uv1);
if (skinInfo)
polygonList.vertexStream().allocate((stripCount * 14)); // coords and colors
else
polygonList.vertexStream().allocate((stripCount * 8)); // 3 coords, 3 colors, 2 uv
f32* tempStream = polygonList.vertexStream().objects();
for (uint d = 0; d < stripCount; ++d)
{
const DegenerateMesh::Vertex& vertex = vertices[stripList[d]];
*tempStream++ = vertex.position.x;
*tempStream++ = vertex.position.y;
*tempStream++ = vertex.position.z;
*tempStream++ = colors[colorSelection + 0];
*tempStream++ = colors[colorSelection + 1];
*tempStream++ = colors[colorSelection + 2];
*tempStream++ = vertex.uv.x;
*tempStream++ = vertex.uv.y;
if (skinInfo)
{
const SkinInfo& currInfo = skinInfo[stripList[d]];
for (uint d = 0; d < 4; ++d)
{
*tempStream++ = float(currInfo.indices[d]);
*tempStream++ = float(currInfo.weights[d]);
//.........这里部分代码省略.........