[DEV] update to the new architecture
This commit is contained in:
parent
2c54a551b4
commit
58596f179a
@ -13,13 +13,13 @@
|
||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ewol/physicsShape/PhysicsBox.h>
|
||||
#include <ewol/physicsShape/PhysicsCapsule.h>
|
||||
#include <ewol/physicsShape/PhysicsCone.h>
|
||||
#include <ewol/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ewol/physicsShape/PhysicsCylinder.h>
|
||||
#include <ewol/physicsShape/PhysicsSphere.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsBox.h>
|
||||
#include <ege/physicsShape/PhysicsCapsule.h>
|
||||
#include <ege/physicsShape/PhysicsCone.h>
|
||||
#include <ege/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ege/physicsShape/PhysicsCylinder.h>
|
||||
#include <ege/physicsShape/PhysicsSphere.h>
|
||||
|
||||
// Documentetion of bullet library :
|
||||
// http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes
|
||||
@ -27,11 +27,11 @@
|
||||
#undef __class__
|
||||
#define __class__ "CollisionShapeCreator"
|
||||
|
||||
btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) {
|
||||
if (NULL == _mesh) {
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
const std::vector<ewol::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
const std::vector<ege::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
if (physiqueProperty.size() == 0) {
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
@ -51,8 +51,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
continue;
|
||||
}
|
||||
switch (physiqueProperty[iii]->getType()) {
|
||||
case ewol::PhysicsShape::box : {
|
||||
const ewol::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
|
||||
case ege::PhysicsShape::box : {
|
||||
const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
@ -69,8 +69,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ewol::PhysicsShape::cylinder : {
|
||||
const ewol::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
|
||||
case ege::PhysicsShape::cylinder : {
|
||||
const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
@ -87,8 +87,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ewol::PhysicsShape::capsule : {
|
||||
const ewol::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
|
||||
case ege::PhysicsShape::capsule : {
|
||||
const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
@ -105,8 +105,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ewol::PhysicsShape::cone : {
|
||||
const ewol::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
|
||||
case ege::PhysicsShape::cone : {
|
||||
const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
@ -123,8 +123,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ewol::PhysicsShape::sphere : {
|
||||
const ewol::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
|
||||
case ege::PhysicsShape::sphere : {
|
||||
const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
@ -141,8 +141,8 @@ btCollisionShape* ege::collision::createShape(const ewol::Mesh* _mesh) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ewol::PhysicsShape::convexHull : {
|
||||
const ewol::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
|
||||
case ege::PhysicsShape::convexHull : {
|
||||
const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
|
||||
if (NULL == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
|
@ -11,12 +11,12 @@
|
||||
#define __EGE_COLLISION_SHAPE_CREATOR_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/resources/Mesh.h>
|
||||
#include <ege/resource/Mesh.h>
|
||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
||||
|
||||
namespace ege {
|
||||
namespace collision {
|
||||
btCollisionShape* createShape(const ewol::Mesh* _mesh);
|
||||
btCollisionShape* createShape(const ege::resource::Mesh* _mesh);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <ege/debug.h>
|
||||
#include <ege/ElementGame.h>
|
||||
#include <ege/Environement.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
||||
#include <LinearMath/btDefaultMotionState.h>
|
||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
||||
@ -61,7 +60,7 @@ ege::ElementGame::~ElementGame(void) {
|
||||
// same ...
|
||||
dynamicDisable();
|
||||
removeShape();
|
||||
ewol::Mesh::release(m_mesh);
|
||||
ege::resource::Mesh::release(m_mesh);
|
||||
if (NULL != m_body) {
|
||||
delete(m_body);
|
||||
m_body = NULL;
|
||||
@ -97,8 +96,7 @@ void ege::ElementGame::FunctionFreeShape(void* _pointer) {
|
||||
}
|
||||
|
||||
bool ege::ElementGame::loadMesh(const std::string& _meshFileName) {
|
||||
ewol::Mesh* tmpMesh=NULL;
|
||||
tmpMesh = ewol::Mesh::keep(_meshFileName);
|
||||
ege::resource::Mesh* tmpMesh = ege::resource::Mesh::keep(_meshFileName);
|
||||
if(NULL == tmpMesh) {
|
||||
EGE_ERROR("can not load the resources : " << _meshFileName);
|
||||
return false;
|
||||
@ -106,10 +104,10 @@ bool ege::ElementGame::loadMesh(const std::string& _meshFileName) {
|
||||
return setMesh(tmpMesh);
|
||||
}
|
||||
|
||||
bool ege::ElementGame::setMesh(ewol::Mesh* _mesh) {
|
||||
bool ege::ElementGame::setMesh(ege::resource::Mesh* _mesh) {
|
||||
if (NULL!=m_mesh) {
|
||||
removeShape();
|
||||
ewol::Mesh::release(m_mesh);
|
||||
ege::resource::Mesh::release(m_mesh);
|
||||
}
|
||||
m_mesh = _mesh;
|
||||
// auto load the shape :
|
||||
@ -184,7 +182,7 @@ const float ege::ElementGame::getInvMass(void) {
|
||||
return 0.0000000001f;
|
||||
};
|
||||
|
||||
static void drawSphere(ewol::Colored3DObject* _draw,
|
||||
static void drawSphere(ewol::resource::Colored3DObject* _draw,
|
||||
btScalar _radius,
|
||||
int _lats,
|
||||
int _longs,
|
||||
@ -232,7 +230,7 @@ const float lifeHeight = 0.3f;
|
||||
const float lifeWidth = 2.0f;
|
||||
const float lifeYPos = 1.7f;
|
||||
|
||||
void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera& _camera) {
|
||||
void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) {
|
||||
if (NULL == _draw) {
|
||||
return;
|
||||
}
|
||||
@ -270,7 +268,7 @@ void ege::ElementGame::drawLife(ewol::Colored3DObject* _draw, const ege::Camera&
|
||||
}
|
||||
|
||||
static void drawShape(const btCollisionShape* _shape,
|
||||
ewol::Colored3DObject* _draw,
|
||||
ewol::resource::Colored3DObject* _draw,
|
||||
mat4 _transformationMatrix,
|
||||
std::vector<vec3> _tmpVertices) {
|
||||
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.setColor(0x00FF00FF);
|
||||
m_debugText.setPos(vec3(-20,32,0));
|
||||
|
@ -15,8 +15,9 @@
|
||||
#include <vector>
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/renderer/openGL.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <ewol/resource/Colored3DObject.h>
|
||||
#include <ege/resource/Mesh.h>
|
||||
#include <ege/Camera.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <ege/Environement.h>
|
||||
@ -27,10 +28,8 @@
|
||||
|
||||
#define ELEMENT_SCALE (1.0f/8.0f)
|
||||
|
||||
namespace ege
|
||||
{
|
||||
class ElementGame
|
||||
{
|
||||
namespace ege {
|
||||
class ElementGame {
|
||||
private:
|
||||
static void FunctionFreeShape(void* _pointer);
|
||||
protected:
|
||||
@ -76,7 +75,7 @@ namespace ege
|
||||
return m_uID;
|
||||
};
|
||||
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)
|
||||
public:
|
||||
/**
|
||||
@ -92,7 +91,7 @@ namespace ege
|
||||
* @note : this remove the shape and the mesh properties.
|
||||
* @return true if no error occured
|
||||
*/
|
||||
bool setMesh(ewol::Mesh* _mesh);
|
||||
bool setMesh(ege::resource::Mesh* _mesh);
|
||||
/**
|
||||
* @brief set the shape properties.
|
||||
* @param[in] _shape The shape pointer.
|
||||
@ -104,7 +103,7 @@ namespace ege
|
||||
* @brief get a pointer on the Mesh file.
|
||||
* @return the mesh pointer.
|
||||
*/
|
||||
inline ewol::Mesh* getMesh(void) {
|
||||
inline ege::resource::Mesh* getMesh(void) {
|
||||
return m_mesh;
|
||||
};
|
||||
/**
|
||||
@ -187,17 +186,17 @@ namespace ege
|
||||
/**
|
||||
* @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:
|
||||
// For debug only ...
|
||||
ewol::Text m_debugText;
|
||||
ewol::compositing::Text m_debugText;
|
||||
public:
|
||||
/**
|
||||
* @brief Debug display of the current element
|
||||
* @param[in,out] draw Basic system to draw the debug shape and informations
|
||||
*/
|
||||
virtual void drawDebug(ewol::Colored3DObject* _draw, const ege::Camera& _camera);
|
||||
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 ...
|
||||
|
@ -6,10 +6,10 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/Light.h>
|
||||
#include <ewol/debug.h>
|
||||
#include <ege/Light.h>
|
||||
#include <ege/debug.h>
|
||||
|
||||
ewol::Light::Light(void) :
|
||||
ege::Light::Light(void) :
|
||||
m_direction(0,0,0),
|
||||
m_halfplane(0,0,0),
|
||||
m_ambientColor(0,0,0,0),
|
||||
@ -23,11 +23,11 @@ ewol::Light::Light(void) :
|
||||
// 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) {
|
||||
return;
|
||||
}
|
||||
@ -38,7 +38,7 @@ void ewol::Light::link(ewol::Program* _prog, const std::string& _baseName) {
|
||||
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_halfplane, m_halfplane);
|
||||
_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);
|
||||
}
|
||||
|
||||
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 << "dir=" << _obj.m_direction;
|
||||
_os << " halfplan=" << _obj.m_halfplane;
|
||||
|
16
ege/Light.h
16
ege/Light.h
@ -6,15 +6,15 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_LIGHT_H__
|
||||
#define __EWOL_LIGHT_H__
|
||||
#ifndef __EGE_LIGHT_H__
|
||||
#define __EGE_LIGHT_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <ewol/resources/Program.h>
|
||||
#include <ewol/resource/Program.h>
|
||||
|
||||
namespace ewol {
|
||||
namespace ege {
|
||||
class Light {
|
||||
private:
|
||||
// values
|
||||
@ -33,8 +33,8 @@ namespace ewol {
|
||||
public:
|
||||
Light(void);
|
||||
~Light(void);
|
||||
void link(ewol::Program* _prog, const std::string& _baseName);
|
||||
void draw(ewol::Program* _prog);
|
||||
void link(ewol::resource::Program* _prog, const std::string& _baseName);
|
||||
void draw(ewol::resource::Program* _prog);
|
||||
void setDirection(const vec3& val) {
|
||||
m_direction = val;
|
||||
}
|
||||
@ -51,9 +51,9 @@ namespace ewol {
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <ewol/Material.h>
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <ege/Material.h>
|
||||
#include <ege/debug.h>
|
||||
|
||||
ewol::MaterialGlId::MaterialGlId(void) :
|
||||
ege::MaterialGlId::MaterialGlId(void) :
|
||||
m_GL_ambientFactor(0),
|
||||
m_GL_diffuseFactor(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) {
|
||||
return;
|
||||
}
|
||||
@ -31,7 +31,7 @@ void ewol::MaterialGlId::link(ewol::Program* _prog, const std::string& _baseName
|
||||
m_GL_texture0 = _prog->getUniform("EW_texID");
|
||||
}
|
||||
|
||||
ewol::Material::Material(void) :
|
||||
ege::Material::Material(void) :
|
||||
m_ambientFactor(1,1,1,1),
|
||||
m_diffuseFactor(0,0,0,1),
|
||||
m_specularFactor(0,0,0,1),
|
||||
@ -39,13 +39,13 @@ ewol::Material::Material(void) :
|
||||
m_texture0(NULL) {
|
||||
// nothing to do else ...
|
||||
}
|
||||
ewol::Material::~Material(void) {
|
||||
ege::Material::~Material(void) {
|
||||
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_diffuseFactor, m_diffuseFactor);
|
||||
_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);
|
||||
// prevent overloard error :
|
||||
ewol::TextureFile* tmpCopy = m_texture0;
|
||||
m_texture0 = ewol::TextureFile::keep(_filename, tmpSize);
|
||||
ewol::resource::TextureFile* tmpCopy = m_texture0;
|
||||
m_texture0 = ewol::resource::TextureFile::keep(_filename, tmpSize);
|
||||
if (NULL == m_texture0 ) {
|
||||
EWOL_ERROR("Can not load specific texture : " << _filename);
|
||||
EGE_ERROR("Can not load specific texture : " << _filename);
|
||||
// retreave previous texture:
|
||||
m_texture0 = tmpCopy;
|
||||
return;
|
||||
}
|
||||
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...
|
||||
ewol::TextureFile::release(tmpCopy);
|
||||
ewol::resource::TextureFile::release(tmpCopy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,16 +6,19 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_MATERIAL_H__
|
||||
#define __EWOL_MATERIAL_H__
|
||||
#ifndef __EGE_MATERIAL_H__
|
||||
#define __EGE_MATERIAL_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <ewol/resources/Program.h>
|
||||
#include <ewol/resources/Image.h>
|
||||
#include <ewol/resource/Program.h>
|
||||
#include <ewol/resource/Image.h>
|
||||
|
||||
namespace ewol {
|
||||
namespace ege {
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
class MaterialGlId {
|
||||
public:
|
||||
// GL index
|
||||
@ -25,7 +28,7 @@ namespace ewol {
|
||||
int32_t m_GL_shininess;
|
||||
int32_t m_GL_texture0;
|
||||
MaterialGlId(void);
|
||||
void link(ewol::Program* _prog, const std::string& _baseName);
|
||||
void link(ewol::resource::Program* _prog, const std::string& _baseName);
|
||||
};
|
||||
class Material {
|
||||
private:
|
||||
@ -34,13 +37,13 @@ namespace ewol {
|
||||
vec4 m_diffuseFactor;
|
||||
vec4 m_specularFactor;
|
||||
float m_shininess;
|
||||
ewol::TextureFile* m_texture0;
|
||||
ewol::resource::TextureFile* m_texture0;
|
||||
public:
|
||||
std::vector<uint32_t> m_listIndexFaces;
|
||||
public:
|
||||
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) {
|
||||
m_ambientFactor = _val;
|
||||
}
|
||||
@ -55,11 +58,26 @@ namespace ewol {
|
||||
}
|
||||
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 ...
|
||||
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
|
||||
void flush(void) { if (m_texture0 == NULL){return;} m_texture0->flush(); };
|
||||
void flush(void) {
|
||||
if (m_texture0 == NULL){
|
||||
return;
|
||||
}
|
||||
m_texture0->flush();
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
144
ege/Scene.h
144
ege/Scene.h
@ -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
|
||||
|
||||
|
@ -5,18 +5,18 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsBox.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsBox.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsBox::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsBox::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
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] );
|
||||
EWOL_VERBOSE(" halfSize=" << m_size);
|
||||
EGE_VERBOSE(" halfSize=" << m_size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,15 +6,15 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_BOX_H__
|
||||
#define __EWOL_PHYSICS_BOX_H__
|
||||
#ifndef __EGE_PHYSICS_BOX_H__
|
||||
#define __EGE_PHYSICS_BOX_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsBox : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsBox : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsBox(void) {};
|
||||
virtual ~PhysicsBox(void) {};
|
||||
@ -22,8 +22,8 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::box;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::box;
|
||||
};
|
||||
private:
|
||||
vec3 m_size; // Box size property in X, Y and Z
|
||||
@ -32,10 +32,10 @@ namespace ewol {
|
||||
return m_size;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsBox* toBox(void) const {
|
||||
virtual const ege::PhysicsBox* toBox(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsBox* toBox(void) {
|
||||
virtual ege::PhysicsBox* toBox(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -5,23 +5,23 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCapsule.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsCapsule.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsCapsule::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsCapsule::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
EGE_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "height : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_height );
|
||||
EWOL_VERBOSE(" height=" << m_height);
|
||||
EGE_VERBOSE(" height=" << m_height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,16 +6,16 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CAPSULE_H__
|
||||
#define __EWOL_PHYSICS_CAPSULE_H__
|
||||
#ifndef __EGE_PHYSICS_CAPSULE_H__
|
||||
#define __EGE_PHYSICS_CAPSULE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCapsule : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsCapsule : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsCapsule(void) {};
|
||||
virtual ~PhysicsCapsule(void) {};
|
||||
@ -23,8 +23,8 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::capsule;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::capsule;
|
||||
};
|
||||
private:
|
||||
float m_radius;
|
||||
@ -39,10 +39,10 @@ namespace ewol {
|
||||
return m_height;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCapsule* toCapsule(void) const {
|
||||
virtual const ege::PhysicsCapsule* toCapsule(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCapsule* toCapsule(void) {
|
||||
virtual ege::PhysicsCapsule* toCapsule(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -5,23 +5,23 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCone.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsCone.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsCone::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsCone::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
EGE_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "height : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_height );
|
||||
EWOL_VERBOSE(" height=" << m_height);
|
||||
EGE_VERBOSE(" height=" << m_height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,16 +6,16 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CONE_H__
|
||||
#define __EWOL_PHYSICS_CONE_H__
|
||||
#ifndef __EGE_PHYSICS_CONE_H__
|
||||
#define __EGE_PHYSICS_CONE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCone : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsCone : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsCone(void) {};
|
||||
virtual ~PhysicsCone(void) {};
|
||||
@ -23,8 +23,8 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::cone;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::cone;
|
||||
};
|
||||
private:
|
||||
float m_radius;
|
||||
@ -39,10 +39,10 @@ namespace ewol {
|
||||
return m_height;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCone* toCone(void) const {
|
||||
virtual const ege::PhysicsCone* toCone(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCone* toCone(void) {
|
||||
virtual ege::PhysicsCone* toCone(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -5,17 +5,17 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsConvexHull.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsConvexHull::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsConvexHull::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
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* tmp= strchr(base, '|');
|
||||
vec3 pos(0,0,0);
|
||||
@ -30,14 +30,14 @@ bool ewol::PhysicsConvexHull::parse(const char* _line) {
|
||||
m_points.push_back(pos);
|
||||
/*
|
||||
for (int32_t iii=0; iii<m_points.size(); iii++) {
|
||||
EWOL_VERBOSE(" parsed " << m_points[iii]);
|
||||
EGE_VERBOSE(" parsed " << m_points[iii]);
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
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] );
|
||||
EWOL_VERBOSE(" scale=" << m_scale);
|
||||
EGE_VERBOSE(" scale=" << m_scale);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,16 +6,16 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CONVEX_HULL_H__
|
||||
#define __EWOL_PHYSICS_CONVEX_HULL_H__
|
||||
#ifndef __EGE_PHYSICS_CONVEX_HULL_H__
|
||||
#define __EGE_PHYSICS_CONVEX_HULL_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsConvexHull : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsConvexHull : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsConvexHull(void) {};
|
||||
virtual ~PhysicsConvexHull(void) {};
|
||||
@ -23,8 +23,8 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::convexHull;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::convexHull;
|
||||
};
|
||||
private:
|
||||
vec3 m_scale;
|
||||
@ -39,10 +39,10 @@ namespace ewol {
|
||||
return m_points;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsConvexHull* toConvexHull(void) const {
|
||||
virtual const ege::PhysicsConvexHull* toConvexHull(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsConvexHull* toConvexHull(void) {
|
||||
virtual ege::PhysicsConvexHull* toConvexHull(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -5,17 +5,17 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCylinder.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsCylinder.h>
|
||||
|
||||
|
||||
bool ewol::PhysicsCylinder::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsCylinder::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
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] );
|
||||
EWOL_VERBOSE(" halfSize=" << m_size);
|
||||
EGE_VERBOSE(" halfSize=" << m_size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,16 +6,16 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CYLINDER_H__
|
||||
#define __EWOL_PHYSICS_CYLINDER_H__
|
||||
#ifndef __EGE_PHYSICS_CYLINDER_H__
|
||||
#define __EGE_PHYSICS_CYLINDER_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCylinder : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsCylinder : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsCylinder(void) {};
|
||||
virtual ~PhysicsCylinder(void) {};
|
||||
@ -23,8 +23,8 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::cylinder;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::cylinder;
|
||||
};
|
||||
private:
|
||||
vec3 m_size;
|
||||
@ -33,10 +33,10 @@ namespace ewol {
|
||||
return m_size;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCylinder* toCylinder(void) const {
|
||||
virtual const ege::PhysicsCylinder* toCylinder(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCylinder* toCylinder(void) {
|
||||
virtual ege::PhysicsCylinder* toCylinder(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -5,51 +5,51 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ewol/physicsShape/PhysicsBox.h>
|
||||
#include <ewol/physicsShape/PhysicsCapsule.h>
|
||||
#include <ewol/physicsShape/PhysicsCone.h>
|
||||
#include <ewol/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ewol/physicsShape/PhysicsCylinder.h>
|
||||
#include <ewol/physicsShape/PhysicsSphere.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsBox.h>
|
||||
#include <ege/physicsShape/PhysicsCapsule.h>
|
||||
#include <ege/physicsShape/PhysicsCone.h>
|
||||
#include <ege/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ege/physicsShape/PhysicsCylinder.h>
|
||||
#include <ege/physicsShape/PhysicsSphere.h>
|
||||
|
||||
|
||||
ewol::PhysicsShape* ewol::PhysicsShape::create(const std::string& _name) {
|
||||
ewol::PhysicsShape* tmpp = NULL;
|
||||
ege::PhysicsShape* ege::PhysicsShape::create(const std::string& _name) {
|
||||
ege::PhysicsShape* tmpp = NULL;
|
||||
std::string name = to_lower(_name);
|
||||
if (name == "box") {
|
||||
tmpp = new ewol::PhysicsBox();
|
||||
tmpp = new ege::PhysicsBox();
|
||||
} else if (name == "sphere") {
|
||||
tmpp = new ewol::PhysicsSphere();
|
||||
tmpp = new ege::PhysicsSphere();
|
||||
} else if (name == "cone") {
|
||||
tmpp = new ewol::PhysicsCone();
|
||||
tmpp = new ege::PhysicsCone();
|
||||
} else if (name == "cylinder") {
|
||||
tmpp = new ewol::PhysicsCylinder();
|
||||
tmpp = new ege::PhysicsCylinder();
|
||||
} else if (name == "capsule") {
|
||||
tmpp = new ewol::PhysicsCapsule();
|
||||
tmpp = new ege::PhysicsCapsule();
|
||||
} else if (name == "convexhull") {
|
||||
tmpp = new ewol::PhysicsConvexHull();
|
||||
tmpp = new ege::PhysicsConvexHull();
|
||||
} 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;
|
||||
}
|
||||
if (tmpp == NULL) {
|
||||
EWOL_ERROR("Allocation error for physical element : '" << _name << "'");
|
||||
EGE_ERROR("Allocation error for physical element : '" << _name << "'");
|
||||
}
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::PhysicsShape::parse(const char* _line) {
|
||||
bool ege::PhysicsShape::parse(const char* _line) {
|
||||
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] );
|
||||
EWOL_VERBOSE(" Origin=" << m_origin);
|
||||
EGE_VERBOSE(" Origin=" << m_origin);
|
||||
return true;
|
||||
}
|
||||
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] );
|
||||
EWOL_VERBOSE(" rotate=" << m_quaternion);
|
||||
EGE_VERBOSE(" rotate=" << m_quaternion);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,8 +6,8 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_SHAPE_H__
|
||||
#define __EWOL_PHYSICS_SHAPE_H__
|
||||
#ifndef __EGE_PHYSICS_SHAPE_H__
|
||||
#define __EGE_PHYSICS_SHAPE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
@ -16,7 +16,7 @@
|
||||
#include <etk/math/Vector3D.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
namespace ege {
|
||||
class PhysicsBox;
|
||||
class PhysicsCylinder;
|
||||
class PhysicsCapsule;
|
||||
@ -26,7 +26,7 @@ namespace ewol {
|
||||
|
||||
class PhysicsShape {
|
||||
public:
|
||||
static PhysicsShape* create(const std::string& _name);
|
||||
static ege::PhysicsShape* create(const std::string& _name);
|
||||
public:
|
||||
enum type {
|
||||
unknow,
|
||||
@ -38,15 +38,17 @@ namespace ewol {
|
||||
sphere
|
||||
};
|
||||
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) {
|
||||
|
||||
};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::unknow;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::unknow;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -68,63 +70,63 @@ namespace ewol {
|
||||
};
|
||||
public:
|
||||
bool isBox(void) {
|
||||
return getType() == ewol::PhysicsShape::box;
|
||||
return getType() == ege::PhysicsShape::box;
|
||||
};
|
||||
bool isCylinder(void) {
|
||||
return getType() == ewol::PhysicsShape::cylinder;
|
||||
return getType() == ege::PhysicsShape::cylinder;
|
||||
};
|
||||
bool isCapsule(void) {
|
||||
return getType() == ewol::PhysicsShape::capsule;
|
||||
return getType() == ege::PhysicsShape::capsule;
|
||||
};
|
||||
bool isCone(void) {
|
||||
return getType() == ewol::PhysicsShape::cone;
|
||||
return getType() == ege::PhysicsShape::cone;
|
||||
};
|
||||
bool isConvexHull(void) {
|
||||
return getType() == ewol::PhysicsShape::convexHull;
|
||||
return getType() == ege::PhysicsShape::convexHull;
|
||||
};
|
||||
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;
|
||||
};
|
||||
virtual PhysicsBox* toBox(void) {
|
||||
virtual ege::PhysicsBox* toBox(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCylinder* toCylinder(void) const {
|
||||
virtual const ege::PhysicsCylinder* toCylinder(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCylinder* toCylinder(void) {
|
||||
virtual ege::PhysicsCylinder* toCylinder(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCapsule* toCapsule(void) const {
|
||||
virtual const ege::PhysicsCapsule* toCapsule(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCapsule* toCapsule(void) {
|
||||
virtual ege::PhysicsCapsule* toCapsule(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCone* toCone(void) const {
|
||||
virtual const ege::PhysicsCone* toCone(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCone* toCone(void) {
|
||||
virtual ege::PhysicsCone* toCone(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsConvexHull* toConvexHull(void) const {
|
||||
virtual const ege::PhysicsConvexHull* toConvexHull(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsConvexHull* toConvexHull(void) {
|
||||
virtual ege::PhysicsConvexHull* toConvexHull(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsSphere* toSphere(void) const {
|
||||
virtual const ege::PhysicsSphere* toSphere(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsSphere* toSphere(void) {
|
||||
virtual ege::PhysicsSphere* toSphere(void) {
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
@ -5,18 +5,18 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsSphere.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/physicsShape/PhysicsSphere.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsSphere::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
bool ege::PhysicsSphere::parse(const char* _line) {
|
||||
if (true == ege::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
EGE_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,16 +6,16 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_SPHERE_H__
|
||||
#define __EWOL_PHYSICS_SPHERE_H__
|
||||
#ifndef __EGE_PHYSICS_SPHERE_H__
|
||||
#define __EGE_PHYSICS_SPHERE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsSphere : public ewol::PhysicsShape {
|
||||
namespace ege {
|
||||
class PhysicsSphere : public ege::PhysicsShape {
|
||||
public:
|
||||
PhysicsSphere(void) {};
|
||||
virtual ~PhysicsSphere(void) {};
|
||||
@ -23,18 +23,20 @@ namespace ewol {
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::sphere;
|
||||
virtual enum ege::PhysicsShape::type getType(void) {
|
||||
return ege::PhysicsShape::sphere;
|
||||
};
|
||||
private:
|
||||
float m_radius; // props["radius"] = obj.scale.x
|
||||
public:
|
||||
float getRadius(void) const { return m_radius; };
|
||||
float getRadius(void) const {
|
||||
return m_radius;
|
||||
};
|
||||
private:
|
||||
virtual const PhysicsSphere* toSphere(void) const {
|
||||
virtual const ege::PhysicsSphere* toSphere(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsSphere* toSphere(void) {
|
||||
virtual ege::PhysicsSphere* toSphere(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
@ -6,22 +6,22 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/resources/Mesh.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ege/resource/Mesh.h>
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "resource::Mesh"
|
||||
|
||||
ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
|
||||
ewol::resource::Resource(_fileName),
|
||||
ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
|
||||
ewol::Resource(_fileName),
|
||||
m_normalMode(normalModeNone),
|
||||
m_checkNormal(false),
|
||||
m_pointerShape(NULL),
|
||||
m_functionFreeShape(NULL) {
|
||||
addObjectType("ewol::Mesh");
|
||||
EWOL_VERBOSE("Load a new mesh : '" << _fileName << "'");
|
||||
addObjectType("ewol::resource::Mesh");
|
||||
EGE_VERBOSE("Load a new mesh : '" << _fileName << "'");
|
||||
// get the shader resource :
|
||||
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.setSpecularColor(vec4(0.0,0.0,0.0,1));
|
||||
|
||||
//EWOL_DEBUG(m_name << " " << m_light);
|
||||
m_GLprogram = ewol::Program::keep(_shaderName);
|
||||
//EGE_DEBUG(m_name << " " << m_light);
|
||||
m_GLprogram = ewol::resource::Program::keep(_shaderName);
|
||||
if (NULL != m_GLprogram ) {
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||
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");
|
||||
}
|
||||
// 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 :
|
||||
std::string tmpName = to_lower(_fileName);
|
||||
// select the corect loader :
|
||||
if (end_with(tmpName, ".obj") == true) {
|
||||
if (loadOBJ(_fileName) == false) {
|
||||
EWOL_ERROR("Error To load OBJ file " << tmpName );
|
||||
EGE_ERROR("Error To load OBJ file " << tmpName );
|
||||
return;
|
||||
}
|
||||
} else if (end_with(tmpName, ".emf") ) {
|
||||
if (loadEMF(_fileName) == false) {
|
||||
EWOL_ERROR("Error To load EMF file " << tmpName );
|
||||
EGE_ERROR("Error To load EMF file " << tmpName );
|
||||
return;
|
||||
}
|
||||
//EWOL_CRITICAL("Load a new mesh : '" << _fileName << "' (end)");
|
||||
//EGE_CRITICAL("Load a new mesh : '" << _fileName << "' (end)");
|
||||
} else {
|
||||
// nothing to do == > reqiest an enmpty mesh ==> user manage it ...
|
||||
}
|
||||
}
|
||||
|
||||
ewol::resource::Mesh::~Mesh(void) {
|
||||
ege::resource::Mesh::~Mesh(void) {
|
||||
// remove dynamics dependencies :
|
||||
ewol::resource::Program::release(m_GLprogram);
|
||||
ewol::resource::VirtualBufferObject::release(m_verticesVBO);
|
||||
@ -77,14 +77,14 @@ ewol::resource::Mesh::~Mesh(void) {
|
||||
|
||||
//#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
|
||||
void ewol::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
bool _enableDepthTest,
|
||||
bool _enableDepthUpdate) {
|
||||
if (m_GLprogram == NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
EGE_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
//EWOL_DEBUG(m_name << " " << m_light);
|
||||
//EGE_DEBUG(m_name << " " << m_light);
|
||||
if (_enableDepthTest == true) {
|
||||
ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
if (false == _enableDepthUpdate) {
|
||||
@ -93,7 +93,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
} else {
|
||||
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();
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
@ -115,7 +115,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
#endif
|
||||
for (int32_t kkk=0; kkk<m_listFaces.size(); 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;
|
||||
}
|
||||
m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial);
|
||||
@ -135,7 +135,7 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
cameraNormal.normalized();
|
||||
// remove face that is notin the view ...
|
||||
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;
|
||||
if (normalModeFace == m_normalMode) {
|
||||
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
|
||||
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
|
||||
m_GLprogram->unUse();
|
||||
if (_enableDepthTest == true){
|
||||
@ -178,9 +178,9 @@ void ewol::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
}
|
||||
|
||||
// normal calculation of the normal face is really easy :
|
||||
void ewol::resource::Mesh::calculateNormaleFace(void) {
|
||||
void ege::resource::Mesh::calculateNormaleFace(void) {
|
||||
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;
|
||||
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.
|
||||
@ -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_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();
|
||||
if (m_normalMode != ewol::Mesh::normalModeVertex) {
|
||||
if (m_normalMode != ege::resource::Mesh::normalModeVertex) {
|
||||
for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) {
|
||||
std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces;
|
||||
vec3 normal(0,0,0);
|
||||
@ -213,7 +213,7 @@ void ewol::resource::Mesh::calculateNormaleEdge(void) {
|
||||
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 TRY_MINIMAL_VBO
|
||||
|
||||
void ewol::resource::Mesh::generateVBO(void) {
|
||||
void ege::resource::Mesh::generateVBO(void) {
|
||||
// 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 ....
|
||||
calculateNormaleFace();
|
||||
}
|
||||
@ -242,7 +242,7 @@ void ewol::resource::Mesh::generateVBO(void) {
|
||||
for(size_t indice=0 ; indice<3; indice++) {
|
||||
vec3 position = m_listVertex[tmpFaceList.m_faces[iii].m_vertex[indice]];
|
||||
vec3 normal;
|
||||
if (m_normalMode == ewol::Mesh::normalModeVertex) {
|
||||
if (m_normalMode == normalModeVertex) {
|
||||
normal = m_listVertexNormal[tmpFaceList.m_faces[iii].m_normal[indice]];
|
||||
} else {
|
||||
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) {
|
||||
vertexVBOId[indice] = jjj;
|
||||
elementFind = true;
|
||||
//EWOL_DEBUG("search indice : " << jjj);
|
||||
//EGE_DEBUG("search indice : " << jjj);
|
||||
tmpppppp += jjj;
|
||||
// stop searching ...
|
||||
break;
|
||||
@ -276,7 +276,7 @@ void ewol::resource::Mesh::generateVBO(void) {
|
||||
}
|
||||
}
|
||||
#ifdef TRY_MINIMAL_VBO
|
||||
EWOL_DEBUG("nb cycle ? : " << tmpppppp);
|
||||
EGE_DEBUG("nb cycle ? : " << tmpppppp);
|
||||
#endif
|
||||
}
|
||||
// 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) {
|
||||
m_normalMode = ewol::Mesh::normalModeNone;
|
||||
void ege::resource::Mesh::createViewBox(const std::string& _materialName,float _size) {
|
||||
m_normalMode = normalModeNone;
|
||||
// This is the direct generation basis on the .obj system
|
||||
/*
|
||||
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) {
|
||||
m_normalMode = ewol::Mesh::normalModeNone;
|
||||
bool ege::resource::Mesh::loadOBJ(const std::string& _fileName) {
|
||||
m_normalMode = normalModeNone;
|
||||
#if 0
|
||||
etk::FSNode fileName(_fileName);
|
||||
// get the fileSize ...
|
||||
int32_t size = fileName.fileSize();
|
||||
if (size == 0 ) {
|
||||
EWOL_ERROR("No data in the file named=\"" << fileName << "\"");
|
||||
EGE_ERROR("No data in the file named=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.fileOpenRead() ) {
|
||||
EWOL_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
EGE_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
char inputDataLine[2048];
|
||||
@ -442,7 +442,7 @@ bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) {
|
||||
&vertexIndex[1], &uvIndex[1],
|
||||
&vertexIndex[2], &uvIndex[2] );
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -459,9 +459,9 @@ bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) {
|
||||
vertexIndex[2]-1, uvIndex[2]-1));
|
||||
}
|
||||
/*
|
||||
EWOL_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]);
|
||||
EWOL_DEBUG(" : " << tmpFace.m_uv[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_uv[0]);
|
||||
EGE_DEBUG(" plop : " << tmpFace.m_nbElement << " ? " << m_listFaces[m_listFaces.size()-1].m_nbElement);
|
||||
EGE_DEBUG(" : " << tmpFace.m_vertex[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_vertex[0]);
|
||||
EGE_DEBUG(" : " << tmpFace.m_uv[0] << " ? " << m_listFaces[m_listFaces.size()-1].m_uv[0]);
|
||||
*/
|
||||
} else if (inputDataLine[0] == 's') {
|
||||
// ??? : s off
|
||||
@ -513,10 +513,10 @@ int32_t countIndent(etk::FSNode& _file) {
|
||||
int32_t nbIndent=0;
|
||||
int32_t nbSpacesTab=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()) {
|
||||
nbChar++;
|
||||
//EWOL_DEBUG("parse : " << current);
|
||||
//EGE_DEBUG("parse : " << current);
|
||||
if (current == '\t') {
|
||||
nbSpacesTab = 0;
|
||||
nbIndent++;
|
||||
@ -535,7 +535,7 @@ int32_t countIndent(etk::FSNode& _file) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("indent : " << nbIndent);
|
||||
//EGE_DEBUG("indent : " << nbIndent);
|
||||
_file.fileSeek(-nbChar, etk::FSN_SEEK_CURRENT);
|
||||
return nbIndent;
|
||||
}
|
||||
@ -570,7 +570,7 @@ char* loadNextData(char* _elementLine,
|
||||
&& _stopColomn == true) )
|
||||
{
|
||||
*element = '\0';
|
||||
//EWOL_DEBUG(" plop : '" << _elementLine << "'" );
|
||||
//EGE_DEBUG(" plop : '" << _elementLine << "'" );
|
||||
return _elementLine;
|
||||
} else if( element == _elementLine
|
||||
&& current != '\t') {
|
||||
@ -626,18 +626,18 @@ enum emfModuleMode {
|
||||
EMFModuleMaterial_END,
|
||||
};
|
||||
|
||||
bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
m_checkNormal = true;
|
||||
m_normalMode = ewol::Mesh::normalModeNone;
|
||||
m_normalMode = normalModeNone;
|
||||
etk::FSNode fileName(_fileName);
|
||||
// get the fileSize ...
|
||||
int32_t size = fileName.fileSize();
|
||||
if (size == 0 ) {
|
||||
EWOL_ERROR("No data in the file named=\"" << fileName << "\"");
|
||||
EGE_ERROR("No data in the file named=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.fileOpenRead() ) {
|
||||
EWOL_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
EGE_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
char inputDataLine[2048];
|
||||
@ -646,22 +646,22 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
if(0 == strncmp(inputDataLine, "EMF(STRING)", 11)) {
|
||||
// parse in string mode ...
|
||||
} 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;
|
||||
} else {
|
||||
EWOL_ERROR(" file mode is not supported now : 'EMF(? ? ?)' = '" << inputDataLine << "'");
|
||||
EGE_ERROR(" file mode is not supported now : 'EMF(? ? ?)' = '" << inputDataLine << "'");
|
||||
return false;
|
||||
}
|
||||
enum emfModuleMode currentMode = EMFModuleNone;
|
||||
EWOL_VERBOSE("Start parsing Mesh file : " << fileName);
|
||||
EGE_VERBOSE("Start parsing Mesh file : " << fileName);
|
||||
// mesh global param :
|
||||
std::string currentMeshName = "";
|
||||
int32_t meshFaceMaterialID = -1;
|
||||
// material global param :
|
||||
std::string materialName = "";
|
||||
ewol::Material* material = NULL;
|
||||
ege::Material* material = NULL;
|
||||
// physical shape:
|
||||
ewol::PhysicsShape* physics = NULL;
|
||||
ege::PhysicsShape* physics = NULL;
|
||||
while(1) {
|
||||
int32_t level = countIndent(fileName);
|
||||
if (level == 0) {
|
||||
@ -672,10 +672,10 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
if(0 == strncmp(inputDataLine, "Mesh :", 6) ) {
|
||||
currentMode = EMFModuleMesh;
|
||||
EWOL_VERBOSE("Parse Mesh :");
|
||||
EGE_VERBOSE("Parse Mesh :");
|
||||
} else if(0 == strncmp(inputDataLine, "Materials : ", 11) ) {
|
||||
currentMode = EMFModuleMaterial;
|
||||
EWOL_VERBOSE("Parse Material :");
|
||||
EGE_VERBOSE("Parse Material :");
|
||||
} else {
|
||||
currentMode = EMFModuleNone;
|
||||
}
|
||||
@ -690,7 +690,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
removeEndLine(inputDataLine);
|
||||
currentMeshName = inputDataLine;
|
||||
currentMode = EMFModuleMeshNamed;
|
||||
EWOL_VERBOSE(" "<< currentMeshName);
|
||||
EGE_VERBOSE(" "<< currentMeshName);
|
||||
continue;
|
||||
}
|
||||
if (level == 2) {
|
||||
@ -702,24 +702,24 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
removeEndLine(inputDataLine);
|
||||
if(0 == strncmp(inputDataLine, "Vertex", 6) ) {
|
||||
currentMode = EMFModuleMeshVertex;
|
||||
EWOL_VERBOSE(" Vertex ...");
|
||||
EGE_VERBOSE(" Vertex ...");
|
||||
} else if(0 == strncmp(inputDataLine, "UV-mapping", 10) ) {
|
||||
currentMode = EMFModuleMeshUVMapping;
|
||||
EWOL_VERBOSE(" UV-mapping ...");
|
||||
EGE_VERBOSE(" UV-mapping ...");
|
||||
} else if(0 == strncmp(inputDataLine, "Normal(vertex)", 14) ) {
|
||||
currentMode = EMFModuleMeshNormalVertex;
|
||||
EWOL_VERBOSE(" Normal(vertex) ...");
|
||||
EGE_VERBOSE(" Normal(vertex) ...");
|
||||
} else if(0 == strncmp(inputDataLine, "Normal(face)", 12) ) {
|
||||
currentMode = EMFModuleMeshNormalFace;
|
||||
EWOL_VERBOSE(" Normal(face) ...");
|
||||
EGE_VERBOSE(" Normal(face) ...");
|
||||
} else if(0 == strncmp(inputDataLine, "Face", 4) ) {
|
||||
currentMode = EMFModuleMeshFace;
|
||||
EWOL_VERBOSE(" Face ...");
|
||||
EGE_VERBOSE(" Face ...");
|
||||
} else if(0 == strncmp(inputDataLine, "Physics", 7) ) {
|
||||
currentMode = EMFModuleMeshPhysics;
|
||||
EWOL_VERBOSE(" Physics ...");
|
||||
EGE_VERBOSE(" Physics ...");
|
||||
} else {
|
||||
EWOL_ERROR(" Unknow mesh property '"<<inputDataLine<<"'");
|
||||
EGE_ERROR(" Unknow mesh property '"<<inputDataLine<<"'");
|
||||
currentMode = EMFModuleMeshNamed;
|
||||
}
|
||||
continue;
|
||||
@ -727,7 +727,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
// level > 2
|
||||
switch (currentMode) {
|
||||
default:
|
||||
EWOL_ERROR("Unknow ... "<< level);
|
||||
EGE_ERROR("Unknow ... "<< level);
|
||||
jumpEndLine(fileName);
|
||||
break;
|
||||
case EMFModuleMeshVertex: {
|
||||
@ -744,7 +744,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE(" " << m_listVertex.size() << " vertex");
|
||||
EGE_VERBOSE(" " << m_listVertex.size() << " vertex");
|
||||
break;
|
||||
}
|
||||
case EMFModuleMeshUVMapping: {
|
||||
@ -761,11 +761,11 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE(" " << m_listUV.size() << " coord");
|
||||
EGE_VERBOSE(" " << m_listUV.size() << " coord");
|
||||
break;
|
||||
}
|
||||
case EMFModuleMeshNormalVertex: {
|
||||
m_normalMode = ewol::Mesh::normalModeVertex;
|
||||
m_normalMode = normalModeVertex;
|
||||
vec3 normal(0,0,0);
|
||||
// find the vertex Normal list.
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
@ -780,11 +780,11 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE(" " << m_listVertexNormal.size() << " Normals");
|
||||
EGE_VERBOSE(" " << m_listVertexNormal.size() << " Normals");
|
||||
break;
|
||||
}
|
||||
case EMFModuleMeshNormalFace: {
|
||||
m_normalMode = ewol::Mesh::normalModeFace;
|
||||
m_normalMode = normalModeFace;
|
||||
vec3 normal(0,0,0);
|
||||
// find the face Normal list.
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
@ -799,7 +799,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE(" " << m_listFacesNormal.size() << " Normals");
|
||||
EGE_VERBOSE(" " << m_listFacesNormal.size() << " Normals");
|
||||
break;
|
||||
}
|
||||
case EMFModuleMeshFace:
|
||||
@ -816,7 +816,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
FaceIndexing empty;
|
||||
m_listFaces.add(inputDataLine, empty);
|
||||
meshFaceMaterialID = m_listFaces.getId(inputDataLine);
|
||||
EWOL_VERBOSE(" " << inputDataLine);
|
||||
EGE_VERBOSE(" " << inputDataLine);
|
||||
} else if (currentMode == EMFModuleMeshFaceMaterial) {
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
@ -844,7 +844,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
vertexIndex[1], uvIndex[1], normalIndex[1],
|
||||
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[2] << "/" << uvIndex[2] << "/" << normalIndex[2]);
|
||||
*/
|
||||
@ -854,10 +854,10 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE(" " << m_listFaces.getValue(meshFaceMaterialID).m_faces.size() << " faces");
|
||||
EGE_VERBOSE(" " << m_listFaces.getValue(meshFaceMaterialID).m_faces.size() << " faces");
|
||||
} else {
|
||||
// insert element without material ...
|
||||
EWOL_ERROR(" try to add face without material selection ...");
|
||||
EGE_ERROR(" try to add face without material selection ...");
|
||||
jumpEndLine(fileName);
|
||||
}
|
||||
break;
|
||||
@ -869,21 +869,21 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
removeEndLine(inputDataLine);
|
||||
if (level == 3) {
|
||||
physics = ewol::PhysicsShape::create(inputDataLine);
|
||||
physics = ege::PhysicsShape::create(inputDataLine);
|
||||
if (physics == NULL) {
|
||||
EWOL_ERROR("Allocation error when creating physical shape ...");
|
||||
EGE_ERROR("Allocation error when creating physical shape ...");
|
||||
continue;
|
||||
}
|
||||
m_physics.push_back(physics);
|
||||
EWOL_VERBOSE(" " << m_physics.size() << " " << inputDataLine);
|
||||
EGE_VERBOSE(" " << m_physics.size() << " " << inputDataLine);
|
||||
currentMode = EMFModuleMeshPhysicsNamed;
|
||||
} else if (currentMode == EMFModuleMeshPhysicsNamed) {
|
||||
if (physics == NULL) {
|
||||
EWOL_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
|
||||
EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
|
||||
continue;
|
||||
}
|
||||
if (false == physics->parse(inputDataLine)) {
|
||||
EWOL_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ...");
|
||||
EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ...");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -904,20 +904,20 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
materialName = "";
|
||||
material = NULL;
|
||||
}
|
||||
material = new ewol::Material();
|
||||
material = new ege::Material();
|
||||
materialName = inputDataLine;
|
||||
currentMode = EMFModuleMaterialNamed;
|
||||
EWOL_VERBOSE(" "<< materialName);
|
||||
EGE_VERBOSE(" "<< materialName);
|
||||
continue;
|
||||
}
|
||||
// level >1
|
||||
if (currentMode != EMFModuleMaterialNamed) {
|
||||
EWOL_WARNING(" Unknow element ..."<< level);
|
||||
EGE_WARNING(" Unknow element ..."<< level);
|
||||
jumpEndLine(fileName);
|
||||
continue;
|
||||
}
|
||||
if (NULL == material) {
|
||||
EWOL_ERROR("material allocation error");
|
||||
EGE_ERROR("material allocation error");
|
||||
jumpEndLine(fileName);
|
||||
continue;
|
||||
}
|
||||
@ -925,7 +925,7 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
float tmpVal=0;
|
||||
sscanf(&inputDataLine[3], "%f", &tmpVal);
|
||||
material->setShininess(tmpVal);
|
||||
EWOL_VERBOSE(" Shininess " << tmpVal);
|
||||
EGE_VERBOSE(" Shininess " << tmpVal);
|
||||
} else if(0 == strncmp(inputDataLine,"Ka ",3)) {
|
||||
float tmpVal1=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);
|
||||
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
|
||||
material->setAmbientFactor(tmp);
|
||||
EWOL_VERBOSE(" AmbientFactor " << tmp);
|
||||
EGE_VERBOSE(" AmbientFactor " << tmp);
|
||||
} else if(0 == strncmp(inputDataLine,"Kd ",3)) {
|
||||
float tmpVal1=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);
|
||||
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
|
||||
material->setDiffuseFactor(tmp);
|
||||
EWOL_VERBOSE(" DiffuseFactor " << tmp);
|
||||
EGE_VERBOSE(" DiffuseFactor " << tmp);
|
||||
} else if(0 == strncmp(inputDataLine,"Ks ",3)) {
|
||||
float tmpVal1=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);
|
||||
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
|
||||
material->setSpecularFactor(tmp);
|
||||
EWOL_VERBOSE(" SpecularFactor " << tmp);
|
||||
EGE_VERBOSE(" SpecularFactor " << tmp);
|
||||
} else if(0 == strncmp(inputDataLine,"Ni ",3)) {
|
||||
float tmpVal=0;
|
||||
sscanf(&inputDataLine[3], "%f", &tmpVal);
|
||||
// TODO : ...
|
||||
EWOL_VERBOSE(" Ni " << tmpVal);
|
||||
EGE_VERBOSE(" Ni " << tmpVal);
|
||||
} else if(0 == strncmp(inputDataLine,"d ",2)) {
|
||||
float tmpVal=0;
|
||||
sscanf(&inputDataLine[2], "%f", &tmpVal);
|
||||
// TODO : ...
|
||||
EWOL_VERBOSE(" d " << tmpVal);
|
||||
EGE_VERBOSE(" d " << tmpVal);
|
||||
} else if(0 == strncmp(inputDataLine,"illum ",6)) {
|
||||
int tmpVal=0;
|
||||
sscanf(&inputDataLine[6], "%d", &tmpVal);
|
||||
// TODO : ...
|
||||
EWOL_VERBOSE(" illum " << tmpVal);
|
||||
EGE_VERBOSE(" illum " << tmpVal);
|
||||
} else if(0 == strncmp(inputDataLine,"map_Kd ",7)) {
|
||||
material->setTexture0(fileName.getRelativeFolder() + &inputDataLine[7]);
|
||||
EWOL_VERBOSE(" Texture " << &inputDataLine[7]);
|
||||
EGE_VERBOSE(" Texture " << &inputDataLine[7]);
|
||||
} else {
|
||||
EWOL_ERROR("unknow material property ... : '" << inputDataLine << "'");
|
||||
EGE_ERROR("unknow material property ... : '" << inputDataLine << "'");
|
||||
}
|
||||
} else {
|
||||
// unknow ...
|
||||
EWOL_WARNING("Unknow type of line == > jump end of line ... ");
|
||||
EGE_WARNING("Unknow type of line == > jump end of line ... ");
|
||||
jumpEndLine(fileName);
|
||||
}
|
||||
}
|
||||
@ -985,27 +985,27 @@ bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
materialName = "";
|
||||
material = NULL;
|
||||
}
|
||||
EWOL_VERBOSE("Stop parsing Mesh file");
|
||||
EGE_VERBOSE("Stop parsing Mesh file");
|
||||
|
||||
fileName.fileClose();
|
||||
generateVBO();
|
||||
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) {
|
||||
EWOL_ERROR(" can not add material with null pointer");
|
||||
EGE_ERROR(" can not add material with null pointer");
|
||||
return;
|
||||
}
|
||||
if (_name == "") {
|
||||
EWOL_ERROR(" can not add material with no name");
|
||||
EGE_ERROR(" can not add material with no name");
|
||||
return;
|
||||
}
|
||||
// really add the material :
|
||||
m_materials.add(_name, _data);
|
||||
}
|
||||
|
||||
void ewol::resource::Mesh::setShape(void* _shape) {
|
||||
void ege::resource::Mesh::setShape(void* _shape) {
|
||||
if (m_functionFreeShape!=NULL) {
|
||||
m_functionFreeShape(m_pointerShape);
|
||||
m_pointerShape = NULL;
|
||||
@ -1013,26 +1013,26 @@ void ewol::resource::Mesh::setShape(void* _shape) {
|
||||
m_pointerShape=_shape;
|
||||
}
|
||||
|
||||
ewol::resource::Mesh* ewol::resource::Mesh::keep(const std::string& _meshName) {
|
||||
ewol::resource::Mesh* object = static_cast<ewol::resource::Mesh*>(getManager().localKeep(_meshName));
|
||||
ege::resource::Mesh* ege::resource::Mesh::keep(const std::string& _meshName) {
|
||||
ege::resource::Mesh* object = static_cast<ege::resource::Mesh*>(getManager().localKeep(_meshName));
|
||||
if (NULL != object) {
|
||||
return object;
|
||||
}
|
||||
EWOL_DEBUG("CREATE: Mesh: '" << _meshName << "'");
|
||||
object = new ewol::resource::Mesh(_meshName);
|
||||
EGE_DEBUG("CREATE: Mesh: '" << _meshName << "'");
|
||||
object = new ege::resource::Mesh(_meshName);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
return NULL;
|
||||
}
|
||||
getManager().localAdd(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
void ewol::resource::Mesh::release(ewol::Mesh*& _object) {
|
||||
void ege::resource::Mesh::release(ege::resource::Mesh*& _object) {
|
||||
if (NULL == _object) {
|
||||
return;
|
||||
}
|
||||
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
||||
getManager().release(object2);
|
||||
_object = NULL;
|
||||
}
|
@ -6,19 +6,19 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __MESH_H__
|
||||
#define __MESH_H__
|
||||
#ifndef __EGE_MESH_H__
|
||||
#define __EGE_MESH_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/Hash.h>
|
||||
#include <ewol/resources/Resource.h>
|
||||
#include <ewol/resources/Image.h>
|
||||
#include <ewol/resources/Shader.h>
|
||||
#include <ewol/resources/Program.h>
|
||||
#include <ewol/resources/VirtualBufferObject.h>
|
||||
#include <ewol/Light.h>
|
||||
#include <ewol/Material.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
#include <ewol/resource/Resource.h>
|
||||
#include <ewol/resource/Image.h>
|
||||
#include <ewol/resource/Shader.h>
|
||||
#include <ewol/resource/Program.h>
|
||||
#include <ewol/resource/VirtualBufferObject.h>
|
||||
#include <ege/Light.h>
|
||||
#include <ege/Material.h>
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
// 3 "float" elements
|
||||
#define MESH_VBO_VERTICES (0)
|
||||
// 2 "float" elements
|
||||
@ -30,49 +30,58 @@
|
||||
// 4 "float" elements
|
||||
#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 {
|
||||
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;
|
||||
};
|
||||
};
|
||||
class FaceIndexing {
|
||||
public:
|
||||
std::vector<Face> m_faces;
|
||||
std::vector<uint32_t> m_index;
|
||||
};
|
||||
class Mesh : public ewol::resource::Resource {
|
||||
class Mesh : public ewol::Resource {
|
||||
public:
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
enum normalMode {
|
||||
normalModeNone,
|
||||
normalModeFace,
|
||||
@ -82,32 +91,37 @@ namespace ewol {
|
||||
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
|
||||
protected:
|
||||
ewol::Program* m_GLprogram;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLMatrixPosition;
|
||||
int32_t m_GLNormal;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_bufferOfset;
|
||||
int32_t m_numberOfElments;
|
||||
ewol::resource::Program* m_GLprogram;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLMatrixPosition;
|
||||
int32_t m_GLNormal;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_bufferOfset;
|
||||
int32_t m_numberOfElments;
|
||||
MaterialGlId m_GLMaterial;
|
||||
ewol::Light m_light;
|
||||
ege::Light m_light;
|
||||
protected:
|
||||
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<vec3> m_listFacesNormal; //!< 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<ewol::Material*> m_materials;
|
||||
std::vector<ewol::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
etk::Hash<ege::Material*> m_materials;
|
||||
std::vector<ege::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
protected:
|
||||
ewol::VirtualBufferObject* m_verticesVBO;
|
||||
ewol::resource::VirtualBufferObject* m_verticesVBO;
|
||||
protected:
|
||||
Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog");
|
||||
virtual ~Mesh(void);
|
||||
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,
|
||||
const etk::Color<float>& _mainColor,
|
||||
bool _enableDepthTest = true,
|
||||
bool _enableDepthUpdate = true) {
|
||||
draw(_positionMatrix, _enableDepthTest, _enableDepthUpdate);
|
||||
}
|
||||
void generateVBO(void);
|
||||
private:
|
||||
void calculateNormaleFace(void);
|
||||
@ -118,19 +132,25 @@ namespace ewol {
|
||||
bool loadOBJ(const std::string& _fileName);
|
||||
bool loadEMF(const std::string& _fileName);
|
||||
public:
|
||||
void addMaterial(const std::string& _name, ewol::Material* _data);
|
||||
void addMaterial(const std::string& _name, ege::Material* _data);
|
||||
public:
|
||||
/**
|
||||
* @brief set the check of normal position befor sending it to the openGl card
|
||||
* @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
|
||||
* @return get the chcking stus of normal or not
|
||||
*/
|
||||
bool getCheckNormal(void) { return m_checkNormal; };
|
||||
const std::vector<ewol::PhysicsShape*>& getPhysicalProperties(void) const { return m_physics; };
|
||||
bool getCheckNormal(void) {
|
||||
return m_checkNormal;
|
||||
};
|
||||
const std::vector<ege::PhysicsShape*>& getPhysicalProperties(void) const {
|
||||
return m_physics;
|
||||
};
|
||||
private:
|
||||
void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib
|
||||
public:
|
||||
@ -143,11 +163,15 @@ namespace ewol {
|
||||
* @brief get the pointer on the shame (no type)
|
||||
* @return Pointer on shape.
|
||||
*/
|
||||
void* getShape(void) { return m_pointerShape; };
|
||||
void* getShape(void) {
|
||||
return m_pointerShape;
|
||||
};
|
||||
private:
|
||||
void (*m_functionFreeShape)(void* _pointer);
|
||||
public:
|
||||
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) { m_functionFreeShape = _functionFreeShape; };
|
||||
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) {
|
||||
m_functionFreeShape = _functionFreeShape;
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief keep the resource pointer.
|
||||
@ -155,12 +179,12 @@ namespace ewol {
|
||||
* @param[in] _filename Name of the ewol mesh file.
|
||||
* @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
|
||||
* @param[in,out] reference on the object pointer
|
||||
*/
|
||||
static void release(ewol::Mesh*& _object);
|
||||
static void release(ege::resource::Mesh*& _object);
|
||||
};
|
||||
};
|
||||
};
|
@ -8,10 +8,10 @@
|
||||
|
||||
#include <ege/debug.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) :
|
||||
ewol::Mesh(_fileName, _shaderName)
|
||||
ege::resource::Mesh(_fileName, _shaderName)
|
||||
{
|
||||
if (m_GLprogram != NULL) {
|
||||
m_GLMainColor = m_GLprogram->getUniform("EW_mainColor");
|
||||
@ -29,10 +29,10 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
bool _enableDepthUpdate)
|
||||
{
|
||||
if (m_GLprogram == NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
EGE_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
//EWOL_DEBUG(m_name << " " << m_light);
|
||||
//EGE_DEBUG(m_name << " " << m_light);
|
||||
if (_enableDepthTest == true) {
|
||||
ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
if (false == _enableDepthUpdate) {
|
||||
@ -41,7 +41,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
} else {
|
||||
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();
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
@ -65,7 +65,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
#endif
|
||||
for (int32_t kkk=0; kkk<m_listFaces.size(); 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;
|
||||
}
|
||||
m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial);
|
||||
@ -85,7 +85,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
cameraNormal.normalized();
|
||||
// remove face that is notin the view ...
|
||||
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;
|
||||
if (normalModeFace == m_normalMode) {
|
||||
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
|
||||
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
|
||||
m_GLprogram->unUse();
|
||||
if (_enableDepthTest == true){
|
||||
@ -134,7 +134,7 @@ ege::resource::ParticuleMesh* ege::resource::ParticuleMesh::keep(const std::stri
|
||||
}
|
||||
object = new ege::resource::ParticuleMesh(_meshName, _shaderName);
|
||||
if (object == NULL) {
|
||||
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
return NULL;
|
||||
}
|
||||
getManager().localAdd(object);
|
||||
|
@ -9,22 +9,21 @@
|
||||
#ifndef __EGE_RESOURCE_PARTICULE_MESH_H__
|
||||
#define __EGE_RESOURCE_PARTICULE_MESH_H__
|
||||
|
||||
#include <ewol/resources/Mesh.h>
|
||||
#include <ege/resource/Mesh.h>
|
||||
|
||||
namespace ege
|
||||
{
|
||||
namespace resource
|
||||
{
|
||||
class ParticuleMesh : public ewol::Mesh
|
||||
{
|
||||
namespace ege {
|
||||
namespace resource {
|
||||
class ParticuleMesh : public ege::resource::Mesh {
|
||||
protected:
|
||||
int32_t m_GLMainColor;
|
||||
int32_t m_GLMainColor;
|
||||
protected:
|
||||
ParticuleMesh(const std::string& _fileName, const std::string& _shaderName);
|
||||
virtual ~ParticuleMesh(void);
|
||||
public:
|
||||
virtual const char* getType(void) { return "ege::resource::ParticuleMesh"; };
|
||||
virtual void draw(mat4& _positionMatrix, const etk::Color<float>& _mainColor, bool _enableDepthTest=true, bool _enableDepthUpdate=true);
|
||||
virtual void draw(mat4& _positionMatrix,
|
||||
const etk::Color<float>& _mainColor,
|
||||
bool _enableDepthTest = true,
|
||||
bool _enableDepthUpdate = true);
|
||||
public:
|
||||
/**
|
||||
* @brief keep the resource pointer.
|
||||
|
@ -6,9 +6,10 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Mesh.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <ege/widget/Mesh.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <ege/debug.h>
|
||||
|
||||
|
||||
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_object(NULL),
|
||||
m_position(0,0,0),
|
||||
m_angle(0,0,0),
|
||||
m_angleSpeed(0,0,0),
|
||||
m_cameraDistance(10.0) {
|
||||
addObjectType("ewol::widget::Mesh");
|
||||
addObjectType("ege::widget::Mesh");
|
||||
addEventId(ewolEventMeshPressed);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
if (_filename!="") {
|
||||
m_object = ewol::Mesh::keep(m_meshName);
|
||||
m_object = ege::resource::Mesh::keep(m_meshName);
|
||||
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) {
|
||||
ewol::Mesh::release(m_object);
|
||||
ege::widget::Mesh::~Mesh(void) {
|
||||
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))
|
||||
* etk::matTranslate(m_position)
|
||||
* 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();
|
||||
// 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(),
|
||||
@ -60,7 +61,7 @@ void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
|
||||
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 tmpMat = tmpProjection * m_camera.getMatrix();
|
||||
// set internal matrix system :
|
||||
@ -71,21 +72,21 @@ void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
|
||||
ewol::openGL::pop();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::onRegenerateDisplay(void) {
|
||||
void ege::widget::Mesh::onRegenerateDisplay(void) {
|
||||
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();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
|
||||
//EWOL_DEBUG("Event on BT ...");
|
||||
bool ege::widget::Mesh::onEventInput(const ewol::event::Input& _event) {
|
||||
//EGE_DEBUG("Event on BT ...");
|
||||
if (1 == _event.getId()) {
|
||||
if(ewol::keyEvent::statusSingle == _event.getStatus()) {
|
||||
if(ewol::key::statusSingle == _event.getStatus()) {
|
||||
generateEventId(ewolEventMeshPressed);
|
||||
return true;
|
||||
}
|
||||
@ -93,30 +94,30 @@ bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setFile(const std::string& _filename) {
|
||||
void ege::widget::Mesh::setFile(const std::string& _filename) {
|
||||
if( _filename!=""
|
||||
&& m_meshName != _filename ) {
|
||||
ewol::Mesh::release(m_object);
|
||||
ege::resource::Mesh::release(m_object);
|
||||
m_meshName = _filename;
|
||||
m_object = ewol::Mesh::keep(m_meshName);
|
||||
m_object = ege::resource::Mesh::keep(m_meshName);
|
||||
if (NULL == m_object) {
|
||||
EWOL_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
EGE_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setPosition(const vec3& _pos) {
|
||||
void ege::widget::Mesh::setPosition(const vec3& _pos) {
|
||||
m_position = _pos;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setAngle(const vec3& _angle) {
|
||||
void ege::widget::Mesh::setAngle(const vec3& _angle) {
|
||||
m_angle = _angle;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
|
||||
void ege::widget::Mesh::setAngleSpeed(const vec3& _speed) {
|
||||
if (_speed!=vec3(0,0,0)) {
|
||||
periodicCallEnable();
|
||||
} else {
|
||||
@ -126,7 +127,7 @@ void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setDistance(float _distance)
|
||||
void ege::widget::Mesh::setDistance(float _distance)
|
||||
{
|
||||
m_cameraDistance = _distance;
|
||||
markToRedraw();
|
||||
|
@ -11,12 +11,12 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/resources/Mesh.h>
|
||||
#include <ege/resource/Mesh.h>
|
||||
|
||||
extern const char * const ewolEventMeshPressed;
|
||||
|
||||
|
||||
namespace ewol {
|
||||
namespace ege {
|
||||
namespace widget {
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
@ -25,47 +25,47 @@ namespace ewol {
|
||||
private:
|
||||
// mesh name :
|
||||
std::string m_meshName;
|
||||
ewol::Mesh* m_object;
|
||||
ege::resource::Mesh* m_object;
|
||||
// mesh display properties:
|
||||
vec3 m_position;
|
||||
vec3 m_angle;
|
||||
vec3 m_angleSpeed;
|
||||
float m_cameraDistance;
|
||||
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);
|
||||
public: // Derived function
|
||||
virtual void onRegenerateDisplay(void);
|
||||
virtual void systemDraw(const ewol::DrawProperty& displayProp);
|
||||
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
|
||||
virtual void onDraw(void);
|
||||
virtual bool onEventInput(const ewol::EventInput& _event);
|
||||
virtual void periodicCall(const ewol::EventTime& _event);
|
||||
virtual bool onEventInput(const ewol::event::Input& _event);
|
||||
virtual void periodicCall(const ewol::event::Time& _event);
|
||||
public:
|
||||
/**
|
||||
* @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
|
||||
* @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
|
||||
* @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
|
||||
* @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
|
||||
* @param[in] dist Diatance of the mesh
|
||||
* @param[in] _distance Diatance of the mesh
|
||||
*/
|
||||
void setDistance(float distance);
|
||||
void setDistance(float _distance);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -7,12 +7,12 @@
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/Scene.h>
|
||||
#include <ege/widget/Scene.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <ege/debug.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/renderer/openGL.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <etk/math/Matrix4.h>
|
||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
||||
#include <LinearMath/btDefaultMotionState.h>
|
||||
@ -31,12 +31,12 @@
|
||||
#define __class__ "Scene"
|
||||
|
||||
|
||||
const char * const ege::Scene::eventPlayTimeChange = "event-scene-play-time-change";
|
||||
const char * const ege::Scene::eventKillEnemy = "event-scene-kill-ennemy";
|
||||
const char * const ege::widget::Scene::eventPlayTimeChange = "event-scene-play-time-change";
|
||||
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_angleView(M_PI/3.0),
|
||||
m_dynamicsWorld(NULL),
|
||||
@ -50,7 +50,7 @@ ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
|
||||
addEventId(eventPlayTimeChange);
|
||||
addEventId(eventKillEnemy);
|
||||
|
||||
m_debugDrawing = ewol::Colored3DObject::keep();
|
||||
m_debugDrawing = ewol::resource::Colored3DObject::keep();
|
||||
|
||||
m_ratioTime = 1.0f;
|
||||
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,
|
||||
btBroadphaseInterface* _broadphase,
|
||||
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) {
|
||||
m_camera = _camera;
|
||||
} else {
|
||||
@ -112,8 +112,8 @@ void ege::Scene::setCamera(ege::Camera* _camera) {
|
||||
}
|
||||
}
|
||||
|
||||
ege::Scene::~Scene(void) {
|
||||
ewol::Colored3DObject::release(m_debugDrawing);
|
||||
ege::widget::Scene::~Scene(void) {
|
||||
ewol::resource::Colored3DObject::release(m_debugDrawing);
|
||||
/*
|
||||
ewol::resource::release(m_directDrawObject);
|
||||
//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()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ege::Scene::pause(void) {
|
||||
void ege::widget::Scene::pause(void) {
|
||||
EGE_DEBUG("Set pause");
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
void ege::Scene::resume(void) {
|
||||
void ege::widget::Scene::resume(void) {
|
||||
EGE_DEBUG("Set resume");
|
||||
m_isRunning = true;
|
||||
}
|
||||
|
||||
void ege::Scene::pauseToggle(void) {
|
||||
void ege::widget::Scene::pauseToggle(void) {
|
||||
if(true == m_isRunning) {
|
||||
EGE_DEBUG("Set Toggle: pause");
|
||||
m_isRunning=false;
|
||||
@ -173,7 +173,7 @@ void ege::Scene::pauseToggle(void) {
|
||||
#define NUMBER_OF_SUB_PASS (0)
|
||||
|
||||
|
||||
void ege::Scene::onDraw(void) {
|
||||
void ege::widget::Scene::onDraw(void) {
|
||||
#ifdef SCENE_DISPLAY_SPEED
|
||||
g_counterNbTimeDisplay++;
|
||||
g_startTime = ewol::getTime();
|
||||
@ -236,7 +236,7 @@ btRigidBody& btActionInterface::getFixedBody(void) {
|
||||
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();
|
||||
// small hack to change speed ...
|
||||
if (m_ratioTime != 1) {
|
||||
@ -298,7 +298,7 @@ void ege::Scene::periodicCall(const ewol::EventTime& _event) {
|
||||
|
||||
//#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
|
||||
int64_t tmp___startTime0 = ewol::getTime();
|
||||
@ -348,7 +348,7 @@ EWOL_DEBUG(" SCENE444 : " << tmp___localTime4 << "ms ");
|
||||
#endif
|
||||
}
|
||||
|
||||
vec2 ege::Scene::calculateDeltaAngle(const vec2& _posScreen) {
|
||||
vec2 ege::widget::Scene::calculateDeltaAngle(const vec2& _posScreen) {
|
||||
double ratio = m_size.x() / m_size.y();
|
||||
vec2 pos = vec2(m_size.x()/-2.0, m_size.y()/-2.0) + _posScreen;
|
||||
|
||||
@ -365,7 +365,7 @@ vec2 ege::Scene::calculateDeltaAngle(const vec2& _posScreen) {
|
||||
angleY);
|
||||
}
|
||||
|
||||
vec3 ege::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) {
|
||||
vec3 ege::widget::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) {
|
||||
return m_camera->projectOnZGround(calculateDeltaAngle(_posScreen));
|
||||
}
|
||||
|
146
ege/widget/Scene.h
Normal file
146
ege/widget/Scene.h
Normal 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
|
||||
|
||||
|
15
lutin_ege.py
15
lutin_ege.py
@ -22,9 +22,20 @@ def Create(target):
|
||||
'ege/Particule.cpp',
|
||||
'ege/ParticuleEngine.cpp',
|
||||
'ege/ParticuleSimple.cpp',
|
||||
'ege/Scene.cpp',
|
||||
'ege/widget/Mesh.cpp',
|
||||
'ege/widget/Scene.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.*','')
|
||||
|
Loading…
x
Reference in New Issue
Block a user