removed unnecessary junk from Material and updated to match properties we now need. added Color class
This commit is contained in:
parent
69e4eee05b
commit
80a4c87b92
|
@ -80,7 +80,6 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\assets\material.cpp" />
|
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\md2\md2.cpp" />
|
<ClCompile Include="src\md2\md2.cpp" />
|
||||||
<ClCompile Include="src\ms3d\ms3d.cpp" />
|
<ClCompile Include="src\ms3d\ms3d.cpp" />
|
||||||
|
@ -89,6 +88,7 @@
|
||||||
<ClCompile Include="src\util\files.cpp" />
|
<ClCompile Include="src\util\files.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\assets\color.h" />
|
||||||
<ClInclude Include="src\assets\material.h" />
|
<ClInclude Include="src\assets\material.h" />
|
||||||
<ClInclude Include="src\chunks\materials.h" />
|
<ClInclude Include="src\chunks\materials.h" />
|
||||||
<ClInclude Include="src\chunks\normals.h" />
|
<ClInclude Include="src\chunks\normals.h" />
|
||||||
|
|
80
MeshConverter/src/assets/color.h
Normal file
80
MeshConverter/src/assets/color.h
Normal file
|
@ -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
|
|
@ -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()
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef __MATERIAL_H_INCLUDED__
|
#ifndef __ASSETS_MATERIAL_H_INCLUDED__
|
||||||
#define __MATERIAL_H_INCLUDED__
|
#define __ASSETS_MATERIAL_H_INCLUDED__
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
#define RGB_32(r, g, b, a) ((b)|((g) << 8)|((r) << 16)|((a) << 24))
|
#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))
|
#define RGB_24(r, g, b) ((b)|((g) << 8)|((r) << 16))
|
||||||
|
@ -11,30 +13,13 @@
|
||||||
class Material
|
class Material
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Material(unsigned long ambient = 0, unsigned long diffuse = 0, unsigned long specular = 0, unsigned long emission = 0, std::string texture = "");
|
std::string name;
|
||||||
virtual ~Material();
|
Color ambient;
|
||||||
|
Color diffuse;
|
||||||
void SetAmbient(unsigned long ambient) { m_ambient = ambient; }
|
Color specular;
|
||||||
void SetDiffuse(unsigned long diffuse) { m_diffuse = diffuse; }
|
Color emissive;
|
||||||
void SetSpecular(unsigned long specular) { m_specular = specular; }
|
float shininess;
|
||||||
void SetEmission(unsigned long emission) { m_emission = emission; }
|
float opacity;
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in a new issue