From 3f2ba7907f335f1333093705aca93fe57e1ca9af Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 11 Aug 2013 22:32:33 +0200 Subject: [PATCH] [DEV] add physics parsing --- data/textured3D2.vert | 2 - external/etk | 2 +- sources/ewol/renderer/resources/Mesh.cpp | 80 +++++++------------ sources/ewol/renderer/resources/Mesh.h | 72 +---------------- .../resources/physicsShape/PhysicsBox.cpp | 24 ++++++ .../resources/physicsShape/PhysicsBox.h | 33 ++++++++ .../resources/physicsShape/PhysicsCapsule.cpp | 29 +++++++ .../resources/physicsShape/PhysicsCapsule.h | 36 +++++++++ .../resources/physicsShape/PhysicsCone.cpp | 29 +++++++ .../resources/physicsShape/PhysicsCone.h | 36 +++++++++ .../physicsShape/PhysicsConvexHull.cpp | 28 +++++++ .../physicsShape/PhysicsConvexHull.h | 43 ++++++++++ .../physicsShape/PhysicsCylinder.cpp | 23 ++++++ .../resources/physicsShape/PhysicsCylinder.h | 34 ++++++++ .../resources/physicsShape/PhysicsShape.cpp | 59 ++++++++++++++ .../resources/physicsShape/PhysicsShape.h | 66 +++++++++++++++ .../resources/physicsShape/PhysicsSphere.cpp | 26 ++++++ .../resources/physicsShape/PhysicsSphere.h | 34 ++++++++ sources/lutin_ewol.py | 7 ++ 19 files changed, 538 insertions(+), 125 deletions(-) create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsBox.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCone.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsShape.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsShape.h create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsSphere.cpp create mode 100644 sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h diff --git a/data/textured3D2.vert b/data/textured3D2.vert index bf56ca53..69ddada3 100644 --- a/data/textured3D2.vert +++ b/data/textured3D2.vert @@ -6,7 +6,6 @@ precision mediump int; attribute vec3 EW_coord3d; attribute vec2 EW_texture2d; attribute vec3 EW_normal; -attribute vec3 EW_faceNormal; uniform mat4 EW_MatrixTransformation; uniform mat4 EW_MatrixPosition; @@ -23,5 +22,4 @@ void main(void) { MatrixPosition[3][1] = 0.0; MatrixPosition[3][2] = 0.0; v_ecNormal = vec3(MatrixPosition * vec4(EW_normal, 1.0) ); - //v_ecNormal = vec3(MatrixPosition * vec4(EW_faceNormal, 1.0) ); } diff --git a/external/etk b/external/etk index 16bf0724..3ac971ec 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 16bf072432200c30e6aa3683d4ea55cc03467cdb +Subproject commit 3ac971ecb6c1a8d60593c1edc5db4368d3a601ca diff --git a/sources/ewol/renderer/resources/Mesh.cpp b/sources/ewol/renderer/resources/Mesh.cpp index 8128bd4f..87c653bb 100644 --- a/sources/ewol/renderer/resources/Mesh.cpp +++ b/sources/ewol/renderer/resources/Mesh.cpp @@ -14,54 +14,6 @@ #undef __class__ #define __class__ "Mesh" -typedef enum { - VERTEX_OLD, - VERTEX_CENTER_FACE, - VERTEX_CERTER_EDGE -} vertex_te; - -class VertexNode { - private: - vertex_te m_type; - vec3 m_pos; - etk::Vector m_link; - public: - VertexNode(vertex_te type, const vec3& pos) : - m_type(type), - m_pos(pos) - { - - }; - void AddLink(int32_t id) - { - for(int32_t iii=0; iii& GetLink(void) - { - return m_link; - }; - -}; - - - ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) : ewol::Resource(_fileName), m_normalMode(normalModeNone) @@ -80,7 +32,6 @@ ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d"); m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); m_GLNormal = m_GLprogram->GetAttribute("EW_normal"); - m_GLNormalFace = m_GLprogram->GetAttribute("EW_faceNormal"); m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); m_GLMatrixPosition = m_GLprogram->GetUniform("EW_MatrixPosition"); // Link material and Lights @@ -579,7 +530,7 @@ int32_t CountIndent(etk::FSNode& _file) return nbIndent; } -char* LoadNextData(char* _elementLine, int64_t _maxData, etk::FSNode& _file, bool _removeTabs=false, bool _stopColomn=false) +char* LoadNextData(char* _elementLine, int64_t _maxData, etk::FSNode& _file, bool _removeTabs=false, bool _stopColomn=false, bool _stopPipe=true) { memset(_elementLine, 0, _maxData); char * element = _elementLine; @@ -599,7 +550,8 @@ char* LoadNextData(char* _elementLine, int64_t _maxData, etk::FSNode& _file, boo } if( current == '\n' || current == '\r' - || current == '|' + || ( current == '|' + && _stopPipe==true) || ( current == ':' && _stopColomn==true) ) { @@ -694,6 +646,8 @@ bool ewol::Mesh::LoadEMF(const etk::UString& _fileName) // material global param : etk::UString materialName = ""; ewol::Material* material = NULL; + // physical shape: + ewol::PhysicsShape* physics = NULL; while(1) { int32_t level = CountIndent(fileName); if (level==0) { @@ -896,7 +850,29 @@ bool ewol::Mesh::LoadEMF(const etk::UString& _fileName) break; case EMFModuleMeshPhysics: case EMFModuleMeshPhysicsNamed: - JumpEndLine(fileName); + if (NULL == LoadNextData(inputDataLine, 2048, fileName, true, false, false)) { + // reach end of file ... + break; + } + RemoveEndLine(inputDataLine); + if (level == 3) { + physics = ewol::PhysicsShape::Create(inputDataLine); + if (physics==NULL) { + EWOL_ERROR("Allocation error when creating physical shape ..."); + continue; + } + m_physics.PushBack(physics); + EWOL_DEBUG(" " << inputDataLine); + currentMode = EMFModuleMeshPhysicsNamed; + } else if (currentMode == EMFModuleMeshPhysicsNamed) { + if (physics == NULL) { + EWOL_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ..."); + continue; + } + if (false == physics->Parse(inputDataLine)) { + EWOL_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ..."); + } + } break; } continue; diff --git a/sources/ewol/renderer/resources/Mesh.h b/sources/ewol/renderer/resources/Mesh.h index 1004d89e..61533c63 100644 --- a/sources/ewol/renderer/resources/Mesh.h +++ b/sources/ewol/renderer/resources/Mesh.h @@ -18,6 +18,7 @@ #include #include #include +#include // 3 "float" elements #define MESH_VBO_VERTICES (0) // 2 "float" elements @@ -31,75 +32,6 @@ namespace ewol { - class DisplacementTable - { - private: - ivec2 m_size; - public: - etk::Vector m_data; - DisplacementTable(const ivec2& size) : - m_size(size), - m_data(size.x()*size.y()) - { - // TODO : Check input ... - m_data.ReSize(m_size.x()*m_size.y(), 0); - for(int32_t iii=0; iii=1.0) { x-= 1.0; } - while (y>=1.0) { y-= 1.0; } - x *= m_size.x(); - y *= m_size.y(); - //get fractional part of x and y - float fractX = x - (int32_t)x; - float fractY = y - (int32_t)y; - - //wrap around - int32_t x1 = (int32_t)x; - int32_t y1 = (int32_t)y; - - //neighbor values - int32_t x2 = x1 - 1; - int32_t y2 = y1 - 1; - - //smooth the noise with bilinear interpolation - float value = 0.0; - value += fractX * fractY * Get(x1, y1); - value += fractX * (1 - fractY) * Get(x1, y2); - value += (1 - fractX) * fractY * Get(x2, y1); - value += (1 - fractX) * (1 - fractY) * Get(x2, y2); - return value; - } - void Set(int32_t x, int32_t y, float val) - { - // We increment of the size to prevent the <0 result due to the "%" methode ... - x += m_size.x(); - y += m_size.y(); - x %= m_size.x(); - y %= m_size.y(); - m_data[x + y*m_size.x()] = val; - } - const ivec2& GetSize(void) const { return m_size; }; - }; class Face { public: @@ -159,7 +91,6 @@ namespace ewol int32_t m_GLMatrix; int32_t m_GLMatrixPosition; int32_t m_GLNormal; - int32_t m_GLNormalFace; int32_t m_GLtexture; int32_t m_bufferOfset; int32_t m_numberOfElments; @@ -172,6 +103,7 @@ namespace ewol etk::Vector m_listVertexNormal; //!< List of all Face normal, when calculated etk::Hash m_listFaces; //!< List of all Face for the mesh etk::Hash m_materials; + etk::Vector m_physics; //!< collision shape module ... protected: ewol::VirtualBufferObject* m_verticesVBO; public: diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp new file mode 100644 index 00000000..76305d0e --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp @@ -0,0 +1,24 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + + +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_DEBUG(" halfSize=" << m_size); + return true; + } + return false; +} diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsBox.h b/sources/ewol/renderer/resources/physicsShape/PhysicsBox.h new file mode 100644 index 00000000..efd929a8 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsBox.h @@ -0,0 +1,33 @@ +/** + * @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 +#include + +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 type_te GetType(void) { return ewol::PhysicsShape::box; }; + private: + vec3 m_size; + }; +}; + +#endif diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.cpp new file mode 100644 index 00000000..2eb23292 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.cpp @@ -0,0 +1,29 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + + +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_DEBUG(" radius=" << m_radius); + return true; + } + if(0==strncmp(_line, "height : ", 9) ) { + sscanf(&_line[9], "%f", &m_height ); + EWOL_DEBUG(" height=" << m_height); + return true; + } + return false; +} diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.h b/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.h new file mode 100644 index 00000000..8e304a47 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCapsule.h @@ -0,0 +1,36 @@ +/** + * @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 +#include + + +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 type_te GetType(void) { return ewol::PhysicsShape::capsule; }; + private: + float m_radius; // props["radius"] = obj.scale.x + float m_height; // props["height"] = obj.scale.z + }; +}; + + +#endif diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp new file mode 100644 index 00000000..90728918 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp @@ -0,0 +1,29 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + + +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_DEBUG(" radius=" << m_radius); + return true; + } + if(0==strncmp(_line, "height : ", 9) ) { + sscanf(&_line[9], "%f", &m_height ); + EWOL_DEBUG(" height=" << m_height); + return true; + } + return false; +} diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCone.h b/sources/ewol/renderer/resources/physicsShape/PhysicsCone.h new file mode 100644 index 00000000..9f1a2d5c --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCone.h @@ -0,0 +1,36 @@ +/** + * @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 +#include + + +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 type_te GetType(void) { return ewol::PhysicsShape::cone; }; + private: + float m_radius; // props["radius"] = obj.scale.x + float m_height; // props["height"] = obj.scale.z * 2.0 + }; +}; + + +#endif diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.cpp new file mode 100644 index 00000000..34a33767 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.cpp @@ -0,0 +1,28 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + + +bool ewol::PhysicsConvexHull::Parse(const char* _line) +{ + if (true== ewol::PhysicsShape::Parse(_line)) { + return true; + } + if(0==strncmp(_line, "points : ", 8) ) { + EWOL_TODO("convex hull point parsing ..."); + return true; + } + if(0==strncmp(_line, "scale : ", 8) ) { + sscanf(&_line[8], "%f", &m_scale ); + EWOL_DEBUG(" scale=" << m_scale); + return true; + } + return false; +} diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.h b/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.h new file mode 100644 index 00000000..77f8afc3 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsConvexHull.h @@ -0,0 +1,43 @@ +/** + * @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 +#include + + +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 type_te GetType(void) { return ewol::PhysicsShape::convexHull; }; + private: + vec3 m_scale; + etk::Vector m_points; + /* + mesh = obj.to_mesh( bpy.context.scene, True, 'PREVIEW' ) + props["points"] = "" + for v in mesh.vertices: + props["points"] += "" + out_point3( v.co ) + "|" + props["points"] = props["points"].rstrip("|") + */ + }; +}; + + +#endif diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.cpp new file mode 100644 index 00000000..23fbfffd --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.cpp @@ -0,0 +1,23 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + +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_DEBUG(" halfSize=" << m_size); + return true; + } + return false; +} diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.h b/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.h new file mode 100644 index 00000000..481df9ca --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsCylinder.h @@ -0,0 +1,34 @@ +/** + * @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 +#include + + +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 type_te GetType(void) { return ewol::PhysicsShape::cylinder; }; + private: + vec3 m_size; //props["half-extents"] = out_scale3( scale ) + }; +}; + +#endif diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsShape.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsShape.cpp new file mode 100644 index 00000000..a6200a18 --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsShape.cpp @@ -0,0 +1,59 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include +#include +#include +#include +#include +#include +#include + + +ewol::PhysicsShape* ewol::PhysicsShape::Create(const etk::UString& _name) +{ + ewol::PhysicsShape* tmpp = NULL; + etk::UString name = _name.ToLower(); + 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_DEBUG(" 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_DEBUG(" Rotate=" << m_quaternion); + return true; + } + return false; +} + diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsShape.h b/sources/ewol/renderer/resources/physicsShape/PhysicsShape.h new file mode 100644 index 00000000..51fdc88d --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsShape.h @@ -0,0 +1,66 @@ +/** + * @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 +#include +#include +#include + + +namespace ewol +{ + class PhysicsBox; + class PhysicsCylinder; + class PhysicsCapsule; + class PhysicsCone; + class PhysicsConvexHull; + class PhysicsSphere; + + class PhysicsShape + { + public: + static PhysicsShape* Create(const etk::UString& _name); + public: + typedef enum { + unknow, + box, + capsule, + cone, + convexHull, + cylinder, + sphere + } type_te; + public: + PhysicsShape(void) {}; + virtual ~PhysicsShape(void) {}; + public: + virtual type_te GetType(void) { return ewol::PhysicsShape::unknow; }; + + public: + virtual bool Parse(const char* _line); + virtual void Display(void) {}; + private: + vec4 m_quaternion; + public: + + private: + vec3 m_origin; + public: + + public: + //virtual const PhysicsBox* ToBox(void) { return ; + }; +}; + + +#endif + diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.cpp b/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.cpp new file mode 100644 index 00000000..007a442c --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.cpp @@ -0,0 +1,26 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ +#include +#include + + + +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_DEBUG(" radius=" << m_radius); + return true; + } + return false; +} + + diff --git a/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h b/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h new file mode 100644 index 00000000..84ee674b --- /dev/null +++ b/sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h @@ -0,0 +1,34 @@ +/** + * @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 +#include + + +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 type_te GetType(void) { return ewol::PhysicsShape::sphere; }; + private: + float m_radius; // props["radius"] = obj.scale.x + }; +}; + +#endif diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index c8a585b7..a54f9ea5 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -55,6 +55,13 @@ def Create(target): 'ewol/renderer/resources/Texture.cpp', 'ewol/renderer/resources/Colored3DObject.cpp', 'ewol/renderer/resources/Image.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsShape.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsBox.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsCapsule.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsCone.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsConvexHull.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsCylinder.cpp', + 'ewol/renderer/resources/physicsShape/PhysicsSphere.cpp', 'ewol/renderer/ResourceManager.cpp']) # Audio system