[DEV] update to the new architecture

This commit is contained in:
Edouard DUPIN 2013-12-13 21:23:32 +01:00
parent 2c54a551b4
commit 58596f179a
32 changed files with 681 additions and 625 deletions

View File

@ -13,13 +13,13 @@
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h> #include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
#include <BulletCollision/CollisionShapes/btShapeHull.h> #include <BulletCollision/CollisionShapes/btShapeHull.h>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h> #include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
#include <ewol/physicsShape/PhysicsBox.h> #include <ege/physicsShape/PhysicsBox.h>
#include <ewol/physicsShape/PhysicsCapsule.h> #include <ege/physicsShape/PhysicsCapsule.h>
#include <ewol/physicsShape/PhysicsCone.h> #include <ege/physicsShape/PhysicsCone.h>
#include <ewol/physicsShape/PhysicsConvexHull.h> #include <ege/physicsShape/PhysicsConvexHull.h>
#include <ewol/physicsShape/PhysicsCylinder.h> #include <ege/physicsShape/PhysicsCylinder.h>
#include <ewol/physicsShape/PhysicsSphere.h> #include <ege/physicsShape/PhysicsSphere.h>
// Documentetion of bullet library : // Documentetion of bullet library :
// http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes // http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes
@ -27,11 +27,11 @@
#undef __class__ #undef __class__
#define __class__ "CollisionShapeCreator" #define __class__ "CollisionShapeCreator"
btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) { btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) {
if (NULL == _mesh) { if (NULL == _mesh) {
return new btEmptyShape();; return new btEmptyShape();;
} }
const std::vector<ewol::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties(); const std::vector<ege::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties();
if (physiqueProperty.size() == 0) { if (physiqueProperty.size() == 0) {
return new btEmptyShape();; return new btEmptyShape();;
} }
@ -51,8 +51,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
continue; continue;
} }
switch (physiqueProperty[iii]->getType()) { switch (physiqueProperty[iii]->getType()) {
case ewol::PhysicsShape::box : { case ege::PhysicsShape::box : {
const ewol::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox(); const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;
@ -69,8 +69,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
} }
break; break;
} }
case ewol::PhysicsShape::cylinder : { case ege::PhysicsShape::cylinder : {
const ewol::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder(); const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;
@ -87,8 +87,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
} }
break; break;
} }
case ewol::PhysicsShape::capsule : { case ege::PhysicsShape::capsule : {
const ewol::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule(); const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;
@ -105,8 +105,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
} }
break; break;
} }
case ewol::PhysicsShape::cone : { case ege::PhysicsShape::cone : {
const ewol::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone(); const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;
@ -123,8 +123,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
} }
break; break;
} }
case ewol::PhysicsShape::sphere : { case ege::PhysicsShape::sphere : {
const ewol::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere(); const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;
@ -141,8 +141,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
} }
break; break;
} }
case ewol::PhysicsShape::convexHull : { case ege::PhysicsShape::convexHull : {
const ewol::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull(); const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
if (NULL == tmpElement) { if (NULL == tmpElement) {
// ERROR ... // ERROR ...
continue; continue;

View File

@ -11,12 +11,12 @@
#define __EGE_COLLISION_SHAPE_CREATOR_H__ #define __EGE_COLLISION_SHAPE_CREATOR_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/resources/Mesh.h> #include <ege/resource/Mesh.h>
#include <BulletCollision/CollisionShapes/btCollisionShape.h> #include <BulletCollision/CollisionShapes/btCollisionShape.h>
namespace ege { namespace ege {
namespace collision { namespace collision {
btCollisionShape* createShape(const ewol::Mesh* _mesh); btCollisionShape* createShape(const ege::resource::Mesh* _mesh);
}; };
}; };
#endif #endif

View File

@ -10,7 +10,6 @@
#include <ege/debug.h> #include <ege/debug.h>
#include <ege/ElementGame.h> #include <ege/ElementGame.h>
#include <ege/Environement.h> #include <ege/Environement.h>
#include <ewol/resources/ResourceManager.h>
#include <BulletDynamics/Dynamics/btRigidBody.h> #include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h> #include <LinearMath/btDefaultMotionState.h>
#include <BulletDynamics/Dynamics/btDynamicsWorld.h> #include <BulletDynamics/Dynamics/btDynamicsWorld.h>
@ -61,7 +60,7 @@ ege::ElementGame::~ElementGame(void) {
// same ... // same ...
dynamicDisable(); dynamicDisable();
removeShape(); removeShape();
ewol::Mesh::release(m_mesh); ege::resource::Mesh::release(m_mesh);
if (NULL != m_body) { if (NULL != m_body) {
delete(m_body); delete(m_body);
m_body = NULL; m_body = NULL;
@ -97,8 +96,7 @@ void ege::ElementGame::FunctionFreeShape(void* _pointer) {
} }
bool ege::ElementGame::loadMesh(const std::string& _meshFileName) { bool ege::ElementGame::loadMesh(const std::string& _meshFileName) {
ewol::Mesh* tmpMesh=NULL; ege::resource::Mesh* tmpMesh = ege::resource::Mesh::keep(_meshFileName);
tmpMesh = ewol::Mesh::keep(_meshFileName);
if(NULL == tmpMesh) { if(NULL == tmpMesh) {
EGE_ERROR("can not load the resources : " << _meshFileName); EGE_ERROR("can not load the resources : " << _meshFileName);
return false; return false;
@ -106,10 +104,10 @@ bool ege::ElementGame::loadMesh(const std::string& _meshFileName) {
return setMesh(tmpMesh); return setMesh(tmpMesh);
} }
bool ege::ElementGame::setMesh(ewol::Mesh* _mesh) { bool ege::ElementGame::setMesh(ege::resource::Mesh* _mesh) {
if (NULL!=m_mesh) { if (NULL!=m_mesh) {
removeShape(); removeShape();
ewol::Mesh::release(m_mesh); ege::resource::Mesh::release(m_mesh);
} }
m_mesh = _mesh; m_mesh = _mesh;
// auto load the shape : // auto load the shape :
@ -184,7 +182,7 @@ const float ege::ElementGame::getInvMass(void) {
return 0.0000000001f; return 0.0000000001f;
}; };
static void drawSphere(ewol::Colored3DObject* _draw, static void drawSphere(ewol::resource::Colored3DObject* _draw,
btScalar _radius, btScalar _radius,
int _lats, int _lats,
int _longs, int _longs,
@ -232,7 +230,7 @@ const float lifeHeight = 0.3f;
const float lifeWidth = 2.0f; const float lifeWidth = 2.0f;
const float lifeYPos = 1.7f; const float lifeYPos = 1.7f;
void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera) { void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) {
if (NULL == _draw) { if (NULL == _draw) {
return; return;
} }
@ -270,7 +268,7 @@ void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera&
} }
static void drawShape(const btCollisionShape* _shape, static void drawShape(const btCollisionShape* _shape,
ewol::Colored3DObject* _draw, ewol::resource::Colored3DObject* _draw,
mat4 _transformationMatrix, mat4 _transformationMatrix,
std::vector<vec3> _tmpVertices) { std::vector<vec3> _tmpVertices) {
if( NULL == _draw if( NULL == _draw
@ -437,7 +435,7 @@ static void drawShape(const btCollisionShape* _shape,
} }
} }
void ege::ElementGame::drawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera) { void ege::ElementGame::drawDebug(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) {
m_debugText.clear(); m_debugText.clear();
m_debugText.setColor(0x00FF00FF); m_debugText.setColor(0x00FF00FF);
m_debugText.setPos(vec3(-20,32,0)); m_debugText.setPos(vec3(-20,32,0));

View File

@ -15,8 +15,9 @@
#include <vector> #include <vector>
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <ewol/renderer/openGL.h> #include <ewol/openGL/openGL.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resource/Colored3DObject.h>
#include <ege/resource/Mesh.h>
#include <ege/Camera.h> #include <ege/Camera.h>
#include <ewol/compositing/Text.h> #include <ewol/compositing/Text.h>
#include <ege/Environement.h> #include <ege/Environement.h>
@ -27,10 +28,8 @@
#define ELEMENT_SCALE (1.0f/8.0f) #define ELEMENT_SCALE (1.0f/8.0f)
namespace ege namespace ege {
{ class ElementGame {
class ElementGame
{
private: private:
static void FunctionFreeShape(void* _pointer); static void FunctionFreeShape(void* _pointer);
protected: protected:
@ -76,7 +75,7 @@ namespace ege
return m_uID; return m_uID;
}; };
private: private:
ewol::Mesh* m_mesh; //!< Mesh of the Element (can be NULL) ege::resource::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) btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it)
public: public:
/** /**
@ -92,7 +91,7 @@ namespace ege
* @note : this remove the shape and the mesh properties. * @note : this remove the shape and the mesh properties.
* @return true if no error occured * @return true if no error occured
*/ */
bool setMesh(ewol::Mesh* _mesh); bool setMesh(ege::resource::Mesh* _mesh);
/** /**
* @brief set the shape properties. * @brief set the shape properties.
* @param[in] _shape The shape pointer. * @param[in] _shape The shape pointer.
@ -104,7 +103,7 @@ namespace ege
* @brief get a pointer on the Mesh file. * @brief get a pointer on the Mesh file.
* @return the mesh pointer. * @return the mesh pointer.
*/ */
inline ewol::Mesh* getMesh(void) { inline ege::resource::Mesh* getMesh(void) {
return m_mesh; return m_mesh;
}; };
/** /**
@ -187,17 +186,17 @@ namespace ege
/** /**
* @brief draw the current life of the element * @brief draw the current life of the element
*/ */
virtual void drawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera); virtual void drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera);
protected: protected:
// For debug only ... // For debug only ...
ewol::Text m_debugText; ewol::compositing::Text m_debugText;
public: public:
/** /**
* @brief Debug display of the current element * @brief Debug display of the current element
* @param[in,out] draw Basic system to draw the debug shape and informations * @param[in,out] draw Basic system to draw the debug shape and informations
*/ */
virtual void drawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera); virtual void drawDebug(ewol::resource::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 ... * @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 ...

View File

@ -6,10 +6,10 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/Light.h> #include <ege/Light.h>
#include <ewol/debug.h> #include <ege/debug.h>
ewol::Light::Light(void) : ege::Light::Light(void) :
m_direction(0,0,0), m_direction(0,0,0),
m_halfplane(0,0,0), m_halfplane(0,0,0),
m_ambientColor(0,0,0,0), m_ambientColor(0,0,0,0),
@ -23,11 +23,11 @@ ewol::Light::Light(void) :
// nothing to do else ... // nothing to do else ...
} }
ewol::Light::~Light(void) { ege::Light::~Light(void) {
} }
void ewol::Light::link(ewol::Program* _prog, const std::string& _baseName) { void ege::Light::link(ewol::resource::Program* _prog, const std::string& _baseName) {
if (NULL == _prog) { if (NULL == _prog) {
return; return;
} }
@ -38,7 +38,7 @@ void ewol::Light::link(ewol::Program* _prog, const std::string& _baseName) {
m_GL_specularColor = _prog->getUniform(_baseName+".specularColor"); m_GL_specularColor = _prog->getUniform(_baseName+".specularColor");
} }
void ewol::Light::draw(ewol::Program* _prog) { void ege::Light::draw(ewol::resource::Program* _prog) {
_prog->uniform3(m_GL_direction, m_direction); _prog->uniform3(m_GL_direction, m_direction);
_prog->uniform3(m_GL_halfplane, m_halfplane); _prog->uniform3(m_GL_halfplane, m_halfplane);
_prog->uniform4(m_GL_ambientColor, m_ambientColor); _prog->uniform4(m_GL_ambientColor, m_ambientColor);
@ -46,7 +46,7 @@ void ewol::Light::draw(ewol::Program* _prog) {
_prog->uniform4(m_GL_specularColor, m_specularColor); _prog->uniform4(m_GL_specularColor, m_specularColor);
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Light& _obj) { etk::CCout& ege::operator <<(etk::CCout& _os, const ege::Light& _obj) {
_os << "light:{"; _os << "light:{";
_os << "dir=" << _obj.m_direction; _os << "dir=" << _obj.m_direction;
_os << " halfplan=" << _obj.m_halfplane; _os << " halfplan=" << _obj.m_halfplane;

View File

@ -6,15 +6,15 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_LIGHT_H__ #ifndef __EGE_LIGHT_H__
#define __EWOL_LIGHT_H__ #define __EGE_LIGHT_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
#include <etk/math/Vector4D.h> #include <etk/math/Vector4D.h>
#include <ewol/resources/Program.h> #include <ewol/resource/Program.h>
namespace ewol { namespace ege {
class Light { class Light {
private: private:
// values // values
@ -33,8 +33,8 @@ namespace ewol {
public: public:
Light(void); Light(void);
~Light(void); ~Light(void);
void link(ewol::Program* _prog, const std::string& _baseName); void link(ewol::resource::Program* _prog, const std::string& _baseName);
void draw(ewol::Program* _prog); void draw(ewol::resource::Program* _prog);
void setDirection(const vec3& val) { void setDirection(const vec3& val) {
m_direction = val; m_direction = val;
} }
@ -51,9 +51,9 @@ namespace ewol {
m_specularColor = val; m_specularColor = val;
} }
friend etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj); friend etk::CCout& operator <<(etk::CCout& _os, const ege::Light& _obj);
}; };
etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj); etk::CCout& operator <<(etk::CCout& _os, const ege::Light& _obj);
}; };

View File

@ -6,11 +6,11 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/resources/ResourceManager.h> #include <ewol/resource/Manager.h>
#include <ewol/Material.h> #include <ege/Material.h>
#include <ewol/debug.h> #include <ege/debug.h>
ewol::MaterialGlId::MaterialGlId(void) : ege::MaterialGlId::MaterialGlId(void) :
m_GL_ambientFactor(0), m_GL_ambientFactor(0),
m_GL_diffuseFactor(0), m_GL_diffuseFactor(0),
m_GL_specularFactor(0), m_GL_specularFactor(0),
@ -20,7 +20,7 @@ ewol::MaterialGlId::MaterialGlId(void) :
} }
void ewol::MaterialGlId::link(ewol::Program* _prog, const std::string& _baseName) { void ege::MaterialGlId::link(ewol::resource::Program* _prog, const std::string& _baseName) {
if (NULL == _prog) { if (NULL == _prog) {
return; return;
} }
@ -31,7 +31,7 @@ void ewol::MaterialGlId::link(ewol::Program* _prog, const std::string& _baseName
m_GL_texture0 = _prog->getUniform("EW_texID"); m_GL_texture0 = _prog->getUniform("EW_texID");
} }
ewol::Material::Material(void) : ege::Material::Material(void) :
m_ambientFactor(1,1,1,1), m_ambientFactor(1,1,1,1),
m_diffuseFactor(0,0,0,1), m_diffuseFactor(0,0,0,1),
m_specularFactor(0,0,0,1), m_specularFactor(0,0,0,1),
@ -39,13 +39,13 @@ ewol::Material::Material(void) :
m_texture0(NULL) { m_texture0(NULL) {
// nothing to do else ... // nothing to do else ...
} }
ewol::Material::~Material(void) { ege::Material::~Material(void) {
if(NULL!=m_texture0) { if(NULL!=m_texture0) {
ewol::TextureFile::release(m_texture0); ewol::resource::TextureFile::release(m_texture0);
} }
} }
void ewol::Material::draw(ewol::Program* _prog, const MaterialGlId& _glID) { void ege::Material::draw(ewol::resource::Program* _prog, const MaterialGlId& _glID) {
_prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor); _prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor);
_prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor); _prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor);
_prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor); _prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor);
@ -55,20 +55,20 @@ void ewol::Material::draw(ewol::Program* _prog, const MaterialGlId& _glID) {
} }
} }
void ewol::Material::setTexture0(const std::string& _filename) { void ege::Material::setTexture0(const std::string& _filename) {
ivec2 tmpSize(256, 256); ivec2 tmpSize(256, 256);
// prevent overloard error : // prevent overloard error :
ewol::TextureFile* tmpCopy = m_texture0; ewol::resource::TextureFile* tmpCopy = m_texture0;
m_texture0 = ewol::TextureFile::keep(_filename, tmpSize); m_texture0 = ewol::resource::TextureFile::keep(_filename, tmpSize);
if (NULL == m_texture0 ) { if (NULL == m_texture0 ) {
EWOL_ERROR("Can not load specific texture : " << _filename); EGE_ERROR("Can not load specific texture : " << _filename);
// retreave previous texture: // retreave previous texture:
m_texture0 = tmpCopy; m_texture0 = tmpCopy;
return; return;
} }
if (NULL != tmpCopy) { if (NULL != tmpCopy) {
// really release previous texture. In case of same texture loading, then we did not have reload it .. just increase and decrease index... // really release previous texture. In case of same texture loading, then we did not have reload it .. just increase and decrease index...
ewol::TextureFile::release(tmpCopy); ewol::resource::TextureFile::release(tmpCopy);
} }
} }

View File

@ -6,16 +6,19 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_MATERIAL_H__ #ifndef __EGE_MATERIAL_H__
#define __EWOL_MATERIAL_H__ #define __EGE_MATERIAL_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
#include <etk/math/Vector4D.h> #include <etk/math/Vector4D.h>
#include <ewol/resources/Program.h> #include <ewol/resource/Program.h>
#include <ewol/resources/Image.h> #include <ewol/resource/Image.h>
namespace ewol { namespace ege {
/**
* @not-in-doc
*/
class MaterialGlId { class MaterialGlId {
public: public:
// GL index // GL index
@ -25,7 +28,7 @@ namespace ewol {
int32_t m_GL_shininess; int32_t m_GL_shininess;
int32_t m_GL_texture0; int32_t m_GL_texture0;
MaterialGlId(void); MaterialGlId(void);
void link(ewol::Program* _prog, const std::string& _baseName); void link(ewol::resource::Program* _prog, const std::string& _baseName);
}; };
class Material { class Material {
private: private:
@ -34,13 +37,13 @@ namespace ewol {
vec4 m_diffuseFactor; vec4 m_diffuseFactor;
vec4 m_specularFactor; vec4 m_specularFactor;
float m_shininess; float m_shininess;
ewol::TextureFile* m_texture0; ewol::resource::TextureFile* m_texture0;
public: public:
std::vector<uint32_t> m_listIndexFaces; std::vector<uint32_t> m_listIndexFaces;
public: public:
Material(void); Material(void);
~Material(void); ~Material(void);
void draw(ewol::Program* _prog, const MaterialGlId& _glID); void draw(ewol::resource::Program* _prog, const ege::MaterialGlId& _glID);
void setAmbientFactor(const vec4& _val) { void setAmbientFactor(const vec4& _val) {
m_ambientFactor = _val; m_ambientFactor = _val;
} }
@ -55,11 +58,26 @@ namespace ewol {
} }
void setTexture0(const std::string& _filename); void setTexture0(const std::string& _filename);
void setImageSize(const ivec2& _newSize) { if (m_texture0 == NULL){return;} m_texture0->setImageSize(_newSize); }; void setImageSize(const ivec2& _newSize) {
if (m_texture0 == NULL){
return;
}
m_texture0->setImageSize(_newSize);
};
// get the reference on this image to draw nomething on it ... // get the reference on this image to draw nomething on it ...
egami::Image* get(void) { if (m_texture0 == NULL){return NULL;} return &m_texture0->get(); }; egami::Image* get(void) {
if (m_texture0 == NULL){
return NULL;
}
return &m_texture0->get();
};
// flush the data to send it at the openGl system // flush the data to send it at the openGl system
void flush(void) { if (m_texture0 == NULL){return;} m_texture0->flush(); }; void flush(void) {
if (m_texture0 == NULL){
return;
}
m_texture0->flush();
};
}; };
}; };

View File

@ -1,144 +0,0 @@
/**
* @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 <vector>
#include <ewol/debug.h>
#include <ege/Camera.h>
#include <ewol/widget/Widget.h>
#include <ewol/renderer/openGL.h>
#include <ewol/resources/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(bool _setAutoBullet=true, bool _setAutoCamera=true);
/**
* @brief Destructor of the widget classes
*/
virtual ~Scene(void);
void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=NULL,
btCollisionDispatcher* _dispatcher=NULL,
btBroadphaseInterface* _broadphase=NULL,
btConstraintSolver* _solver=NULL,
btDynamicsWorld* _dynamicsWorld=NULL);
void setCamera(ege::Camera* _camera=NULL);
private:
float m_gameTime; //!< time of the game running
protected:
float m_angleView;
///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.
// Other elements
bool m_isRunning; //!< the display is running (not in pause)
float m_ratioTime; //!< Ratio time for the speed of the game ...
// Note : This is only for temporary elements : on the display
std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
public:
/**
* @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);
protected:
bool m_debugMode;
ewol::Colored3DObject* m_debugDrawing; //!< for the debug draw elements
public:
/**
* @brief Toggle the debug mode == > usefull for DEBUG only ...
*/
void debugToggle(void) {
m_debugMode = m_debugMode?false:true;
};
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t _localTime, int32_t _deltaTime) { };
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,
std::vector<ege::Environement::ResultNearestElement>& _resultList);
protected: // Derived function
virtual void onDraw(void);
public: // Derived function
virtual const char * const getObjectType(void) { return "ege::Scene"; };
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void periodicCall(const ewol::EventTime& _event);
};
};
#endif

View File

@ -5,18 +5,18 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsBox.h> #include <ege/physicsShape/PhysicsBox.h>
bool ewol::PhysicsBox::parse(const char* _line) { bool ege::PhysicsBox::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "half-extents : ", 15) ) { if(0 == strncmp(_line, "half-extents : ", 15) ) {
sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] );
EWOL_VERBOSE(" halfSize=" << m_size); EGE_VERBOSE(" halfSize=" << m_size);
return true; return true;
} }
return false; return false;

View File

@ -6,15 +6,15 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_BOX_H__ #ifndef __EGE_PHYSICS_BOX_H__
#define __EWOL_PHYSICS_BOX_H__ #define __EGE_PHYSICS_BOX_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsBox : public ewol::PhysicsShape { class PhysicsBox : public ege::PhysicsShape {
public: public:
PhysicsBox(void) {}; PhysicsBox(void) {};
virtual ~PhysicsBox(void) {}; virtual ~PhysicsBox(void) {};
@ -22,8 +22,8 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::box; return ege::PhysicsShape::box;
}; };
private: private:
vec3 m_size; // Box size property in X, Y and Z vec3 m_size; // Box size property in X, Y and Z
@ -32,10 +32,10 @@ namespace ewol {
return m_size; return m_size;
}; };
public: public:
virtual const PhysicsBox* toBox(void) const { virtual const ege::PhysicsBox* toBox(void) const {
return this; return this;
}; };
virtual PhysicsBox* toBox(void) { virtual ege::PhysicsBox* toBox(void) {
return this; return this;
}; };
}; };

View File

@ -5,23 +5,23 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsCapsule.h> #include <ege/physicsShape/PhysicsCapsule.h>
bool ewol::PhysicsCapsule::parse(const char* _line) { bool ege::PhysicsCapsule::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "radius : ", 9) ) { if(0 == strncmp(_line, "radius : ", 9) ) {
sscanf(&_line[9], "%f", &m_radius ); sscanf(&_line[9], "%f", &m_radius );
EWOL_VERBOSE(" radius=" << m_radius); EGE_VERBOSE(" radius=" << m_radius);
return true; return true;
} }
if(0 == strncmp(_line, "height : ", 9) ) { if(0 == strncmp(_line, "height : ", 9) ) {
sscanf(&_line[9], "%f", &m_height ); sscanf(&_line[9], "%f", &m_height );
EWOL_VERBOSE(" height=" << m_height); EGE_VERBOSE(" height=" << m_height);
return true; return true;
} }
return false; return false;

View File

@ -6,16 +6,16 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_CAPSULE_H__ #ifndef __EGE_PHYSICS_CAPSULE_H__
#define __EWOL_PHYSICS_CAPSULE_H__ #define __EGE_PHYSICS_CAPSULE_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsCapsule : public ewol::PhysicsShape { class PhysicsCapsule : public ege::PhysicsShape {
public: public:
PhysicsCapsule(void) {}; PhysicsCapsule(void) {};
virtual ~PhysicsCapsule(void) {}; virtual ~PhysicsCapsule(void) {};
@ -23,8 +23,8 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::capsule; return ege::PhysicsShape::capsule;
}; };
private: private:
float m_radius; float m_radius;
@ -39,10 +39,10 @@ namespace ewol {
return m_height; return m_height;
}; };
public: public:
virtual const PhysicsCapsule* toCapsule(void) const { virtual const ege::PhysicsCapsule* toCapsule(void) const {
return this; return this;
}; };
virtual PhysicsCapsule* toCapsule(void) { virtual ege::PhysicsCapsule* toCapsule(void) {
return this; return this;
}; };
}; };

View File

@ -5,23 +5,23 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsCone.h> #include <ege/physicsShape/PhysicsCone.h>
bool ewol::PhysicsCone::parse(const char* _line) { bool ege::PhysicsCone::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "radius : ", 9) ) { if(0 == strncmp(_line, "radius : ", 9) ) {
sscanf(&_line[9], "%f", &m_radius ); sscanf(&_line[9], "%f", &m_radius );
EWOL_VERBOSE(" radius=" << m_radius); EGE_VERBOSE(" radius=" << m_radius);
return true; return true;
} }
if(0 == strncmp(_line, "height : ", 9) ) { if(0 == strncmp(_line, "height : ", 9) ) {
sscanf(&_line[9], "%f", &m_height ); sscanf(&_line[9], "%f", &m_height );
EWOL_VERBOSE(" height=" << m_height); EGE_VERBOSE(" height=" << m_height);
return true; return true;
} }
return false; return false;

View File

@ -6,16 +6,16 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_CONE_H__ #ifndef __EGE_PHYSICS_CONE_H__
#define __EWOL_PHYSICS_CONE_H__ #define __EGE_PHYSICS_CONE_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsCone : public ewol::PhysicsShape { class PhysicsCone : public ege::PhysicsShape {
public: public:
PhysicsCone(void) {}; PhysicsCone(void) {};
virtual ~PhysicsCone(void) {}; virtual ~PhysicsCone(void) {};
@ -23,8 +23,8 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::cone; return ege::PhysicsShape::cone;
}; };
private: private:
float m_radius; float m_radius;
@ -39,10 +39,10 @@ namespace ewol {
return m_height; return m_height;
}; };
public: public:
virtual const PhysicsCone* toCone(void) const { virtual const ege::PhysicsCone* toCone(void) const {
return this; return this;
}; };
virtual PhysicsCone* toCone(void) { virtual ege::PhysicsCone* toCone(void) {
return this; return this;
}; };
}; };

View File

@ -5,17 +5,17 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsConvexHull.h> #include <ege/physicsShape/PhysicsConvexHull.h>
bool ewol::PhysicsConvexHull::parse(const char* _line) { bool ege::PhysicsConvexHull::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "points : ", 8) ) { if(0 == strncmp(_line, "points : ", 8) ) {
//EWOL_DEBUG("convex hull point parsing " << _line); //EGE_DEBUG("convex hull point parsing " << _line);
char* base = (char*)(&_line[8]); char* base = (char*)(&_line[8]);
char* tmp= strchr(base, '|'); char* tmp= strchr(base, '|');
vec3 pos(0,0,0); vec3 pos(0,0,0);
@ -30,14 +30,14 @@ bool ewol::PhysicsConvexHull::parse(const char* _line) {
m_points.push_back(pos); m_points.push_back(pos);
/* /*
for (int32_t iii=0; iii<m_points.size(); iii++) { for (int32_t iii=0; iii<m_points.size(); iii++) {
EWOL_VERBOSE(" parsed " << m_points[iii]); EGE_VERBOSE(" parsed " << m_points[iii]);
} }
*/ */
return true; return true;
} }
if(0 == strncmp(_line, "scale : ", 8) ) { if(0 == strncmp(_line, "scale : ", 8) ) {
sscanf(&_line[8], "%f %f %f", &m_scale.m_floats[0], &m_scale.m_floats[1], &m_scale.m_floats[2] ); sscanf(&_line[8], "%f %f %f", &m_scale.m_floats[0], &m_scale.m_floats[1], &m_scale.m_floats[2] );
EWOL_VERBOSE(" scale=" << m_scale); EGE_VERBOSE(" scale=" << m_scale);
return true; return true;
} }
return false; return false;

View File

@ -6,16 +6,16 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_CONVEX_HULL_H__ #ifndef __EGE_PHYSICS_CONVEX_HULL_H__
#define __EWOL_PHYSICS_CONVEX_HULL_H__ #define __EGE_PHYSICS_CONVEX_HULL_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsConvexHull : public ewol::PhysicsShape { class PhysicsConvexHull : public ege::PhysicsShape {
public: public:
PhysicsConvexHull(void) {}; PhysicsConvexHull(void) {};
virtual ~PhysicsConvexHull(void) {}; virtual ~PhysicsConvexHull(void) {};
@ -23,8 +23,8 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::convexHull; return ege::PhysicsShape::convexHull;
}; };
private: private:
vec3 m_scale; vec3 m_scale;
@ -39,10 +39,10 @@ namespace ewol {
return m_points; return m_points;
}; };
public: public:
virtual const PhysicsConvexHull* toConvexHull(void) const { virtual const ege::PhysicsConvexHull* toConvexHull(void) const {
return this; return this;
}; };
virtual PhysicsConvexHull* toConvexHull(void) { virtual ege::PhysicsConvexHull* toConvexHull(void) {
return this; return this;
}; };
}; };

View File

@ -5,17 +5,17 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsCylinder.h> #include <ege/physicsShape/PhysicsCylinder.h>
bool ewol::PhysicsCylinder::parse(const char* _line) { bool ege::PhysicsCylinder::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "half-extents : ", 15) ) { if(0 == strncmp(_line, "half-extents : ", 15) ) {
sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] );
EWOL_VERBOSE(" halfSize=" << m_size); EGE_VERBOSE(" halfSize=" << m_size);
return true; return true;
} }
return false; return false;

View File

@ -6,16 +6,16 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_CYLINDER_H__ #ifndef __EGE_PHYSICS_CYLINDER_H__
#define __EWOL_PHYSICS_CYLINDER_H__ #define __EGE_PHYSICS_CYLINDER_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsCylinder : public ewol::PhysicsShape { class PhysicsCylinder : public ege::PhysicsShape {
public: public:
PhysicsCylinder(void) {}; PhysicsCylinder(void) {};
virtual ~PhysicsCylinder(void) {}; virtual ~PhysicsCylinder(void) {};
@ -23,8 +23,8 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::cylinder; return ege::PhysicsShape::cylinder;
}; };
private: private:
vec3 m_size; vec3 m_size;
@ -33,10 +33,10 @@ namespace ewol {
return m_size; return m_size;
}; };
public: public:
virtual const PhysicsCylinder* toCylinder(void) const { virtual const ege::PhysicsCylinder* toCylinder(void) const {
return this; return this;
}; };
virtual PhysicsCylinder* toCylinder(void) { virtual ege::PhysicsCylinder* toCylinder(void) {
return this; return this;
}; };
}; };

View File

@ -5,51 +5,51 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
#include <ewol/physicsShape/PhysicsBox.h> #include <ege/physicsShape/PhysicsBox.h>
#include <ewol/physicsShape/PhysicsCapsule.h> #include <ege/physicsShape/PhysicsCapsule.h>
#include <ewol/physicsShape/PhysicsCone.h> #include <ege/physicsShape/PhysicsCone.h>
#include <ewol/physicsShape/PhysicsConvexHull.h> #include <ege/physicsShape/PhysicsConvexHull.h>
#include <ewol/physicsShape/PhysicsCylinder.h> #include <ege/physicsShape/PhysicsCylinder.h>
#include <ewol/physicsShape/PhysicsSphere.h> #include <ege/physicsShape/PhysicsSphere.h>
ewol::PhysicsShape* ewol::PhysicsShape::create(const std::string& _name) { ege::PhysicsShape* ege::PhysicsShape::create(const std::string& _name) {
ewol::PhysicsShape* tmpp = NULL; ege::PhysicsShape* tmpp = NULL;
std::string name = to_lower(_name); std::string name = to_lower(_name);
if (name == "box") { if (name == "box") {
tmpp = new ewol::PhysicsBox(); tmpp = new ege::PhysicsBox();
} else if (name == "sphere") { } else if (name == "sphere") {
tmpp = new ewol::PhysicsSphere(); tmpp = new ege::PhysicsSphere();
} else if (name == "cone") { } else if (name == "cone") {
tmpp = new ewol::PhysicsCone(); tmpp = new ege::PhysicsCone();
} else if (name == "cylinder") { } else if (name == "cylinder") {
tmpp = new ewol::PhysicsCylinder(); tmpp = new ege::PhysicsCylinder();
} else if (name == "capsule") { } else if (name == "capsule") {
tmpp = new ewol::PhysicsCapsule(); tmpp = new ege::PhysicsCapsule();
} else if (name == "convexhull") { } else if (name == "convexhull") {
tmpp = new ewol::PhysicsConvexHull(); tmpp = new ege::PhysicsConvexHull();
} else { } else {
EWOL_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]"); EGE_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]");
return NULL; return NULL;
} }
if (tmpp == NULL) { if (tmpp == NULL) {
EWOL_ERROR("Allocation error for physical element : '" << _name << "'"); EGE_ERROR("Allocation error for physical element : '" << _name << "'");
} }
return tmpp; return tmpp;
} }
bool ewol::PhysicsShape::parse(const char* _line) { bool ege::PhysicsShape::parse(const char* _line) {
if(0 == strncmp(_line, "origin : ", 9) ) { if(0 == strncmp(_line, "origin : ", 9) ) {
sscanf(&_line[9], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] ); sscanf(&_line[9], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] );
EWOL_VERBOSE(" Origin=" << m_origin); EGE_VERBOSE(" Origin=" << m_origin);
return true; return true;
} }
if(0 == strncmp(_line, "rotate : ", 9) ) { if(0 == strncmp(_line, "rotate : ", 9) ) {
sscanf(&_line[9], "%f %f %f %f", &m_quaternion.m_floats[0], &m_quaternion.m_floats[1], &m_quaternion.m_floats[2], &m_quaternion.m_floats[3] ); sscanf(&_line[9], "%f %f %f %f", &m_quaternion.m_floats[0], &m_quaternion.m_floats[1], &m_quaternion.m_floats[2], &m_quaternion.m_floats[3] );
EWOL_VERBOSE(" rotate=" << m_quaternion); EGE_VERBOSE(" rotate=" << m_quaternion);
return true; return true;
} }
return false; return false;

View File

@ -6,8 +6,8 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_SHAPE_H__ #ifndef __EGE_PHYSICS_SHAPE_H__
#define __EWOL_PHYSICS_SHAPE_H__ #define __EGE_PHYSICS_SHAPE_H__
#include <etk/types.h> #include <etk/types.h>
@ -16,7 +16,7 @@
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
namespace ewol { namespace ege {
class PhysicsBox; class PhysicsBox;
class PhysicsCylinder; class PhysicsCylinder;
class PhysicsCapsule; class PhysicsCapsule;
@ -26,7 +26,7 @@ namespace ewol {
class PhysicsShape { class PhysicsShape {
public: public:
static PhysicsShape* create(const std::string& _name); static ege::PhysicsShape* create(const std::string& _name);
public: public:
enum type { enum type {
unknow, unknow,
@ -38,15 +38,17 @@ namespace ewol {
sphere sphere
}; };
public: public:
PhysicsShape(void) : m_quaternion(1,0,0,0), m_origin(0,0,0) { PhysicsShape(void) :
m_quaternion(1,0,0,0),
m_origin(0,0,0) {
}; };
virtual ~PhysicsShape(void) { virtual ~PhysicsShape(void) {
}; };
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::unknow; return ege::PhysicsShape::unknow;
}; };
public: public:
@ -68,63 +70,63 @@ namespace ewol {
}; };
public: public:
bool isBox(void) { bool isBox(void) {
return getType() == ewol::PhysicsShape::box; return getType() == ege::PhysicsShape::box;
}; };
bool isCylinder(void) { bool isCylinder(void) {
return getType() == ewol::PhysicsShape::cylinder; return getType() == ege::PhysicsShape::cylinder;
}; };
bool isCapsule(void) { bool isCapsule(void) {
return getType() == ewol::PhysicsShape::capsule; return getType() == ege::PhysicsShape::capsule;
}; };
bool isCone(void) { bool isCone(void) {
return getType() == ewol::PhysicsShape::cone; return getType() == ege::PhysicsShape::cone;
}; };
bool isConvexHull(void) { bool isConvexHull(void) {
return getType() == ewol::PhysicsShape::convexHull; return getType() == ege::PhysicsShape::convexHull;
}; };
bool isSphere(void) { bool isSphere(void) {
return getType() == ewol::PhysicsShape::sphere; return getType() == ege::PhysicsShape::sphere;
}; };
virtual const PhysicsBox* toBox(void) const { virtual const ege::PhysicsBox* toBox(void) const {
return NULL; return NULL;
}; };
virtual PhysicsBox* toBox(void) { virtual ege::PhysicsBox* toBox(void) {
return NULL; return NULL;
}; };
virtual const PhysicsCylinder* toCylinder(void) const { virtual const ege::PhysicsCylinder* toCylinder(void) const {
return NULL; return NULL;
}; };
virtual PhysicsCylinder* toCylinder(void) { virtual ege::PhysicsCylinder* toCylinder(void) {
return NULL; return NULL;
}; };
virtual const PhysicsCapsule* toCapsule(void) const { virtual const ege::PhysicsCapsule* toCapsule(void) const {
return NULL; return NULL;
}; };
virtual PhysicsCapsule* toCapsule(void) { virtual ege::PhysicsCapsule* toCapsule(void) {
return NULL; return NULL;
}; };
virtual const PhysicsCone* toCone(void) const { virtual const ege::PhysicsCone* toCone(void) const {
return NULL; return NULL;
}; };
virtual PhysicsCone* toCone(void) { virtual ege::PhysicsCone* toCone(void) {
return NULL; return NULL;
}; };
virtual const PhysicsConvexHull* toConvexHull(void) const { virtual const ege::PhysicsConvexHull* toConvexHull(void) const {
return NULL; return NULL;
}; };
virtual PhysicsConvexHull* toConvexHull(void) { virtual ege::PhysicsConvexHull* toConvexHull(void) {
return NULL; return NULL;
}; };
virtual const PhysicsSphere* toSphere(void) const { virtual const ege::PhysicsSphere* toSphere(void) const {
return NULL; return NULL;
}; };
virtual PhysicsSphere* toSphere(void) { virtual ege::PhysicsSphere* toSphere(void) {
return NULL; return NULL;
}; };
}; };

View File

@ -5,18 +5,18 @@
* *
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/physicsShape/PhysicsSphere.h> #include <ege/physicsShape/PhysicsSphere.h>
bool ewol::PhysicsSphere::parse(const char* _line) { bool ege::PhysicsSphere::parse(const char* _line) {
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ege::PhysicsShape::parse(_line)) {
return true; return true;
} }
if(0 == strncmp(_line, "radius : ", 9) ) { if(0 == strncmp(_line, "radius : ", 9) ) {
sscanf(&_line[9], "%f", &m_radius ); sscanf(&_line[9], "%f", &m_radius );
EWOL_VERBOSE(" radius=" << m_radius); EGE_VERBOSE(" radius=" << m_radius);
return true; return true;
} }
return false; return false;

View File

@ -6,16 +6,16 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __EWOL_PHYSICS_SPHERE_H__ #ifndef __EGE_PHYSICS_SPHERE_H__
#define __EWOL_PHYSICS_SPHERE_H__ #define __EGE_PHYSICS_SPHERE_H__
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
namespace ewol { namespace ege {
class PhysicsSphere : public ewol::PhysicsShape { class PhysicsSphere : public ege::PhysicsShape {
public: public:
PhysicsSphere(void) {}; PhysicsSphere(void) {};
virtual ~PhysicsSphere(void) {}; virtual ~PhysicsSphere(void) {};
@ -23,18 +23,20 @@ namespace ewol {
virtual bool parse(const char* _line); virtual bool parse(const char* _line);
virtual void display(void) {}; virtual void display(void) {};
public: public:
virtual enum type getType(void) { virtual enum ege::PhysicsShape::type getType(void) {
return ewol::PhysicsShape::sphere; return ege::PhysicsShape::sphere;
}; };
private: private:
float m_radius; // props["radius"] = obj.scale.x float m_radius; // props["radius"] = obj.scale.x
public: public:
float getRadius(void) const { return m_radius; }; float getRadius(void) const {
return m_radius;
};
private: private:
virtual const PhysicsSphere* toSphere(void) const { virtual const ege::PhysicsSphere* toSphere(void) const {
return this; return this;
}; };
virtual PhysicsSphere* toSphere(void) { virtual ege::PhysicsSphere* toSphere(void) {
return this; return this;
}; };
}; };

View File

@ -6,22 +6,22 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/debug.h> #include <ege/debug.h>
#include <ewol/resources/Mesh.h> #include <ege/resource/Mesh.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resource/Manager.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#undef __class__ #undef __class__
#define __class__ "resource::Mesh" #define __class__ "resource::Mesh"
ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) : ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
ewol::resource::Resource(_fileName), ewol::Resource(_fileName),
m_normalMode(normalModeNone), m_normalMode(normalModeNone),
m_checkNormal(false), m_checkNormal(false),
m_pointerShape(NULL), m_pointerShape(NULL),
m_functionFreeShape(NULL) { m_functionFreeShape(NULL) {
addObjectType("ewol::Mesh"); addObjectType("ewol::resource::Mesh");
EWOL_VERBOSE("Load a new mesh : '" << _fileName << "'"); EGE_VERBOSE("Load a new mesh : '" << _fileName << "'");
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
@ -31,8 +31,8 @@ ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _sha
m_light.setDiffuseColor(vec4(1.0,1.0,1.0,1)); m_light.setDiffuseColor(vec4(1.0,1.0,1.0,1));
m_light.setSpecularColor(vec4(0.0,0.0,0.0,1)); m_light.setSpecularColor(vec4(0.0,0.0,0.0,1));
//EWOL_DEBUG(m_name << " " << m_light); //EGE_DEBUG(m_name << " " << m_light);
m_GLprogram = ewol::Program::keep(_shaderName); m_GLprogram = ewol::resource::Program::keep(_shaderName);
if (NULL != m_GLprogram ) { if (NULL != m_GLprogram ) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
@ -44,28 +44,28 @@ ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _sha
m_light.link(m_GLprogram, "EW_directionalLight"); m_light.link(m_GLprogram, "EW_directionalLight");
} }
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=flaot "i"=integer // this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=flaot "i"=integer
m_verticesVBO = ewol::VirtualBufferObject::keep(4); m_verticesVBO = ewol::resource::VirtualBufferObject::keep(4);
// load the curent file : // load the curent file :
std::string tmpName = to_lower(_fileName); std::string tmpName = to_lower(_fileName);
// select the corect loader : // select the corect loader :
if (end_with(tmpName, ".obj") == true) { if (end_with(tmpName, ".obj") == true) {
if (loadOBJ(_fileName) == false) { if (loadOBJ(_fileName) == false) {
EWOL_ERROR("Error To load OBJ file " << tmpName ); EGE_ERROR("Error To load OBJ file " << tmpName );
return; return;
} }
} else if (end_with(tmpName, ".emf") ) { } else if (end_with(tmpName, ".emf") ) {
if (loadEMF(_fileName) == false) { if (loadEMF(_fileName) == false) {
EWOL_ERROR("Error To load EMF file " << tmpName ); EGE_ERROR("Error To load EMF file " << tmpName );
return; return;
} }
//EWOL_CRITICAL("Load a new mesh : '" << _fileName << "' (end)"); //EGE_CRITICAL("Load a new mesh : '" << _fileName << "' (end)");
} else { } else {
// nothing to do == > reqiest an enmpty mesh ==> user manage it ... // nothing to do == > reqiest an enmpty mesh ==> user manage it ...
} }
} }
ewol::resource::Mesh::~Mesh(void) { ege::resource::Mesh::~Mesh(void) {
// remove dynamics dependencies : // remove dynamics dependencies :
ewol::resource::Program::release(m_GLprogram); ewol::resource::Program::release(m_GLprogram);
ewol::resource::VirtualBufferObject::release(m_verticesVBO); ewol::resource::VirtualBufferObject::release(m_verticesVBO);
@ -77,14 +77,14 @@ ewol::resource::Mesh::~Mesh(void) {
//#define DISPLAY_NB_VERTEX_DISPLAYED //#define DISPLAY_NB_VERTEX_DISPLAYED
void ewol::resource::Mesh::draw(mat4& _positionMatrix, void ege::resource::Mesh::draw(mat4& _positionMatrix,
bool _enableDepthTest, bool _enableDepthTest,
bool _enableDepthUpdate) { bool _enableDepthUpdate) {
if (m_GLprogram == NULL) { if (m_GLprogram == NULL) {
EWOL_ERROR("No shader ..."); EGE_ERROR("No shader ...");
return; return;
} }
//EWOL_DEBUG(m_name << " " << m_light); //EGE_DEBUG(m_name << " " << m_light);
if (_enableDepthTest == true) { if (_enableDepthTest == true) {
ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST);
if (false == _enableDepthUpdate) { if (false == _enableDepthUpdate) {
@ -93,7 +93,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
} else { } else {
ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST);
} }
//EWOL_DEBUG(" display " << m_coord.size() << " elements" ); //EGE_DEBUG(" display " << m_coord.size() << " elements" );
m_GLprogram->use(); m_GLprogram->use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 projMatrix = ewol::openGL::getMatrix(); mat4 projMatrix = ewol::openGL::getMatrix();
@ -115,7 +115,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
#endif #endif
for (int32_t kkk=0; kkk<m_listFaces.size(); kkk++) { for (int32_t kkk=0; kkk<m_listFaces.size(); kkk++) {
if (false == m_materials.exist(m_listFaces.getKey(kkk))) { if (false == m_materials.exist(m_listFaces.getKey(kkk))) {
EWOL_WARNING("missing materials : '" << m_listFaces.getKey(kkk) << "'"); EGE_WARNING("missing materials : '" << m_listFaces.getKey(kkk) << "'");
continue; continue;
} }
m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial); m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial);
@ -135,7 +135,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
cameraNormal.normalized(); cameraNormal.normalized();
// remove face that is notin the view ... // remove face that is notin the view ...
std::vector<uint32_t> tmpIndexResult; std::vector<uint32_t> tmpIndexResult;
std::vector<ewol::Face>& tmppFaces = m_listFaces.getValue(kkk).m_faces; std::vector<ege::Face>& tmppFaces = m_listFaces.getValue(kkk).m_faces;
//std::vector<uint32_t>& tmppIndex = m_listFaces.getValue(kkk).m_index; //std::vector<uint32_t>& tmppIndex = m_listFaces.getValue(kkk).m_index;
if (normalModeFace == m_normalMode) { if (normalModeFace == m_normalMode) {
for(size_t iii=0; iii<tmppFaces.size() ; ++iii) { for(size_t iii=0; iii<tmppFaces.size() ; ++iii) {
@ -164,7 +164,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
} }
} }
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
EWOL_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]"); EGE_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
#endif #endif
m_GLprogram->unUse(); m_GLprogram->unUse();
if (_enableDepthTest == true){ if (_enableDepthTest == true){
@ -178,9 +178,9 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
} }
// normal calculation of the normal face is really easy : // normal calculation of the normal face is really easy :
void ewol::resource::Mesh::calculateNormaleFace(void) { void ege::resource::Mesh::calculateNormaleFace(void) {
m_listFacesNormal.clear(); m_listFacesNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeFace) { if (m_normalMode != ege::resource::Mesh::normalModeFace) {
std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces; std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces;
for(size_t iii=0 ; iii<tmpFaceList.size() ; iii++) { for(size_t iii=0 ; iii<tmpFaceList.size() ; iii++) {
// for all case, We use only the 3 vertex for quad element, in theory 3D modeler export element in triangle if it is not a real plane. // for all case, We use only the 3 vertex for quad element, in theory 3D modeler export element in triangle if it is not a real plane.
@ -188,13 +188,13 @@ void ewol::resource::Mesh::calculateNormaleFace(void) {
m_listVertex[tmpFaceList[iii].m_vertex[1]]-m_listVertex[tmpFaceList[iii].m_vertex[2]]); m_listVertex[tmpFaceList[iii].m_vertex[1]]-m_listVertex[tmpFaceList[iii].m_vertex[2]]);
m_listFacesNormal.push_back(normal.normalized()); m_listFacesNormal.push_back(normal.normalized());
} }
m_normalMode = ewol::Mesh::normalModeFace; m_normalMode = ege::resource::Mesh::normalModeFace;
} }
} }
void ewol::resource::Mesh::calculateNormaleEdge(void) { void ege::resource::Mesh::calculateNormaleEdge(void) {
m_listVertexNormal.clear(); m_listVertexNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeVertex) { if (m_normalMode != ege::resource::Mesh::normalModeVertex) {
for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) { for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) {
std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces; std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces;
vec3 normal(0,0,0); vec3 normal(0,0,0);
@ -213,7 +213,7 @@ void ewol::resource::Mesh::calculateNormaleEdge(void) {
m_listVertexNormal.push_back(normal.normalized()); m_listVertexNormal.push_back(normal.normalized());
} }
} }
m_normalMode = ewol::Mesh::normalModeVertex; m_normalMode = ege::resource::Mesh::normalModeVertex;
} }
} }
@ -221,9 +221,9 @@ void ewol::resource::Mesh::calculateNormaleEdge(void) {
//#define PRINT_HALF (1) //#define PRINT_HALF (1)
//#define TRY_MINIMAL_VBO //#define TRY_MINIMAL_VBO
void ewol::resource::Mesh::generateVBO(void) { void ege::resource::Mesh::generateVBO(void) {
// calculate the normal of all faces if needed // calculate the normal of all faces if needed
if (m_normalMode == ewol::Mesh::normalModeNone) { if (m_normalMode == ege::resource::Mesh::normalModeNone) {
// when no normal detected == > auto generate Face normal .... // when no normal detected == > auto generate Face normal ....
calculateNormaleFace(); calculateNormaleFace();
} }
@ -242,7 +242,7 @@ void ewol::resource::Mesh::generateVBO(void) {
for(size_t indice=0 ; indice<3; indice++) { for(size_t indice=0 ; indice<3; indice++) {
vec3 position = m_listVertex[tmpFaceList.m_faces[iii].m_vertex[indice]]; vec3 position = m_listVertex[tmpFaceList.m_faces[iii].m_vertex[indice]];
vec3 normal; vec3 normal;
if (m_normalMode == ewol::Mesh::normalModeVertex) { if (m_normalMode == normalModeVertex) {
normal = m_listVertexNormal[tmpFaceList.m_faces[iii].m_normal[indice]]; normal = m_listVertexNormal[tmpFaceList.m_faces[iii].m_normal[indice]];
} else { } else {
normal = m_listFacesNormal[tmpFaceList.m_faces[iii].m_normal[indice]]; normal = m_listFacesNormal[tmpFaceList.m_faces[iii].m_normal[indice]];
@ -257,7 +257,7 @@ void ewol::resource::Mesh::generateVBO(void) {
&& m_verticesVBO->getOnBufferVec2(MESH_VBO_TEXTURE,jjj) == texturepos) { && m_verticesVBO->getOnBufferVec2(MESH_VBO_TEXTURE,jjj) == texturepos) {
vertexVBOId[indice] = jjj; vertexVBOId[indice] = jjj;
elementFind = true; elementFind = true;
//EWOL_DEBUG("search indice : " << jjj); //EGE_DEBUG("search indice : " << jjj);
tmpppppp += jjj; tmpppppp += jjj;
// stop searching ... // stop searching ...
break; break;
@ -276,7 +276,7 @@ void ewol::resource::Mesh::generateVBO(void) {
} }
} }
#ifdef TRY_MINIMAL_VBO #ifdef TRY_MINIMAL_VBO
EWOL_DEBUG("nb cycle ? : " << tmpppppp); EGE_DEBUG("nb cycle ? : " << tmpppppp);
#endif #endif
} }
// update all the VBO elements ... // update all the VBO elements ...
@ -284,8 +284,8 @@ void ewol::resource::Mesh::generateVBO(void) {
} }
void ewol::resource::Mesh::createViewBox(const std::string& _materialName,float _size) { void ege::resource::Mesh::createViewBox(const std::string& _materialName,float _size) {
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = normalModeNone;
// This is the direct generation basis on the .obj system // This is the direct generation basis on the .obj system
/* /*
5 6 5 6
@ -377,18 +377,18 @@ void ewol::resource::Mesh::createViewBox(const std::string& _materialName,float
} }
bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) { bool ege::resource::Mesh::loadOBJ(const std::string& _fileName) {
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = normalModeNone;
#if 0 #if 0
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
// get the fileSize ... // get the fileSize ...
int32_t size = fileName.fileSize(); int32_t size = fileName.fileSize();
if (size == 0 ) { if (size == 0 ) {
EWOL_ERROR("No data in the file named=\"" << fileName << "\""); EGE_ERROR("No data in the file named=\"" << fileName << "\"");
return false; return false;
} }
if(false == fileName.fileOpenRead() ) { if(false == fileName.fileOpenRead() ) {
EWOL_ERROR("Can not find the file name=\"" << fileName << "\""); EGE_ERROR("Can not find the file name=\"" << fileName << "\"");
return false; return false;
} }
char inputDataLine[2048]; char inputDataLine[2048];
@ -442,7 +442,7 @@ bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) {
&vertexIndex[1], &uvIndex[1], &vertexIndex[1], &uvIndex[1],
&vertexIndex[2], &uvIndex[2] ); &vertexIndex[2], &uvIndex[2] );
if (6 != matches){ if (6 != matches){
EWOL_ERROR("Parsing error in the .obj files : " << fileName << " (l=" << lineID << ") in 'f' section : \"" << &inputDataLine[2] << "\" expected : %d/%d(/%d) %d/%d(/%d) %d/%d(/%d) (%d/%d(/%d)) () for option"); EGE_ERROR("Parsing error in the .obj files : " << fileName << " (l=" << lineID << ") in 'f' section : \"" << &inputDataLine[2] << "\" expected : %d/%d(/%d) %d/%d(/%d) %d/%d(/%d) (%d/%d(/%d)) () for option");
continue; continue;
} }
} }
@ -459,9 +459,9 @@ bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) {
vertexIndex[2]-1, uvIndex[2]-1)); vertexIndex[2]-1, uvIndex[2]-1));
} }
/* /*
EWOL_DEBUG(" plop : " << tmpFace.m_nbElement << " ? " << m_listFaces[m_listFaces.size()-1].m_nbElement); EGE_DEBUG(" plop : " << tmpFace.m_nbElement << " ? " << m_listFaces[m_listFaces.size()-1].m_nbElement);
EWOL_DEBUG(" : " << tmpFace.m_vertex[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_vertex[0]); EGE_DEBUG(" : " << tmpFace.m_vertex[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_vertex[0]);
EWOL_DEBUG(" : " << tmpFace.m_uv[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_uv[0]); EGE_DEBUG(" : " << tmpFace.m_uv[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_uv[0]);
*/ */
} else if (inputDataLine[0] == 's') { } else if (inputDataLine[0] == 's') {
// ??? : s off // ??? : s off
@ -513,10 +513,10 @@ int32_t countIndent(etk::FSNode& _file) {
int32_t nbIndent=0; int32_t nbIndent=0;
int32_t nbSpacesTab=0; int32_t nbSpacesTab=0;
int32_t nbChar=0; int32_t nbChar=0;
//EWOL_DEBUG(" start count Indent"); //EGE_DEBUG(" start count Indent");
for(char current=_file.fileGet(); current != '\0'; current=_file.fileGet()) { for(char current=_file.fileGet(); current != '\0'; current=_file.fileGet()) {
nbChar++; nbChar++;
//EWOL_DEBUG("parse : " << current); //EGE_DEBUG("parse : " << current);
if (current == '\t') { if (current == '\t') {
nbSpacesTab = 0; nbSpacesTab = 0;
nbIndent++; nbIndent++;
@ -535,7 +535,7 @@ int32_t countIndent(etk::FSNode& _file) {
break; break;
} }
} }
//EWOL_DEBUG("indent : " << nbIndent); //EGE_DEBUG("indent : " << nbIndent);
_file.fileSeek(-nbChar, etk::FSN_SEEK_CURRENT); _file.fileSeek(-nbChar, etk::FSN_SEEK_CURRENT);
return nbIndent; return nbIndent;
} }
@ -570,7 +570,7 @@ char* loadNextData(char* _elementLine,
&& _stopColomn == true) ) && _stopColomn == true) )
{ {
*element = '\0'; *element = '\0';
//EWOL_DEBUG(" plop : '" << _elementLine << "'" ); //EGE_DEBUG(" plop : '" << _elementLine << "'" );
return _elementLine; return _elementLine;
} else if( element == _elementLine } else if( element == _elementLine
&& current != '\t') { && current != '\t') {
@ -626,18 +626,18 @@ enum emfModuleMode {
EMFModuleMaterial_END, EMFModuleMaterial_END,
}; };
bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) { bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
m_checkNormal = true; m_checkNormal = true;
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = normalModeNone;
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
// get the fileSize ... // get the fileSize ...
int32_t size = fileName.fileSize(); int32_t size = fileName.fileSize();
if (size == 0 ) { if (size == 0 ) {
EWOL_ERROR("No data in the file named=\"" << fileName << "\""); EGE_ERROR("No data in the file named=\"" << fileName << "\"");
return false; return false;
} }
if(false == fileName.fileOpenRead() ) { if(false == fileName.fileOpenRead() ) {
EWOL_ERROR("Can not find the file name=\"" << fileName << "\""); EGE_ERROR("Can not find the file name=\"" << fileName << "\"");
return false; return false;
} }
char inputDataLine[2048]; char inputDataLine[2048];
@ -646,22 +646,22 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
if(0 == strncmp(inputDataLine, "EMF(STRING)", 11)) { if(0 == strncmp(inputDataLine, "EMF(STRING)", 11)) {
// parse in string mode ... // parse in string mode ...
} else if (0 == strncmp(inputDataLine, "EMF(BINARY)", 11)) { } else if (0 == strncmp(inputDataLine, "EMF(BINARY)", 11)) {
EWOL_ERROR(" file binary mode is not supported now : 'EMF(BINARY)'"); EGE_ERROR(" file binary mode is not supported now : 'EMF(BINARY)'");
return false; return false;
} else { } else {
EWOL_ERROR(" file mode is not supported now : 'EMF(? ? ?)' = '" << inputDataLine << "'"); EGE_ERROR(" file mode is not supported now : 'EMF(? ? ?)' = '" << inputDataLine << "'");
return false; return false;
} }
enum emfModuleMode currentMode = EMFModuleNone; enum emfModuleMode currentMode = EMFModuleNone;
EWOL_VERBOSE("Start parsing Mesh file : " << fileName); EGE_VERBOSE("Start parsing Mesh file : " << fileName);
// mesh global param : // mesh global param :
std::string currentMeshName = ""; std::string currentMeshName = "";
int32_t meshFaceMaterialID = -1; int32_t meshFaceMaterialID = -1;
// material global param : // material global param :
std::string materialName = ""; std::string materialName = "";
ewol::Material* material = NULL; ege::Material* material = NULL;
// physical shape: // physical shape:
ewol::PhysicsShape* physics = NULL; ege::PhysicsShape* physics = NULL;
while(1) { while(1) {
int32_t level = countIndent(fileName); int32_t level = countIndent(fileName);
if (level == 0) { if (level == 0) {
@ -672,10 +672,10 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
} }
if(0 == strncmp(inputDataLine, "Mesh :", 6) ) { if(0 == strncmp(inputDataLine, "Mesh :", 6) ) {
currentMode = EMFModuleMesh; currentMode = EMFModuleMesh;
EWOL_VERBOSE("Parse Mesh :"); EGE_VERBOSE("Parse Mesh :");
} else if(0 == strncmp(inputDataLine, "Materials : ", 11) ) { } else if(0 == strncmp(inputDataLine, "Materials : ", 11) ) {
currentMode = EMFModuleMaterial; currentMode = EMFModuleMaterial;
EWOL_VERBOSE("Parse Material :"); EGE_VERBOSE("Parse Material :");
} else { } else {
currentMode = EMFModuleNone; currentMode = EMFModuleNone;
} }
@ -690,7 +690,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
currentMeshName = inputDataLine; currentMeshName = inputDataLine;
currentMode = EMFModuleMeshNamed; currentMode = EMFModuleMeshNamed;
EWOL_VERBOSE(" "<< currentMeshName); EGE_VERBOSE(" "<< currentMeshName);
continue; continue;
} }
if (level == 2) { if (level == 2) {
@ -702,24 +702,24 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
if(0 == strncmp(inputDataLine, "Vertex", 6) ) { if(0 == strncmp(inputDataLine, "Vertex", 6) ) {
currentMode = EMFModuleMeshVertex; currentMode = EMFModuleMeshVertex;
EWOL_VERBOSE(" Vertex ..."); EGE_VERBOSE(" Vertex ...");
} else if(0 == strncmp(inputDataLine, "UV-mapping", 10) ) { } else if(0 == strncmp(inputDataLine, "UV-mapping", 10) ) {
currentMode = EMFModuleMeshUVMapping; currentMode = EMFModuleMeshUVMapping;
EWOL_VERBOSE(" UV-mapping ..."); EGE_VERBOSE(" UV-mapping ...");
} else if(0 == strncmp(inputDataLine, "Normal(vertex)", 14) ) { } else if(0 == strncmp(inputDataLine, "Normal(vertex)", 14) ) {
currentMode = EMFModuleMeshNormalVertex; currentMode = EMFModuleMeshNormalVertex;
EWOL_VERBOSE(" Normal(vertex) ..."); EGE_VERBOSE(" Normal(vertex) ...");
} else if(0 == strncmp(inputDataLine, "Normal(face)", 12) ) { } else if(0 == strncmp(inputDataLine, "Normal(face)", 12) ) {
currentMode = EMFModuleMeshNormalFace; currentMode = EMFModuleMeshNormalFace;
EWOL_VERBOSE(" Normal(face) ..."); EGE_VERBOSE(" Normal(face) ...");
} else if(0 == strncmp(inputDataLine, "Face", 4) ) { } else if(0 == strncmp(inputDataLine, "Face", 4) ) {
currentMode = EMFModuleMeshFace; currentMode = EMFModuleMeshFace;
EWOL_VERBOSE(" Face ..."); EGE_VERBOSE(" Face ...");
} else if(0 == strncmp(inputDataLine, "Physics", 7) ) { } else if(0 == strncmp(inputDataLine, "Physics", 7) ) {
currentMode = EMFModuleMeshPhysics; currentMode = EMFModuleMeshPhysics;
EWOL_VERBOSE(" Physics ..."); EGE_VERBOSE(" Physics ...");
} else { } else {
EWOL_ERROR(" Unknow mesh property '"<<inputDataLine<<"'"); EGE_ERROR(" Unknow mesh property '"<<inputDataLine<<"'");
currentMode = EMFModuleMeshNamed; currentMode = EMFModuleMeshNamed;
} }
continue; continue;
@ -727,7 +727,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
// level > 2 // level > 2
switch (currentMode) { switch (currentMode) {
default: default:
EWOL_ERROR("Unknow ... "<< level); EGE_ERROR("Unknow ... "<< level);
jumpEndLine(fileName); jumpEndLine(fileName);
break; break;
case EMFModuleMeshVertex: { case EMFModuleMeshVertex: {
@ -744,7 +744,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
break; break;
} }
} }
EWOL_VERBOSE(" " << m_listVertex.size() << " vertex"); EGE_VERBOSE(" " << m_listVertex.size() << " vertex");
break; break;
} }
case EMFModuleMeshUVMapping: { case EMFModuleMeshUVMapping: {
@ -761,11 +761,11 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
break; break;
} }
} }
EWOL_VERBOSE(" " << m_listUV.size() << " coord"); EGE_VERBOSE(" " << m_listUV.size() << " coord");
break; break;
} }
case EMFModuleMeshNormalVertex: { case EMFModuleMeshNormalVertex: {
m_normalMode = ewol::Mesh::normalModeVertex; m_normalMode = normalModeVertex;
vec3 normal(0,0,0); vec3 normal(0,0,0);
// find the vertex Normal list. // find the vertex Normal list.
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
@ -780,11 +780,11 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
break; break;
} }
} }
EWOL_VERBOSE(" " << m_listVertexNormal.size() << " Normals"); EGE_VERBOSE(" " << m_listVertexNormal.size() << " Normals");
break; break;
} }
case EMFModuleMeshNormalFace: { case EMFModuleMeshNormalFace: {
m_normalMode = ewol::Mesh::normalModeFace; m_normalMode = normalModeFace;
vec3 normal(0,0,0); vec3 normal(0,0,0);
// find the face Normal list. // find the face Normal list.
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
@ -799,7 +799,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
break; break;
} }
} }
EWOL_VERBOSE(" " << m_listFacesNormal.size() << " Normals"); EGE_VERBOSE(" " << m_listFacesNormal.size() << " Normals");
break; break;
} }
case EMFModuleMeshFace: case EMFModuleMeshFace:
@ -816,7 +816,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
FaceIndexing empty; FaceIndexing empty;
m_listFaces.add(inputDataLine, empty); m_listFaces.add(inputDataLine, empty);
meshFaceMaterialID = m_listFaces.getId(inputDataLine); meshFaceMaterialID = m_listFaces.getId(inputDataLine);
EWOL_VERBOSE(" " << inputDataLine); EGE_VERBOSE(" " << inputDataLine);
} else if (currentMode == EMFModuleMeshFaceMaterial) { } else if (currentMode == EMFModuleMeshFaceMaterial) {
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
@ -844,7 +844,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
vertexIndex[1], uvIndex[1], normalIndex[1], vertexIndex[1], uvIndex[1], normalIndex[1],
vertexIndex[2], uvIndex[2], normalIndex[2])); vertexIndex[2], uvIndex[2], normalIndex[2]));
/* /*
EWOL_DEBUG("face :" << vertexIndex[0] << "/" << uvIndex[0] << "/" << normalIndex[0] << EGE_DEBUG("face :" << vertexIndex[0] << "/" << uvIndex[0] << "/" << normalIndex[0] <<
" " << vertexIndex[1] << "/" << uvIndex[1] << "/" << normalIndex[1] << " " << vertexIndex[1] << "/" << uvIndex[1] << "/" << normalIndex[1] <<
" " << vertexIndex[2] << "/" << uvIndex[2] << "/" << normalIndex[2]); " " << vertexIndex[2] << "/" << uvIndex[2] << "/" << normalIndex[2]);
*/ */
@ -854,10 +854,10 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
break; break;
} }
} }
EWOL_VERBOSE(" " << m_listFaces.getValue(meshFaceMaterialID).m_faces.size() << " faces"); EGE_VERBOSE(" " << m_listFaces.getValue(meshFaceMaterialID).m_faces.size() << " faces");
} else { } else {
// insert element without material ... // insert element without material ...
EWOL_ERROR(" try to add face without material selection ..."); EGE_ERROR(" try to add face without material selection ...");
jumpEndLine(fileName); jumpEndLine(fileName);
} }
break; break;
@ -869,21 +869,21 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
} }
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
if (level == 3) { if (level == 3) {
physics = ewol::PhysicsShape::create(inputDataLine); physics = ege::PhysicsShape::create(inputDataLine);
if (physics == NULL) { if (physics == NULL) {
EWOL_ERROR("Allocation error when creating physical shape ..."); EGE_ERROR("Allocation error when creating physical shape ...");
continue; continue;
} }
m_physics.push_back(physics); m_physics.push_back(physics);
EWOL_VERBOSE(" " << m_physics.size() << " " << inputDataLine); EGE_VERBOSE(" " << m_physics.size() << " " << inputDataLine);
currentMode = EMFModuleMeshPhysicsNamed; currentMode = EMFModuleMeshPhysicsNamed;
} else if (currentMode == EMFModuleMeshPhysicsNamed) { } else if (currentMode == EMFModuleMeshPhysicsNamed) {
if (physics == NULL) { if (physics == NULL) {
EWOL_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
continue; continue;
} }
if (false == physics->parse(inputDataLine)) { if (false == physics->parse(inputDataLine)) {
EWOL_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ...");
} }
} }
break; break;
@ -904,20 +904,20 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
materialName = ""; materialName = "";
material = NULL; material = NULL;
} }
material = new ewol::Material(); material = new ege::Material();
materialName = inputDataLine; materialName = inputDataLine;
currentMode = EMFModuleMaterialNamed; currentMode = EMFModuleMaterialNamed;
EWOL_VERBOSE(" "<< materialName); EGE_VERBOSE(" "<< materialName);
continue; continue;
} }
// level >1 // level >1
if (currentMode != EMFModuleMaterialNamed) { if (currentMode != EMFModuleMaterialNamed) {
EWOL_WARNING(" Unknow element ..."<< level); EGE_WARNING(" Unknow element ..."<< level);
jumpEndLine(fileName); jumpEndLine(fileName);
continue; continue;
} }
if (NULL == material) { if (NULL == material) {
EWOL_ERROR("material allocation error"); EGE_ERROR("material allocation error");
jumpEndLine(fileName); jumpEndLine(fileName);
continue; continue;
} }
@ -925,7 +925,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[3], "%f", &tmpVal); sscanf(&inputDataLine[3], "%f", &tmpVal);
material->setShininess(tmpVal); material->setShininess(tmpVal);
EWOL_VERBOSE(" Shininess " << tmpVal); EGE_VERBOSE(" Shininess " << tmpVal);
} else if(0 == strncmp(inputDataLine,"Ka ",3)) { } else if(0 == strncmp(inputDataLine,"Ka ",3)) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
@ -933,7 +933,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3); sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3);
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setAmbientFactor(tmp); material->setAmbientFactor(tmp);
EWOL_VERBOSE(" AmbientFactor " << tmp); EGE_VERBOSE(" AmbientFactor " << tmp);
} else if(0 == strncmp(inputDataLine,"Kd ",3)) { } else if(0 == strncmp(inputDataLine,"Kd ",3)) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
@ -941,7 +941,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3); sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3);
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setDiffuseFactor(tmp); material->setDiffuseFactor(tmp);
EWOL_VERBOSE(" DiffuseFactor " << tmp); EGE_VERBOSE(" DiffuseFactor " << tmp);
} else if(0 == strncmp(inputDataLine,"Ks ",3)) { } else if(0 == strncmp(inputDataLine,"Ks ",3)) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
@ -949,31 +949,31 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3); sscanf(&inputDataLine[3], "%f %f %f", &tmpVal1, &tmpVal2, &tmpVal3);
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setSpecularFactor(tmp); material->setSpecularFactor(tmp);
EWOL_VERBOSE(" SpecularFactor " << tmp); EGE_VERBOSE(" SpecularFactor " << tmp);
} else if(0 == strncmp(inputDataLine,"Ni ",3)) { } else if(0 == strncmp(inputDataLine,"Ni ",3)) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[3], "%f", &tmpVal); sscanf(&inputDataLine[3], "%f", &tmpVal);
// TODO : ... // TODO : ...
EWOL_VERBOSE(" Ni " << tmpVal); EGE_VERBOSE(" Ni " << tmpVal);
} else if(0 == strncmp(inputDataLine,"d ",2)) { } else if(0 == strncmp(inputDataLine,"d ",2)) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[2], "%f", &tmpVal); sscanf(&inputDataLine[2], "%f", &tmpVal);
// TODO : ... // TODO : ...
EWOL_VERBOSE(" d " << tmpVal); EGE_VERBOSE(" d " << tmpVal);
} else if(0 == strncmp(inputDataLine,"illum ",6)) { } else if(0 == strncmp(inputDataLine,"illum ",6)) {
int tmpVal=0; int tmpVal=0;
sscanf(&inputDataLine[6], "%d", &tmpVal); sscanf(&inputDataLine[6], "%d", &tmpVal);
// TODO : ... // TODO : ...
EWOL_VERBOSE(" illum " << tmpVal); EGE_VERBOSE(" illum " << tmpVal);
} else if(0 == strncmp(inputDataLine,"map_Kd ",7)) { } else if(0 == strncmp(inputDataLine,"map_Kd ",7)) {
material->setTexture0(fileName.getRelativeFolder() + &inputDataLine[7]); material->setTexture0(fileName.getRelativeFolder() + &inputDataLine[7]);
EWOL_VERBOSE(" Texture " << &inputDataLine[7]); EGE_VERBOSE(" Texture " << &inputDataLine[7]);
} else { } else {
EWOL_ERROR("unknow material property ... : '" << inputDataLine << "'"); EGE_ERROR("unknow material property ... : '" << inputDataLine << "'");
} }
} else { } else {
// unknow ... // unknow ...
EWOL_WARNING("Unknow type of line == > jump end of line ... "); EGE_WARNING("Unknow type of line == > jump end of line ... ");
jumpEndLine(fileName); jumpEndLine(fileName);
} }
} }
@ -985,27 +985,27 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
materialName = ""; materialName = "";
material = NULL; material = NULL;
} }
EWOL_VERBOSE("Stop parsing Mesh file"); EGE_VERBOSE("Stop parsing Mesh file");
fileName.fileClose(); fileName.fileClose();
generateVBO(); generateVBO();
return true; return true;
} }
void ewol::resource::Mesh::addMaterial(const std::string& _name, ewol::Material* _data) { void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _data) {
if (NULL == _data) { if (NULL == _data) {
EWOL_ERROR(" can not add material with null pointer"); EGE_ERROR(" can not add material with null pointer");
return; return;
} }
if (_name == "") { if (_name == "") {
EWOL_ERROR(" can not add material with no name"); EGE_ERROR(" can not add material with no name");
return; return;
} }
// really add the material : // really add the material :
m_materials.add(_name, _data); m_materials.add(_name, _data);
} }
void ewol::resource::Mesh::setShape(void* _shape) { void ege::resource::Mesh::setShape(void* _shape) {
if (m_functionFreeShape!=NULL) { if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape); m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL; m_pointerShape = NULL;
@ -1013,26 +1013,26 @@ void ewol::resource::Mesh::setShape(void* _shape) {
m_pointerShape=_shape; m_pointerShape=_shape;
} }
ewol::resource::Mesh* ewol::resource::Mesh::keep(const std::string& _meshName) { ege::resource::Mesh* ege::resource::Mesh::keep(const std::string& _meshName) {
ewol::resource::Mesh* object = static_cast<ewol::resource::Mesh*>(getManager().localKeep(_meshName)); ege::resource::Mesh* object = static_cast<ege::resource::Mesh*>(getManager().localKeep(_meshName));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
EWOL_DEBUG("CREATE: Mesh: '" << _meshName << "'"); EGE_DEBUG("CREATE: Mesh: '" << _meshName << "'");
object = new ewol::resource::Mesh(_meshName); object = new ege::resource::Mesh(_meshName);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName); EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
return NULL; return NULL;
} }
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }
void ewol::resource::Mesh::release(ewol::Mesh*& _object) { void ege::resource::Mesh::release(ege::resource::Mesh*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object); ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -6,19 +6,19 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#ifndef __MESH_H__ #ifndef __EGE_MESH_H__
#define __MESH_H__ #define __EGE_MESH_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/Hash.h> #include <etk/Hash.h>
#include <ewol/resources/Resource.h> #include <ewol/resource/Resource.h>
#include <ewol/resources/Image.h> #include <ewol/resource/Image.h>
#include <ewol/resources/Shader.h> #include <ewol/resource/Shader.h>
#include <ewol/resources/Program.h> #include <ewol/resource/Program.h>
#include <ewol/resources/VirtualBufferObject.h> #include <ewol/resource/VirtualBufferObject.h>
#include <ewol/Light.h> #include <ege/Light.h>
#include <ewol/Material.h> #include <ege/Material.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ege/physicsShape/PhysicsShape.h>
// 3 "float" elements // 3 "float" elements
#define MESH_VBO_VERTICES (0) #define MESH_VBO_VERTICES (0)
// 2 "float" elements // 2 "float" elements
@ -30,49 +30,58 @@
// 4 "float" elements // 4 "float" elements
#define MESH_VBO_COLOR (4) #define MESH_VBO_COLOR (4)
namespace ewol { namespace ege {
/**
* @not-in-doc
*/
class Face {
public:
int32_t m_vertex[3];
int32_t m_uv[3];
int32_t m_normal[3];
public:
Face(void) {};
Face(int32_t v1, int32_t t1,
int32_t v2, int32_t t2,
int32_t v3, int32_t t3) {
m_vertex[0] = v1;
m_vertex[1] = v2;
m_vertex[2] = v3;
m_uv[0] = t1;
m_uv[1] = t2;
m_uv[2] = t3;
m_normal[0] = -1;
m_normal[1] = -1;
m_normal[2] = -1;
};
Face(int32_t v1, int32_t t1, int32_t n1,
int32_t v2, int32_t t2, int32_t n2,
int32_t v3, int32_t t3, int32_t n3) {
m_vertex[0] = v1;
m_vertex[1] = v2;
m_vertex[2] = v3;
m_uv[0] = t1;
m_uv[1] = t2;
m_uv[2] = t3;
m_normal[0] = n1;
m_normal[1] = n2;
m_normal[2] = n3;
};
};
/**
* @not-in-doc
*/
class FaceIndexing {
public:
std::vector<Face> m_faces;
std::vector<uint32_t> m_index;
};
namespace resource { namespace resource {
class Face { class Mesh : public ewol::Resource {
public:
int32_t m_vertex[3];
int32_t m_uv[3];
int32_t m_normal[3];
public:
Face(void) {};
Face(int32_t v1, int32_t t1,
int32_t v2, int32_t t2,
int32_t v3, int32_t t3) {
m_vertex[0] = v1;
m_vertex[1] = v2;
m_vertex[2] = v3;
m_uv[0] = t1;
m_uv[1] = t2;
m_uv[2] = t3;
m_normal[0] = -1;
m_normal[1] = -1;
m_normal[2] = -1;
};
Face(int32_t v1, int32_t t1, int32_t n1,
int32_t v2, int32_t t2, int32_t n2,
int32_t v3, int32_t t3, int32_t n3) {
m_vertex[0] = v1;
m_vertex[1] = v2;
m_vertex[2] = v3;
m_uv[0] = t1;
m_uv[1] = t2;
m_uv[2] = t3;
m_normal[0] = n1;
m_normal[1] = n2;
m_normal[2] = n3;
};
};
class FaceIndexing {
public:
std::vector<Face> m_faces;
std::vector<uint32_t> m_index;
};
class Mesh : public ewol::resource::Resource {
public: public:
/**
* @not-in-doc
*/
enum normalMode { enum normalMode {
normalModeNone, normalModeNone,
normalModeFace, normalModeFace,
@ -82,32 +91,37 @@ namespace ewol {
enum normalMode m_normalMode; // select the normal mode of display enum normalMode m_normalMode; // select the normal mode of display
bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card
protected: protected:
ewol::Program* m_GLprogram; ewol::resource::Program* m_GLprogram;
int32_t m_GLPosition; int32_t m_GLPosition;
int32_t m_GLMatrix; int32_t m_GLMatrix;
int32_t m_GLMatrixPosition; int32_t m_GLMatrixPosition;
int32_t m_GLNormal; int32_t m_GLNormal;
int32_t m_GLtexture; int32_t m_GLtexture;
int32_t m_bufferOfset; int32_t m_bufferOfset;
int32_t m_numberOfElments; int32_t m_numberOfElments;
MaterialGlId m_GLMaterial; MaterialGlId m_GLMaterial;
ewol::Light m_light; ege::Light m_light;
protected: protected:
std::vector<vec3> m_listVertex; //!< List of all vertex in the element std::vector<vec3> m_listVertex; //!< List of all vertex in the element
std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture) std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture)
std::vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated std::vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated
std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
etk::Hash<ewol::Material*> m_materials; etk::Hash<ege::Material*> m_materials;
std::vector<ewol::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib) std::vector<ege::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
protected: protected:
ewol::VirtualBufferObject* m_verticesVBO; ewol::resource::VirtualBufferObject* m_verticesVBO;
protected: protected:
Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog"); Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog");
virtual ~Mesh(void); virtual ~Mesh(void);
public: public:
virtual const char* getType(void) { return "ewol::Mesh"; };
virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true); virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true);
virtual void draw(mat4& _positionMatrix,
const etk::Color<float>& _mainColor,
bool _enableDepthTest = true,
bool _enableDepthUpdate = true) {
draw(_positionMatrix, _enableDepthTest, _enableDepthUpdate);
}
void generateVBO(void); void generateVBO(void);
private: private:
void calculateNormaleFace(void); void calculateNormaleFace(void);
@ -118,19 +132,25 @@ namespace ewol {
bool loadOBJ(const std::string& _fileName); bool loadOBJ(const std::string& _fileName);
bool loadEMF(const std::string& _fileName); bool loadEMF(const std::string& _fileName);
public: public:
void addMaterial(const std::string& _name, ewol::Material* _data); void addMaterial(const std::string& _name, ege::Material* _data);
public: public:
/** /**
* @brief set the check of normal position befor sending it to the openGl card * @brief set the check of normal position befor sending it to the openGl card
* @param[in] _status New state. * @param[in] _status New state.
*/ */
void setCheckNormal(bool _status) { m_checkNormal=_status; }; void setCheckNormal(bool _status) {
m_checkNormal=_status;
};
/** /**
* @brief get the check value of normal position befor sending it to the openGl card * @brief get the check value of normal position befor sending it to the openGl card
* @return get the chcking stus of normal or not * @return get the chcking stus of normal or not
*/ */
bool getCheckNormal(void) { return m_checkNormal; }; bool getCheckNormal(void) {
const std::vector<ewol::PhysicsShape*>& getPhysicalProperties(void) const { return m_physics; }; return m_checkNormal;
};
const std::vector<ege::PhysicsShape*>& getPhysicalProperties(void) const {
return m_physics;
};
private: private:
void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib
public: public:
@ -143,11 +163,15 @@ namespace ewol {
* @brief get the pointer on the shame (no type) * @brief get the pointer on the shame (no type)
* @return Pointer on shape. * @return Pointer on shape.
*/ */
void* getShape(void) { return m_pointerShape; }; void* getShape(void) {
return m_pointerShape;
};
private: private:
void (*m_functionFreeShape)(void* _pointer); void (*m_functionFreeShape)(void* _pointer);
public: public:
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) { m_functionFreeShape = _functionFreeShape; }; void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) {
m_functionFreeShape = _functionFreeShape;
};
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.
@ -155,12 +179,12 @@ namespace ewol {
* @param[in] _filename Name of the ewol mesh file. * @param[in] _filename Name of the ewol mesh file.
* @return pointer on the resource or NULL if an error occured. * @return pointer on the resource or NULL if an error occured.
*/ */
static ewol::Mesh* keep(const std::string& _meshname); static ege::resource::Mesh* keep(const std::string& _meshname);
/** /**
* @brief release the keeped resources * @brief release the keeped resources
* @param[in,out] reference on the object pointer * @param[in,out] reference on the object pointer
*/ */
static void release(ewol::Mesh*& _object); static void release(ege::resource::Mesh*& _object);
}; };
}; };
}; };

View File

@ -8,10 +8,10 @@
#include <ege/debug.h> #include <ege/debug.h>
#include <ege/resource/ParticuleMesh.h> #include <ege/resource/ParticuleMesh.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resource/Manager.h>
ege::resource::ParticuleMesh::ParticuleMesh(const std::string& _fileName, const std::string& _shaderName) : ege::resource::ParticuleMesh::ParticuleMesh(const std::string& _fileName, const std::string& _shaderName) :
ewol::Mesh(_fileName, _shaderName) ege::resource::Mesh(_fileName, _shaderName)
{ {
if (m_GLprogram != NULL) { if (m_GLprogram != NULL) {
m_GLMainColor = m_GLprogram->getUniform("EW_mainColor"); m_GLMainColor = m_GLprogram->getUniform("EW_mainColor");
@ -29,10 +29,10 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
bool _enableDepthUpdate) bool _enableDepthUpdate)
{ {
if (m_GLprogram == NULL) { if (m_GLprogram == NULL) {
EWOL_ERROR("No shader ..."); EGE_ERROR("No shader ...");
return; return;
} }
//EWOL_DEBUG(m_name << " " << m_light); //EGE_DEBUG(m_name << " " << m_light);
if (_enableDepthTest == true) { if (_enableDepthTest == true) {
ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST);
if (false == _enableDepthUpdate) { if (false == _enableDepthUpdate) {
@ -41,7 +41,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
} else { } else {
ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST);
} }
//EWOL_DEBUG(" display " << m_coord.size() << " elements" ); //EGE_DEBUG(" display " << m_coord.size() << " elements" );
m_GLprogram->use(); m_GLprogram->use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 projMatrix = ewol::openGL::getMatrix(); mat4 projMatrix = ewol::openGL::getMatrix();
@ -65,7 +65,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
#endif #endif
for (int32_t kkk=0; kkk<m_listFaces.size(); kkk++) { for (int32_t kkk=0; kkk<m_listFaces.size(); kkk++) {
if (false == m_materials.exist(m_listFaces.getKey(kkk))) { if (false == m_materials.exist(m_listFaces.getKey(kkk))) {
EWOL_WARNING("missing materials : '" << m_listFaces.getKey(kkk) << "'"); EGE_WARNING("missing materials : '" << m_listFaces.getKey(kkk) << "'");
continue; continue;
} }
m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial); m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial);
@ -85,7 +85,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
cameraNormal.normalized(); cameraNormal.normalized();
// remove face that is notin the view ... // remove face that is notin the view ...
std::vector<uint32_t> tmpIndexResult; std::vector<uint32_t> tmpIndexResult;
std::vector<ewol::Face>& tmppFaces = m_listFaces.getValue(kkk).m_faces; std::vector<ege::Face>& tmppFaces = m_listFaces.getValue(kkk).m_faces;
//std::vector<uint32_t>& tmppIndex = m_listFaces.getValue(kkk).m_index; //std::vector<uint32_t>& tmppIndex = m_listFaces.getValue(kkk).m_index;
if (normalModeFace == m_normalMode) { if (normalModeFace == m_normalMode) {
for(size_t iii=0; iii<tmppFaces.size() ; ++iii) { for(size_t iii=0; iii<tmppFaces.size() ; ++iii) {
@ -114,7 +114,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
} }
} }
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
EWOL_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]"); EGE_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
#endif #endif
m_GLprogram->unUse(); m_GLprogram->unUse();
if (_enableDepthTest == true){ if (_enableDepthTest == true){
@ -134,7 +134,7 @@ ege::resource::ParticuleMesh* ege::resource::ParticuleMesh::keep(const std::stri
} }
object = new ege::resource::ParticuleMesh(_meshName, _shaderName); object = new ege::resource::ParticuleMesh(_meshName, _shaderName);
if (object == NULL) { if (object == NULL) {
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName); EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
return NULL; return NULL;
} }
getManager().localAdd(object); getManager().localAdd(object);

View File

@ -9,22 +9,21 @@
#ifndef __EGE_RESOURCE_PARTICULE_MESH_H__ #ifndef __EGE_RESOURCE_PARTICULE_MESH_H__
#define __EGE_RESOURCE_PARTICULE_MESH_H__ #define __EGE_RESOURCE_PARTICULE_MESH_H__
#include <ewol/resources/Mesh.h> #include <ege/resource/Mesh.h>
namespace ege namespace ege {
{ namespace resource {
namespace resource class ParticuleMesh : public ege::resource::Mesh {
{
class ParticuleMesh : public ewol::Mesh
{
protected: protected:
int32_t m_GLMainColor; int32_t m_GLMainColor;
protected: protected:
ParticuleMesh(const std::string& _fileName, const std::string& _shaderName); ParticuleMesh(const std::string& _fileName, const std::string& _shaderName);
virtual ~ParticuleMesh(void); virtual ~ParticuleMesh(void);
public: public:
virtual const char* getType(void) { return "ege::resource::ParticuleMesh"; }; virtual void draw(mat4& _positionMatrix,
virtual void draw(mat4& _positionMatrix, const etk::Color<float>& _mainColor, bool _enableDepthTest=true, bool _enableDepthUpdate=true); const etk::Color<float>& _mainColor,
bool _enableDepthTest = true,
bool _enableDepthUpdate = true);
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.

View File

@ -6,9 +6,10 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <ewol/widget/Mesh.h> #include <ege/widget/Mesh.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/Manager.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resource/Manager.h>
#include <ege/debug.h>
extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed"; extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed";
@ -18,30 +19,30 @@ extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed";
ewol::widget::Mesh::Mesh(const std::string& _filename) : ege::widget::Mesh::Mesh(const std::string& _filename) :
m_meshName(_filename), m_meshName(_filename),
m_object(NULL), m_object(NULL),
m_position(0,0,0), m_position(0,0,0),
m_angle(0,0,0), m_angle(0,0,0),
m_angleSpeed(0,0,0), m_angleSpeed(0,0,0),
m_cameraDistance(10.0) { m_cameraDistance(10.0) {
addObjectType("ewol::widget::Mesh"); addObjectType("ege::widget::Mesh");
addEventId(ewolEventMeshPressed); addEventId(ewolEventMeshPressed);
// Limit event at 1: // Limit event at 1:
setMouseLimit(1); setMouseLimit(1);
if (_filename!="") { if (_filename!="") {
m_object = ewol::Mesh::keep(m_meshName); m_object = ege::resource::Mesh::keep(m_meshName);
if (NULL == m_object) { if (NULL == m_object) {
EWOL_ERROR("Can not load the resource : \"" << m_meshName << "\""); EGE_ERROR("Can not load the resource : \"" << m_meshName << "\"");
} }
} }
} }
ewol::widget::Mesh::~Mesh(void) { ege::widget::Mesh::~Mesh(void) {
ewol::Mesh::release(m_object); ege::resource::Mesh::release(m_object);
} }
void ewol::widget::Mesh::onDraw(void) { void ege::widget::Mesh::onDraw(void) {
mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance)) mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance))
* etk::matTranslate(m_position) * etk::matTranslate(m_position)
* etk::matRotate(vec3(1,0,0),m_angle.x()) * etk::matRotate(vec3(1,0,0),m_angle.x())
@ -52,7 +53,7 @@ void ewol::widget::Mesh::onDraw(void) {
} }
} }
void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) { void ege::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::openGL::push(); 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 // 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(), glViewport( m_origin.x(),
@ -60,7 +61,7 @@ void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
m_size.x(), m_size.x(),
m_size.y()); m_size.y());
float ratio = m_size.x() / m_size.y(); float ratio = m_size.x() / m_size.y();
//EWOL_INFO("ratio : " << ratio); //EGE_INFO("ratio : " << ratio);
mat4 tmpProjection = etk::matPerspective(M_PI/3.0, ratio, 0.5, 100); mat4 tmpProjection = etk::matPerspective(M_PI/3.0, ratio, 0.5, 100);
//mat4 tmpMat = tmpProjection * m_camera.getMatrix(); //mat4 tmpMat = tmpProjection * m_camera.getMatrix();
// set internal matrix system : // set internal matrix system :
@ -71,21 +72,21 @@ void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::openGL::pop(); ewol::openGL::pop();
} }
void ewol::widget::Mesh::onRegenerateDisplay(void) { void ege::widget::Mesh::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
} }
} }
void ewol::widget::Mesh::periodicCall(const ewol::EventTime& _event) { void ege::widget::Mesh::periodicCall(const ewol::event::Time& _event) {
m_angle += m_angleSpeed*_event.getDeltaCall(); m_angle += m_angleSpeed*_event.getDeltaCall();
markToRedraw(); markToRedraw();
} }
bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) { bool ege::widget::Mesh::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Event on BT ..."); //EGE_DEBUG("Event on BT ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
if(ewol::keyEvent::statusSingle == _event.getStatus()) { if(ewol::key::statusSingle == _event.getStatus()) {
generateEventId(ewolEventMeshPressed); generateEventId(ewolEventMeshPressed);
return true; return true;
} }
@ -93,30 +94,30 @@ bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
void ewol::widget::Mesh::setFile(const std::string& _filename) { void ege::widget::Mesh::setFile(const std::string& _filename) {
if( _filename!="" if( _filename!=""
&& m_meshName != _filename ) { && m_meshName != _filename ) {
ewol::Mesh::release(m_object); ege::resource::Mesh::release(m_object);
m_meshName = _filename; m_meshName = _filename;
m_object = ewol::Mesh::keep(m_meshName); m_object = ege::resource::Mesh::keep(m_meshName);
if (NULL == m_object) { if (NULL == m_object) {
EWOL_ERROR("Can not load the resource : \"" << m_meshName << "\""); EGE_ERROR("Can not load the resource : \"" << m_meshName << "\"");
} }
} }
markToRedraw(); markToRedraw();
} }
void ewol::widget::Mesh::setPosition(const vec3& _pos) { void ege::widget::Mesh::setPosition(const vec3& _pos) {
m_position = _pos; m_position = _pos;
markToRedraw(); markToRedraw();
} }
void ewol::widget::Mesh::setAngle(const vec3& _angle) { void ege::widget::Mesh::setAngle(const vec3& _angle) {
m_angle = _angle; m_angle = _angle;
markToRedraw(); markToRedraw();
} }
void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) { void ege::widget::Mesh::setAngleSpeed(const vec3& _speed) {
if (_speed!=vec3(0,0,0)) { if (_speed!=vec3(0,0,0)) {
periodicCallEnable(); periodicCallEnable();
} else { } else {
@ -126,7 +127,7 @@ void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
markToRedraw(); markToRedraw();
} }
void ewol::widget::Mesh::setDistance(float _distance) void ege::widget::Mesh::setDistance(float _distance)
{ {
m_cameraDistance = _distance; m_cameraDistance = _distance;
markToRedraw(); markToRedraw();

View File

@ -11,12 +11,12 @@
#include <etk/types.h> #include <etk/types.h>
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <ewol/resources/Mesh.h> #include <ege/resource/Mesh.h>
extern const char * const ewolEventMeshPressed; extern const char * const ewolEventMeshPressed;
namespace ewol { namespace ege {
namespace widget { namespace widget {
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
@ -25,47 +25,47 @@ namespace ewol {
private: private:
// mesh name : // mesh name :
std::string m_meshName; std::string m_meshName;
ewol::Mesh* m_object; ege::resource::Mesh* m_object;
// mesh display properties: // mesh display properties:
vec3 m_position; vec3 m_position;
vec3 m_angle; vec3 m_angle;
vec3 m_angleSpeed; vec3 m_angleSpeed;
float m_cameraDistance; float m_cameraDistance;
public: public:
Mesh(const std::string& filename); // automatic considering in the appl Data older Mesh(const std::string& _filename); // automatic considering in the appl Data older
virtual ~Mesh(void); virtual ~Mesh(void);
public: // Derived function public: // Derived function
virtual void onRegenerateDisplay(void); virtual void onRegenerateDisplay(void);
virtual void systemDraw(const ewol::DrawProperty& displayProp); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onDraw(void); virtual void onDraw(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual bool onEventInput(const ewol::event::Input& _event);
virtual void periodicCall(const ewol::EventTime& _event); virtual void periodicCall(const ewol::event::Time& _event);
public: public:
/** /**
* @brief set a mesh name file * @brief set a mesh name file
* @param[in] filename Name of the new mesh * @param[in] _filename Name of the new mesh
*/ */
void setFile(const std::string& filename); void setFile(const std::string& _filename);
/** /**
* @brief set the mesh position * @brief set the mesh position
* @param[in] pos The new position of the mesh * @param[in] _pos The new position of the mesh
*/ */
void setPosition(const vec3& pos); void setPosition(const vec3& _pos);
/** /**
* @brief set the mesh angle of view * @brief set the mesh angle of view
* @param[in] angle view angle of the mesh * @param[in] _angle view angle of the mesh
*/ */
void setAngle(const vec3& angle); void setAngle(const vec3& _angle);
/** /**
* @brief set the mesh angle speed * @brief set the mesh angle speed
* @param[in] spped radian speed of the mesh * @param[in] _speed Radian speed of the mesh
*/ */
void setAngleSpeed(const vec3& speed); void setAngleSpeed(const vec3& _speed);
/** /**
* @brief set the camera distance of the mesh * @brief set the camera distance of the mesh
* @param[in] dist Diatance of the mesh * @param[in] _distance Diatance of the mesh
*/ */
void setDistance(float distance); void setDistance(float _distance);
}; };
}; };
}; };

View File

@ -7,12 +7,12 @@
*/ */
#include <ege/debug.h> #include <ege/debug.h>
#include <ege/Scene.h> #include <ege/widget/Scene.h>
#include <math.h> #include <math.h>
#include <ege/debug.h> #include <ege/debug.h>
#include <ewol/ewol.h> #include <ewol/ewol.h>
#include <ewol/renderer/openGL.h> #include <ewol/openGL/openGL.h>
#include <etk/math/Matrix4.h> #include <etk/math/Matrix4.h>
#include <BulletDynamics/Dynamics/btRigidBody.h> #include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h> #include <LinearMath/btDefaultMotionState.h>
@ -31,12 +31,12 @@
#define __class__ "Scene" #define __class__ "Scene"
const char * const ege::Scene::eventPlayTimeChange = "event-scene-play-time-change"; const char * const ege::widget::Scene::eventPlayTimeChange = "event-scene-play-time-change";
const char * const ege::Scene::eventKillEnemy = "event-scene-kill-ennemy"; const char * const ege::widget::Scene::eventKillEnemy = "event-scene-kill-ennemy";
ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) : ege::widget::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
m_gameTime(0), m_gameTime(0),
m_angleView(M_PI/3.0), m_angleView(M_PI/3.0),
m_dynamicsWorld(NULL), m_dynamicsWorld(NULL),
@ -50,7 +50,7 @@ ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
addEventId(eventPlayTimeChange); addEventId(eventPlayTimeChange);
addEventId(eventKillEnemy); addEventId(eventKillEnemy);
m_debugDrawing = ewol::Colored3DObject::keep(); m_debugDrawing = ewol::resource::Colored3DObject::keep();
m_ratioTime = 1.0f; m_ratioTime = 1.0f;
if (_setAutoBullet == true) { if (_setAutoBullet == true) {
@ -61,7 +61,7 @@ ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
} }
} }
void ege::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration, void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration,
btCollisionDispatcher* _dispatcher, btCollisionDispatcher* _dispatcher,
btBroadphaseInterface* _broadphase, btBroadphaseInterface* _broadphase,
btConstraintSolver* _solver, btConstraintSolver* _solver,
@ -102,7 +102,7 @@ void ege::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConf
} }
void ege::Scene::setCamera(ege::Camera* _camera) { void ege::widget::Scene::setCamera(ege::Camera* _camera) {
if (NULL != _camera) { if (NULL != _camera) {
m_camera = _camera; m_camera = _camera;
} else { } else {
@ -112,8 +112,8 @@ void ege::Scene::setCamera(ege::Camera* _camera) {
} }
} }
ege::Scene::~Scene(void) { ege::widget::Scene::~Scene(void) {
ewol::Colored3DObject::release(m_debugDrawing); ewol::resource::Colored3DObject::release(m_debugDrawing);
/* /*
ewol::resource::release(m_directDrawObject); ewol::resource::release(m_directDrawObject);
//cleanup in the reverse order of creation/initialization //cleanup in the reverse order of creation/initialization
@ -136,23 +136,23 @@ ege::Scene::~Scene(void) {
*/ */
} }
void ege::Scene::onRegenerateDisplay(void) { void ege::widget::Scene::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
} }
} }
void ege::Scene::pause(void) { void ege::widget::Scene::pause(void) {
EGE_DEBUG("Set pause"); EGE_DEBUG("Set pause");
m_isRunning = false; m_isRunning = false;
} }
void ege::Scene::resume(void) { void ege::widget::Scene::resume(void) {
EGE_DEBUG("Set resume"); EGE_DEBUG("Set resume");
m_isRunning = true; m_isRunning = true;
} }
void ege::Scene::pauseToggle(void) { void ege::widget::Scene::pauseToggle(void) {
if(true == m_isRunning) { if(true == m_isRunning) {
EGE_DEBUG("Set Toggle: pause"); EGE_DEBUG("Set Toggle: pause");
m_isRunning=false; m_isRunning=false;
@ -173,7 +173,7 @@ void ege::Scene::pauseToggle(void) {
#define NUMBER_OF_SUB_PASS (0) #define NUMBER_OF_SUB_PASS (0)
void ege::Scene::onDraw(void) { void ege::widget::Scene::onDraw(void) {
#ifdef SCENE_DISPLAY_SPEED #ifdef SCENE_DISPLAY_SPEED
g_counterNbTimeDisplay++; g_counterNbTimeDisplay++;
g_startTime = ewol::getTime(); g_startTime = ewol::getTime();
@ -236,7 +236,7 @@ btRigidBody& btActionInterface::getFixedBody(void) {
return s_fixed; return s_fixed;
} }
void ege::Scene::periodicCall(const ewol::EventTime& _event) { void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) {
float curentDelta=_event.getDeltaCall(); float curentDelta=_event.getDeltaCall();
// small hack to change speed ... // small hack to change speed ...
if (m_ratioTime != 1) { if (m_ratioTime != 1) {
@ -298,7 +298,7 @@ void ege::Scene::periodicCall(const ewol::EventTime& _event) {
//#define SCENE_BRUT_PERFO_TEST //#define SCENE_BRUT_PERFO_TEST
void ege::Scene::systemDraw(const ewol::DrawProperty& _displayProp) void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp)
{ {
#ifdef SCENE_BRUT_PERFO_TEST #ifdef SCENE_BRUT_PERFO_TEST
int64_t tmp___startTime0 = ewol::getTime(); int64_t tmp___startTime0 = ewol::getTime();
@ -348,7 +348,7 @@ EWOL_DEBUG(" SCENE444 : " << tmp___localTime4 << "ms ");
#endif #endif
} }
vec2 ege::Scene::calculateDeltaAngle(const vec2& _posScreen) { vec2 ege::widget::Scene::calculateDeltaAngle(const vec2& _posScreen) {
double ratio = m_size.x() / m_size.y(); 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;
@ -365,7 +365,7 @@ vec2 ege::Scene::calculateDeltaAngle(const vec2& _posScreen) {
angleY); angleY);
} }
vec3 ege::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) { vec3 ege::widget::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) {
return m_camera->projectOnZGround(calculateDeltaAngle(_posScreen)); return m_camera->projectOnZGround(calculateDeltaAngle(_posScreen));
} }

146
ege/widget/Scene.h Normal file
View File

@ -0,0 +1,146 @@
/**
* @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 <vector>
#include <ewol/debug.h>
#include <ege/Camera.h>
#include <ewol/widget/Widget.h>
#include <ewol/openGL/openGL.h>
#include <ewol/resource/Manager.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 {
namespace widget {
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(bool _setAutoBullet=true, bool _setAutoCamera=true);
/**
* @brief Destructor of the widget classes
*/
virtual ~Scene(void);
void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=NULL,
btCollisionDispatcher* _dispatcher=NULL,
btBroadphaseInterface* _broadphase=NULL,
btConstraintSolver* _solver=NULL,
btDynamicsWorld* _dynamicsWorld=NULL);
void setCamera(ege::Camera* _camera=NULL);
private:
float m_gameTime; //!< time of the game running
protected:
float m_angleView;
///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.
// Other elements
bool m_isRunning; //!< the display is running (not in pause)
float m_ratioTime; //!< Ratio time for the speed of the game ...
// Note : This is only for temporary elements : on the display
std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
public:
/**
* @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);
protected:
bool m_debugMode;
ewol::resource::Colored3DObject* m_debugDrawing; //!< for the debug draw elements
public:
/**
* @brief Toggle the debug mode == > usefull for DEBUG only ...
*/
void debugToggle(void) {
m_debugMode = m_debugMode?false:true;
};
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t _localTime, int32_t _deltaTime) { };
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,
std::vector<ege::Environement::ResultNearestElement>& _resultList);
protected: // Derived function
virtual void onDraw(void);
public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void periodicCall(const ewol::event::Time& _event);
};
};
};
#endif

View File

@ -22,9 +22,20 @@ def Create(target):
'ege/Particule.cpp', 'ege/Particule.cpp',
'ege/ParticuleEngine.cpp', 'ege/ParticuleEngine.cpp',
'ege/ParticuleSimple.cpp', 'ege/ParticuleSimple.cpp',
'ege/Scene.cpp', 'ege/widget/Mesh.cpp',
'ege/widget/Scene.cpp',
'ege/Environement.cpp', 'ege/Environement.cpp',
'ege/resource/ParticuleMesh.cpp' 'ege/resource/Mesh.cpp',
'ege/resource/ParticuleMesh.cpp',
'ege/Light.cpp',
'ege/Material.cpp',
'ege/physicsShape/PhysicsShape.cpp',
'ege/physicsShape/PhysicsBox.cpp',
'ege/physicsShape/PhysicsCapsule.cpp',
'ege/physicsShape/PhysicsCone.cpp',
'ege/physicsShape/PhysicsConvexHull.cpp',
'ege/physicsShape/PhysicsCylinder.cpp',
'ege/physicsShape/PhysicsSphere.cpp',
]) ])
myModule.CopyFolder('data/ParticuleMesh.*','') myModule.CopyFolder('data/ParticuleMesh.*','')