-
Notifications
You must be signed in to change notification settings - Fork 0
/
SGMaterial.cpp
61 lines (45 loc) · 1.43 KB
/
SGMaterial.cpp
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
#include "stdafx.h"
#include "SGMaterial.h"
#include "SGScript.h"
namespace CSGProcessor
{
SGTextureAttrCarve operator*(double s, const SGTextureAttrCarve &t) {
return SGTextureAttrCarve(t.u * s, t.v * s);
}
SGTextureAttrCarve &operator+=(SGTextureAttrCarve &t1, const SGTextureAttrCarve &t2) {
t1.u += t2.u;
t1.v += t2.v;
return t1;
}
std::shared_ptr<SGMaterial> SGMaterial::invisibleMaterial = std::make_shared<SGMaterial>();
void SGMaterial::LuaBind( lua_State* L )
{
using namespace luabind;
module(L)
[
class_<SGMaterial>("material")
.def(constructor<const char*>())
.def(constructor<const char*, const SGLuaVector&>())
.def(constructor<const char*, const SGLuaVector&, const SGLuaVector&>())
.def(constructor<const SGMaterial&, const SGLuaVector&>())
// .def(constructor<const cl_I&>())
// .def(constructor<float>())
// .def(constructor<const char*>())
// .def(tostring(const_self))
// .def("render",&CSGMaterial::SGLuaMaterial::render)
// .def("light",&CSGMaterial::SGLuaMaterial::light)
];
luabind::globals(L)["INVISIBLE"] = invisibleMaterial.get();
CSGScript::GetInstance()->SetMaterial((INT_PTR)invisibleMaterial.get(),invisibleMaterial);
}
SGMaterial* SGMaterial::getLocalInst() const
{
auto i = CSGScript::GetInstance();
auto m = i->GetMaterial((INT_PTR)this);
if (!m){
m = std::make_shared<SGMaterial>(*this);
i->SetMaterial((INT_PTR)this,m);
}
return m.get();
}
}