[DEV] transfer special game element in the local lib
This commit is contained in:
parent
bc3e08d665
commit
2c54a551b4
59
ege/Light.cpp
Normal file
59
ege/Light.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/Light.h>
|
||||
#include <ewol/debug.h>
|
||||
|
||||
ewol::Light::Light(void) :
|
||||
m_direction(0,0,0),
|
||||
m_halfplane(0,0,0),
|
||||
m_ambientColor(0,0,0,0),
|
||||
m_diffuseColor(0,0,0,0),
|
||||
m_specularColor(0,0,0,0),
|
||||
m_GL_direction(0),
|
||||
m_GL_halfplane(0),
|
||||
m_GL_ambientColor(0),
|
||||
m_GL_diffuseColor(0),
|
||||
m_GL_specularColor(0) {
|
||||
// nothing to do else ...
|
||||
}
|
||||
|
||||
ewol::Light::~Light(void) {
|
||||
|
||||
}
|
||||
|
||||
void ewol::Light::link(ewol::Program* _prog, const std::string& _baseName) {
|
||||
if (NULL == _prog) {
|
||||
return;
|
||||
}
|
||||
m_GL_direction = _prog->getUniform(_baseName+".direction");
|
||||
m_GL_halfplane = _prog->getUniform(_baseName+".halfplane");
|
||||
m_GL_ambientColor = _prog->getUniform(_baseName+".ambientColor");
|
||||
m_GL_diffuseColor = _prog->getUniform(_baseName+".diffuseColor");
|
||||
m_GL_specularColor = _prog->getUniform(_baseName+".specularColor");
|
||||
}
|
||||
|
||||
void ewol::Light::draw(ewol::Program* _prog) {
|
||||
_prog->uniform3(m_GL_direction, m_direction);
|
||||
_prog->uniform3(m_GL_halfplane, m_halfplane);
|
||||
_prog->uniform4(m_GL_ambientColor, m_ambientColor);
|
||||
_prog->uniform4(m_GL_diffuseColor, m_diffuseColor);
|
||||
_prog->uniform4(m_GL_specularColor, m_specularColor);
|
||||
}
|
||||
|
||||
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Light& _obj) {
|
||||
_os << "light:{";
|
||||
_os << "dir=" << _obj.m_direction;
|
||||
_os << " halfplan=" << _obj.m_halfplane;
|
||||
_os << " color:{ anbiant=" << _obj.m_ambientColor;
|
||||
_os << " diffuse=" << _obj.m_diffuseColor;
|
||||
_os << " specular=" << _obj.m_specularColor;
|
||||
_os << "}}";
|
||||
return _os;
|
||||
}
|
||||
|
61
ege/Light.h
Normal file
61
ege/Light.h
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_LIGHT_H__
|
||||
#define __EWOL_LIGHT_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <ewol/resources/Program.h>
|
||||
|
||||
namespace ewol {
|
||||
class Light {
|
||||
private:
|
||||
// values
|
||||
vec3 m_direction;
|
||||
vec3 m_halfplane;
|
||||
vec4 m_ambientColor;
|
||||
vec4 m_diffuseColor;
|
||||
vec4 m_specularColor;
|
||||
private:
|
||||
// GL index
|
||||
int32_t m_GL_direction;
|
||||
int32_t m_GL_halfplane;
|
||||
int32_t m_GL_ambientColor;
|
||||
int32_t m_GL_diffuseColor;
|
||||
int32_t m_GL_specularColor;
|
||||
public:
|
||||
Light(void);
|
||||
~Light(void);
|
||||
void link(ewol::Program* _prog, const std::string& _baseName);
|
||||
void draw(ewol::Program* _prog);
|
||||
void setDirection(const vec3& val) {
|
||||
m_direction = val;
|
||||
}
|
||||
void setHalfPlane(const vec3& val) {
|
||||
m_halfplane = val;
|
||||
}
|
||||
void setAmbientColor(const vec4& val) {
|
||||
m_ambientColor = val;
|
||||
}
|
||||
void setDiffuseColor(const vec4& val) {
|
||||
m_diffuseColor = val;
|
||||
}
|
||||
void setSpecularColor(const vec4& val) {
|
||||
m_specularColor = val;
|
||||
}
|
||||
|
||||
friend etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
76
ege/Material.cpp
Normal file
76
ege/Material.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <ewol/Material.h>
|
||||
#include <ewol/debug.h>
|
||||
|
||||
ewol::MaterialGlId::MaterialGlId(void) :
|
||||
m_GL_ambientFactor(0),
|
||||
m_GL_diffuseFactor(0),
|
||||
m_GL_specularFactor(0),
|
||||
m_GL_shininess(0),
|
||||
m_GL_texture0(0) {
|
||||
// nothing to do else ...
|
||||
}
|
||||
|
||||
|
||||
void ewol::MaterialGlId::link(ewol::Program* _prog, const std::string& _baseName) {
|
||||
if (NULL == _prog) {
|
||||
return;
|
||||
}
|
||||
m_GL_ambientFactor = _prog->getUniform(_baseName+".ambientFactor");
|
||||
m_GL_diffuseFactor = _prog->getUniform(_baseName+".diffuseFactor");
|
||||
m_GL_specularFactor = _prog->getUniform(_baseName+".specularFactor");
|
||||
m_GL_shininess = _prog->getUniform(_baseName+".shininess");
|
||||
m_GL_texture0 = _prog->getUniform("EW_texID");
|
||||
}
|
||||
|
||||
ewol::Material::Material(void) :
|
||||
m_ambientFactor(1,1,1,1),
|
||||
m_diffuseFactor(0,0,0,1),
|
||||
m_specularFactor(0,0,0,1),
|
||||
m_shininess(1),
|
||||
m_texture0(NULL) {
|
||||
// nothing to do else ...
|
||||
}
|
||||
ewol::Material::~Material(void) {
|
||||
if(NULL!=m_texture0) {
|
||||
ewol::TextureFile::release(m_texture0);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::Material::draw(ewol::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);
|
||||
_prog->uniform1f(_glID.m_GL_shininess, m_shininess);
|
||||
if (NULL != m_texture0) {
|
||||
_prog->setTexture0(_glID.m_GL_texture0, m_texture0->getId());
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::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);
|
||||
if (NULL == m_texture0 ) {
|
||||
EWOL_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
69
ege/Material.h
Normal file
69
ege/Material.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_MATERIAL_H__
|
||||
#define __EWOL_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>
|
||||
|
||||
namespace ewol {
|
||||
class MaterialGlId {
|
||||
public:
|
||||
// GL index
|
||||
int32_t m_GL_ambientFactor;
|
||||
int32_t m_GL_diffuseFactor;
|
||||
int32_t m_GL_specularFactor;
|
||||
int32_t m_GL_shininess;
|
||||
int32_t m_GL_texture0;
|
||||
MaterialGlId(void);
|
||||
void link(ewol::Program* _prog, const std::string& _baseName);
|
||||
};
|
||||
class Material {
|
||||
private:
|
||||
// values
|
||||
vec4 m_ambientFactor;
|
||||
vec4 m_diffuseFactor;
|
||||
vec4 m_specularFactor;
|
||||
float m_shininess;
|
||||
ewol::TextureFile* m_texture0;
|
||||
public:
|
||||
std::vector<uint32_t> m_listIndexFaces;
|
||||
public:
|
||||
Material(void);
|
||||
~Material(void);
|
||||
void draw(ewol::Program* _prog, const MaterialGlId& _glID);
|
||||
void setAmbientFactor(const vec4& _val) {
|
||||
m_ambientFactor = _val;
|
||||
}
|
||||
void setDiffuseFactor(const vec4& _val) {
|
||||
m_diffuseFactor = _val;
|
||||
}
|
||||
void setSpecularFactor(const vec4& _val) {
|
||||
m_specularFactor = _val;
|
||||
}
|
||||
void setShininess(float _val) {
|
||||
m_shininess = _val;
|
||||
}
|
||||
void setTexture0(const std::string& _filename);
|
||||
|
||||
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(); };
|
||||
// flush the data to send it at the openGl system
|
||||
void flush(void) { if (m_texture0 == NULL){return;} m_texture0->flush(); };
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
23
ege/physicsShape/PhysicsBox.cpp
Normal file
23
ege/physicsShape/PhysicsBox.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsBox.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsBox::parse(const char* _line) {
|
||||
if (true == ewol::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);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
44
ege/physicsShape/PhysicsBox.h
Normal file
44
ege/physicsShape/PhysicsBox.h
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_BOX_H__
|
||||
#define __EWOL_PHYSICS_BOX_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsBox : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsBox(void) {};
|
||||
virtual ~PhysicsBox(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::box;
|
||||
};
|
||||
private:
|
||||
vec3 m_size; // Box size property in X, Y and Z
|
||||
public:
|
||||
const vec3& getSize(void) const {
|
||||
return m_size;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsBox* toBox(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsBox* toBox(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
28
ege/physicsShape/PhysicsCapsule.cpp
Normal file
28
ege/physicsShape/PhysicsCapsule.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCapsule.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsCapsule::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "height : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_height );
|
||||
EWOL_VERBOSE(" height=" << m_height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
52
ege/physicsShape/PhysicsCapsule.h
Normal file
52
ege/physicsShape/PhysicsCapsule.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CAPSULE_H__
|
||||
#define __EWOL_PHYSICS_CAPSULE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCapsule : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsCapsule(void) {};
|
||||
virtual ~PhysicsCapsule(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::capsule;
|
||||
};
|
||||
private:
|
||||
float m_radius;
|
||||
public:
|
||||
float getRadius(void) const {
|
||||
return m_radius;
|
||||
};
|
||||
private:
|
||||
float m_height;
|
||||
public:
|
||||
float getHeight(void) const {
|
||||
return m_height;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCapsule* toCapsule(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCapsule* toCapsule(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
28
ege/physicsShape/PhysicsCone.cpp
Normal file
28
ege/physicsShape/PhysicsCone.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCone.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsCone::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "height : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_height );
|
||||
EWOL_VERBOSE(" height=" << m_height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
52
ege/physicsShape/PhysicsCone.h
Normal file
52
ege/physicsShape/PhysicsCone.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CONE_H__
|
||||
#define __EWOL_PHYSICS_CONE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCone : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsCone(void) {};
|
||||
virtual ~PhysicsCone(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::cone;
|
||||
};
|
||||
private:
|
||||
float m_radius;
|
||||
public:
|
||||
float getRadius(void) const {
|
||||
return m_radius;
|
||||
};
|
||||
private:
|
||||
float m_height;
|
||||
public:
|
||||
float getHeight(void) const {
|
||||
return m_height;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCone* toCone(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCone* toCone(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
44
ege/physicsShape/PhysicsConvexHull.cpp
Normal file
44
ege/physicsShape/PhysicsConvexHull.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsConvexHull.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsConvexHull::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "points : ", 8) ) {
|
||||
//EWOL_DEBUG("convex hull point parsing " << _line);
|
||||
char* base = (char*)(&_line[8]);
|
||||
char* tmp= strchr(base, '|');
|
||||
vec3 pos(0,0,0);
|
||||
while (tmp != NULL) {
|
||||
*tmp = '\0';
|
||||
sscanf(base, "%f %f %f", &pos.m_floats[0], &pos.m_floats[1], &pos.m_floats[2] );
|
||||
m_points.push_back(pos);
|
||||
base = tmp+1;
|
||||
tmp= strchr(base, '|');
|
||||
}
|
||||
sscanf(base, "%f %f %f", &pos.m_floats[0], &pos.m_floats[1], &pos.m_floats[2] );
|
||||
m_points.push_back(pos);
|
||||
/*
|
||||
for (int32_t iii=0; iii<m_points.size(); iii++) {
|
||||
EWOL_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);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
52
ege/physicsShape/PhysicsConvexHull.h
Normal file
52
ege/physicsShape/PhysicsConvexHull.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CONVEX_HULL_H__
|
||||
#define __EWOL_PHYSICS_CONVEX_HULL_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsConvexHull : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsConvexHull(void) {};
|
||||
virtual ~PhysicsConvexHull(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::convexHull;
|
||||
};
|
||||
private:
|
||||
vec3 m_scale;
|
||||
public:
|
||||
vec3 getScale(void) const {
|
||||
return m_scale;
|
||||
};
|
||||
private:
|
||||
std::vector<vec3> m_points;
|
||||
public:
|
||||
const std::vector<vec3>& getPointList(void) const {
|
||||
return m_points;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsConvexHull* toConvexHull(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsConvexHull* toConvexHull(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
22
ege/physicsShape/PhysicsCylinder.cpp
Normal file
22
ege/physicsShape/PhysicsCylinder.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsCylinder.h>
|
||||
|
||||
|
||||
bool ewol::PhysicsCylinder::parse(const char* _line) {
|
||||
if (true == ewol::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);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
45
ege/physicsShape/PhysicsCylinder.h
Normal file
45
ege/physicsShape/PhysicsCylinder.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_CYLINDER_H__
|
||||
#define __EWOL_PHYSICS_CYLINDER_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsCylinder : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsCylinder(void) {};
|
||||
virtual ~PhysicsCylinder(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::cylinder;
|
||||
};
|
||||
private:
|
||||
vec3 m_size;
|
||||
public:
|
||||
vec3 getSize(void) const {
|
||||
return m_size;
|
||||
};
|
||||
public:
|
||||
virtual const PhysicsCylinder* toCylinder(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsCylinder* toCylinder(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
57
ege/physicsShape/PhysicsShape.cpp
Normal file
57
ege/physicsShape/PhysicsShape.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @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>
|
||||
|
||||
|
||||
ewol::PhysicsShape* ewol::PhysicsShape::create(const std::string& _name) {
|
||||
ewol::PhysicsShape* tmpp = NULL;
|
||||
std::string name = to_lower(_name);
|
||||
if (name == "box") {
|
||||
tmpp = new ewol::PhysicsBox();
|
||||
} else if (name == "sphere") {
|
||||
tmpp = new ewol::PhysicsSphere();
|
||||
} else if (name == "cone") {
|
||||
tmpp = new ewol::PhysicsCone();
|
||||
} else if (name == "cylinder") {
|
||||
tmpp = new ewol::PhysicsCylinder();
|
||||
} else if (name == "capsule") {
|
||||
tmpp = new ewol::PhysicsCapsule();
|
||||
} else if (name == "convexhull") {
|
||||
tmpp = new ewol::PhysicsConvexHull();
|
||||
} else {
|
||||
EWOL_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 << "'");
|
||||
}
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::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);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
135
ege/physicsShape/PhysicsShape.h
Normal file
135
ege/physicsShape/PhysicsShape.h
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_SHAPE_H__
|
||||
#define __EWOL_PHYSICS_SHAPE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsBox;
|
||||
class PhysicsCylinder;
|
||||
class PhysicsCapsule;
|
||||
class PhysicsCone;
|
||||
class PhysicsConvexHull;
|
||||
class PhysicsSphere;
|
||||
|
||||
class PhysicsShape {
|
||||
public:
|
||||
static PhysicsShape* create(const std::string& _name);
|
||||
public:
|
||||
enum type {
|
||||
unknow,
|
||||
box,
|
||||
capsule,
|
||||
cone,
|
||||
convexHull,
|
||||
cylinder,
|
||||
sphere
|
||||
};
|
||||
public:
|
||||
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;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {
|
||||
|
||||
};
|
||||
private:
|
||||
vec4 m_quaternion;
|
||||
public:
|
||||
const vec4& getQuaternion(void) const {
|
||||
return m_quaternion;
|
||||
};
|
||||
private:
|
||||
vec3 m_origin;
|
||||
public:
|
||||
const vec3& getOrigin(void) const {
|
||||
return m_origin;
|
||||
};
|
||||
public:
|
||||
bool isBox(void) {
|
||||
return getType() == ewol::PhysicsShape::box;
|
||||
};
|
||||
bool isCylinder(void) {
|
||||
return getType() == ewol::PhysicsShape::cylinder;
|
||||
};
|
||||
bool isCapsule(void) {
|
||||
return getType() == ewol::PhysicsShape::capsule;
|
||||
};
|
||||
bool isCone(void) {
|
||||
return getType() == ewol::PhysicsShape::cone;
|
||||
};
|
||||
bool isConvexHull(void) {
|
||||
return getType() == ewol::PhysicsShape::convexHull;
|
||||
};
|
||||
bool isSphere(void) {
|
||||
return getType() == ewol::PhysicsShape::sphere;
|
||||
};
|
||||
|
||||
virtual const PhysicsBox* toBox(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsBox* toBox(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCylinder* toCylinder(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCylinder* toCylinder(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCapsule* toCapsule(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCapsule* toCapsule(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsCone* toCone(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsCone* toCone(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsConvexHull* toConvexHull(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsConvexHull* toConvexHull(void) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual const PhysicsSphere* toSphere(void) const {
|
||||
return NULL;
|
||||
};
|
||||
virtual PhysicsSphere* toSphere(void) {
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
25
ege/physicsShape/PhysicsSphere.cpp
Normal file
25
ege/physicsShape/PhysicsSphere.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/physicsShape/PhysicsSphere.h>
|
||||
|
||||
|
||||
|
||||
bool ewol::PhysicsSphere::parse(const char* _line) {
|
||||
if (true == ewol::PhysicsShape::parse(_line)) {
|
||||
return true;
|
||||
}
|
||||
if(0 == strncmp(_line, "radius : ", 9) ) {
|
||||
sscanf(&_line[9], "%f", &m_radius );
|
||||
EWOL_VERBOSE(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
43
ege/physicsShape/PhysicsSphere.h
Normal file
43
ege/physicsShape/PhysicsSphere.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PHYSICS_SPHERE_H__
|
||||
#define __EWOL_PHYSICS_SPHERE_H__
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/physicsShape/PhysicsShape.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class PhysicsSphere : public ewol::PhysicsShape {
|
||||
public:
|
||||
PhysicsSphere(void) {};
|
||||
virtual ~PhysicsSphere(void) {};
|
||||
public:
|
||||
virtual bool parse(const char* _line);
|
||||
virtual void display(void) {};
|
||||
public:
|
||||
virtual enum type getType(void) {
|
||||
return ewol::PhysicsShape::sphere;
|
||||
};
|
||||
private:
|
||||
float m_radius; // props["radius"] = obj.scale.x
|
||||
public:
|
||||
float getRadius(void) const { return m_radius; };
|
||||
private:
|
||||
virtual const PhysicsSphere* toSphere(void) const {
|
||||
return this;
|
||||
};
|
||||
virtual PhysicsSphere* toSphere(void) {
|
||||
return this;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
1038
ege/resources/Mesh.cpp
Normal file
1038
ege/resources/Mesh.cpp
Normal file
File diff suppressed because it is too large
Load Diff
169
ege/resources/Mesh.h
Normal file
169
ege/resources/Mesh.h
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __MESH_H__
|
||||
#define __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>
|
||||
// 3 "float" elements
|
||||
#define MESH_VBO_VERTICES (0)
|
||||
// 2 "float" elements
|
||||
#define MESH_VBO_TEXTURE (1)
|
||||
// 3 "float" elements
|
||||
#define MESH_VBO_VERTICES_NORMAL (2)
|
||||
// Face normal position :
|
||||
#define MESH_VBO_FACE_NORMAL (3)
|
||||
// 4 "float" elements
|
||||
#define MESH_VBO_COLOR (4)
|
||||
|
||||
namespace ewol {
|
||||
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 {
|
||||
public:
|
||||
enum normalMode {
|
||||
normalModeNone,
|
||||
normalModeFace,
|
||||
normalModeVertex,
|
||||
};
|
||||
protected:
|
||||
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;
|
||||
MaterialGlId m_GLMaterial;
|
||||
ewol::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)
|
||||
protected:
|
||||
ewol::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);
|
||||
void generateVBO(void);
|
||||
private:
|
||||
void calculateNormaleFace(void);
|
||||
void calculateNormaleEdge(void);
|
||||
public :
|
||||
void createViewBox(const std::string& _materialName,float _size=1.0);
|
||||
private:
|
||||
bool loadOBJ(const std::string& _fileName);
|
||||
bool loadEMF(const std::string& _fileName);
|
||||
public:
|
||||
void addMaterial(const std::string& _name, ewol::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; };
|
||||
/**
|
||||
* @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; };
|
||||
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:
|
||||
/**
|
||||
* @brief set the shape pointer (no type == > user might know it ...)
|
||||
* @param[in] _shape The new shape (this remove the previous one)
|
||||
*/
|
||||
void setShape(void* _shape);
|
||||
/**
|
||||
* @brief get the pointer on the shame (no type)
|
||||
* @return Pointer on shape.
|
||||
*/
|
||||
void* getShape(void) { return m_pointerShape; };
|
||||
private:
|
||||
void (*m_functionFreeShape)(void* _pointer);
|
||||
public:
|
||||
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) { m_functionFreeShape = _functionFreeShape; };
|
||||
public:
|
||||
/**
|
||||
* @brief keep the resource pointer.
|
||||
* @note Never free this pointer by your own...
|
||||
* @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);
|
||||
/**
|
||||
* @brief release the keeped resources
|
||||
* @param[in,out] reference on the object pointer
|
||||
*/
|
||||
static void release(ewol::Mesh*& _object);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
133
ege/widget/Mesh.cpp
Normal file
133
ege/widget/Mesh.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Mesh.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
|
||||
|
||||
extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed";
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Mesh"
|
||||
|
||||
|
||||
|
||||
ewol::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");
|
||||
addEventId(ewolEventMeshPressed);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
if (_filename!="") {
|
||||
m_object = ewol::Mesh::keep(m_meshName);
|
||||
if (NULL == m_object) {
|
||||
EWOL_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ewol::widget::Mesh::~Mesh(void) {
|
||||
ewol::Mesh::release(m_object);
|
||||
}
|
||||
|
||||
void ewol::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())
|
||||
* etk::matRotate(vec3(0,1,0),m_angle.y())
|
||||
* etk::matRotate(vec3(0,0,1),m_angle.z());
|
||||
if (NULL != m_object) {
|
||||
m_object->draw(transformationMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::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(),
|
||||
m_origin.y(),
|
||||
m_size.x(),
|
||||
m_size.y());
|
||||
float ratio = m_size.x() / m_size.y();
|
||||
//EWOL_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 :
|
||||
//ewol::openGL::setMatrix(tmpMat);
|
||||
ewol::openGL::setMatrix(tmpProjection);
|
||||
|
||||
onDraw();
|
||||
ewol::openGL::pop();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::onRegenerateDisplay(void) {
|
||||
if (true == needRedraw()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::periodicCall(const ewol::EventTime& _event) {
|
||||
m_angle += m_angleSpeed*_event.getDeltaCall();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
|
||||
//EWOL_DEBUG("Event on BT ...");
|
||||
if (1 == _event.getId()) {
|
||||
if(ewol::keyEvent::statusSingle == _event.getStatus()) {
|
||||
generateEventId(ewolEventMeshPressed);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setFile(const std::string& _filename) {
|
||||
if( _filename!=""
|
||||
&& m_meshName != _filename ) {
|
||||
ewol::Mesh::release(m_object);
|
||||
m_meshName = _filename;
|
||||
m_object = ewol::Mesh::keep(m_meshName);
|
||||
if (NULL == m_object) {
|
||||
EWOL_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setPosition(const vec3& _pos) {
|
||||
m_position = _pos;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setAngle(const vec3& _angle) {
|
||||
m_angle = _angle;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
|
||||
if (_speed!=vec3(0,0,0)) {
|
||||
periodicCallEnable();
|
||||
} else {
|
||||
periodicCallDisable();
|
||||
}
|
||||
m_angleSpeed = _speed;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Mesh::setDistance(float _distance)
|
||||
{
|
||||
m_cameraDistance = _distance;
|
||||
markToRedraw();
|
||||
}
|
74
ege/widget/Mesh.h
Normal file
74
ege/widget/Mesh.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_WIDGET_MESH_H__
|
||||
#define __EWOL_WIDGET_MESH_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/resources/Mesh.h>
|
||||
|
||||
extern const char * const ewolEventMeshPressed;
|
||||
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Mesh :public ewol::Widget {
|
||||
private:
|
||||
// mesh name :
|
||||
std::string m_meshName;
|
||||
ewol::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
|
||||
virtual ~Mesh(void);
|
||||
public: // Derived function
|
||||
virtual void onRegenerateDisplay(void);
|
||||
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);
|
||||
public:
|
||||
/**
|
||||
* @brief set a mesh name file
|
||||
* @param[in] filename Name of the new mesh
|
||||
*/
|
||||
void setFile(const std::string& filename);
|
||||
/**
|
||||
* @brief set the mesh position
|
||||
* @param[in] pos The new position of the mesh
|
||||
*/
|
||||
void setPosition(const vec3& pos);
|
||||
/**
|
||||
* @brief set the mesh angle of view
|
||||
* @param[in] angle view angle of the mesh
|
||||
*/
|
||||
void setAngle(const vec3& angle);
|
||||
/**
|
||||
* @brief set the mesh angle speed
|
||||
* @param[in] spped radian speed of the mesh
|
||||
*/
|
||||
void setAngleSpeed(const vec3& speed);
|
||||
/**
|
||||
* @brief set the camera distance of the mesh
|
||||
* @param[in] dist Diatance of the mesh
|
||||
*/
|
||||
void setDistance(float distance);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user