Added default initialization of materials in io importer
This commit is contained in:
parent
66fde513b1
commit
a745b77c04
|
@ -273,6 +273,7 @@ namespace vcg {
|
||||||
// triangles of this face will share the same color
|
// triangles of this face will share the same color
|
||||||
|
|
||||||
Material defaultMaterial; // default material: white
|
Material defaultMaterial; // default material: white
|
||||||
|
defaultMaterial.index=currentMaterialIdx;
|
||||||
materials.push_back(defaultMaterial);
|
materials.push_back(defaultMaterial);
|
||||||
|
|
||||||
int numVertices = 0; // stores the number of vertices been read till now
|
int numVertices = 0; // stores the number of vertices been read till now
|
||||||
|
|
|
@ -65,18 +65,18 @@ namespace io {
|
||||||
*/
|
*/
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
unsigned int index;//index of material
|
unsigned int index=-1;//index of material
|
||||||
std::string materialName;
|
std::string materialName;
|
||||||
|
|
||||||
Point3f Ka;//ambient
|
Point3f Ka=Point3f(0.2f, 0.2f, 0.2f);//ambient
|
||||||
Point3f Kd;//diffuse
|
Point3f Kd=Point3f(1.0f, 1.0f, 1.0f);//diffuse
|
||||||
Point3f Ks;//specular
|
Point3f Ks=Point3f(1.0f, 1.0f, 1.0f);//specular
|
||||||
|
|
||||||
float d;//alpha
|
float d;//alpha
|
||||||
float Tr;//alpha
|
float Tr=1.0f;//alpha
|
||||||
|
|
||||||
int illum;//specular illumination
|
int illum=2;//specular illumination
|
||||||
float Ns;
|
float Ns=0.f;
|
||||||
|
|
||||||
std::string map_Kd; //filename texture
|
std::string map_Kd; //filename texture
|
||||||
};
|
};
|
||||||
|
@ -96,13 +96,6 @@ public:
|
||||||
inline static int CreateNewMaterial(SaveMeshType &m, std::vector<Material> &materials, FaceIterator &fi)
|
inline static int CreateNewMaterial(SaveMeshType &m, std::vector<Material> &materials, FaceIterator &fi)
|
||||||
{
|
{
|
||||||
Material mtl;
|
Material mtl;
|
||||||
mtl.index = -1; // index of materials
|
|
||||||
mtl.Ka = Point3f(0.2f,0.2f,0.2f); // ambient
|
|
||||||
mtl.Kd = Point3f(1,1,1); // diffuse
|
|
||||||
mtl.Ks = Point3f(1.0f,1.0f,1.0f); // specular
|
|
||||||
mtl.Tr = 1.0f; // alpha
|
|
||||||
mtl.Ns = 0.0f;
|
|
||||||
mtl.illum = 2; // illumination
|
|
||||||
|
|
||||||
if(HasPerFaceColor(m)){
|
if(HasPerFaceColor(m)){
|
||||||
mtl.Kd = Point3f((float)((*fi).C()[0])/255.0f,(float)((*fi).C()[1])/255.0f,(float)((*fi).C()[2])/255.0f);//diffuse
|
mtl.Kd = Point3f((float)((*fi).C()[0])/255.0f,(float)((*fi).C()[1])/255.0f,(float)((*fi).C()[2])/255.0f);//diffuse
|
||||||
|
|
Loading…
Reference in New Issue