[DEV] displa only the face visible

This commit is contained in:
Edouard DUPIN 2013-08-20 21:01:19 +02:00
parent 9e908e992d
commit 8aa072783d
2 changed files with 12 additions and 9 deletions

View File

@ -16,7 +16,8 @@
ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) : ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) :
ewol::Resource(_fileName), ewol::Resource(_fileName),
m_normalMode(normalModeNone) m_normalMode(normalModeNone),
m_checkNormal(false)
{ {
EWOL_DEBUG("Load a new mesh : '" << _fileName << "'"); EWOL_DEBUG("Load a new mesh : '" << _fileName << "'");
// get the shader resource : // get the shader resource :
@ -105,19 +106,19 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
continue; continue;
} }
m_materials[m_listFaces.GetKey(kkk)]->Draw(m_GLprogram, m_GLMaterial); m_materials[m_listFaces.GetKey(kkk)]->Draw(m_GLprogram, m_GLMaterial);
#if 0 if (m_checkNormal==false) {
ewol::openGL::DrawElements(GL_TRIANGLES, m_listFaces.GetValue(kkk).m_index); ewol::openGL::DrawElements(GL_TRIANGLES, m_listFaces.GetValue(kkk).m_index);
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
nbElementDraw += m_listFaces.GetValue(kkk).m_index.Size(); nbElementDraw += m_listFaces.GetValue(kkk).m_index.Size();
nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size(); nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size();
#endif #endif
#else } else {
mat4 mattttt = (projMatrix * camMatrix) * positionMatrix; mat4 mattttt = (projMatrix * camMatrix) * positionMatrix;
mattttt.m_mat[3] = 0; mattttt.m_mat[3] = 0;
mattttt.m_mat[7] = 0; mattttt.m_mat[7] = 0;
mattttt.m_mat[11] = 0; mattttt.m_mat[11] = 0;
//vec3 cameraNormal = vec3(-mattttt.m_mat[2], -mattttt.m_mat[6], -mattttt.m_mat[10]); //vec3 cameraNormal = vec3(-mattttt.m_mat[2], -mattttt.m_mat[6], -mattttt.m_mat[10]);
vec3 cameraNormal = mattttt*vec3(0,0,-1); vec3 cameraNormal = vec3(0,0,-1);
cameraNormal.normalized(); cameraNormal.normalized();
// remove face that is notin the view ... // remove face that is notin the view ...
etk::Vector<uint32_t> tmpIndexResult; etk::Vector<uint32_t> tmpIndexResult;
@ -133,9 +134,9 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
} }
} else { } else {
for(int32_t iii=0; iii<tmppFaces.Size() ; ++iii) { for(int32_t iii=0; iii<tmppFaces.Size() ; ++iii) {
if( (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[0]], cameraNormal) >= 0.0f) if( (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[0]], cameraNormal) >= -0.2f)
|| (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[1]], cameraNormal) >= 0.0f) || (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[1]], cameraNormal) >= -0.2f)
|| (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[2]], cameraNormal) >= 0.0f) ) { || (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[2]], cameraNormal) >= -0.2f) ) {
tmpIndexResult.PushBack(iii*3); tmpIndexResult.PushBack(iii*3);
tmpIndexResult.PushBack(iii*3+1); tmpIndexResult.PushBack(iii*3+1);
tmpIndexResult.PushBack(iii*3+2); tmpIndexResult.PushBack(iii*3+2);
@ -147,7 +148,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
nbElementDraw += tmpIndexResult.Size(); nbElementDraw += tmpIndexResult.Size();
nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size(); nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size();
#endif #endif
#endif }
} }
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]"); EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
@ -658,6 +659,7 @@ typedef enum {
bool ewol::Mesh::LoadEMF(const etk::UString& _fileName) bool ewol::Mesh::LoadEMF(const etk::UString& _fileName)
{ {
m_checkNormal = true;
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
// Get the fileSize ... // Get the fileSize ...

View File

@ -84,7 +84,8 @@ namespace ewol
normalModeVertex, normalModeVertex,
} normalMode_te; } normalMode_te;
private: private:
normalMode_te m_normalMode; normalMode_te 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: protected:
ewol::Program* m_GLprogram; ewol::Program* m_GLprogram;
int32_t m_GLPosition; int32_t m_GLPosition;