[DEV] add special system
This commit is contained in:
parent
59bf3520f4
commit
3c83e6a76b
@ -74,7 +74,7 @@ namespace ege {
|
||||
inline uint32_t getUID() const {
|
||||
return m_uID;
|
||||
};
|
||||
private:
|
||||
protected:
|
||||
std::shared_ptr<ege::resource::Mesh> m_mesh; //!< Mesh of the Element (can be nullptr)
|
||||
btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it)
|
||||
public:
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include <ege/resource/Mesh.h>
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ege/resource/tools/viewBox.h>
|
||||
#include <ege/resource/tools/isoSphere.h>
|
||||
#include <ege/resource/tools/icoSphere.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "resource::Mesh"
|
||||
@ -20,11 +23,11 @@ ege::resource::Mesh::Mesh() :
|
||||
m_pointerShape(nullptr),
|
||||
m_functionFreeShape(nullptr) {
|
||||
addObjectType("ege::resource::Mesh");
|
||||
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::init(const std::string& _fileName, const std::string& _shaderName) {
|
||||
ewol::Resource::init(_fileName);
|
||||
addObjectType("ege::resource::Mesh");
|
||||
EGE_VERBOSE("Load a new mesh : '" << _fileName << "'");
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
@ -69,6 +72,7 @@ void ege::resource::Mesh::init(const std::string& _fileName, const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ege::resource::Mesh::~Mesh() {
|
||||
// remove dynamics dependencies :
|
||||
if (m_functionFreeShape!=nullptr) {
|
||||
@ -77,6 +81,23 @@ ege::resource::Mesh::~Mesh() {
|
||||
}
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::clean() {
|
||||
for (auto &elem : m_physics) {
|
||||
delete(elem);
|
||||
}
|
||||
m_physics.clear();
|
||||
for (int32_t iii=0; iii<m_materials.size(); ++iii) {
|
||||
delete(m_materials[iii]);
|
||||
}
|
||||
m_materials.clear();
|
||||
m_listFaces.clear();
|
||||
m_listVertexNormal.clear();
|
||||
m_listFacesNormal.clear();
|
||||
m_listUV.clear();
|
||||
m_listVertex.clear();
|
||||
}
|
||||
|
||||
|
||||
//#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
|
||||
void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
@ -288,96 +309,17 @@ void ege::resource::Mesh::generateVBO() {
|
||||
|
||||
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
|
||||
o---------------------o
|
||||
/. /|
|
||||
/ . / |
|
||||
/ . / |
|
||||
/ . / |
|
||||
/ . / |
|
||||
4 / . / |
|
||||
o---------------------o |
|
||||
| . |7 |
|
||||
| . | |
|
||||
| . | |
|
||||
| . | |
|
||||
| o..............|......o
|
||||
| . 1 | / 2
|
||||
| . | /
|
||||
| . | /
|
||||
| . | /
|
||||
| . | /
|
||||
|. |/
|
||||
o---------------------o
|
||||
0 3
|
||||
*/
|
||||
m_listVertex.push_back(vec3( _size, -_size, -_size)); // 0
|
||||
m_listVertex.push_back(vec3( _size, -_size, _size)); // 1
|
||||
m_listVertex.push_back(vec3(-_size, -_size, _size)); // 2
|
||||
m_listVertex.push_back(vec3(-_size, -_size, -_size)); // 3
|
||||
m_listVertex.push_back(vec3( _size, _size, -_size)); // 4
|
||||
m_listVertex.push_back(vec3( _size, _size, _size)); // 5
|
||||
m_listVertex.push_back(vec3(-_size, _size, _size)); // 6
|
||||
m_listVertex.push_back(vec3(-_size, _size, -_size)); // 7
|
||||
/*
|
||||
o----------o----------o----------o
|
||||
|8 |9 |10 |11
|
||||
| | | |
|
||||
| | | |
|
||||
| 0 | 1 | 2 |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
o----------o----------o----------o
|
||||
|4 |5 |6 |7
|
||||
| | | |
|
||||
| | | |
|
||||
| 3 | 4 | 5 |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
o----------o----------o----------o
|
||||
0 1 2 3
|
||||
*/
|
||||
m_listUV.push_back(vec2(0.0 , 0.0 )); // 0
|
||||
m_listUV.push_back(vec2(1.0/3.0, 0.0 )); // 1
|
||||
m_listUV.push_back(vec2(2.0/3.0, 0.0 )); // 2
|
||||
m_listUV.push_back(vec2(1.0 , 0.0 )); // 3
|
||||
m_listUV.push_back(vec2(0.0 , 0.5 )); // 4
|
||||
m_listUV.push_back(vec2(1.0/3.0, 0.5 )); // 5
|
||||
m_listUV.push_back(vec2(2.0/3.0, 0.5 )); // 6
|
||||
m_listUV.push_back(vec2(1.0 , 0.5 )); // 7
|
||||
m_listUV.push_back(vec2(0.0 , 1.0 )); // 8
|
||||
m_listUV.push_back(vec2(1.0/3.0, 1.0 )); // 9
|
||||
m_listUV.push_back(vec2(2.0/3.0, 1.0 )); // 10
|
||||
m_listUV.push_back(vec2(1.0 , 1.0 )); // 11
|
||||
|
||||
if (m_listFaces.exist(_materialName) == false) {
|
||||
FaceIndexing empty;
|
||||
m_listFaces.add(_materialName, empty);
|
||||
}
|
||||
{
|
||||
FaceIndexing& tmpElement = m_listFaces[_materialName];
|
||||
tmpElement.m_faces.push_back(Face(0,1, 1,5, 2,6)); // 4
|
||||
tmpElement.m_faces.push_back(Face(0,1, 2,6, 3,2)); // 4
|
||||
tmpElement.m_faces.push_back(Face(4,4, 0,0, 3,1)); // 3
|
||||
tmpElement.m_faces.push_back(Face(4,4, 3,1, 7,5)); // 3
|
||||
tmpElement.m_faces.push_back(Face(2,6, 6,10, 7,11)); // 2
|
||||
tmpElement.m_faces.push_back(Face(2,6, 7,11, 3,7)); // 2
|
||||
tmpElement.m_faces.push_back(Face(4,2, 7,3, 6,7)); // 5
|
||||
tmpElement.m_faces.push_back(Face(4,2, 6,7, 5,6)); // 5
|
||||
tmpElement.m_faces.push_back(Face(1,5, 5,9, 6,10)); // 1
|
||||
tmpElement.m_faces.push_back(Face(1,5, 6,10, 2,6)); // 1
|
||||
tmpElement.m_faces.push_back(Face(0,4, 4,8, 5,9)); // 0
|
||||
tmpElement.m_faces.push_back(Face(0,4, 5,9, 1,5)); // 0
|
||||
}
|
||||
ege::viewBox::create(m_materials, m_listFaces, m_listVertex, m_listUV,
|
||||
_materialName, _size);
|
||||
calculateNormaleFace();
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::createIcoSphere(const std::string& _materialName,float _size) {
|
||||
m_normalMode = normalModeNone;
|
||||
ege::icoSphere::create(m_materials, m_listFaces, m_listVertex, m_listUV,
|
||||
_materialName, 2);
|
||||
calculateNormaleFace();
|
||||
}
|
||||
|
||||
bool ege::resource::Mesh::loadOBJ(const std::string& _fileName) {
|
||||
m_normalMode = normalModeNone;
|
||||
|
@ -18,6 +18,9 @@
|
||||
#include <ewol/resource/VirtualBufferObject.h>
|
||||
#include <ege/Light.h>
|
||||
#include <ege/Material.h>
|
||||
#include <ege/resource/tools/Face.h>
|
||||
#include <ege/resource/tools/FaceIndexing.h>
|
||||
|
||||
#include <ege/physicsShape/PhysicsShape.h>
|
||||
// 3 "float" elements
|
||||
#define MESH_VBO_VERTICES (0)
|
||||
@ -31,51 +34,6 @@
|
||||
#define MESH_VBO_COLOR (4)
|
||||
|
||||
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() {};
|
||||
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 Mesh : public ewol::Resource {
|
||||
public:
|
||||
@ -109,6 +67,7 @@ namespace ege {
|
||||
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
|
||||
etk::Hash<ege::Material*> m_materials;
|
||||
std::vector<ege::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
void clean();
|
||||
protected:
|
||||
std::shared_ptr<ewol::resource::VirtualBufferObject> m_verticesVBO;
|
||||
protected:
|
||||
@ -131,6 +90,7 @@ namespace ege {
|
||||
void calculateNormaleEdge();
|
||||
public :
|
||||
void createViewBox(const std::string& _materialName,float _size=1.0);
|
||||
void createIcoSphere(const std::string& _materialName,float _size=1.0);
|
||||
private:
|
||||
bool loadOBJ(const std::string& _fileName);
|
||||
bool loadEMF(const std::string& _fileName);
|
||||
|
0
ege/resource/tools/Face.cpp
Normal file
0
ege/resource/tools/Face.cpp
Normal file
52
ege/resource/tools/Face.h
Normal file
52
ege/resource/tools/Face.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_FACE_H__
|
||||
#define __EGE_FACE_H__
|
||||
|
||||
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() {};
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
0
ege/resource/tools/FaceIndexing.cpp
Normal file
0
ege/resource/tools/FaceIndexing.cpp
Normal file
21
ege/resource/tools/FaceIndexing.h
Normal file
21
ege/resource/tools/FaceIndexing.h
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_FACE_INDEXING_H__
|
||||
#define __EGE_FACE_INDEXING_H__
|
||||
|
||||
namespace ege {
|
||||
class FaceIndexing {
|
||||
public:
|
||||
std::vector<Face> m_faces;
|
||||
std::vector<uint32_t> m_index;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
133
ege/resource/tools/icoSphere.cpp
Normal file
133
ege/resource/tools/icoSphere.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/resource/tools/icoSphere.h>
|
||||
|
||||
// return index of point in the middle of p1 and p2
|
||||
static int32_t getMiddlePoint(std::vector<vec3>& _listVertex, int32_t _p1, int32_t _p2) {
|
||||
vec3 middle = (_listVertex[_p1] + _listVertex[_p2])*0.5f;
|
||||
// check if this point exist:
|
||||
int32_t id=0;
|
||||
for (auto &point : _listVertex) {
|
||||
if (middle == point) {
|
||||
return id;
|
||||
}
|
||||
id++;
|
||||
}
|
||||
_listVertex.push_back(middle.normalize());
|
||||
return _listVertex.size()-1;
|
||||
}
|
||||
|
||||
void ege::icoSphere::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel) {
|
||||
/*
|
||||
5
|
||||
o
|
||||
/|
|
||||
/ |
|
||||
/ |
|
||||
/ |
|
||||
11 / | 9
|
||||
Z o--------/...---------0 1
|
||||
| y | 4o o....|......|--o
|
||||
| / | |. 0 | | /
|
||||
| / | .| . |/
|
||||
| / | . | . |
|
||||
|/ | / | . .|
|
||||
o-------x | / | . / |
|
||||
o--/....|........../--o
|
||||
10 / | 7o / 8
|
||||
/ . . /
|
||||
/ . . /
|
||||
o---------------o
|
||||
2 | / 3
|
||||
| /
|
||||
|/
|
||||
o
|
||||
6
|
||||
*/
|
||||
// create 12 vertices of a icosahedron
|
||||
double size = 1.0;
|
||||
double ttt = (1.0 + sqrt(5.0)) / 2.0*size;
|
||||
EGE_ERROR("podition : " << ttt);
|
||||
_listVertex.push_back(vec3(-size, ttt, 0.0).normalize()); // 0
|
||||
_listVertex.push_back(vec3( size, ttt, 0.0).normalize()); // 1
|
||||
_listVertex.push_back(vec3(-size, -ttt, 0.0).normalize()); // 2
|
||||
_listVertex.push_back(vec3( size, -ttt, 0.0).normalize()); // 3
|
||||
|
||||
_listVertex.push_back(vec3( 0.0, -1, ttt).normalize()); // 4
|
||||
_listVertex.push_back(vec3( 0.0, 1, ttt).normalize()); // 5
|
||||
_listVertex.push_back(vec3( 0.0, -1, -ttt).normalize()); // 6
|
||||
_listVertex.push_back(vec3( 0.0, 1, -ttt).normalize()); // 7
|
||||
|
||||
_listVertex.push_back(vec3( ttt, 0.0, -size).normalize()); // 8
|
||||
_listVertex.push_back(vec3( ttt, 0.0, size).normalize()); // 9
|
||||
_listVertex.push_back(vec3(-ttt, 0.0, -size).normalize()); // 10
|
||||
_listVertex.push_back(vec3(-ttt, 0.0, size).normalize()); // 11
|
||||
|
||||
// _listUV ==> TODO : very bad code ... get from viewBox ....
|
||||
_listUV.push_back(vec2(0.0, 0.0 )); // 0
|
||||
_listUV.push_back(vec2(0.0, 1.0 )); // 1
|
||||
_listUV.push_back(vec2(1.0, 0.0 )); // 2
|
||||
|
||||
for (auto &elem : _listVertex) {
|
||||
EGE_INFO("plop : " << etk::to_string(elem));
|
||||
}
|
||||
|
||||
if (_listFaces.exist(_materialName) == false) {
|
||||
FaceIndexing empty;
|
||||
_listFaces.add(_materialName, empty);
|
||||
}
|
||||
{
|
||||
FaceIndexing& tmpElement = _listFaces[_materialName];
|
||||
// 5 faces around point 0
|
||||
tmpElement.m_faces.push_back(Face(0,0, 11,1, 5,2));
|
||||
tmpElement.m_faces.push_back(Face(0,0, 5,1, 1,2));
|
||||
tmpElement.m_faces.push_back(Face(0,0, 1,1, 7,2));
|
||||
tmpElement.m_faces.push_back(Face(0,0, 7,1, 10,2));
|
||||
tmpElement.m_faces.push_back(Face(0,0, 10,1, 11,2));
|
||||
|
||||
// 5 adjacent faces
|
||||
tmpElement.m_faces.push_back(Face( 1,0, 5,1, 9,2));
|
||||
tmpElement.m_faces.push_back(Face( 5,0, 11,1, 4,2));
|
||||
tmpElement.m_faces.push_back(Face(11,0, 10,1, 2,2));
|
||||
tmpElement.m_faces.push_back(Face(10,0, 7,1, 6,2));
|
||||
tmpElement.m_faces.push_back(Face( 7,0, 1,1, 8,2));
|
||||
|
||||
// 5 faces around point 3
|
||||
tmpElement.m_faces.push_back(Face(3,0, 9,1, 4,2));
|
||||
tmpElement.m_faces.push_back(Face(3,0, 4,1, 2,2));
|
||||
tmpElement.m_faces.push_back(Face(3,0, 2,1, 6,2));
|
||||
tmpElement.m_faces.push_back(Face(3,0, 6,1, 8,2));
|
||||
tmpElement.m_faces.push_back(Face(3,0, 8,1, 9,2));
|
||||
|
||||
// 5 adjacent faces
|
||||
tmpElement.m_faces.push_back(Face(4,0, 9,1, 5,2));
|
||||
tmpElement.m_faces.push_back(Face(2,0, 4,1, 11,2));
|
||||
tmpElement.m_faces.push_back(Face(6,0, 2,1, 10,2));
|
||||
tmpElement.m_faces.push_back(Face(8,0, 6,1, 7,2));
|
||||
tmpElement.m_faces.push_back(Face(9,0, 8,1, 1,2));
|
||||
// refine triangles
|
||||
for (int i = 0; i < _recursionLevel; i++) {
|
||||
std::vector<Face> listFaces;
|
||||
for (auto &tri : tmpElement.m_faces) {
|
||||
// replace triangle by 4 triangles
|
||||
int32_t a = getMiddlePoint(_listVertex, tri.m_vertex[0], tri.m_vertex[1]);
|
||||
int32_t b = getMiddlePoint(_listVertex, tri.m_vertex[1], tri.m_vertex[2]);
|
||||
int32_t c = getMiddlePoint(_listVertex, tri.m_vertex[2], tri.m_vertex[0]);
|
||||
listFaces.push_back(Face(tri.m_vertex[0],0, a,1, c,2));
|
||||
listFaces.push_back(Face(tri.m_vertex[1],0, b,1, a,2));
|
||||
listFaces.push_back(Face(tri.m_vertex[2],0, c,1, b,2));
|
||||
listFaces.push_back(Face(a,0, b,1, c,2));
|
||||
}
|
||||
tmpElement.m_faces = listFaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
ege/resource/tools/icoSphere.h
Normal file
26
ege/resource/tools/icoSphere.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_TOOLS_ICOSPHERE_H__
|
||||
#define __EGE_TOOLS_ICOSPHERE_H__
|
||||
|
||||
#include <ege/resource/tools/Face.h>
|
||||
#include <ege/resource/tools/FaceIndexing.h>
|
||||
#include <etk/Hash.h>
|
||||
#include <ege/Material.h>
|
||||
|
||||
namespace ege {
|
||||
namespace icoSphere {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
27
ege/resource/tools/isoSphere.cpp
Normal file
27
ege/resource/tools/isoSphere.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/resource/tools/isoSphere.h>
|
||||
|
||||
void ege::isoSphere::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel) {
|
||||
_recursionLevel = std::max(_recursionLevel, 3);
|
||||
float size = 1.0f;
|
||||
//Add top and buttom point:
|
||||
_listVertex.push_back(vec3(0.0f, 0.0f, size)); // 0 (top)
|
||||
_listVertex.push_back(vec3(0.0f, 0.0f, -size)); // 1 (buttom)
|
||||
_listUV.push_back(vec2(0.5, 1.0 )); // 0
|
||||
_listUV.push_back(vec2(0.5, 0.0 )); // 1
|
||||
|
||||
for (int32_t iii=0; iii<_recursionLevel; iii++) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
26
ege/resource/tools/isoSphere.h
Normal file
26
ege/resource/tools/isoSphere.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_TOOLS_ISOSPHERE_H__
|
||||
#define __EGE_TOOLS_ISOSPHERE_H__
|
||||
|
||||
#include <ege/resource/tools/Face.h>
|
||||
#include <ege/resource/tools/FaceIndexing.h>
|
||||
#include <etk/Hash.h>
|
||||
#include <ege/Material.h>
|
||||
|
||||
namespace ege {
|
||||
namespace isoSphere {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
103
ege/resource/tools/viewBox.cpp
Normal file
103
ege/resource/tools/viewBox.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/resource/tools/viewBox.h>
|
||||
|
||||
|
||||
|
||||
void ege::viewBox::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size) {
|
||||
// This is the direct generation basis on the .obj system
|
||||
/*
|
||||
5 6
|
||||
o---------------------o
|
||||
/. /|
|
||||
/ . / |
|
||||
/ . / |
|
||||
/ . / |
|
||||
/ . / |
|
||||
4 / . / |
|
||||
o---------------------o |
|
||||
| . |7 |
|
||||
| . | |
|
||||
| . | |
|
||||
| . | |
|
||||
| o..............|......o
|
||||
| . 1 | / 2
|
||||
| . | /
|
||||
| . | /
|
||||
| . | /
|
||||
| . | /
|
||||
|. |/
|
||||
o---------------------o
|
||||
0 3
|
||||
*/
|
||||
_listVertex.push_back(vec3( _size, -_size, -_size)); // 0
|
||||
_listVertex.push_back(vec3( _size, -_size, _size)); // 1
|
||||
_listVertex.push_back(vec3(-_size, -_size, _size)); // 2
|
||||
_listVertex.push_back(vec3(-_size, -_size, -_size)); // 3
|
||||
_listVertex.push_back(vec3( _size, _size, -_size)); // 4
|
||||
_listVertex.push_back(vec3( _size, _size, _size)); // 5
|
||||
_listVertex.push_back(vec3(-_size, _size, _size)); // 6
|
||||
_listVertex.push_back(vec3(-_size, _size, -_size)); // 7
|
||||
/*
|
||||
o----------o----------o----------o
|
||||
|8 |9 |10 |11
|
||||
| | | |
|
||||
| | | |
|
||||
| 0 | 1 | 2 |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
o----------o----------o----------o
|
||||
|4 |5 |6 |7
|
||||
| | | |
|
||||
| | | |
|
||||
| 3 | 4 | 5 |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
o----------o----------o----------o
|
||||
0 1 2 3
|
||||
*/
|
||||
_listUV.push_back(vec2(0.0 , 0.0 )); // 0
|
||||
_listUV.push_back(vec2(1.0/3.0, 0.0 )); // 1
|
||||
_listUV.push_back(vec2(2.0/3.0, 0.0 )); // 2
|
||||
_listUV.push_back(vec2(1.0 , 0.0 )); // 3
|
||||
_listUV.push_back(vec2(0.0 , 0.5 )); // 4
|
||||
_listUV.push_back(vec2(1.0/3.0, 0.5 )); // 5
|
||||
_listUV.push_back(vec2(2.0/3.0, 0.5 )); // 6
|
||||
_listUV.push_back(vec2(1.0 , 0.5 )); // 7
|
||||
_listUV.push_back(vec2(0.0 , 1.0 )); // 8
|
||||
_listUV.push_back(vec2(1.0/3.0, 1.0 )); // 9
|
||||
_listUV.push_back(vec2(2.0/3.0, 1.0 )); // 10
|
||||
_listUV.push_back(vec2(1.0 , 1.0 )); // 11
|
||||
|
||||
if (_listFaces.exist(_materialName) == false) {
|
||||
FaceIndexing empty;
|
||||
_listFaces.add(_materialName, empty);
|
||||
}
|
||||
{
|
||||
FaceIndexing& tmpElement = _listFaces[_materialName];
|
||||
tmpElement.m_faces.push_back(Face(0,1, 1,5, 2,6)); // 4
|
||||
tmpElement.m_faces.push_back(Face(0,1, 2,6, 3,2)); // 4
|
||||
tmpElement.m_faces.push_back(Face(4,4, 0,0, 3,1)); // 3
|
||||
tmpElement.m_faces.push_back(Face(4,4, 3,1, 7,5)); // 3
|
||||
tmpElement.m_faces.push_back(Face(2,6, 6,10, 7,11)); // 2
|
||||
tmpElement.m_faces.push_back(Face(2,6, 7,11, 3,7)); // 2
|
||||
tmpElement.m_faces.push_back(Face(4,2, 7,3, 6,7)); // 5
|
||||
tmpElement.m_faces.push_back(Face(4,2, 6,7, 5,6)); // 5
|
||||
tmpElement.m_faces.push_back(Face(1,5, 5,9, 6,10)); // 1
|
||||
tmpElement.m_faces.push_back(Face(1,5, 6,10, 2,6)); // 1
|
||||
tmpElement.m_faces.push_back(Face(0,4, 4,8, 5,9)); // 0
|
||||
tmpElement.m_faces.push_back(Face(0,4, 5,9, 1,5)); // 0
|
||||
}
|
||||
}
|
26
ege/resource/tools/viewBox.h
Normal file
26
ege/resource/tools/viewBox.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_TOOLS_VIEWBOX_H__
|
||||
#define __EGE_TOOLS_VIEWBOX_H__
|
||||
|
||||
#include <ege/resource/tools/Face.h>
|
||||
#include <ege/resource/tools/FaceIndexing.h>
|
||||
#include <etk/Hash.h>
|
||||
#include <ege/Material.h>
|
||||
|
||||
namespace ege {
|
||||
namespace viewBox {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,9 @@ def create(target):
|
||||
'ege/Environement.cpp',
|
||||
'ege/resource/Mesh.cpp',
|
||||
'ege/resource/ParticuleMesh.cpp',
|
||||
'ege/resource/tools/icoSphere.cpp',
|
||||
'ege/resource/tools/isoSphere.cpp',
|
||||
'ege/resource/tools/viewBox.cpp',
|
||||
'ege/Light.cpp',
|
||||
'ege/Material.cpp',
|
||||
'ege/physicsShape/PhysicsShape.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user