[DEV] add physics parsing
This commit is contained in:
parent
937a6e5e9d
commit
3f2ba7907f
@ -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) );
|
||||
}
|
||||
|
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit 16bf072432200c30e6aa3683d4ea55cc03467cdb
|
||||
Subproject commit 3ac971ecb6c1a8d60593c1edc5db4368d3a601ca
|
@ -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<int32_t> 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<m_link.Size(); iii++) {
|
||||
if (m_link[iii] == id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_link.PushBack(id);
|
||||
};
|
||||
const vec3& GetPos(void)
|
||||
{
|
||||
return m_pos;
|
||||
};
|
||||
void SetPos(const vec3& pos)
|
||||
{
|
||||
m_pos = pos;
|
||||
};
|
||||
const vertex_te GetType(void)
|
||||
{
|
||||
return m_type;
|
||||
};
|
||||
etk::Vector<int32_t>& 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;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <ewol/renderer/resources/VirtualBufferObject.h>
|
||||
#include <ewol/renderer/Light.h>
|
||||
#include <ewol/renderer/Material.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsShape.h>
|
||||
// 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<float> 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<m_size.x()*m_size.y(); iii++) {
|
||||
m_data[iii] = 0;
|
||||
}
|
||||
}
|
||||
float Get(int32_t x, int32_t y) const
|
||||
{
|
||||
// We increment of the size to prevent the <0 result due to the "%" methode ...
|
||||
x %= m_size.x();
|
||||
y %= m_size.y();
|
||||
while (x<0) {
|
||||
x+= m_size.x();
|
||||
}
|
||||
while (y<0) {
|
||||
y+= m_size.y();
|
||||
}
|
||||
return m_data[x + y*m_size.x()];
|
||||
}
|
||||
float GetInterpolate(float x, float y) const
|
||||
{
|
||||
|
||||
while (x<0) { x+= 1.0; }
|
||||
while (y<0) { y+= 1.0; }
|
||||
while (x>=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<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;
|
||||
etk::Vector<ewol::PhysicsShape*> m_physics; //!< collision shape module ...
|
||||
protected:
|
||||
ewol::VirtualBufferObject* m_verticesVBO;
|
||||
public:
|
||||
|
24
sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp
Normal file
24
sources/ewol/renderer/resources/physicsShape/PhysicsBox.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/renderer/resources/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_DEBUG(" halfSize=" << m_size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
33
sources/ewol/renderer/resources/physicsShape/PhysicsBox.h
Normal file
33
sources/ewol/renderer/resources/physicsShape/PhysicsBox.h
Normal file
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 type_te GetType(void) { return ewol::PhysicsShape::box; };
|
||||
private:
|
||||
vec3 m_size;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/renderer/resources/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_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;
|
||||
}
|
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 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
|
29
sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp
Normal file
29
sources/ewol/renderer/resources/physicsShape/PhysicsCone.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/renderer/resources/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_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;
|
||||
}
|
36
sources/ewol/renderer/resources/physicsShape/PhysicsCone.h
Normal file
36
sources/ewol/renderer/resources/physicsShape/PhysicsCone.h
Normal file
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 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
|
@ -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/renderer/resources/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_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;
|
||||
}
|
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 type_te GetType(void) { return ewol::PhysicsShape::convexHull; };
|
||||
private:
|
||||
vec3 m_scale;
|
||||
etk::Vector<vec3> 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
|
@ -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/renderer/resources/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_DEBUG(" halfSize=" << m_size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 type_te GetType(void) { return ewol::PhysicsShape::cylinder; };
|
||||
private:
|
||||
vec3 m_size; //props["half-extents"] = out_scale3( scale )
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsShape.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsBox.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsCapsule.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsCone.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsConvexHull.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsCylinder.h>
|
||||
#include <ewol/renderer/resources/physicsShape/PhysicsSphere.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
66
sources/ewol/renderer/resources/physicsShape/PhysicsShape.h
Normal file
66
sources/ewol/renderer/resources/physicsShape/PhysicsShape.h
Normal file
@ -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 <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 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
|
||||
|
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/renderer/resources/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_DEBUG(" radius=" << m_radius);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
34
sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h
Normal file
34
sources/ewol/renderer/resources/physicsShape/PhysicsSphere.h
Normal file
@ -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 <etk/types.h>
|
||||
#include <ewol/renderer/resources/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 type_te GetType(void) { return ewol::PhysicsShape::sphere; };
|
||||
private:
|
||||
float m_radius; // props["radius"] = obj.scale.x
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user