forked from IfcOpenShell/IfcOpenShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjMaterials.h
More file actions
64 lines (60 loc) · 3.57 KB
/
ObjMaterials.h
File metadata and controls
64 lines (60 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file defines materials in .mtl format for several IFC datatypes *
* *
********************************************************************************/
#include <string>
#include <sstream>
class ObjMaterial {
private:
std::string data;
public:
ObjMaterial(const std::string& name,
double Kd_r = 0.7f,double Kd_g = 0.7f,double Kd_b = 0.7f,
double Ks_r = 0.2f,double Ks_g = 0.2f,double Ks_b = 0.2f,
double Ka_r = 0.1f,double Ka_g = 0.1f,double Ka_b = 0.1f,
double Ns = 10.0f, double Tr = 1.0f) {
std::stringstream ss;
ss << "newmtl " << name << std::endl;
ss << "Kd " << Kd_r << " " << Kd_g << " " << Kd_b << std::endl;
ss << "Ks " << Ks_r << " " << Ks_g << " " << Ks_b << std::endl;
ss << "Ka " << Ka_r << " " << Ka_g << " " << Ka_b << std::endl;
ss << "Ns " << Ns << std::endl;
ss << "Tr " << Tr << std::endl;
ss << "d " << Tr << std::endl;
ss << "D " << Tr << std::endl;
data = ss.str();
}
friend ostream& operator<<(ostream& o, const ObjMaterial& m) {o << m.data; return o;}
};
ObjMaterial GetMaterial(const std::string& s) {
if ( s == "IfcSite" ) { return ObjMaterial("IfcSite",0.75f,0.8f,0.65f); }
if ( s == "IfcSlab" ) { return ObjMaterial("IfcSlab",0.4f,0.4f,0.4f); }
if ( s == "IfcWallStandardCase" ) { return ObjMaterial("IfcWallStandardCase",0.9f,0.9f,0.9f); }
if ( s == "IfcWall" ) { return ObjMaterial("IfcWall",0.9f,0.9f,0.9f); }
if ( s == "IfcWindow" ) { return ObjMaterial("IfcWindow",0.75f,0.8f,0.75f,1.0f,1.0f,1.0f,0.0f,0.0f,0.0f,500.0f,0.3f); }
if ( s == "IfcDoor" ) { return ObjMaterial("IfcDoor",0.55f,0.3f,0.15f); }
if ( s == "IfcBeam" ) { return ObjMaterial("IfcBeam",0.75f,0.7f,0.7f); }
if ( s == "IfcRailing" ) { return ObjMaterial("IfcRailing",0.65f,0.6f,0.6f); }
if ( s == "IfcMember" ) { return ObjMaterial("IfcMember",0.65f,0.6f,0.6f); }
if ( s == "IfcPlate" ) { return ObjMaterial("IfcPlate",0.8f,0.8f,0.8f); }
return ObjMaterial(s);
}