[DEV] First step on the ege engine idea came from basic gane Tethys

This commit is contained in:
Edouard DUPIN 2013-08-13 21:23:11 +02:00
parent b303071de2
commit 2c3084c794
21 changed files with 2237 additions and 2 deletions

11
ege/AudioElement.cpp Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/AudioElement.h>

18
ege/AudioElement.h Normal file
View File

@ -0,0 +1,18 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_AUDIO_ELEMENT_H__
#define __EGE_AUDIO_ELEMENT_H__
namespace ege {
};
#endif

11
ege/AudioEngine.cpp Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/AudioEngine.h>

18
ege/AudioEngine.h Normal file
View File

@ -0,0 +1,18 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_AUDIO_ENGINE_H__
#define __EGE_AUDIO_ENGINE_H__
namespace ege {
};
#endif

147
ege/Camera.cpp Normal file
View File

@ -0,0 +1,147 @@
/**
* @author Edouard DUPIN
*
* @copyright 2013, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/Camera.h>
#include <ege/debug.h>
void ege::Camera::Update(void)
{
// Note the view axes of the basic camera is (0,0,-1)
// clean matrix :
m_matrix.Identity();
// move the world from the camera distance
m_matrix.Translate(vec3(0,0,-m_distance));
// teta represent the angle from the ground to the axes then 90-teta represent the angle to apply (inverted for the world)
m_matrix.Rotate(vec3(1,0,0), -((M_PI/2.0f-m_angleTeta)*m_offsetFactor) );
m_matrix.Rotate(vec3(0,0,1), -m_angleZ );
// move the camera to the end point of view
m_matrix.Translate(-m_eye);
#if 1
m_calculatedViewVector = vec3(0,0,-1);
m_calculatedViewVector = m_calculatedViewVector.rotate(vec3(1,0,0), -((M_PI/2.0f-m_angleTeta)*m_offsetFactor) );
m_calculatedViewVector = m_calculatedViewVector.rotate(vec3(0,0,1), -m_angleZ );
m_calculatedViewVector *= vec3(1,-1,1);
m_calculatedOrigin = m_eye - m_calculatedViewVector*m_distance;
#else
float onGround = cosf(m_angleTeta)*m_distance;
m_calculatedOrigin.setValue(sinf(m_angleZ)*onGround,
-cosf(m_angleZ)*onGround,
sinf(m_angleTeta)*m_distance);
m_calculatedViewVector= -m_calculatedOrigin.normalized();
m_calculatedOrigin += m_eye;
#endif
#if 0
EGE_DEBUG("Camera properties : eye=" << m_eye );
EGE_DEBUG(" Z=" << RAD_TO_DEG(m_angleZ) << "");
EGE_DEBUG(" Teta=" << RAD_TO_DEG(m_angleTeta) << "" );
EGE_DEBUG(" distance=" << m_distance);
EGE_DEBUG(" origin=" << m_calculatedOrigin );
EGE_DEBUG(" m_calculatedViewVector=" << m_calculatedViewVector);
#endif
}
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());
viewVector = viewVector.rotate(vec3(1,0,0), -((M_PI/2.0f-m_angleTeta)*m_offsetFactor) );
viewVector = viewVector.rotate(vec3(0,0,1), -m_angleZ );
viewVector *= vec3(1,-1,1);
// get intersection with the plane : z=0
// equation : pointIntersect = viewVector * alpha + origin;
float alpha = (_zValue - m_calculatedOrigin.z()) / viewVector.z();
return vec3(viewVector.x()*alpha + m_calculatedOrigin.x(),
viewVector.y()*alpha + m_calculatedOrigin.y(),
_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)
{
SetEye(_eye);
SetAngleZ(_angleZ);
SetDistance(_distance);
SetAngleTeta(_angleTeta);
Update();
}
void ege::Camera::SetEye(vec3 _eye)
{
m_eye = _eye;
if (m_eye.x() < -1000) {
m_eye.setX(-1000);
}
if (m_eye.x() > 1000) {
m_eye.setX(1000);
}
if (m_eye.y() < -1000) {
m_eye.setY(-1000);
}
if (m_eye.y() > 1000) {
m_eye.setY(1000);
}
if (m_eye.z() < -10) {
m_eye.setZ(-10);
}
if (m_eye.z() > 10) {
m_eye.setZ(10);
}
Update();
}
void ege::Camera::SetAngleZ(float _angleZ)
{
if (_angleZ==NAN) {
EGE_CRITICAL("try to set NAN value for the angle ...");
} else if (_angleZ==INFINITY) {
EGE_CRITICAL("try to set INFINITY value for the angle ...");
} else {
m_angleZ = _angleZ;
}
Update();
}
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)
{
m_distance = etk_avg(5, _distance, 150);
Update();
}
const float localFactor = 2.0;
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) {
m_offsetFactor -= _step*localFactor;
m_offsetFactor = etk_avg(0,m_offsetFactor,1);
Update();
}
} else {
if (1.0f != m_offsetFactor) {
m_offsetFactor += _step*localFactor;
m_offsetFactor = etk_avg(0,m_offsetFactor,1);
Update();
}
}
}

115
ege/Camera.h Normal file
View File

@ -0,0 +1,115 @@
/**
* @author Edouard DUPIN
*
* @copyright 2013, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_CAMERA_H__
#define __EGE_CAMERA_H__
#include <etk/types.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Vector2D.h>
#include <etk/math/Matrix4.h>
namespace ege
{
class Camera
{
private:
vec3 m_eye; //!< position where the camera see
float m_angleZ;
float m_angleTeta;
float m_distance;
mat4 m_matrix; //!< transformation matrix.
/**
* @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.
* @param[in] _eye Position of the camera destination view.
* @param[in] _angleZ Z rotation angle.
* @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);
/**
* @brief Set the position of the camera.
* @param[in] pos Position of the camera.
*/
void SetEye(vec3 _eye);
/**
* @brief Get the curent Camera Eye position.
* @return the current position.
*/
const vec3& GetEye(void) const { return m_eye; };
/**
* @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; };
/**
* @brief Set the angle on the camera
* @param[in] _angleZ Rotation angle in Z
*/
void SetAngleZ(float _angleZ);
/**
* @brief Get the curent Camera angles.
* @return the current angles Z.
*/
float GetAngleZ(void) const { return m_angleZ; };
/**
* @brief Set the angle on the camera
* @param[in] _angleTeta Rotation angle in Teta
*/
void SetAngleTeta(float _angleTeta);
/**
* @brief Get the curent Camera angles.
* @return the current angles Teta.
*/
float GetAngleTeta(void) const { return m_angleTeta; };
/**
* @brief Set the angle on the camera
* @param[in] _distance Distance to the eye
*/
void SetDistance(float _distance);
/**
* @brief Get the curent Camera angles.
* @return the current distance to the eye.
*/
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);
/**
* @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; };
};
};
#endif

353
ege/ElementGame.cpp Normal file
View File

@ -0,0 +1,353 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/types.h>
#include <ege/debug.h>
#include <ege/ElementGame.h>
#include <ege/Environement.h>
#include <ewol/renderer/ResourceManager.h>
#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h>
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletCollisionCommon.h>
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
#include <BulletCollision/CollisionShapes/btShapeHull.h>
#include <LinearMath/btTransformUtil.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#undef __class__
#define __class__ "ElementGame"
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_shape(NULL),
m_life(100),
m_lifeMax(100),
m_group(0),
m_fixe(true),
m_elementInPhysicsSystem(false)
{
static uint32_t unique=0;
m_uID = unique;
EGE_DEBUG("Create element : uId=" << m_uID);
unique++;
}
ege::ElementGame::~ElementGame(void)
{
EGE_DEBUG("Destroy element : uId=" << m_uID);
}
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)
{
float previousLife = m_life;
m_life += power;
m_life = etk_avg(0, m_life, m_lifeMax);
if (m_life!=previousLife) {
OnLifeChange();
}
}
void ege::ElementGame::SetPosition(const vec3& pos)
{
if (NULL!=m_body) {
btTransform transformation = m_body->getCenterOfMassTransform();
transformation.setOrigin(pos);
m_body->setCenterOfMassTransform(transformation);
}
}
const vec3& ege::ElementGame::GetPosition(void)
{
// this is to prevent error like segmentation fault ...
static vec3 emptyPosition(-1000000,-1000000,-1000000);
if (NULL!=m_body) {
return m_body->getCenterOfMassPosition();
}
return emptyPosition;
};
const vec3& ege::ElementGame::GetSpeed(void)
{
// this is to prevent error like segmentation fault ...
static vec3 emptySpeed(0,0,0);
if (NULL!=m_body) {
return m_body->getLinearVelocity();
}
return emptySpeed;
};
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)
{
int i, j;
etk::Vector<vec3> EwolVertices;
for(i = 0; i <= _lats; i++) {
btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar) (i - 1) / _lats);
btScalar z0 = _radius*sin(lat0);
btScalar zr0 = _radius*cos(lat0);
btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar) i / _lats);
btScalar z1 = _radius*sin(lat1);
btScalar zr1 = _radius*cos(lat1);
//glBegin(GL_QUAD_STRIP);
for(j = 0; j < _longs; j++) {
btScalar lng = 2 * SIMD_PI * (btScalar) (j - 1) / _longs;
btScalar x = cos(lng);
btScalar y = sin(lng);
vec3 v1 = vec3(x * zr1, y * zr1, z1);
vec3 v4 = vec3(x * zr0, y * zr0, z0);
lng = 2 * SIMD_PI * (btScalar) (j) / _longs;
x = cos(lng);
y = sin(lng);
vec3 v2 = vec3(x * zr1, y * zr1, z1);
vec3 v3 = vec3(x * zr0, y * zr0, z0);
EwolVertices.PushBack(v1);
EwolVertices.PushBack(v2);
EwolVertices.PushBack(v3);
EwolVertices.PushBack(v1);
EwolVertices.PushBack(v3);
EwolVertices.PushBack(v4);
}
}
_draw->Draw(EwolVertices, _tmpColor, _transformationMatrix);
}
const float lifeBorder = 0.1f;
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)
{
if (NULL==_draw) {
return;
}
float ratio = GetLifeRatio();
if (ratio == 1.0f) {
return;
}
mat4 transformationMatrix = etk::matTranslate(GetPosition())
* etk::matRotate(vec3(0,0,1),_camera.GetAngleZ())
* etk::matRotate(vec3(1,0,0),(M_PI/2.0f-_camera.GetAngleTeta()));
etk::Vector<vec3> localVertices;
localVertices.PushBack(vec3(-lifeWidth/2.0-lifeBorder,lifeYPos -lifeBorder,0));
localVertices.PushBack(vec3(-lifeWidth/2.0-lifeBorder,lifeYPos+lifeHeight+lifeBorder,0));
localVertices.PushBack(vec3( lifeWidth/2.0+lifeBorder,lifeYPos+lifeHeight+lifeBorder,0));
localVertices.PushBack(vec3(-lifeWidth/2.0-lifeBorder,lifeYPos -lifeBorder,0));
localVertices.PushBack(vec3( lifeWidth/2.0+lifeBorder,lifeYPos+lifeHeight+lifeBorder,0));
localVertices.PushBack(vec3( lifeWidth/2.0+lifeBorder,lifeYPos -lifeBorder,0));
etk::Color<float> myColor(0x0000FF99);
_draw->Draw(localVertices, myColor, transformationMatrix, false, false);
localVertices.Clear();
/** Bounding box ==> model shape **/
localVertices.PushBack(vec3(-lifeWidth/2.0 ,lifeYPos,0));
localVertices.PushBack(vec3(-lifeWidth/2.0 ,lifeYPos + lifeHeight,0));
localVertices.PushBack(vec3(-lifeWidth/2.0+lifeWidth*ratio,lifeYPos + lifeHeight,0));
localVertices.PushBack(vec3(-lifeWidth/2.0 ,lifeYPos,0));
localVertices.PushBack(vec3(-lifeWidth/2.0+lifeWidth*ratio,lifeYPos + lifeHeight,0));
localVertices.PushBack(vec3(-lifeWidth/2.0+lifeWidth*ratio,lifeYPos,0));
myColor =0x00FF00FF;
if (ratio < 0.2f) {
myColor = 0xFF0000FF;
} else if (ratio < 0.4f) {
myColor = 0xDA7B00FF;
}
_draw->Draw(localVertices, myColor, transformationMatrix, false, false);
}
static void DrawShape(const btCollisionShape* _shape,
ewol::Colored3DObject* _draw,
mat4 _transformationMatrix,
etk::Vector<vec3> _tmpVertices)
{
if( NULL == _draw
|| NULL == _shape) {
return;
}
etk::Color<float> tmpColor(1.0, 0.0, 0.0, 0.3);
//EGE_DEBUG(" Draw (6): !btIDebugDraw::DBG_DrawWireframe");
int shapetype=_shape->getShapeType();
switch (shapetype) {
case SPHERE_SHAPE_PROXYTYPE: {
// Sphere collision shape ...
//EGE_DEBUG(" Draw (01): SPHERE_SHAPE_PROXYTYPE");
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(_shape);
float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
DrawSphere(_draw, radius, 10, 10, _transformationMatrix, tmpColor);
break;
}
case BOX_SHAPE_PROXYTYPE: {
// Box collision shape ...
//EGE_DEBUG(" Draw (02): BOX_SHAPE_PROXYTYPE");
const btBoxShape* boxShape = static_cast<const btBoxShape*>(_shape);
btVector3 halfExtent = boxShape->getHalfExtentsWithMargin();
static int indices[36] = { 0,1,2, 3,2,1, 4,0,6,
6,0,2, 5,1,4, 4,1,0,
7,3,1, 7,1,5, 5,4,7,
7,4,6, 7,2,3, 7,6,2};
vec3 vertices[8]={ vec3(halfExtent[0],halfExtent[1],halfExtent[2]),
vec3(-halfExtent[0],halfExtent[1],halfExtent[2]),
vec3(halfExtent[0],-halfExtent[1],halfExtent[2]),
vec3(-halfExtent[0],-halfExtent[1],halfExtent[2]),
vec3(halfExtent[0],halfExtent[1],-halfExtent[2]),
vec3(-halfExtent[0],halfExtent[1],-halfExtent[2]),
vec3(halfExtent[0],-halfExtent[1],-halfExtent[2]),
vec3(-halfExtent[0],-halfExtent[1],-halfExtent[2])};
_tmpVertices.Clear();
for (int32_t iii=0 ; iii<36 ; iii+=3) {
// normal calculation :
//btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]);
//normal.normalize ();
_tmpVertices.PushBack(vertices[indices[iii]]);
_tmpVertices.PushBack(vertices[indices[iii+1]]);
_tmpVertices.PushBack(vertices[indices[iii+2]]);
}
_draw->Draw(_tmpVertices, tmpColor, _transformationMatrix);
break;
}
case CONE_SHAPE_PROXYTYPE: {
// Cone collision shape ...
EGE_DEBUG(" Draw (03): CONE_SHAPE_PROXYTYPE");
break;
}
case CAPSULE_SHAPE_PROXYTYPE: {
// Capsule collision shape ...
EGE_DEBUG(" Draw (04): CAPSULE_SHAPE_PROXYTYPE");
break;
}
case CYLINDER_SHAPE_PROXYTYPE: {
// Cylinder collision shape ...
EGE_DEBUG(" Draw (05): CYLINDER_SHAPE_PROXYTYPE");
break;
}
case CONVEX_HULL_SHAPE_PROXYTYPE: {
// Convex Hull collision shape ...
EGE_DEBUG(" Draw (06): CYLINDER_SHAPE_PROXYTYPE");
break;
}
case COMPOUND_SHAPE_PROXYTYPE: {
// Multiple sub element collision shape ...
//EGE_DEBUG(" Draw (07): COMPOUND_SHAPE_PROXYTYPE");
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(_shape);
for (int32_t iii=compoundShape->getNumChildShapes()-1;iii>=0;iii--) {
btTransform childTrans = compoundShape->getChildTransform(iii);
const btCollisionShape* colShape = compoundShape->getChildShape(iii);
btScalar mmm[16];
childTrans.getOpenGLMatrix(mmm);
mat4 transformationMatrix(mmm);
transformationMatrix.Transpose();
transformationMatrix = _transformationMatrix * transformationMatrix;
DrawShape(colShape, _draw, transformationMatrix, _tmpVertices);
}
break;
}
case EMPTY_SHAPE_PROXYTYPE: {
// No collision shape ...
//EGE_DEBUG(" Draw (08): EMPTY_SHAPE_PROXYTYPE");
// nothing to display ...
break;
}
default: {
// must be done later ...
EGE_DEBUG(" Draw (09): default");
}
}
}
void ege::ElementGame::DrawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera)
{
m_debugText.Clear();
m_debugText.SetFontSize(12);
m_debugText.SetColor(0x00FF00FF);
m_debugText.SetPos(vec3(-20,32,0));
m_debugText.Print(GetType());
m_debugText.SetPos(vec3(-20,20,0));
m_debugText.Print(etk::UString("life=(")+etk::UString(GetLifeRatio()));
//m_debugText.Print(etk::UString("Axe=(")+etk::UString(m_tmpAxe.x())+etk::UString(",")+etk::UString(m_tmpAxe.y())+etk::UString(",")+etk::UString(m_tmpAxe.z())+etk::UString(")"));
btScalar mmm[16];
btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState();
myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(mmm);
mat4 transformationMatrix(mmm);
transformationMatrix.Transpose();
// note : set the vertice here to prevent multiple allocations...
etk::Vector<vec3> EwolVertices;
DrawShape(m_shape, _draw, transformationMatrix, EwolVertices);
m_debugText.Draw( etk::matTranslate(GetPosition())
* etk::matRotate(vec3(0,0,1),_camera.GetAngleZ())
* etk::matRotate(vec3(1,0,0),(M_PI/2.0f-_camera.GetAngleTeta()))
* etk::matScale(vec3(0.05,0.05,0.05)));
}
void ege::ElementGame::DynamicEnable(void)
{
if (false == m_elementInPhysicsSystem) {
if(NULL!=m_body) {
m_env.GetDynamicWorld()->addRigidBody(m_body);
}
m_elementInPhysicsSystem = true;
}
}
void ege::ElementGame::DynamicDisable(void)
{
if (true == m_elementInPhysicsSystem) {
if(NULL!=m_body) {
// Unlink element from the engine
m_env.GetDynamicWorld()->removeRigidBody(m_body);
m_env.GetDynamicWorld()->removeCollisionObject(m_body);
}
m_elementInPhysicsSystem = false;
}
}

204
ege/ElementGame.h Normal file
View File

@ -0,0 +1,204 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_ELEMENT_GAME_H__
#define __EGE_ELEMENT_GAME_H__
#include <etk/types.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Matrix4.h>
#include <etk/Vector.h>
#include <ewol/debug.h>
#include <ewol/game/Camera.h>
#include <ewol/widget/Widget.h>
#include <ewol/renderer/openGL.h>
#include <ewol/renderer/ResourceManager.h>
#include <ege/Camera.h>
#include <ewol/compositing/Text.h>
#include <ege/Environement.h>
#define INDEX_RIGHT_AXIS (0)
#define INDEX_FORWARD_AXIS (1)
#define INDEX_UP_AXIS (2)
#define ELEMENT_SCALE (1.0f/8.0f)
namespace ege
{
class ElementGame
{
protected:
ege::Environement& m_env;
protected:
btRigidBody* m_body; //!< all the element have a body ==> otherwise it will be not manage with this system...
public:
/**
* @brief Constructor
*/
ElementGame(ege::Environement& _env);
/**
* @brief Destructor
*/
virtual ~ElementGame(void);
protected:
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)
public:
/**
* @brief Select a mesh with a specific name.
* @param[in] _meshFileName Filename of the Mesh.
*/
void LoadMesh(const etk::UString& _meshFileName);
protected:
float m_life; //!< Current life of the object
float m_lifeMax; //!< Maximum possible life of the element
public:
/**
* @brief Get the curent life ratio [0..1]
* @return The proportionnal life
*/
float GetLifeRatio(void);
/**
* @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; };
/**
* @brief Request if the element might be removed from the system
* @return true ==> the object is removed
*/
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...
*/
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) {}
private:
uint32_t m_uID; //!< This is a reference on a basic element ID
public:
/**
* @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;
}
/**
* @brief Get the element Type description string
* @return A pointer on the descriptive string (Do not free it ==> it might be a const)
*/
virtual const etk::UString& GetType(void) const;
protected:
int32_t m_group; //!< Every element has a generic group
public:
/**
* @brief Get the Group of the element.
* @return The group ID
*/
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; };
/**
* @brief Can be call tu opdate the list of the element displayed on the scren (example : no display of the hiden triangle)
* @param[in] the camera properties
* @ note by default nothing to do ...
*/
virtual void PreCalculationDraw(const ege::Camera& _camera) { };
/**
* @brief Draw the curent element (can have multiple display)
* @param[in] pass Id of the current pass : [0..?]
*/
virtual void Draw(int32_t _pass=0) { };
/**
* @brief Draw the current life of the element
*/
virtual void DrawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera);
protected:
// For debug only ...
ewol::Text m_debugText;
public:
/**
* @brief Debug display of the current element
* @param[in,out] draw Basic system to draw the debug shape and informations
*/
virtual void DrawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera);
/**
* @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(); };
/**
* @brief Set the current Theoric position of the element
* @param[in] Set the 3D position.
*/
virtual void SetPositionTheoric(const vec3& _pos) { }
/**
* @brief Get the current position of the element
* @return the 3D position.
*/
const vec3& GetPosition(void);
/**
* @brief Set the current position of the element
* @param[in] _pos Set the 3D position.
*/
void SetPosition(const vec3& _pos);
/**
* @brief Get the current speed of the element
* @return the 3D speed.
*/
const vec3& GetSpeed(void);
/**
* @brief Get the current mass of the element
* @return the mass in kG.
*/
const float GetInvMass(void);
/**
* @brief Event arrive when an element has been remove from the system ==> this permit to keep pointer of ennemy, and not search them every cycle ...
* @param[in] _removedElement Pointer on the element removed.
*/
virtual void ElementIsRemoved(ege::ElementGame* _removedElement) { };
protected:
bool m_fixe; //!< Is a fixed element ==> used for placement of every elements
public:
/**
* @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; };
protected:
bool m_elementInPhysicsSystem;
public:
/**
* @brief For intelligent system : this activate the Dynamic object
*/
virtual void DynamicEnable(void);
virtual void DynamicDisable(void);
};
};
#endif

63
ege/ElementGameIA.cpp Normal file
View File

@ -0,0 +1,63 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/ElementGameIA.h>
#include <ewol/renderer/ResourceManager.h>
#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h>
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletCollisionCommon.h>
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
#include <BulletCollision/CollisionShapes/btShapeHull.h>
#include <LinearMath/btTransformUtil.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
ege::ElementGameIA::ElementGameIA(ege::Environement& _env) :
ElementGame(_env),
m_IA(*this),
m_isDynamicStarted(false)
{
}
ege::ElementGameIA::~ElementGameIA(void)
{
DynamicDisable();
}
void ege::ElementGameIA::DynamicEnable(void)
{
ege::ElementGame::DynamicEnable();
if (false == m_isDynamicStarted) {
m_env.GetDynamicWorld()->addAction(&m_IA);
m_isDynamicStarted = true;
}
}
void ege::ElementGameIA::DynamicDisable(void)
{
ege::ElementGame::DynamicDisable();
if (true == m_isDynamicStarted) {
m_env.GetDynamicWorld()->removeAction(&m_IA);
m_isDynamicStarted = false;
}
}

67
ege/ElementGameIA.h Normal file
View File

@ -0,0 +1,67 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_ELEMENT_GAME_IA_H__
#define __EGE_ELEMENT_GAME_IA_H__
#include <ege/ElementGame.h>
namespace ege
{
class ElementGameIA : public ege::ElementGame
{
private:
class localIA : public btActionInterface
{
private:
ElementGameIA& m_element;
public:
/**
* @brief Constructor
*/
localIA(ElementGameIA& element) : m_element(element) { };
/**
* @brief Destructor
*/
virtual ~localIA(void) { };
// herited function
void debugDraw(btIDebugDraw* debugDrawer) { };
// herited function
void updateAction(btCollisionWorld* collisionWorld, btScalar step)
{
m_element.IAAction(step);
}
};
localIA m_IA;
public:
/**
* @brief Constructor
*/
ElementGameIA(ege::Environement& _env);
/**
* @brief Destructor
*/
virtual ~ElementGameIA(void);
/**
* @brief Periodic call for intelligence artificial.
* @param[in] step : step of time in s
*/
virtual void IAAction(float _step)=0;
private:
bool m_isDynamicStarted;
public:
virtual void DynamicEnable(void);
virtual void DynamicDisable(void);
};
};
#endif

198
ege/Environement.cpp Normal file
View File

@ -0,0 +1,198 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/Environement.h>
#include <ege/ElementGame.h>
ege::ElementGame* ege::Environement::GetElementNearest(ege::ElementGame* _sourceRequest, float& _distance)
{
if (NULL==_sourceRequest) {
return NULL;
}
vec3 sourcePosition = _sourceRequest->GetPosition();
ege::ElementGame* result = NULL;
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
// chack NULL pointer
if (NULL == m_listElementGame[iii]) {
continue;
}
if (m_listElementGame[iii]->GetGroup()<=0) {
continue;
}
// check if they are in the same group:
if (m_listElementGame[iii]->GetGroup() == _sourceRequest->GetGroup()) {
continue;
}
// check distance ...
vec3 destPosition = m_listElementGame[iii]->GetPosition();
float distance = btDistance(sourcePosition, destPosition);
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
if (_distance>distance) {
_distance = distance;
result = m_listElementGame[iii];
}
}
return result;
}
void ege::Environement::GetElementNearest(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList)
{
_resultList.Clear();
ege::Environement::ResultNearestElement result;
result.dist = 99999999999.0f;
result.element = NULL;
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
// chack NULL pointer
result.element = m_listElementGame[iii];
if (NULL == result.element) {
continue;
}
// check distance ...
vec3 destPosition = result.element->GetPosition();
if (_sourcePosition == destPosition) {
continue;
}
result.dist = btDistance(_sourcePosition, destPosition);
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
if (_distanceMax>result.dist) {
_resultList.PushBack(result);
}
}
}
void ege::Environement::GetElementNearestFixed(const vec3& _sourcePosition,
float _distanceMax,
etk::Vector<ege::Environement::ResultNearestElement>& _resultList)
{
_resultList.Clear();
ege::Environement::ResultNearestElement result;
result.dist = 99999999999.0f;
result.element = NULL;
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
// chack NULL pointer
result.element = m_listElementGame[iii];
if (NULL==result.element) {
continue;
}
if (false==result.element->IsFixed()) {
continue;
}
// check distance ...
vec3 destPosition = result.element->GetPositionTheoric();
result.dist = btDistance(_sourcePosition, destPosition);
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
if (_distanceMax<=result.dist) {
continue;
}
// try to add the element at the best positions:
int32_t jjj;
for (jjj=0; jjj<_resultList.Size(); jjj++) {
if (_resultList[jjj].dist>result.dist) {
_resultList.Insert(jjj, result);
break;
}
}
// add element at the end :
if (jjj>=_resultList.Size()) {
_resultList.PushBack(result);
}
}
}
void ege::Environement::AddElementGame(ege::ElementGame* _newElement)
{
// prevent memory allocation and un allocation ...
if (NULL == _newElement) {
return;
}
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
if (NULL == m_listElementGame[iii]) {
m_listElementGame[iii] = _newElement;
m_listElementGame[iii]->DynamicEnable();
return;
}
}
m_listElementGame.PushBack(_newElement);
_newElement->DynamicEnable();
}
void ege::Environement::RmElementGame(ege::ElementGame* _removeElement)
{
if (NULL == _removeElement) {
return;
}
// 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]) {
m_listElementGame[iii]->ElementIsRemoved(_removeElement);
}
}
// ream remove on the element :
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
if (_removeElement == m_listElementGame[iii]) {
m_listElementGame[iii]->DynamicDisable();
delete(m_listElementGame[iii]);
m_listElementGame[iii] = NULL;
}
}
}
void ege::Environement::GetOrderedElementForDisplay(etk::Vector<ege::Environement::ResultNearestElement>& _resultList,
const vec3& _position,
const vec3& _direction)
{
// remove all unneeded elements (old display...)
_resultList.Clear();
// basic element result
ege::Environement::ResultNearestElement result;
result.dist = 99999999999.0f;
result.element = NULL;
// for all element in the game we chek if it is needed to display it ...
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
// chack NULL pointer
if (NULL==m_listElementGame[iii]) {
// no pointer null are set in the output list ...
continue;
}
result.element = m_listElementGame[iii];
// check distance ...
vec3 destPosition = result.element->GetPosition();
vec3 angleView = (destPosition - _position).normalized();
float dotResult=angleView.dot(_direction);
//EGE_DEBUG("Dot position : " << destPosition << " ==> dot=" << dotResult);
if (dotResult<=0.85f) {
// they are not in the camera angle view ... ==> no need to process display
continue;
}
result.dist = btDistance(_position, destPosition);
if (result.dist>500.0f) {
// The element is realy too far ... ==> no need to display
continue;
}
// try to add the element at the best positions:
int32_t jjj;
for (jjj=0; jjj<_resultList.Size(); jjj++) {
if (_resultList[jjj].dist>result.dist) {
_resultList.Insert(jjj, result);
break;
}
}
// add element at the end :
if (jjj>=_resultList.Size()) {
_resultList.PushBack(result);
}
}
}

83
ege/Environement.h Normal file
View File

@ -0,0 +1,83 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_ENVIRONEMENT_H__
#define __EGE_ENVIRONEMENT_H__
#include <BulletDynamics/Dynamics/btActionInterface.h>
class btDynamicsWorld;
#include <etk/Vector.h>
#include <etk/math/Vector3D.h>
namespace ege {
class ElementGame;
class Environement
{
private:
btDynamicsWorld* m_dynamicsWorld; //!< curent system world description
etk::Vector<ege::ElementGame*> m_listElementGame; //!< List of all element added in the Game
public:
Environement(void) : m_dynamicsWorld(NULL) { };
virtual ~Environement(void) { };
public:
class ResultNearestElement
{
public:
ege::ElementGame* element;
float dist;
};
/**
* @brief Set the curent world
* @param[in] _newWorld Pointer on the current world
*/
void SetDynamicWorld(btDynamicsWorld* _newWorld) { m_dynamicsWorld=_newWorld; };
/**
* @brief Get the curent world
* @return pointer on the current world
*/
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; };
/**
* @brief Get the nearest Element
* @param[in] _sourceRequest Pointer on the element that request this.
* @param[in] _distance Maximum distance search ==> return the element distance
* @return Pointer on the neares element OR NULL
*/
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);
/**
* @brief Add an element on the list availlable.
* @param[in] _newElement Element to add.
*/
void AddElementGame(ege::ElementGame* _newElement);
/**
* @brief Remove an element on the list availlable.
* @param[in] _removeElement Element to remove.
*/
void RmElementGame(ege::ElementGame* _removeElement);
/**
* @brief Get the element order from the nearest to the farest, and remove all element that are not in the camera angle and axes.
* @param[in,out] _resultList List of the element ordered.
* @param[in] _position Camera position in the space.
* @param[in] _direction Camera direction of the view.
*/
void GetOrderedElementForDisplay(etk::Vector<ege::Environement::ResultNearestElement>& _resultList, const vec3& _position, const vec3& _direction);
};
};
#endif

11
ege/Particule.cpp Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/Particule.h>

18
ege/Particule.h Normal file
View File

@ -0,0 +1,18 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_PARTICULE_H__
#define __EGE_PARTICULE_H__
namespace ege {
};
#endif

11
ege/ParticuleEngine.cpp Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/ParticuleEngine.h>

18
ege/ParticuleEngine.h Normal file
View File

@ -0,0 +1,18 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_PARTICULE_ENGINE_H__
#define __EGE_PARTICULE_ENGINE_H__
namespace ege {
};
#endif

702
ege/Scene.cpp Normal file
View File

@ -0,0 +1,702 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
#include <ege/Scene.h>
#include <math.h>
#include <ege/debug.h>
#include <ewol/ewol.h>
#include <ewol/renderer/openGL.h>
#include <etk/math/Matrix4.h>
#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h>
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletCollisionCommon.h>
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
#include <BulletCollision/CollisionShapes/btShapeHull.h>
#include <LinearMath/btTransformUtil.h>
#include <LinearMath/btIDebugDraw.h>
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#undef __class__
#define __class__ "Scene"
const char * const ege::Scene::eventPlayTimeChange = "event-scene-play-time-change";
const char * const ege::Scene::eventKillEnemy = "event-scene-kill-ennemy";
#define WALK_FLAG_FORWARD (1<<0)
#define WALK_FLAG_BACK (1<<1)
#define WALK_FLAG_LEFT (1<<2)
#define WALK_FLAG_RIGHT (1<<3)
#define WALK_FLAG_CAUTION (1<<4)
ege::Scene::Scene(void) :
m_gameTime(0),
m_angleView(M_PI/3.0),
m_finger_DoubleTouch(false),
m_dynamicsWorld(NULL),
m_camera(vec3(0,0,0), 0, DEG_TO_RAD(45) ,50),
m_isRunning(true),
m_walk(0),
m_debugMode(false),
m_debugDrawing(NULL)
{
SetKeyboardRepeate(false);
SetCanHaveFocus(true);
PeriodicCallEnable();
AddEventId(eventPlayTimeChange);
AddEventId(eventKillEnemy);
ewol::resource::Keep(m_debugDrawing);
m_zoom = 1.0/1000.0;
m_ratioTime = 1.0f;
m_collisionConfiguration = new btDefaultCollisionConfiguration();
///use the default collision dispatcher.
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
///the default constraint solver.
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
// in space, we set no gravity ...
m_dynamicsWorld->setGravity(btVector3(0,0,0));
m_env.SetDynamicWorld(m_dynamicsWorld);
// Add debug display :
ege::ElementGame* tmpElement = NULL;
// SET THE STATION ..
m_camera.SetEye(vec3(0,0,0));
/*
tmpElement = appl::env::GetCreatorList().CreateElement("Station", "(0,0,0)");
if (NULL != tmpElement) {
appl::env::AddElementGame(tmpElement);
tmpElement = NULL;
}
// for the debug :
for (int32_t iii=0; iii<appl::env::GetGird().GetNumberElementInMap(); iii++) {
int32_t typeID = appl::env::GetGird().GetElementType(iii);
char tmppp[256];
vec3 posss = appl::env::GetGird().GetElementPos(iii);
sprintf(tmppp, "(%f,%f,%f)", posss.x(), posss.y(), posss.z());
if (GIRD_ID_GENERATOR==typeID) {
tmpElement = appl::env::GetCreatorList().CreateElement("MonsterGenerator", tmppp);
if (NULL != tmpElement) {
m_env.AddElementGame(tmpElement);
tmpElement = NULL;
}
}
if (GIRD_ID_TOWER==typeID) {
tmpElement = appl::env::GetCreatorList().CreateElement("Tower1", tmppp);
if (NULL != tmpElement) {
m_env.AddElementGame(tmpElement);
tmpElement = NULL;
}
}
if (GIRD_ID_METEOR==typeID) {
tmpElement = appl::env::GetCreatorList().CreateElement("Meteor", tmppp);
if (NULL != tmpElement) {
m_env.AddElementGame(tmpElement);
tmpElement = NULL;
}
}
}
*/
}
ege::Scene::~Scene(void)
{
ewol::resource::Release(m_debugDrawing);
/*
ewol::resource::Release(m_directDrawObject);
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
for (int32_t iii=m_dynamicsWorld->getNumCollisionObjects()-1; iii>=0 ;iii--) {
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[iii];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState()) {
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
*/
}
void ege::Scene::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
}
}
void ege::Scene::Pause(void)
{
EGE_DEBUG("Set Pause");
m_isRunning = false;
}
void ege::Scene::Resume(void)
{
EGE_DEBUG("Set Resume");
m_isRunning = true;
}
void ege::Scene::PauseToggle(void)
{
if(true==m_isRunning) {
EGE_DEBUG("Set Toggle: Pause");
m_isRunning=false;
} else {
EGE_DEBUG("Set Toggle: Resume");
m_isRunning=true;
}
}
//#define SCENE_DISPLAY_SPEED
//////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SCENE_DISPLAY_SPEED
static int64_t g_startTime = 0;
static int32_t g_counterNbTimeDisplay = 0;
#endif
#define NUMBER_OF_SUB_PASS (0)
void ege::Scene::OnDraw(void)
{
#ifdef SCENE_DISPLAY_SPEED
g_counterNbTimeDisplay++;
g_startTime = ewol::GetTime();
#endif
//EGE_DEBUG("Draw (start)");
mat4 tmpMatrix;
if (m_dynamicsWorld) {
m_env.GetOrderedElementForDisplay(m_displayElementOrdered, m_camera.GetOrigin(), m_camera.GetViewVector());
//EGE_DEBUG("DRAW : " << m_displayElementOrdered.Size() << " elements");
// TODO : Remove this ==> no more needed ==> checked in the Generate the list of the element ordered
for (int32_t iii=0; iii<m_displayElementOrdered.Size(); iii++) {
m_displayElementOrdered[iii].element->PreCalculationDraw(m_camera);
}
// note : the first pass is done at the reverse way to prevent multiple display od the same point in the screen
// (and we remember that the first pass is to display all the non transparent elements)
#if 0
// note : We keep this one for the test only ...
for (int32_t iii=0; iii<m_displayElementOrdered.Size(); iii++) {
#else
for (int32_t iii=m_displayElementOrdered.Size()-1; iii>=0; iii--) {
#endif
m_displayElementOrdered[iii].element->Draw(0);
}
// for the other pass the user can draw transparent elements ...
for (int32_t pass=1; pass<=NUMBER_OF_SUB_PASS+1; pass++) {
for (int32_t iii=0; iii<m_displayElementOrdered.Size(); iii++) {
m_displayElementOrdered[iii].element->Draw(pass);
}
}
for (int32_t iii=0; iii<m_displayElementOrdered.Size(); iii++) {
m_displayElementOrdered[iii].element->DrawLife(m_debugDrawing, m_camera);
}
#ifdef DEBUG
if (true == m_debugMode) {
for (int32_t iii=0; iii<m_displayElementOrdered.Size(); iii++) {
m_displayElementOrdered[iii].element->DrawDebug(m_debugDrawing, m_camera);
}
}
#endif
}
#ifdef SCENE_DISPLAY_SPEED
float localTime = (float)(ewol::GetTime() - g_startTime) / 1000.0f;
if (localTime>1) {
EWOL_ERROR(" scene : " << localTime << "ms " << g_counterNbTimeDisplay);
} else {
EWOL_DEBUG(" scene : " << localTime << "ms " << g_counterNbTimeDisplay);
}
#endif
//EGE_DEBUG("Draw (stop)");
}
// I really does not know what is this ...
btRigidBody& btActionInterface::getFixedBody()
{
static btRigidBody s_fixed(0, 0,0);
s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
return s_fixed;
}
#define WALK_FLAG_FORWARD (1<<0)
#define WALK_FLAG_BACK (1<<1)
#define WALK_FLAG_LEFT (1<<2)
#define WALK_FLAG_RIGHT (1<<3)
#define WALK_FLAG_CAUTION (1<<4)
static const float l_walkRatio = 15;
static const float l_walkLateralRatio = 15;
void ege::Scene::PeriodicCall(const ewol::EventTime& _event)
{
float curentDelta=_event.GetDeltaCall();
// small hack to change speed ...
if (m_ratioTime != 1) {
curentDelta *= m_ratioTime;
}
// check if the processing is availlable
if (false == m_isRunning) {
MarkToRedraw();
return;
}
// update game time:
int32_t lastGameTime = m_gameTime;
m_gameTime += curentDelta;
if (lastGameTime != (int32_t)m_gameTime) {
GenerateEventId(eventPlayTimeChange, m_gameTime);
}
//EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime);
// update camera positions:
m_camera.PeriodicCall(curentDelta);
//EGE_DEBUG("stepSimulation (start)");
///step the simulation
if (m_dynamicsWorld) {
m_dynamicsWorld->stepSimulation(curentDelta);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
}
// Remove all element that requested it ...
{
int32_t numberEnnemyKilled=0;
int32_t victoryPoint=0;
etk::Vector<ege::ElementGame*>& elementList = m_env.GetElementGame();
for (int32_t iii=0; iii<elementList.Size(); iii++) {
if(NULL != elementList[iii]) {
if (true == elementList[iii]->NeedToRemove()) {
if (elementList[iii]->GetGroup() > 1) {
numberEnnemyKilled++;
victoryPoint++;
}
m_env.RmElementGame(elementList[iii]);
}
}
}
if (0 != numberEnnemyKilled) {
GenerateEventId(eventKillEnemy, numberEnnemyKilled);
}
}
MarkToRedraw();
if (m_walk!=0) {
float walkValue = 0;
if( (m_walk&WALK_FLAG_FORWARD)!=0
&& (m_walk&WALK_FLAG_BACK)!=0) {
// request back and forward in the same time ... this is really bad ....
walkValue = 0;
} else if ( (m_walk&WALK_FLAG_FORWARD)!=0) {
walkValue = 1;
} else if ( (m_walk&WALK_FLAG_BACK)!=0) {
walkValue = -1;
}
if (walkValue!=0) {
float angleZ = m_camera.GetAngleZ();
vec3 offsetPosition( cosf(angleZ-M_PI/2.0)*walkValue,
-sinf(angleZ-M_PI/2.0)*walkValue,
0);
//EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles);
// walk is 6 km/h
vec3 pos = m_camera.GetEye() + offsetPosition*l_walkRatio*curentDelta;
m_camera.SetEye(pos);
}
walkValue=0;
if( (m_walk&WALK_FLAG_LEFT)!=0
&& (m_walk&WALK_FLAG_RIGHT)!=0) {
// request left and right in the same time ... this is really bad ....
walkValue=0;
} else if ( (m_walk&WALK_FLAG_LEFT)!=0) {
walkValue = 1;
} else if ( (m_walk&WALK_FLAG_RIGHT)!=0) {
walkValue = -1;
}
if (walkValue != 0) {
float angleZ = m_camera.GetAngleZ();
vec3 offsetPosition( cosf(angleZ)*walkValue,
-sinf(angleZ)*walkValue,
0);
//EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles);
// lateral walk is 4 km/h
vec3 pos = m_camera.GetEye() + offsetPosition*l_walkLateralRatio*curentDelta;
m_camera.SetEye(pos);
}
}
}
#define GAME_Z_NEAR (1)
#define GAME_Z_FAR (4000)
//#define SCENE_BRUT_PERFO_TEST
void ege::Scene::SystemDraw(const ewol::DrawProperty& _displayProp)
{
#ifdef SCENE_BRUT_PERFO_TEST
int64_t tmp___startTime0 = ewol::GetTime();
#endif
ewol::openGL::Push();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x(),
m_origin.y(),
m_size.x(),
m_size.y());
#ifdef SCENE_BRUT_PERFO_TEST
float tmp___localTime0 = (float)(ewol::GetTime() - tmp___startTime0) / 1000.0f;
EWOL_DEBUG(" SCENE000 : " << tmp___localTime0 << "ms ");
int64_t tmp___startTime1 = ewol::GetTime();
#endif
float ratio = m_size.x() / m_size.y();
//EWOL_INFO("ratio : " << ratio);
mat4 tmpProjection = etk::matPerspective(m_angleView, ratio, GAME_Z_NEAR, GAME_Z_FAR);
#ifdef SCENE_BRUT_PERFO_TEST
float tmp___localTime1 = (float)(ewol::GetTime() - tmp___startTime1) / 1000.0f;
EWOL_DEBUG(" SCENE111 : " << tmp___localTime1 << "ms ");
int64_t tmp___startTime2 = ewol::GetTime();
#endif
ewol::openGL::SetCameraMatrix(m_camera.GetMatrix());
//mat4 tmpMat = tmpProjection * m_camera.GetMatrix();
// set internal matrix system :
//ewol::openGL::SetMatrix(tmpMat);
ewol::openGL::SetMatrix(tmpProjection);
#ifdef SCENE_BRUT_PERFO_TEST
float tmp___localTime2 = (float)(ewol::GetTime() - tmp___startTime2) / 1000.0f;
EWOL_DEBUG(" SCENE222 : " << tmp___localTime2 << "ms ");
#endif
#ifdef SCENE_BRUT_PERFO_TEST
int64_t tmp___startTime3 = ewol::GetTime();
#endif
OnDraw();
#ifdef SCENE_BRUT_PERFO_TEST
float tmp___localTime3 = (float)(ewol::GetTime() - tmp___startTime3) / 1000.0f;
EWOL_DEBUG(" SCENE333 : " << tmp___localTime3 << "ms ");
int64_t tmp___startTime4 = ewol::GetTime();
#endif
ewol::openGL::Pop();
#ifdef SCENE_BRUT_PERFO_TEST
float tmp___localTime4 = (float)(ewol::GetTime() - tmp___startTime4) / 1000.0f;
EWOL_DEBUG(" SCENE444 : " << tmp___localTime4 << "ms ");
#endif
}
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;
double xmax = tan(m_angleView/2.0);
double ymax = xmax / ratio;
double newX = pos.x() * xmax / m_size.x()*2.0;
double newY = pos.y() * ymax / m_size.y()*2.0;
double angleX = atan(newX);
double angleY = atan(newY);
return vec2(angleX,
angleY);
}
vec3 ege::Scene::ConvertScreenPositionInMapPosition(const vec2& posScreen)
{
return m_camera.projectOnZGround(CalculateDeltaAngle(posScreen));
}
bool ege::Scene::OnEventInput(const ewol::EventInput& _event)
{
//EWOL_DEBUG("Input event : " << _event);
vec2 relPos = RelativePosition(_event.GetPos());
/*
* *
* |\
* | \
* | \
* | \
* | \
* | \
* *------*
* \ \
* \ \
* \ \
* *-*
*/
if (_event.GetType() == ewol::keyEvent::typeMouse) {
if (0 != _event.GetId()) {
KeepFocus();
}
//EGE_DEBUG("Move mouse at position = " << relPos << " ==> " << curentCreatingPosition );
if (1 == _event.GetId()) {
} else if (2 == _event.GetId()) {
// center button : change the angle the camara
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
vec2 tmppPos = relPos-m_centerButtonStartPos;
tmppPos *= M_PI/(360.0f*6);
m_camera.SetAngleZ(m_camera.GetAngleZ()- tmppPos.x());
m_camera.SetAngleTeta(m_camera.GetAngleTeta()-tmppPos.y());
}
// update register position ...
m_centerButtonStartPos = relPos;
} else if (3 == _event.GetId()) {
// center button : change the angle the camara
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
vec3 nextPosition = ConvertScreenPositionInMapPosition(relPos);
vec3 tmppPos = nextPosition-m_finger_StartPosMoving;
vec3 oldposition = m_camera.GetEye();
// update the camera positions:
oldposition.setX(oldposition.x() - tmppPos.x());
oldposition.setY(oldposition.y() - tmppPos.y());
// set the new position
m_camera.SetEye(oldposition);
}
// update register position ...
m_leftButtonStartPos = relPos;
m_finger_StartPosMoving = ConvertScreenPositionInMapPosition(relPos);
} else if (4 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
// scrool input
float cameraDistance = m_camera.GetDistance()-3;
EGE_DEBUG("New camera distance : " << etk_avg(10, cameraDistance, 100));
m_camera.SetDistance(etk_avg(10, cameraDistance, 100));
}
} else if (5 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
// scrool output
float cameraDistance = m_camera.GetDistance()+3;
EGE_DEBUG("New camera distance : " << etk_avg(10, cameraDistance, 100));
m_camera.SetDistance(etk_avg(10, cameraDistance, 100));
}
}
/*
*
* ---
* / \
* | |
* | |
* | |
* | |
* | | --- --- ---
* | |/ \/ \/ \
* | |
* /| |
* / | |
* | |
* | |
* | |
* \ /
* \ /
* \ /
* \ /
*/
} else if (_event.GetType() == ewol::keyEvent::typeFinger) {
KeepFocus();
if (1 == _event.GetId()) {
if (m_finger_DoubleTouch==false) {
} else {
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
m_finger_1Position = relPos;
if (m_finger_2Position.x() > -10000) {
vec2 distance = m_finger_1Position-m_finger_2Position;
float realDistance = distance.length();
float fingerAngle = acosf(etk_avg(-1.0f, (distance.x()/realDistance), 1.0f) );
if (distance.y()<0){
fingerAngle *=-1;
}
realDistance /= 2.0f;
if (m_finger_oldDistance>=0) {
float distanceDelta = m_finger_oldDistance-realDistance;
m_camera.SetDistance(etk_avg(10,m_camera.GetDistance()+distanceDelta/3.0f,100));
float angleDelta = m_finger_oldAngle - fingerAngle;
m_camera.SetAngleZ(m_camera.GetAngleZ()+angleDelta);
}
m_finger_oldDistance = realDistance;
m_finger_oldAngle = fingerAngle;
}
}
}
m_finger_StartPosMoving = ConvertScreenPositionInMapPosition(relPos);
if (ewol::keyEvent::statusUp == _event.GetStatus()) {
m_finger_DoubleTouch = false;
}
} else if (2 == _event.GetId()) {
if (ewol::keyEvent::statusDown == _event.GetStatus()) {
m_finger_DoubleTouch = true;
m_finger_1Position = vec2(-500000,-500000);
m_finger_2Position = vec2(-500000,-500000);
m_finger_oldDistance = -1;
m_finger_oldAngle = 0;
} else if (ewol::keyEvent::statusMove == _event.GetStatus()) {
m_finger_2Position = relPos;
if (m_finger_1Position.x() > -10000) {
vec2 distance = m_finger_1Position-m_finger_2Position;
float realDistance = distance.length();
float fingerAngle = acosf(etk_avg(-1.0f, (distance.x()/realDistance), 1.0f) );
if (distance.y()<0){
fingerAngle *=-1;
}
realDistance /= 2.0f;
if (m_finger_oldDistance>=0) {
float distanceDelta = m_finger_oldDistance-realDistance;
m_camera.SetDistance(etk_avg(10,m_camera.GetDistance()+distanceDelta/3.0f,100));
float angleDelta = m_finger_oldAngle - fingerAngle;
m_camera.SetAngleZ(m_camera.GetAngleZ()+angleDelta);
}
m_finger_oldDistance = realDistance;
m_finger_oldAngle = fingerAngle;
}
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
m_finger_DoubleTouch = false;
}
}
}
return false;
}
bool ege::Scene::OnEventEntry(const ewol::EventEntry& _event)
{
if (_event.GetType() == ewol::keyEvent::keyboardChar) {
EWOL_DEBUG("Entry enevnt : " << _event );
if( _event.GetChar() == 'z'
|| _event.GetChar() == 'Z') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD;
}
}
}
if( _event.GetChar() == 's'
|| _event.GetChar() == 'S') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK;
}
}
}
if( _event.GetChar() == 'q'
|| _event.GetChar() == 'Q') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT;
}
}
}
if( _event.GetChar() == 'd'
|| _event.GetChar() == 'D') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT;
}
}
}
EWOL_DEBUG("m_walk=" << m_walk);
return false;
}
// Move event ...
if (_event.GetType() == ewol::keyEvent::keyboardUp) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD;
}
}
}
if (_event.GetType() == ewol::keyEvent::keyboardDown) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK;
}
}
}
if (_event.GetType() == ewol::keyEvent::keyboardLeft) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT;
}
}
}
if (_event.GetType() == ewol::keyEvent::keyboardRight) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT;
}
}
}
EWOL_DEBUG("m_walk=" << m_walk);
return false;
}
void ege::Scene::OnGetFocus(void)
{
}
void ege::Scene::OnLostFocus(void)
{
}

140
ege/Scene.h Normal file
View File

@ -0,0 +1,140 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_SCENE_H__
#define __EGE_SCENE_H__
#include <etk/types.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Matrix4.h>
#include <etk/Vector.h>
#include <ewol/debug.h>
#include <ege/Camera.h>
#include <ewol/widget/Widget.h>
#include <ewol/renderer/openGL.h>
#include <ewol/renderer/ResourceManager.h>
#include <ege/ElementGame.h>
#include <ewol/Dimension.h>
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btDynamicsWorld;
#include <LinearMath/btScalar.h>
class btVector3;
#include <ewol/widget/Widget.h>
namespace ege {
class Scene : public ewol::Widget
{
public:
static const char * const eventPlayTimeChange;
static const char * const eventKillEnemy;
protected:
ege::Environement m_env;
public:
/**
* @brief Constructor of the widget classes
* @return (no execption generated (not managed in embended platform))
*/
Scene(void);
/**
* @brief Destructor of the widget classes
*/
virtual ~Scene(void);
private:
float m_gameTime; //!< time of the game running
protected:
float m_angleView;
vec2 m_centerButtonStartPos;
vec2 m_leftButtonStartPos;
vec3 m_finger_StartPosMoving;
bool m_finger_DoubleTouch;
vec2 m_finger_1Position;
vec2 m_finger_2Position;
float m_finger_oldDistance;
float m_finger_oldAngle;
///this is the most important class
btDefaultCollisionConfiguration* m_collisionConfiguration;
btCollisionDispatcher* m_dispatcher;
btBroadphaseInterface* m_broadphase;
btConstraintSolver* m_solver;
btDynamicsWorld* m_dynamicsWorld;
// camera section
ege::Camera m_camera; //!< Display point of view.
vec3 m_cameraMovePointStart; //!< Position where the mouse start to move
// Other elements
bool m_isRunning; //!< the display is running (not in pause)
float m_ratioTime; //!< Ratio time for the speed of the game ...
uint32_t m_walk; //!< Wolk properties
bool m_debugMode;
ewol::Colored3DObject* m_debugDrawing; //!< for the debug draw elements
// Note : This is only for temporary elements : on the display
etk::Vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
/**
* @brief Set the scene in pause for a while
*/
void Pause(void);
/**
* @brief Resume the scene activity
*/
void Resume(void);
/**
* @brief Toggle between pause and running
*/
void PauseToggle(void);
void DebugToggle(void) { m_debugMode = m_debugMode?false:true; };
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
// camera properties :
private:
float m_zoom;
public:
vec2 CalculateDeltaAngle(const vec2& posScreen);
vec3 ConvertScreenPositionInMapPosition(const vec2& posScreen);
/**
* @brief Get the current camera reference for the scene rendering
*/
ege::Camera& GetCamera(void) { return m_camera; };
/**
* @brief Set the curent Time Ratio (default 1)
*/
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);
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "appl::Game"; };
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual void OnRegenerateDisplay(void);
virtual void PeriodicCall(const ewol::EventTime& _event);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
};
};
#endif

11
ege/debug.cpp Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ege/debug.h>
const char * egamiLibName = "ege ";

28
ege/debug.h Normal file
View File

@ -0,0 +1,28 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EGE_DEBUG_H__
#define __EGE_DEBUG_H__
#include <etk/types.h>
#include <etk/Debug.h>
extern const char * egeLibName;
#define EGE_CRITICAL(data) ETK_CRITICAL(egeLibName, data)
#define EGE_WARNING(data) ETK_WARNING(egeLibName, data)
#define EGE_ERROR(data) ETK_ERROR(egeLibName, data)
#define EGE_INFO(data) ETK_INFO(egeLibName, data)
#define EGE_DEBUG(data) ETK_DEBUG(egeLibName, data)
#define EGE_VERBOSE(data) ETK_VERBOSE(egeLibName, data)
#define EGE_ASSERT(cond,data) ETK_ASSERT(egeLibName, cond, data)
#define EGE_CHECK_INOUT(cond) ETK_CHECK_INOUT(egeLibName, cond)
#define EGE_TODO(cond) ETK_TODO(egeLibName, cond)
#endif

View File

@ -8,11 +8,19 @@ def Create(target):
# add the file to compile:
myModule.AddSrcFile([
'ege/.cpp'
'ege/AudioElement.cpp',
'ege/AudioEngine.cpp',
'ege/Camera.cpp',
'ege/ElementGame.cpp',
'ege/ElementGameIA.cpp',
'ege/Particule.cpp',
'ege/ParticuleEngine.cpp',
'ege/Scene.cpp',
'ege/Environement.cpp'
])
# name of the dependency
myModule.AddModuleDepend(['ewol', 'bullet'])
myModule.AddModuleDepend(['etk', 'ewol', 'bullet'])
myModule.CompileFlags_CC([
'-Wno-write-strings',