diff --git a/MeshConverter/MeshConverter.vcxproj b/MeshConverter/MeshConverter.vcxproj
index b5aa4a0..ed5b5ef 100644
--- a/MeshConverter/MeshConverter.vcxproj
+++ b/MeshConverter/MeshConverter.vcxproj
@@ -80,7 +80,6 @@
-
@@ -89,6 +88,7 @@
+
diff --git a/MeshConverter/src/assets/color.h b/MeshConverter/src/assets/color.h
new file mode 100644
index 0000000..b7633da
--- /dev/null
+++ b/MeshConverter/src/assets/color.h
@@ -0,0 +1,80 @@
+#ifndef __ASSETS_COLOR_H_INCLUDED__
+#define __ASSETS_COLOR_H_INCLUDED__
+
+#include "../common.h"
+
+#define COLOR_ALPHA_TRANSPARENT 0.0f
+#define COLOR_ALPHA_OPAQUE 1.0f
+
+class Color
+{
+public:
+ Color()
+ {
+ r = 0.0f;
+ g = 0.0f;
+ b = 0.0f;
+ a = COLOR_ALPHA_OPAQUE;
+ }
+
+ Color(float red, float green, float blue)
+ {
+ r = red;
+ g = green;
+ b = blue;
+ a = COLOR_ALPHA_OPAQUE;
+ }
+
+ Color(float red, float green, float blue, float alpha)
+ {
+ r = red;
+ g = green;
+ b = blue;
+ a = alpha;
+ }
+
+ uint32_t ToInt()
+ {
+ return ((uint32_t)(a * 255) << 24) | ((uint32_t)(r * 255) << 16) | ((uint32_t)(g * 255) << 8) | (uint32_t)(b * 255);
+ }
+
+ static uint32_t ToInt(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
+ {
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ }
+
+ static uint32_t ToInt(float r, float g, float b, float a)
+ {
+ return ((int)(a * 255) << 24) | ((int)(r * 255) << 16) | ((int)(g * 255) << 8) | (int)(b * 255);
+ }
+
+ static void FromInt(uint32_t color, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
+ {
+ *a = (color & 0xff000000) >> 24;
+ *r = (color & 0x00ff0000) >> 16;
+ *g = (color & 0x0000ff00) >> 8;
+ *b = (color & 0x000000ff);
+ }
+
+ static void FromInt(uint32_t color, float *r, float *g, float *b, float *a)
+ {
+ *a = ((float)((color & 0xff000000) >> 24)) / 255;
+ *r = ((float)((color & 0x00ff0000) >> 16)) / 255;
+ *g = ((float)((color & 0x0000ff00) >> 8)) / 255;
+ *b = ((float)((color & 0x000000ff))) / 255;
+ }
+
+ static Color FromInt(uint32_t color)
+ {
+ Color out;
+ FromInt(color, &out.r, &out.g, &out.b, &out.a);
+ return out;
+ }
+
+ float r;
+ float g;
+ float b;
+ float a;
+};
+
+#endif
diff --git a/MeshConverter/src/assets/material.cpp b/MeshConverter/src/assets/material.cpp
deleted file mode 100644
index c92f80a..0000000
--- a/MeshConverter/src/assets/material.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "material.h"
-
-Material::Material(unsigned long ambient, unsigned long diffuse, unsigned long specular, unsigned long emission, std::string texture)
-{
- m_ambient = ambient;
- m_diffuse = diffuse;
- m_specular = specular;
- m_emission = emission;
- m_texture = texture;
-}
-
-Material::~Material()
-{
-}
diff --git a/MeshConverter/src/assets/material.h b/MeshConverter/src/assets/material.h
index 0c8c6b4..dbbe9f5 100644
--- a/MeshConverter/src/assets/material.h
+++ b/MeshConverter/src/assets/material.h
@@ -1,7 +1,9 @@
-#ifndef __MATERIAL_H_INCLUDED__
-#define __MATERIAL_H_INCLUDED__
+#ifndef __ASSETS_MATERIAL_H_INCLUDED__
+#define __ASSETS_MATERIAL_H_INCLUDED__
+#include "../common.h"
#include
+#include "color.h"
#define RGB_32(r, g, b, a) ((b)|((g) << 8)|((r) << 16)|((a) << 24))
#define RGB_24(r, g, b) ((b)|((g) << 8)|((r) << 16))
@@ -11,30 +13,13 @@
class Material
{
public:
- Material(unsigned long ambient = 0, unsigned long diffuse = 0, unsigned long specular = 0, unsigned long emission = 0, std::string texture = "");
- virtual ~Material();
-
- void SetAmbient(unsigned long ambient) { m_ambient = ambient; }
- void SetDiffuse(unsigned long diffuse) { m_diffuse = diffuse; }
- void SetSpecular(unsigned long specular) { m_specular = specular; }
- void SetEmission(unsigned long emission) { m_emission = emission; }
- void SetTexture(std::string texture) { m_texture = texture; }
- unsigned long GetAmbient() { return m_ambient; }
- unsigned long GetDiffuse() { return m_diffuse; }
- unsigned long GetSpecular() { return m_specular; }
- unsigned long GetEmission() { return m_emission; }
- std::string GetTexture() { return m_texture; }
-
- static void ApplyDefault();
- static Material GetDefault();
- void Apply();
-
-private:
- unsigned long m_ambient;
- unsigned long m_diffuse;
- unsigned long m_specular;
- unsigned long m_emission;
- std::string m_texture;
+ std::string name;
+ Color ambient;
+ Color diffuse;
+ Color specular;
+ Color emissive;
+ float shininess;
+ float opacity;
};
#endif
\ No newline at end of file