[DEV] end coding style

This commit is contained in:
Edouard DUPIN 2013-10-10 21:11:50 +02:00
parent cc9f514fb3
commit a65abb55e7
15 changed files with 273 additions and 294 deletions

View File

@ -11,10 +11,9 @@
#include <ege/debug.h>
#undef __class__
#define __class__ "Camera"
#define __class__ "Camera"
void ege::Camera::update(void)
{
void ege::Camera::update(void) {
// Note the view axes of the basic camera is (0,0,-1)
// clean matrix :
m_matrix.identity();
@ -50,8 +49,7 @@ void ege::Camera::update(void)
#endif
}
vec3 ege::Camera::projectOnZGround(const vec2& _cameraDeltaAngle, float _zValue)
{
vec3 ege::Camera::projectOnZGround(const vec2& _cameraDeltaAngle, float _zValue) {
vec3 viewVector(0,0,-1);
viewVector = viewVector.rotate(vec3(0,1,0), -_cameraDeltaAngle.x());
viewVector = viewVector.rotate(vec3(1,0,0), -_cameraDeltaAngle.y());
@ -66,14 +64,13 @@ vec3 ege::Camera::projectOnZGround(const vec2& _cameraDeltaAngle, float _zValue)
_zValue);
}
ege::Camera::Camera(vec3 _eye, float _angleZ, float _angleTeta, float _distance) :
m_eye(_eye),
m_angleZ(_angleZ),
m_angleTeta(_angleTeta),
m_distance(_distance),
m_offsetFactor(1.0f),
m_forceViewTop(false)
{
ege::Camera::Camera(const vec3& _eye, float _angleZ, float _angleTeta, float _distance) :
m_offsetFactor(1.0f),
m_eye(_eye),
m_angleZ(_angleZ),
m_angleTeta(_angleTeta),
m_distance(_distance),
m_forceViewTop(false) {
setEye(_eye);
setAngleZ(_angleZ);
setDistance(_distance);
@ -81,8 +78,7 @@ ege::Camera::Camera(vec3 _eye, float _angleZ, float _angleTeta, float _distance)
update();
}
void ege::Camera::setEye(vec3 _eye)
{
void ege::Camera::setEye(const vec3& _eye) {
m_eye = _eye;
if (m_eye.x() < -1000) {
m_eye.setX(-1000);
@ -105,8 +101,7 @@ void ege::Camera::setEye(vec3 _eye)
update();
}
void ege::Camera::setAngleZ(float _angleZ)
{
void ege::Camera::setAngleZ(float _angleZ) {
if (_angleZ == NAN) {
EGE_CRITICAL("try to set NAN value for the angle ...");
} else if (_angleZ == INFINITY) {
@ -117,22 +112,19 @@ void ege::Camera::setAngleZ(float _angleZ)
update();
}
void ege::Camera::setAngleTeta(float _angleTeta)
{
void ege::Camera::setAngleTeta(float _angleTeta) {
m_angleTeta = etk_avg(M_PI/10.0f, _angleTeta, M_PI/2.0f);
update();
}
void ege::Camera::setDistance(float _distance)
{
void ege::Camera::setDistance(float _distance) {
m_distance = etk_avg(5, _distance, 150);
update();
}
const float localFactor = 2.0;
void ege::Camera::periodicCall(float _step)
{
void ege::Camera::periodicCall(float _step) {
//Note we need to view to the top in 500ms
if (true == m_forceViewTop) {
if (0.0f != m_offsetFactor) {

View File

@ -19,21 +19,13 @@ namespace ege
{
class Camera
{
private:
vec3 m_eye; //!< position where the camera see
float m_angleZ;
float m_angleTeta;
float m_distance;
protected:
mat4 m_matrix; //!< transformation matrix.
float m_offsetFactor; //!< this variable is used to move the camera to the top position of the system == > automaticly
/**
* @brief update the matrix property
*/
void update(void);
// these element is calculated when we get the mattrix:
vec3 m_calculatedOrigin;
vec3 m_calculatedViewVector;
float m_offsetFactor; //!< this variable is used to move the camera to the top position of the system == > automaticly
bool m_forceViewTop;
public:
/**
* @brief Constructor.
@ -42,23 +34,45 @@ namespace ege
* @param[in] _angleTeta Angle of the camera inclinason.
* @param[in] _distance distance to the eye point
*/
Camera(vec3 _eye=vec3(0,0,0), float _angleZ=0, float _angleTeta=0, float _distance=10);
Camera(const vec3& _eye=vec3(0,0,0), float _angleZ=0, float _angleTeta=0, float _distance=10);
protected:
vec3 m_eye; //!< position where the camera see
public:
/**
* @brief set the position of the camera.
* @param[in] pos Position of the camera.
*/
void setEye(vec3 _eye);
void setEye(const vec3& _eye);
/**
* @brief get the curent Camera Eye position.
* @return the current position.
*/
const vec3& getEye(void) const { return m_eye; };
const vec3& getEye(void) const {
return m_eye;
};
protected:
vec3 m_calculatedOrigin;
public:
/**
* @brief get the curent Camera origin position.
* @return the current position.
*/
const vec3& getOrigin(void) const { return m_calculatedOrigin; };
const vec3& getViewVector(void) const { return m_calculatedViewVector; };
const vec3& getOrigin(void) const {
return m_calculatedOrigin;
};
protected:
vec3 m_calculatedViewVector;
public:
/**
* @brief Get the camera viewing vector.
* @return the current position.
*/
const vec3& getViewVector(void) const {
return m_calculatedViewVector;
};
protected:
float m_angleZ;
public:
/**
* @brief set the angle on the camera
* @param[in] _angleZ Rotation angle in Z
@ -68,7 +82,12 @@ namespace ege
* @brief get the curent Camera angles.
* @return the current angles Z.
*/
float getAngleZ(void) const { return m_angleZ; };
float getAngleZ(void) const {
return m_angleZ;
};
protected:
float m_angleTeta;
public:
/**
* @brief set the angle on the camera
* @param[in] _angleTeta Rotation angle in Teta
@ -78,7 +97,12 @@ namespace ege
* @brief get the curent Camera angles.
* @return the current angles Teta.
*/
float getAngleTeta(void) const { return m_angleTeta; };
float getAngleTeta(void) const {
return m_angleTeta;
};
protected:
float m_distance;
public:
/**
* @brief set the angle on the camera
* @param[in] _distance Distance to the eye
@ -88,26 +112,33 @@ namespace ege
* @brief get the curent Camera angles.
* @return the current distance to the eye.
*/
float getDistance(void) const { return m_distance; };
float getDistance(void) const {
return m_distance;
};
/**
* @brief get the transformation matix for the camera.
* @return the current transformation matrix
*/
const mat4& getMatrix(void) const { return m_matrix; };
vec3 projectOnZGround(const vec2& _cameraDeltaAngle, float _zValue=0.0f);
/**
* @brief It is really needed to call the camera periodicly for performing automatic movement
* @param[in] step step time of moving
*/
void periodicCall(float step);
const mat4& getMatrix(void) const {
return m_matrix;
};
protected:
bool m_forceViewTop;
public:
/**
* @brief change camera mode of view == > force to the top view
* @param[in] _newState The new state of this mode...
*/
void setForcingViewTop(bool _newState) { m_forceViewTop = _newState; };
void setForcingViewTop(bool _newState) {
m_forceViewTop = _newState;
};
/**
* @brief It is really needed to call the camera periodicly for performing automatic movement
* @param[in] _step step time of moving
*/
void periodicCall(float _step);
vec3 projectOnZGround(const vec2& _cameraDeltaAngle, float _zValue=0.0f);
};
};

View File

@ -27,8 +27,7 @@
#undef __class__
#define __class__ "CollisionShapeCreator"
btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh)
{
btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
if (NULL == _mesh) {
return new btEmptyShape();;
}

View File

@ -29,27 +29,25 @@
#undef __class__
#define __class__ "ElementGame"
const etk::UString& ege::ElementGame::getType(void) const
{
const etk::UString& ege::ElementGame::getType(void) const {
static const etk::UString nameType("----");
return nameType;
}
ege::ElementGame::ElementGame(ege::Environement& _env) :
m_env(_env),
m_body(NULL),
m_uID(0),
m_mesh(NULL),
m_shape(NULL),
m_life(100),
m_lifeMax(100),
m_group(0),
m_fixe(true),
m_radius(0),
m_elementInPhysicsSystem(false),
m_IA(NULL)
{
m_env(_env),
m_body(NULL),
m_uID(0),
m_mesh(NULL),
m_shape(NULL),
m_life(100),
m_lifeMax(100),
m_group(0),
m_fixe(true),
m_radius(0),
m_elementInPhysicsSystem(false),
m_IA(NULL) {
static uint32_t unique=0;
m_uID = unique;
EGE_DEBUG("Create element : uId=" << m_uID);
@ -57,8 +55,7 @@ ege::ElementGame::ElementGame(ege::Environement& _env) :
unique++;
}
ege::ElementGame::~ElementGame(void)
{
ege::ElementGame::~ElementGame(void) {
// in every case remove IA
iaDisable();
// same ...
@ -72,8 +69,7 @@ ege::ElementGame::~ElementGame(void)
EGE_DEBUG("Destroy element : uId=" << m_uID);
}
void ege::ElementGame::removeShape(void)
{
void ege::ElementGame::removeShape(void) {
// no shape
if (NULL == m_shape) {
return;
@ -93,16 +89,14 @@ void ege::ElementGame::removeShape(void)
// otherwise : the shape is auto remove by the resources when no more needed ...
}
void ege::ElementGame::FunctionFreeShape(void* _pointer)
{
void ege::ElementGame::FunctionFreeShape(void* _pointer) {
if (NULL == _pointer) {
return;
}
delete(static_cast<btCollisionShape*>(_pointer));
}
bool ege::ElementGame::loadMesh(const etk::UString& _meshFileName)
{
bool ege::ElementGame::loadMesh(const etk::UString& _meshFileName) {
ewol::Mesh* tmpMesh=NULL;
tmpMesh = ewol::Mesh::keep(_meshFileName);
if(NULL == tmpMesh) {
@ -112,8 +106,7 @@ bool ege::ElementGame::loadMesh(const etk::UString& _meshFileName)
return setMesh(tmpMesh);
}
bool ege::ElementGame::setMesh(ewol::Mesh* _mesh)
{
bool ege::ElementGame::setMesh(ewol::Mesh* _mesh) {
if (NULL!=m_mesh) {
removeShape();
ewol::Mesh::release(m_mesh);
@ -133,27 +126,22 @@ bool ege::ElementGame::setMesh(ewol::Mesh* _mesh)
return true;
}
bool ege::ElementGame::setShape(btCollisionShape* _shape)
{
bool ege::ElementGame::setShape(btCollisionShape* _shape) {
removeShape();
m_shape = _shape;
return true;
}
float ege::ElementGame::getLifeRatio(void)
{
float ege::ElementGame::getLifeRatio(void) {
if (0 >= m_life) {
return 0;
}
return m_life/m_lifeMax;
}
void ege::ElementGame::setFireOn(int32_t groupIdSource, int32_t type, float power, const vec3& center)
{
void ege::ElementGame::setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center) {
float previousLife = m_life;
m_life += power;
m_life += _power;
m_life = etk_avg(0, m_life, m_lifeMax);
if (m_life <= 0) {
EGE_DEBUG("[" << getUID() << "] element is killed ..." << getType());
@ -163,17 +151,15 @@ void ege::ElementGame::setFireOn(int32_t groupIdSource, int32_t type, float powe
}
}
void ege::ElementGame::setPosition(const vec3& pos)
{
void ege::ElementGame::setPosition(const vec3& _pos) {
if (NULL!=m_body) {
btTransform transformation = m_body->getCenterOfMassTransform();
transformation.setOrigin(pos);
transformation.setOrigin(_pos);
m_body->setCenterOfMassTransform(transformation);
}
}
const vec3& ege::ElementGame::getPosition(void)
{
const vec3& ege::ElementGame::getPosition(void) {
// this is to prevent error like segmentation fault ...
static vec3 emptyPosition(-1000000,-1000000,-1000000);
if (NULL!=m_body) {
@ -182,8 +168,7 @@ const vec3& ege::ElementGame::getPosition(void)
return emptyPosition;
};
const vec3& ege::ElementGame::getSpeed(void)
{
const vec3& ege::ElementGame::getSpeed(void) {
// this is to prevent error like segmentation fault ...
static vec3 emptySpeed(0,0,0);
if (NULL!=m_body) {
@ -192,22 +177,19 @@ const vec3& ege::ElementGame::getSpeed(void)
return emptySpeed;
};
const float ege::ElementGame::getInvMass(void)
{
const float ege::ElementGame::getInvMass(void) {
if (NULL!=m_body) {
return m_body->getInvMass();
}
return 0.0000000001f;
};
static void drawSphere(ewol::Colored3DObject* _draw,
btScalar _radius,
int _lats,
int _longs,
mat4& _transformationMatrix,
etk::Color<float>& _tmpColor)
{
etk::Color<float>& _tmpColor) {
int i, j;
etk::Vector<vec3> EwolVertices;
for(i = 0; i <= _lats; i++) {
@ -250,8 +232,7 @@ const float lifeHeight = 0.3f;
const float lifeWidth = 2.0f;
const float lifeYPos = 1.7f;
void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera)
{
void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera) {
if (NULL == _draw) {
return;
}
@ -291,8 +272,7 @@ void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera&
static void drawShape(const btCollisionShape* _shape,
ewol::Colored3DObject* _draw,
mat4 _transformationMatrix,
etk::Vector<vec3> _tmpVertices)
{
etk::Vector<vec3> _tmpVertices) {
if( NULL == _draw
|| NULL == _shape) {
return;
@ -457,8 +437,7 @@ static void drawShape(const btCollisionShape* _shape,
}
}
void ege::ElementGame::drawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera)
{
void ege::ElementGame::drawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera) {
m_debugText.clear();
m_debugText.setColor(0x00FF00FF);
m_debugText.setPos(vec3(-20,32,0));
@ -483,8 +462,7 @@ void ege::ElementGame::drawDebug(ewol::Colored3DObject* _draw, const ege::Camera
* etk::matScale(vec3(0.05,0.05,0.05)));
}
void ege::ElementGame::draw(int32_t _pass)
{
void ege::ElementGame::draw(int32_t _pass) {
if (false == m_elementInPhysicsSystem) {
return;
}
@ -503,8 +481,7 @@ void ege::ElementGame::draw(int32_t _pass)
}
}
void ege::ElementGame::dynamicEnable(void)
{
void ege::ElementGame::dynamicEnable(void) {
if (true == m_elementInPhysicsSystem) {
return;
}
@ -517,8 +494,7 @@ void ege::ElementGame::dynamicEnable(void)
m_elementInPhysicsSystem = true;
}
void ege::ElementGame::dynamicDisable(void)
{
void ege::ElementGame::dynamicDisable(void) {
if (false == m_elementInPhysicsSystem) {
return;
}
@ -533,8 +509,7 @@ void ege::ElementGame::dynamicDisable(void)
m_elementInPhysicsSystem = false;
}
void ege::ElementGame::iaEnable(void)
{
void ege::ElementGame::iaEnable(void) {
if (NULL != m_IA) {
// IA already started ...
return;
@ -549,8 +524,7 @@ void ege::ElementGame::iaEnable(void)
}
}
void ege::ElementGame::iaDisable(void)
{
void ege::ElementGame::iaDisable(void) {
if (NULL == m_IA) {
// IA already stopped ...
return;

View File

@ -59,8 +59,12 @@ namespace ege
* @param[in] _value pointer on the value type
* @return true, the element is corectly initialized.
*/
virtual bool init(property_te _property, void* _value) { return false; };
virtual bool unInit(void) { return true; };
virtual bool init(property_te _property, void* _value) {
return false;
};
virtual bool unInit(void) {
return true;
};
private:
uint32_t m_uID; //!< This is a reference on a basic element ID
public:
@ -68,7 +72,9 @@ namespace ege
* @brief get the curent Element Unique ID in the all Game.
* @return The requested Unique ID.
*/
inline uint32_t getUID(void) const { return m_uID; };
inline uint32_t getUID(void) const {
return m_uID;
};
private:
ewol::Mesh* m_mesh; //!< Mesh of the Element (can be NULL)
btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it)
@ -98,12 +104,16 @@ namespace ege
* @brief get a pointer on the Mesh file.
* @return the mesh pointer.
*/
inline ewol::Mesh* getMesh(void) { return m_mesh; };
inline ewol::Mesh* getMesh(void) {
return m_mesh;
};
/**
* @brief get a pointer on the bullet collision shape.
* @return the collision pointer.
*/
inline btCollisionShape* getShape(void) { return m_shape; };
inline btCollisionShape* getShape(void) {
return m_shape;
};
private:
/**
* @brief remove the curent selected shape.
@ -122,27 +132,28 @@ namespace ege
* @brief Check if the element is dead.
* @return true if the element does not exist anymore, false otherwise.
*/
bool isDead(void) { return (0 >= m_life)?true:false; };
bool isDead(void) {
return (0 >= m_life)?true:false;
};
/**
* @brief Request if the element might be removed from the system
* @return true == > the object is removed
*/
virtual bool needToRemove(void)
{
virtual bool needToRemove(void) {
return isDead();
}
/**
* @brief apply a fire on the element at a current power and a specific power.
* @param[in] groupIdSource Source Id of the group, by default all event arrive at all group, buf some event can not be obviously apply at the ennemy like reparing ....
* @param[in] type Type of event on the life propertied
* @param[in] power Power of the event (can be >0 for adding life).
* @param[in] center Some fire decrease in function of space distance...
* @param[in] _groupIdSource Source Id of the group, by default all event arrive at all group, buf some event can not be obviously apply at the ennemy like reparing ....
* @param[in] _type Type of event on the life propertied
* @param[in] _power Power of the event (can be >0 for adding life).
* @param[in] _center Some fire decrease in function of space distance...
*/
virtual void setFireOn(int32_t groupIdSource, int32_t type, float power, const vec3& center=vec3(0,0,0));
virtual void setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center=vec3(0,0,0));
/**
* @brief Call chan the element life change
*/
virtual void onLifeChange(void) {}
virtual void onLifeChange(void) { };
protected:
int32_t m_group; //!< Every element has a generic group
public:
@ -150,12 +161,16 @@ namespace ege
* @brief get the Group of the element.
* @return The group ID
*/
inline int32_t getGroup(void) const { return m_group; };
inline int32_t getGroup(void) const {
return m_group;
};
/**
* @brief set the group of the curent element
* @param[in] newGroup The new Group ID of the element.
*/
inline void setGroup(int32_t _newGroup) { m_group=_newGroup; };
inline void setGroup(int32_t _newGroup) {
m_group=_newGroup;
};
/**
* @brief Can be call tu opdate the list of the element displayed on the scren (example : no display of the hiden triangle)
@ -188,12 +203,14 @@ namespace ege
* @brief get the theoric position. Sometimes, the element has move due to an explosion or something else, then its real position in not the one that woult it be at the end ...
* @return the theoric position
*/
virtual vec3 getPositionTheoric(void) { return getPosition(); };
virtual vec3 getPositionTheoric(void) {
return getPosition();
};
/**
* @brief set the current Theoric position of the element
* @param[in] set the 3D position.
*/
virtual void setPositionTheoric(const vec3& _pos) { }
virtual void setPositionTheoric(const vec3& _pos) { };
/**
* @brief get the current position of the element
* @return the 3D position.
@ -226,7 +243,9 @@ namespace ege
* @brief get the element if it is fixed or not. if the element is fixed this is for tower, and all thing does not really move
* @return true : The element is fixed.
*/
inline bool isFixed(void) { return m_fixe; };
inline bool isFixed(void) {
return m_fixe;
};
protected:
float m_radius; //!< Radius of the element (all element have a radius, if == 0 ==> then ghost ...
public:
@ -250,8 +269,7 @@ namespace ege
*/
void dynamicDisable(void);
private:
class localIA : public btActionInterface
{
class localIA : public btActionInterface {
private:
ege::ElementGame& m_element;
public:
@ -262,15 +280,16 @@ namespace ege
/**
* @brief Destructor
*/
virtual ~localIA(void) { };
// herited function
void debugDraw(btIDebugDraw* debugDrawer) { };
// herited function
void updateAction(btCollisionWorld* collisionWorld, btScalar step)
{
m_element.iaAction(step);
}
virtual ~localIA(void) {
};
public: // herited function
void debugDraw(btIDebugDraw* _debugDrawer) {
};
void updateAction(btCollisionWorld* _collisionWorld, btScalar _step) {
m_element.iaAction(_step);
};
};
localIA* m_IA;
public:

View File

@ -12,11 +12,10 @@
#undef __class__
#define __class__ "Environement"
#define __class__ "Environement"
ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _sourceRequest, float& _distance)
{
ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _sourceRequest, float& _distance) {
if (NULL == _sourceRequest) {
return NULL;
}
@ -49,8 +48,7 @@ ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _source
void ege::Environement::getElementNearest(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList)
{
etk::Vector<ege::Environement::ResultNearestElement>& _resultList) {
_resultList.clear();
ege::Environement::ResultNearestElement result;
result.dist = 99999999999.0f;
@ -76,8 +74,7 @@ void ege::Environement::getElementNearest(const vec3& _sourcePosition,
void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList)
{
etk::Vector<ege::Environement::ResultNearestElement>& _resultList) {
_resultList.clear();
ege::Environement::ResultNearestElement result;
result.dist = 99999999999.0f;
@ -113,16 +110,12 @@ void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
}
}
static etk::Hash<ege::createElement_tf>& getHachTableCreating(void)
{
static etk::Hash<ege::createElement_tf>& getHachTableCreating(void) {
static etk::Hash<ege::createElement_tf> s_table;
return s_table;
}
void ege::Environement::addCreator(const etk::UString& _type, ege::createElement_tf _creator)
{
void ege::Environement::addCreator(const etk::UString& _type, ege::createElement_tf _creator) {
if (NULL == _creator) {
EGE_ERROR("Try to add an empty CREATOR ...");
return;
@ -134,8 +127,7 @@ void ege::Environement::addCreator(const etk::UString& _type, ege::createElement
getHachTableCreating().add(_type, _creator);
}
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, bool _autoAddElement, ege::property_te _property, void* _value)
{
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, bool _autoAddElement, ege::property_te _property, void* _value) {
if (false == getHachTableCreating().exist(_type)) {
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
return NULL;
@ -162,24 +154,20 @@ ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, bo
return tmpElement;
}
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, etk::UString& _description, bool _autoAddElement)
{
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, etk::UString& _description, bool _autoAddElement) {
return createElement(_type, _autoAddElement, ege::typeString, static_cast<void*>(&_description));
}
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, ejson::Value* _value, bool _autoAddElement)
{
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, ejson::Value* _value, bool _autoAddElement) {
return createElement(_type, _autoAddElement, ege::typeJson, static_cast<void*>(_value));
}
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, exml::Node* _node, bool _autoAddElement)
{
ege::ElementGame* ege::Environement::createElement(const etk::UString& _type, exml::Node* _node, bool _autoAddElement) {
return createElement(_type, _autoAddElement, ege::typeXml, static_cast<void*>(_node));
}
void ege::Environement::addElementGame(ege::ElementGame* _newElement)
{
void ege::Environement::addElementGame(ege::ElementGame* _newElement) {
// prevent memory allocation and un allocation ...
if (NULL == _newElement) {
return;
@ -195,8 +183,7 @@ void ege::Environement::addElementGame(ege::ElementGame* _newElement)
_newElement->dynamicEnable();
}
void ege::Environement::rmElementGame(ege::ElementGame* _removeElement)
{
void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) {
if (NULL == _removeElement) {
return;
}
@ -221,8 +208,7 @@ void ege::Environement::rmElementGame(ege::ElementGame* _removeElement)
void ege::Environement::getOrderedElementForDisplay(etk::Vector<ege::Environement::ResultNearestElement>& _resultList,
const vec3& _position,
const vec3& _direction)
{
const vec3& _direction) {
// remove all unneeded elements (old display...)
_resultList.clear();
// basic element result
@ -267,8 +253,7 @@ void ege::Environement::getOrderedElementForDisplay(etk::Vector<ege::Environemen
}
void ege::Environement::generateInteraction(ege::ElementInteraction& _event)
{
void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
for (int32_t iii=0; iii<m_listElementGame.size() ; iii++) {
if (NULL == m_listElementGame[iii]) {
@ -288,8 +273,7 @@ void ege::Environement::generateInteraction(ege::ElementInteraction& _event)
}
ege::Environement::Environement(void) :
m_dynamicsWorld(NULL),
m_particuleEngine(*this)
{
m_dynamicsWorld(NULL),
m_particuleEngine(*this) {
// nothing to do ...
}

View File

@ -38,8 +38,7 @@ namespace ege {
class Environement;
typedef ege::ElementGame* (*createElement_tf)(ege::Environement& _env);
class ElementInteraction
{
class ElementInteraction {
protected:
int32_t m_type;
public:
@ -67,8 +66,7 @@ namespace ege {
virtual void applyEvent(ege::ElementGame& _element) { };
};
class Environement
{
class Environement {
private:
btDynamicsWorld* m_dynamicsWorld; //!< curent system world description
etk::Vector<ege::ElementGame*> m_listElementGame; //!< List of all element added in the Game
@ -95,8 +93,7 @@ namespace ege {
ege::ElementGame* createElement(const etk::UString& _type, ejson::Value* _value, bool _autoAddElement=true);
ege::ElementGame* createElement(const etk::UString& _type, exml::Node* _node, bool _autoAddElement=true);
public:
class ResultNearestElement
{
class ResultNearestElement {
public:
ege::ElementGame* element;
float dist;
@ -105,17 +102,23 @@ namespace ege {
* @brief set the curent world
* @param[in] _newWorld Pointer on the current world
*/
void setDynamicWorld(btDynamicsWorld* _newWorld) { m_dynamicsWorld=_newWorld; };
void setDynamicWorld(btDynamicsWorld* _newWorld) {
m_dynamicsWorld=_newWorld;
};
/**
* @brief get the curent world
* @return pointer on the current world
*/
btDynamicsWorld* getDynamicWorld(void) { return m_dynamicsWorld; };
btDynamicsWorld* getDynamicWorld(void) {
return m_dynamicsWorld;
};
/**
* @breif get a reference on the curent list of element games
* @return all element list
*/
etk::Vector<ege::ElementGame*>& getElementGame(void) { return m_listElementGame; };
etk::Vector<ege::ElementGame*>& getElementGame(void) {
return m_listElementGame;
};
/**
* @brief get the nearest Element
* @param[in] _sourceRequest Pointer on the element that request this.
@ -124,8 +127,12 @@ namespace ege {
*/
ege::ElementGame* getElementNearest(ege::ElementGame* _sourceRequest, float& _distance);
void getElementNearest(const vec3& _sourcePosition, float _distanceMax, etk::Vector<ege::Environement::ResultNearestElement>& _resultList);
void getElementNearestFixed(const vec3& _sourcePosition, float _distanceMax, etk::Vector<ege::Environement::ResultNearestElement>& _resultList);
void getElementNearest(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList);
void getElementNearestFixed(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList);
/**
* @brief add an element on the list availlable.
* @param[in] _newElement Element to add.
@ -155,7 +162,9 @@ namespace ege {
* @brief get the particule engine reference.
* @return The requested reference on the engine
*/
ege::ParticuleEngine& getParticuleEngine(void) { return m_particuleEngine; };
ege::ParticuleEngine& getParticuleEngine(void) {
return m_particuleEngine;
};
};
};

View File

@ -13,9 +13,8 @@
#define __class__ "Particule"
ege::Particule::Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType) :
m_particuleEngine(_particuleEngine),
m_particuleType(_particuleType)
{
m_particuleEngine(_particuleEngine),
m_particuleType(_particuleType) {
m_particuleEngine.add(this);
}

View File

@ -24,8 +24,7 @@ namespace ege {
* it does not have any control, for example smoke or reactor generation ...
* or explosion particule ...
*/
class Particule
{
class Particule {
protected:
ege::ParticuleEngine& m_particuleEngine;
const char* m_particuleType;
@ -62,12 +61,16 @@ namespace ege {
* @return true : The element might be removed
* @return false : The element might be keeped
*/
virtual bool needRemove(void) { return false; };
virtual bool needRemove(void) {
return false;
};
/**
* @brief get the type of the particule
* @return Type of the current particule
*/
const char* getParticuleType(void) { return m_particuleType; };
const char* getParticuleType(void) {
return m_particuleType;
};
/**
* @brief When the particule arrive to his end of life, this function is called.
*/

View File

@ -10,21 +10,18 @@
#include <ege/ParticuleEngine.h>
#undef __class__
#define __class__ "ParticuleEngine"
#define __class__ "ParticuleEngine"
ege::ParticuleEngine::ParticuleEngine(ege::Environement& _env) :
m_env(_env)
{
m_env(_env) {
}
ege::ParticuleEngine::~ParticuleEngine(void)
{
ege::ParticuleEngine::~ParticuleEngine(void) {
clear();
}
void ege::ParticuleEngine::add(Particule* _particule)
{
void ege::ParticuleEngine::add(Particule* _particule) {
if (_particule == NULL) {
EGE_ERROR("Try to add particule NULL");
return;
@ -40,8 +37,7 @@ void ege::ParticuleEngine::add(Particule* _particule)
m_particuleList.pushBack(_particule);
}
void ege::ParticuleEngine::addRemoved(Particule* _particule)
{
void ege::ParticuleEngine::addRemoved(Particule* _particule) {
if (_particule == NULL) {
return;
}
@ -56,8 +52,7 @@ void ege::ParticuleEngine::addRemoved(Particule* _particule)
m_particuleRemoved.pushBack(_particule);
}
ege::Particule* ege::ParticuleEngine::respown(const char* _particuleType)
{
ege::Particule* ege::ParticuleEngine::respown(const char* _particuleType) {
if (_particuleType == NULL) {
return NULL;
}
@ -76,8 +71,7 @@ ege::Particule* ege::ParticuleEngine::respown(const char* _particuleType)
return NULL;
}
void ege::ParticuleEngine::update(float _deltaTime)
{
void ege::ParticuleEngine::update(float _deltaTime) {
if (_deltaTime>(1.0f/60.0f)) {
_deltaTime = (1.0f/60.0f);
}
@ -115,8 +109,7 @@ void ege::ParticuleEngine::update(float _deltaTime)
*/
}
void ege::ParticuleEngine::draw(const ege::Camera& _camera)
{
void ege::ParticuleEngine::draw(const ege::Camera& _camera) {
for (esize_t iii=0; iii<m_particuleList.size(); ++iii) {
if (m_particuleList[iii] == NULL) {
continue;
@ -125,8 +118,7 @@ void ege::ParticuleEngine::draw(const ege::Camera& _camera)
}
}
void ege::ParticuleEngine::clear(void)
{
void ege::ParticuleEngine::clear(void) {
// clear element not removed
for (esize_t iii=0; iii<m_particuleList.size(); ++iii) {
if (m_particuleList[iii] == NULL) {

View File

@ -20,8 +20,7 @@ namespace ege {
#include <ege/Particule.h>
namespace ege {
class ParticuleEngine
{
class ParticuleEngine {
private:
ege::Environement& m_env;
public:

View File

@ -9,19 +9,16 @@
#include <ege/debug.h>
#include <ege/ParticuleSimple.h>
#undef __class__
#define __class__ "ParticuleSimple"
#define __class__ "ParticuleSimple"
ege::ParticuleSimple::ParticuleSimple(ege::ParticuleEngine& _particuleEngine, const char* _particuleType) :
Particule(_particuleEngine, _particuleType)
{
Particule(_particuleEngine, _particuleType) {
init();
}
void ege::ParticuleSimple::init(void)
{
void ege::ParticuleSimple::init(void) {
m_lifeFull = 3;
m_life = m_lifeFull;
m_level = 0;
@ -32,52 +29,43 @@ void ege::ParticuleSimple::init(void)
m_scaleExpand = vec3(0,0,0);
}
bool ege::ParticuleSimple::needRemove(void)
{
bool ege::ParticuleSimple::needRemove(void) {
return m_life<0.0f;
}
void ege::ParticuleSimple::update(float _delta)
{
void ege::ParticuleSimple::update(float _delta) {
//EGE_DEBUG("Life : " << m_life << "-" << _delta);
m_life -= _delta;
m_pos += m_speed*_delta;
m_scale += m_scaleExpand*_delta;
}
void ege::ParticuleSimple::setLife(float _life)
{
void ege::ParticuleSimple::setLife(float _life) {
m_lifeFull = _life;
m_life = m_lifeFull;
}
void ege::ParticuleSimple::setLevel(float _level)
{
void ege::ParticuleSimple::setLevel(float _level) {
m_level = _level;
}
void ege::ParticuleSimple::setPosition(const vec3& _pos)
{
void ege::ParticuleSimple::setPosition(const vec3& _pos) {
m_pos = _pos;
}
void ege::ParticuleSimple::setAngle(float _angle)
{
void ege::ParticuleSimple::setAngle(float _angle) {
m_angle = _angle;
}
void ege::ParticuleSimple::setMoveSpeed(const vec3& _speed)
{
void ege::ParticuleSimple::setMoveSpeed(const vec3& _speed) {
m_speed = _speed;
}
void ege::ParticuleSimple::setScale(const vec3& _scale)
{
void ege::ParticuleSimple::setScale(const vec3& _scale) {
m_scale = _scale;
}
void ege::ParticuleSimple::setScaleExpend(const vec3& _scaleExpand)
{
void ege::ParticuleSimple::setScaleExpend(const vec3& _scaleExpand) {
m_scaleExpand=_scaleExpand;
}

View File

@ -27,8 +27,7 @@ namespace ege {
* it does not have any control, for example smoke or reactor generation ...
* or explosion particule ...
*/
class ParticuleSimple : public Particule
{
class ParticuleSimple : public Particule {
public:
/**
* @brief Constructor.

View File

@ -28,7 +28,7 @@
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#undef __class__
#define __class__ "Scene"
#define __class__ "Scene"
const char * const ege::Scene::eventPlayTimeChange = "event-scene-play-time-change";
@ -37,14 +37,13 @@ const char * const ege::Scene::eventKillEnemy = "event-scene-kill-ennemy";
ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
m_gameTime(0),
m_angleView(M_PI/3.0),
m_dynamicsWorld(NULL),
m_camera(NULL),
m_isRunning(true),
m_debugMode(false),
m_debugDrawing(NULL)
{
m_gameTime(0),
m_angleView(M_PI/3.0),
m_dynamicsWorld(NULL),
m_camera(NULL),
m_isRunning(true),
m_debugMode(false),
m_debugDrawing(NULL) {
setKeyboardRepeate(false);
setCanHaveFocus(true);
periodicCallEnable();
@ -66,8 +65,7 @@ void ege::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConf
btCollisionDispatcher* _dispatcher,
btBroadphaseInterface* _broadphase,
btConstraintSolver* _solver,
btDynamicsWorld* _dynamicsWorld)
{
btDynamicsWorld* _dynamicsWorld) {
if (NULL != _collisionConfiguration) {
m_collisionConfiguration = _collisionConfiguration;
} else {
@ -104,8 +102,7 @@ void ege::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConf
}
void ege::Scene::setCamera(ege::Camera* _camera)
{
void ege::Scene::setCamera(ege::Camera* _camera) {
if (NULL != _camera) {
m_camera = _camera;
} else {
@ -115,8 +112,7 @@ void ege::Scene::setCamera(ege::Camera* _camera)
}
}
ege::Scene::~Scene(void)
{
ege::Scene::~Scene(void) {
ewol::Colored3DObject::release(m_debugDrawing);
/*
ewol::resource::release(m_directDrawObject);
@ -140,31 +136,23 @@ ege::Scene::~Scene(void)
*/
}
void ege::Scene::onRegenerateDisplay(void)
{
void ege::Scene::onRegenerateDisplay(void) {
if (true == needRedraw()) {
}
}
void ege::Scene::pause(void)
{
void ege::Scene::pause(void) {
EGE_DEBUG("Set pause");
m_isRunning = false;
}
void ege::Scene::resume(void)
{
void ege::Scene::resume(void) {
EGE_DEBUG("Set resume");
m_isRunning = true;
}
void ege::Scene::pauseToggle(void)
{
void ege::Scene::pauseToggle(void) {
if(true == m_isRunning) {
EGE_DEBUG("Set Toggle: pause");
m_isRunning=false;
@ -185,8 +173,7 @@ void ege::Scene::pauseToggle(void)
#define NUMBER_OF_SUB_PASS (0)
void ege::Scene::onDraw(void)
{
void ege::Scene::onDraw(void) {
#ifdef SCENE_DISPLAY_SPEED
g_counterNbTimeDisplay++;
g_startTime = ewol::getTime();
@ -243,16 +230,13 @@ void ege::Scene::onDraw(void)
}
// I really does not know what is this ...
btRigidBody& btActionInterface::getFixedBody()
{
btRigidBody& btActionInterface::getFixedBody(void) {
static btRigidBody s_fixed(0, 0,0);
s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
return s_fixed;
}
void ege::Scene::periodicCall(const ewol::EventTime& _event)
{
void ege::Scene::periodicCall(const ewol::EventTime& _event) {
float curentDelta=_event.getDeltaCall();
// small hack to change speed ...
if (m_ratioTime != 1) {
@ -364,10 +348,9 @@ EWOL_DEBUG(" SCENE444 : " << tmp___localTime4 << "ms ");
#endif
}
vec2 ege::Scene::calculateDeltaAngle(const vec2& posScreen)
{
vec2 ege::Scene::calculateDeltaAngle(const vec2& _posScreen) {
double ratio = m_size.x() / m_size.y();
vec2 pos = vec2(m_size.x()/-2.0, m_size.y()/-2.0) + posScreen;
vec2 pos = vec2(m_size.x()/-2.0, m_size.y()/-2.0) + _posScreen;
double xmax = tan(m_angleView/2.0);
double ymax = xmax / ratio;
@ -382,9 +365,8 @@ vec2 ege::Scene::calculateDeltaAngle(const vec2& posScreen)
angleY);
}
vec3 ege::Scene::convertScreenPositionInMapPosition(const vec2& posScreen)
{
return m_camera->projectOnZGround(calculateDeltaAngle(posScreen));
vec3 ege::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) {
return m_camera->projectOnZGround(calculateDeltaAngle(_posScreen));
}

View File

@ -94,13 +94,15 @@ namespace ege {
/**
* @brief Toggle the debug mode == > usefull for DEBUG only ...
*/
void debugToggle(void) { m_debugMode = m_debugMode?false:true; };
void debugToggle(void) {
m_debugMode = m_debugMode?false:true;
};
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
virtual void ScenePeriodicCall(int64_t _localTime, int32_t _deltaTime) { };
public:
vec2 calculateDeltaAngle(const vec2& posScreen);
vec3 convertScreenPositionInMapPosition(const vec2& posScreen);
vec2 calculateDeltaAngle(const vec2& _posScreen);
vec3 convertScreenPositionInMapPosition(const vec2& _posScreen);
/**
* @brief get the current camera reference for the scene rendering
*/
@ -108,17 +110,24 @@ namespace ege {
/**
* @brief set the curent Time Ratio (default 1)
*/
void setRatioTime(float newRatio) { m_ratioTime = newRatio; };
void setRatioTime(float _newRatio) {
m_ratioTime = _newRatio;
};
void renderscene(int pass);
void drawOpenGL(btScalar* m,
const btCollisionShape* shape,
const btVector3& color,
int32_t debugMode,
const btVector3& worldBoundsMin,
const btVector3& worldBoundsMax);
void drawSphere(btScalar radius, int lats, int longs, mat4& transformationMatrix, etk::Color<float>& tmpColor);
void getElementAroundNewElement(vec3 sourcePosition, etk::Vector<ege::Environement::ResultNearestElement>& resultList);
const btCollisionShape* _shape,
const btVector3& _color,
int32_t _debugMode,
const btVector3& _worldBoundsMin,
const btVector3& _worldBoundsMax);
void drawSphere(btScalar _radius,
int _lats,
int _longs,
mat4& _transformationMatrix,
etk::Color<float>& _tmpColor);
void getElementAroundNewElement(vec3 _sourcePosition,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList);
protected: // Derived function
virtual void onDraw(void);