#ifndef OAG_OAGOBJECT_H
#define OAG_OAGOBJECT_H
#include "OAGTree.h"
#ifdef _WIN32
#ifdef _MSC_VER
#include "..\..\..\Common\include\OAGColor.h"
#include "..\..\..\Common\include\OAG2DMath.h"
#include <string.h>
#endif
#endif
class CCamera;
#include "OAGXMLData.h"
namespace oag
{
class OAGObject : public oag::OAGNode
{
public:
OAGObject(void);
virtual ~OAGObject(void);
//Attributes
protected:
std::string m_strName;
bool m_bIsSelected;
GLenum m_PolygonFace; //GL_FRONT, GL_BACK or GL_FRONT_AND_BACK
GLenum m_PolygonMode; //GL_POINT, GL_LINE or GL_FILL
oag::OAGColor m_Color; //object color
public:
oag::OAGVector3f m_position; // object position
oag::OAGVector3f m_scale; // object scale
oag::OAGVector3f m_rotation; // object rotation
oag::OAGVector3f velocity; // velocity of object
oag::OAGVector3f acceleration; // acceleration
float size; // size of bounding sphere (radius)
//Operations
public:
//Draws the objects and childs
void Draw();
public:
//Gets the current color set for the object
void GetColor(oag::OAGColor &color)
{
color.SetColor( m_Color.GetRed(), m_Color.GetGreen(), m_Color.GetBlue(), m_Color.GetAlpha() );
}
//Gets the current name set for the object
std::string GetObjectName()
{
return m_strName;
}
//Gets the status for the object selection
//Return TRUE if the object is selected.
bool IsSelected()
{
return m_bIsSelected;
}
//Sets the color for the object
void SetColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255)
{
m_Color.SetColor(red, green, blue, alpha);
}
//Sets a for the object
void SetObjectName(std::string strName)
{
m_strName = strName;
}
//Selects a polygon rasterization mode.
//@Param face - The face mode for the polygons => GL_FRONT, GL_BACK or GL_FRONT_AND_BACK
//@Param mode - The way polygons will be rasterized => GL_POINT, GL_LINE or GL_FILL
void SetPolygonMode(GLenum mode, GLenum face = GL_FRONT_AND_BACK)
{
m_PolygonMode = mode; m_PolygonFace = face;
}
//Sets the position for the object or translate the object.
void SetPosition(oag::OAGVector3f vector)
{
m_position = vector;
}
//Sets the position for the object or translate the object.
void SetPosition(float x, float y, float z)
{
m_position.SetVertex(x, y, z);
}
//Sets the position for the object or translate the object.
void SetPosition(CXmlNode* pNode)
{
if ( pNode )
{
CXmlNode* pNodeTranslation = pNode->GetNode("Translation");
if ( pNodeTranslation )
{
float x = (float)atof ( pNodeTranslation->GetAttribute("x").c_str() );
float y = (float)atof ( pNodeTranslation->GetAttribute("y").c_str() );
float z = (float)atof ( pNodeTranslation->GetAttribute("z").c_str() );
SetPosition( x, y, z);
}
}
}
//Sets the scale for the object
void SetScale(oag::OAGVector3f vector)
{
m_scale = vector;
}
//Sets the rotation for the object
void SetRotation(oag::OAGVector3f vector)
{
m_rotation = vector;
}
//Sets the status for the selected object.
void SetSelected(bool bSelected)
{
m_bIsSelected = bSelected;
}
//Virtual Operations
public:
//Reads the xmlnode written for the object and loads its data.
virtual void ReadNodeXML(CXmlNode* pNode);
//Writes the xmlnode for the object with the data.
virtual void SaveNodeXML(CXmlNode* pNode);
protected:
//Called by funtion Draw. Draws the objects
virtual void OnDraw(){};
//Operations for XML
public:
CXmlNode* CreateNodeColor();
//Functions for game engine
};
};
#endif //OAG_OAGOBJECT_H