本文整理汇总了C++中MyMesh::material方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::material方法的具体用法?C++ MyMesh::material怎么用?C++ MyMesh::material使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::material方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool Load(const char* filename, MyMesh& mesh)
{
//Create the data descriport for the custom attributes
nanoply::NanoPlyWrapper<MyMesh>::CustomAttributeDescriptor customAttrib;
customAttrib.GetMeshAttrib(filename);
int count = customAttrib.meshAttribCnt["material"];
mesh.material().resize(count);
customAttrib.AddVertexAttribDescriptor<int, int, 1>(std::string("materialId"), nanoply::NNP_INT32, NULL);
customAttrib.AddFaceAttribDescriptor<vcg::Point3f, float, 3>(std::string("barycenter"), nanoply::NNP_LIST_UINT8_FLOAT32, NULL);
customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("kd"), nanoply::NNP_FLOAT32, mesh.material()[0].kd.V());
customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("ks"), nanoply::NNP_FLOAT32, mesh.material()[0].ks.V());
customAttrib.AddMeshAttribDescriptor<Material, float, 1>(std::string("material"), std::string("rho"), nanoply::NNP_FLOAT32, &mesh.material()[0].rho);
//Load the ply file
unsigned int mask = 0;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOORD;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTNORMAL;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOLOR;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTRADIUS;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTATTRIB;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEINDEX;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACENORMAL;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEATTRIB;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_MESHATTRIB;
return (nanoply::NanoPlyWrapper<MyMesh>::LoadModel(filename, mesh, mask, customAttrib) != 0);
}
示例2: Save
bool Save(const char* filename, MyMesh& mesh, bool binary)
{
//Create the data descriport for the custom attributes
nanoply::NanoPlyWrapper<MyMesh>::CustomAttributeDescriptor customAttrib;
customAttrib.AddVertexAttribDescriptor<int, int, 1>(std::string("materialId"), nanoply::NNP_INT32, &mesh.vertexMaterial[0]);
customAttrib.AddFaceAttribDescriptor<vcg::Point3f, float, 3>(std::string("barycenter"), nanoply::NNP_LIST_UINT8_FLOAT32, mesh.faceBarycenter[0].V());
customAttrib.AddMeshAttrib(std::string("material"), 2);
customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("kd"), nanoply::NNP_LIST_UINT8_FLOAT32, mesh.material()[0].kd.V());
customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("ks"), nanoply::NNP_LIST_UINT8_FLOAT32, mesh.material()[0].ks.V());
customAttrib.AddMeshAttribDescriptor<Material, float, 1>(std::string("material"), std::string("rho"), nanoply::NNP_FLOAT32, &mesh.material()[0].rho);
//Save the ply file
unsigned int mask = 0;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOORD;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTNORMAL;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOLOR;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTRADIUS;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTATTRIB;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEINDEX;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACENORMAL;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEATTRIB;
mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_MESHATTRIB;
return nanoply::NanoPlyWrapper<MyMesh>::SaveModel(filename, mesh, mask, customAttrib, binary);
}