From fd136fb6563f31fec0de8a36116c2a8562de8a9f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 1 Oct 2014 22:17:03 +0200 Subject: [PATCH] [DEV] add icosphere correct --- ege/resource/Mesh.cpp | 2 +- ege/resource/tools/icoSphere.cpp | 88 +++++++++++++++++++++++++++++++- ege/resource/tools/icoSphere.h | 2 +- 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/ege/resource/Mesh.cpp b/ege/resource/Mesh.cpp index e049b69..15d5f7a 100644 --- a/ege/resource/Mesh.cpp +++ b/ege/resource/Mesh.cpp @@ -317,7 +317,7 @@ void ege::resource::Mesh::createViewBox(const std::string& _materialName,float _ 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); + _materialName, _size, 3); calculateNormaleFace(); } diff --git a/ege/resource/tools/icoSphere.cpp b/ege/resource/tools/icoSphere.cpp index 2cb5a86..ede8ddf 100644 --- a/ege/resource/tools/icoSphere.cpp +++ b/ege/resource/tools/icoSphere.cpp @@ -8,6 +8,7 @@ #include #include +#include // return index of point in the middle of p1 and p2 static int32_t getMiddlePoint(std::vector& _listVertex, int32_t _p1, int32_t _p2) { @@ -24,8 +25,15 @@ static int32_t getMiddlePoint(std::vector& _listVertex, int32_t _p1, int32 return _listVertex.size()-1; } +static int32_t addUV(std::vector& _listUV, int32_t _uvId, float _add) { + //vec2 plop(-_add, _listUV[_uvId].y()); + //_listUV.push_back(plop); + _listUV.push_back(_listUV[_uvId] + vec2(_add, 0.0f)); + return _listUV.size()-1; +} + void ege::icoSphere::create(etk::Hash& _materials, etk::Hash& _listFaces, std::vector& _listVertex, std::vector& _listUV, - const std::string& _materialName, int32_t _recursionLevel) { + const std::string& _materialName, float _size, int32_t _recursionLevel) { /* 5 o @@ -128,6 +136,84 @@ void ege::icoSphere::create(etk::Hash& _materials, etk::Hash