Logo
Material.h
1#pragma once
2
3namespace SharpKmyGfx
4{
5 public enum class UNIFORMPARAMTYPE {
6 kFLOAT,
7 kVEC2,
8 kVEC3,
9 kVEC4,
10 kCOLOR3,
11 kCOLOR4,
12 kMATRIX,
13 kINT,
14 kINT2,
15 kINT3,
16 kBOOL,
18 kENUM,
20
23 };
24
25 public ref class Material
26 {
27 public:
28 Material(bool skinned, System::String^ shadername, System::Guid guid);
29 Material(kmyGfx::Material* mtl);
30 Material(System::String^ defimage, System::Guid guid);
31 ~Material();
32
33 System::String^ getName();
35 void setShader(System::String^ shadername);
36 void setParameterF(System::String^ slotname, float x, float y, float z, float w);
37 void setParameterI(System::String^ slotname, int x, int y, int z, int w);
38 void setParameterB(System::String^ slotname, bool b);
39 void setTextureFileName(System::String^ slotname, System::String^ texfilename);
40 void setTexture(System::String^ slotname, Texture^ tex);
41 Texture^ getTexture(System::String^ slotname);
42 Texture^ getTexture(int index);
43 int getEnumCount(System::String^ slotname);
44 System::String^ getEnumString(System::String^ slotname, int index);
45 static int getMaterialTextureNumMax() { return USER_FP_TEXTURE_NUM_MAX; }
46
47 System::String^ getShaderName();
48 //System::String^ getShaderDescription();
49 bool getSlotName(int idx, UNIFORMPARAMTYPE %paramtype,
50 bool %hideInEditor,
51 [Runtime::InteropServices::Out] System::String ^%name);
52 UNIFORMPARAMTYPE getSlotType(System::String^ name);
53 float getParameterF(System::String^ slotname, int channel);
54 int getParameterI(System::String^ slotname, int channel);
55 float getParameterMin(System::String^ slotname, int channel);
56 float getParameterMax(System::String^ slotname, int channel);
57 bool getParameterB(System::String^ slotname);
58 System::String^ getTextureFileName(System::String^ slotname);
59 //System::String^ getDescription(System::String^ slotname);
60 float getUScrollSpeed();
61 float getVScrollSpeed();
62 void setUScrollSpeed(float v);
63 void setVScrollSpeed(float v);
64 unsigned int getUDiv();
65 unsigned int getVDiv();
66 void setUDiv(unsigned int v);
67 void setVDiv(unsigned int v);
68 float getUVStepInterval();
69 void setUVStepInterval(float v);
70 unsigned int getUVStepFrameCount();
71 void setUVStepFrameCount(unsigned int v);
72 void enableUScrollAnim(bool flg);
73 void enableVScrollAnim(bool flg);
74 void enableUVStepAnim(bool flg);
77 bool isEnableUVStepAnim();
78 void enableEmissiveBlink(bool flg);
80 void setEmissiveBlinkSpeed(float v);
84 void setCastShadow(bool flg);
85 bool getCastShadow();
87 int getSortIndex() { return obj!=nullptr ? obj->getSortIdx() : 0; }
88 void setSortIndex(int val) { if (obj)obj->setSortIdx(val); }
93 CULLTYPE getCullType() { return (CULLTYPE)obj->getPolygonState().m_cullType; }
95 auto ps = obj->getPolygonState();
96 ps.m_cullType = (kmyGfx::CULLTYPE)t;
97 obj->setPolygonState(ps);
98 }
99 void setDrawOutlineEnable(bool flg)
100 {
101 if (obj)obj->setDrawOutlineEnable(flg);
102 }
104 {
105 if (obj)return obj->getDrawOutlineEnable();
106 return false;
107 }
108 void setOutlineWidth(float w)
109 {
110 if (obj)obj->setOutlineWidth(w);
111 }
113 {
114 if (obj)return obj->getOutlineWidth();
115 return 0;
116 }
118 {
119 if (obj)obj->setOutlineColor(kmyGfx::Color(color.r, color.g, color.b, color.a));
120 }
122 {
123 kmyGfx::Color c = kmyGfx::Color::black();
124 if(obj)c = obj->getOutlineColor();
125 return Color(c.r, c.g, c.b, c.a);
126 }
128 {
129 if (obj)obj->setOverrideOutlineSetting(flg);
130 }
132 {
133 if (obj)return obj->getOverrideOutlineSetting();
134 return false;
135 }
136 void setDistanceFadeEnable(bool flg) { if (obj)obj->setDistanceFadeEnable(flg); }
137 bool getDistanceFadeEnable() { return obj ? obj->getDistanceFadeEnable() : false; }
138 void setReceiveDecal(bool flg) { if (obj)obj->setReceiveDecal(flg); }
139 bool getReceiveDecal() { return obj ? obj->getReceiveDecal() : false; }
140
142 {
143 return kmyGfx::Material::getCommonDrawOutlineEnable();
144 }
145 static void setCommonDrawOutlineEnable(bool flg)
146 {
147 return kmyGfx::Material::setCommonDrawOutlineEnable(flg);
148 }
150 {
151 return kmyGfx::Material::getCommonOutlineWidth();
152 }
153 static void setCommonOutlineWidth(float w)
154 {
155 kmyGfx::Material::setCommonOutlineWidth(w);
156 }
158 {
159 kmyGfx::Color c = kmyGfx::Material::getCommonOutlineColor();
160 return Color(c.r, c.g, c.b, c.a);
161 }
162 static void setCommonOutlineColor(Color color)
163 {
164 kmyGfx::Color c(color.r, color.g, color.b, color.a);
165 kmyGfx::Material::setCommonOutlineColor(c);
166 }
167
168 bool isEnableSetCastShadow() { return obj->isEnableSetCastShadow(); }
169
170 System::String^ getDefText();
171 void setDefByText(System::String^ text);
172
173 bool owning = true;
174 kmyGfx::Material *obj = nullptr;
175
176 void addRef();
177 void removeRef();
178 };
179
180}
Definition: Color.h:5
float r
Definition: Color.h:7
float b
Definition: Color.h:7
float a
Definition: Color.h:7
float g
Definition: Color.h:7
Definition: Material.h:26
bool isEnableSetCastShadow()
Definition: Material.h:168
int getSortIndex()
Definition: Material.h:87
SharpKmyMath::Vector2 getUVScale()
Definition: Material.cpp:474
bool getOverrideOutlineSetting()
Definition: Material.h:131
void setUVOffset(SharpKmyMath::Vector2 v)
Definition: Material.cpp:489
bool getSlotName(int idx, UNIFORMPARAMTYPE %paramtype, bool %hideInEditor, [Runtime::InteropServices::Out] System::String ^%name)
Definition: Material.cpp:234
System::String getDefText()
Definition: Material.cpp:408
float getUVStepInterval()
Definition: Material.cpp:463
static bool getCommonDrawOutlineEnable()
Definition: Material.h:141
void setCastShadow(bool flg)
Definition: Material.cpp:488
void setParameterB(System::String^ slotname, bool b)
Definition: Material.cpp:87
void setUVScale(SharpKmyMath::Vector2 v)
Definition: Material.cpp:490
unsigned int getVDiv()
Definition: Material.cpp:461
void setEmissiveBlinkSpeed(float v)
Definition: Material.cpp:486
void setDrawOutlineEnable(bool flg)
Definition: Material.h:99
bool owning
Definition: Material.h:173
unsigned int getUVStepFrameCount()
Definition: Material.cpp:462
bool getCastShadow()
Definition: Material.cpp:467
Texture getTexture(System::String^ slotname)
Definition: Material.cpp:107
void setVScrollSpeed(float v)
Definition: Material.cpp:479
~Material()
Definition: Material.cpp:35
Color getOutlineColor()
Definition: Material.h:121
float getOutlineWidth()
Definition: Material.h:112
void enableUScrollAnim(bool flg)
Definition: Material.cpp:476
void setVDiv(unsigned int v)
Definition: Material.cpp:482
void setUVStepInterval(float v)
Definition: Material.cpp:484
void enableVScrollAnim(bool flg)
Definition: Material.cpp:478
float getParameterMin(System::String^ slotname, int channel)
Definition: Material.cpp:337
UNIFORMPARAMTYPE getSlotType(System::String^ name)
Definition: Material.cpp:273
void setTextureFileName(System::String^ slotname, System::String^ texfilename)
Definition: Material.cpp:175
void setDefByText(System::String^ text)
Definition: Material.cpp:432
bool isEmissiveLinkBuildingLight()
Definition: Material.cpp:466
Material(bool skinned, System::String^ shadername, System::Guid guid)
Definition: Material.cpp:5
static float getCommonOutlineWidth()
Definition: Material.h:149
System::String getTextureFileName(System::String^ slotname)
Definition: Material.cpp:373
void setOutlineColor(Color color)
Definition: Material.h:117
float getParameterF(System::String^ slotname, int channel)
Definition: Material.cpp:289
void setParameterI(System::String^ slotname, int x, int y, int z, int w)
Definition: Material.cpp:74
System::String getName()
Definition: Material.cpp:40
System::String getShaderName()
Definition: Material.cpp:191
void removeRef()
Definition: Material.cpp:493
float getEmissiveBlinkSpeed()
Definition: Material.cpp:465
void setReceiveDecal(bool flg)
Definition: Material.h:138
void setParameterF(System::String^ slotname, float x, float y, float z, float w)
Definition: Material.cpp:61
bool isEnableVScrollAnim()
Definition: Material.cpp:457
void setUVStepFrameCount(unsigned int v)
Definition: Material.cpp:483
int getParameterI(System::String^ slotname, int channel)
Definition: Material.cpp:306
int getEnumCount(System::String^ slotname)
Definition: Material.cpp:135
SharpKmyMath::Vector2 getUVOffset()
Definition: Material.cpp:473
bool getParameterB(System::String^ slotname)
Definition: Material.cpp:323
float getParameterMax(System::String^ slotname, int channel)
Definition: Material.cpp:355
void enableEmissiveBlink(bool flg)
Definition: Material.cpp:485
void setShader(System::String^ shadername)
Definition: Material.cpp:53
static void setCommonDrawOutlineEnable(bool flg)
Definition: Material.h:145
bool isEnableUScrollAnim()
Definition: Material.cpp:455
static int getMaterialTextureNumMax()
Definition: Material.h:45
void setSortIndex(int val)
Definition: Material.h:88
bool getReceiveDecal()
Definition: Material.h:139
static void setCommonOutlineWidth(float w)
Definition: Material.h:153
bool isEnableUVStepAnim()
Definition: Material.cpp:459
void setOutlineWidth(float w)
Definition: Material.h:108
Shader getShader()
Definition: Material.cpp:48
static void setCommonOutlineColor(Color color)
Definition: Material.h:162
void setUDiv(unsigned int v)
Definition: Material.cpp:481
void setDistanceFadeEnable(bool flg)
Definition: Material.h:136
bool isEnableEmissiveBlink()
Definition: Material.cpp:464
void setTexture(System::String^ slotname, Texture^ tex)
Definition: Material.cpp:100
void setOverrideOutlineSetting(bool flg)
Definition: Material.h:127
void addRef()
Definition: Material.cpp:492
unsigned int getUDiv()
Definition: Material.cpp:460
void setUScrollSpeed(float v)
Definition: Material.cpp:477
System::String getEnumString(System::String^ slotname, int index)
Definition: Material.cpp:154
bool getDrawOutlineEnable()
Definition: Material.h:103
float getVScrollSpeed()
Definition: Material.cpp:458
bool getDistanceFadeEnable()
Definition: Material.h:137
void setCullType(CULLTYPE t)
Definition: Material.h:94
void enableUVStepAnim(bool flg)
Definition: Material.cpp:480
float getUScrollSpeed()
Definition: Material.cpp:456
kmyGfx::Material * obj
Definition: Material.h:174
void enableEmissiveLinkBuildingLight(bool flg)
Definition: Material.cpp:487
CULLTYPE getCullType()
Definition: Material.h:93
static Color getCommonOutlineColor()
Definition: Material.h:157
bool isEnableSetSortIndex()
Definition: Material.cpp:468
Definition: Shader.h:8
Definition: Texture.h:72
Definition: Billboard.cpp:4
UNIFORMPARAMTYPE
Definition: Material.h:5
CULLTYPE
Definition: DrawInfo.h:25
Definition: Vector3.h:186