#ifndef OAG_OAGCUBE_H
#define OAG_OAGCUBE_H
#include "OAGObject.h"
#include "OAGPrimitives.h"
namespace oag
{
class OAGCube : public oag::OAGObject
{
public:
OAGCube(void);
OAGCube(float nWidth, float nHeight, float nDepth);
virtual ~OAGCube(void);
//Attributes
protected:
float m_nWidth, m_nHeight, m_nDepth;
oag::OAGPrimitives leftFace, rightFace, frontFace, backFace, topFace, bottomFace;
//Operations
protected:
void CreateNodeColor( oag::OAGColor &color, CXmlNode* pNodeColor)
{
//Color node
char buffer[_CVTBUFSIZE];
_gcvt_s(buffer, _CVTBUFSIZE, color.GetRed()/255.f, 2 ); pNodeColor->AddAttribute("Red", buffer);
_gcvt_s(buffer, _CVTBUFSIZE, color.GetGreen()/255.f, 2 ); pNodeColor->AddAttribute("Green", buffer);
_gcvt_s(buffer, _CVTBUFSIZE, color.GetBlue()/255.f, 2 ); pNodeColor->AddAttribute("Blue", buffer);
_gcvt_s(buffer, _CVTBUFSIZE, color.GetAlpha()/255.f, 2 ); pNodeColor->AddAttribute("Alpha", buffer);
}
public:
void CreateCube();
float GetDepth() { return m_nDepth; };
float GetHeight() { return m_nHeight; };
float GetWidth() { return m_nWidth; };
void SetDepth(float nDepth) { m_nDepth = nDepth; };
void SetHeight(float nHeight) { m_nHeight = nHeight; };
void SetWidth(float nWidth) { m_nWidth = nWidth; };
void SetLeftFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
leftFace.SetColor(red, green, blue, alpha);
}
void SetRightFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
rightFace.SetColor(red, green, blue, alpha);
}
void SetFrontFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
frontFace.SetColor(red, green, blue, alpha);
}
void SetBackFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
backFace.SetColor(red, green, blue, alpha);
}
void SetTopFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
topFace.SetColor(red, green, blue, alpha);
}
void SetBottomFaceColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
bottomFace.SetColor(red, green, blue, alpha);
}
//Virtual
public:
virtual void OnDraw();
virtual void ReadNodeXML(CXmlNode* pNode);
virtual void SaveNodeXML(CXmlNode* pNode);
//Sets the color for the object
void SetColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
SetFrontFaceColor(red, green, blue, alpha);
SetBackFaceColor(red, green, blue, alpha);
SetRightFaceColor(red, green, blue, alpha);
SetLeftFaceColor(red, green, blue, alpha);
SetTopFaceColor(red, green, blue, alpha);
SetBottomFaceColor(red, green, blue, alpha);
}
//Selects a polygon rasterization mode.
void SetPolygonMode(GLenum mode, GLenum face = GL_FRONT_AND_BACK)
{
frontFace.SetPolygonMode(mode, face);
backFace.SetPolygonMode(mode, face);
rightFace.SetPolygonMode(mode, face);
leftFace.SetPolygonMode(mode, face);
topFace.SetPolygonMode(mode, face);
bottomFace.SetPolygonMode(mode, face);
}
//Sets the position for the object or translate the object.
void SetPosition(float x, float y, float z)
{
oag::OAGObject::SetPosition(x, y, z);
frontFace.SetPosition(x, y, z);
rightFace.SetPosition(x, y, z);
backFace.SetPosition(x, y, z);
leftFace.SetPosition(x, y, z);
bottomFace.SetPosition(x, y, z);
topFace.SetPosition(x, y, z);
}
};
};
#endif //OAG_OAGCUBE_H