[DEV] try to display only the triangle visible
This commit is contained in:
parent
d4dfe30d23
commit
9e908e992d
@ -50,3 +50,15 @@ void ewol::Light::Draw(ewol::Program* prog)
|
||||
prog->Uniform4(m_GL_specularColor, m_specularColor);
|
||||
}
|
||||
|
||||
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Light& _obj)
|
||||
{
|
||||
_os << "light:{";
|
||||
_os << "dir=" << _obj.m_direction;
|
||||
_os << " halfplan=" << _obj.m_halfplane;
|
||||
_os << " color:{ anbiant=" << _obj.m_ambientColor;
|
||||
_os << " diffuse=" << _obj.m_diffuseColor;
|
||||
_os << " specular=" << _obj.m_specularColor;
|
||||
_os << "}}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,11 @@ namespace ewol
|
||||
void SetSpecularColor(const vec4& val) {
|
||||
m_specularColor = val;
|
||||
}
|
||||
|
||||
friend etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,6 +28,8 @@ ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName)
|
||||
m_light.SetDiffuseColor(vec4(1.0,1.0,1.0,1));
|
||||
m_light.SetSpecularColor(vec4(0.0,0.0,0.0,1));
|
||||
|
||||
//EWOL_DEBUG(m_name << " " << m_light);
|
||||
|
||||
if (true == ewol::resource::Keep(_shaderName, m_GLprogram) ) {
|
||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d");
|
||||
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||
@ -67,7 +69,7 @@ ewol::Mesh::~Mesh(void)
|
||||
ewol::resource::Release(m_verticesVBO);
|
||||
}
|
||||
|
||||
//#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
|
||||
void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
{
|
||||
@ -75,6 +77,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
//EWOL_DEBUG(m_name << " " << m_light);
|
||||
ewol::openGL::Enable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
|
||||
m_GLprogram->Use();
|
||||
@ -93,6 +96,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
// draw lights :
|
||||
m_light.Draw(m_GLprogram);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
int32_t nbElementDrawTheoric = 0;
|
||||
int32_t nbElementDraw = 0;
|
||||
#endif
|
||||
for (esize_t kkk=0; kkk<m_listFaces.Size(); kkk++) {
|
||||
@ -101,13 +105,52 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
continue;
|
||||
}
|
||||
m_materials[m_listFaces.GetKey(kkk)]->Draw(m_GLprogram, m_GLMaterial);
|
||||
ewol::openGL::DrawElements(GL_TRIANGLES, m_listFaces.GetValue(kkk).m_index);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
nbElementDraw += m_listFaces.GetValue(kkk).m_index.Size();
|
||||
#if 0
|
||||
ewol::openGL::DrawElements(GL_TRIANGLES, m_listFaces.GetValue(kkk).m_index);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
nbElementDraw += m_listFaces.GetValue(kkk).m_index.Size();
|
||||
nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size();
|
||||
#endif
|
||||
#else
|
||||
mat4 mattttt = (projMatrix * camMatrix) * positionMatrix;
|
||||
mattttt.m_mat[3] = 0;
|
||||
mattttt.m_mat[7] = 0;
|
||||
mattttt.m_mat[11] = 0;
|
||||
//vec3 cameraNormal = vec3(-mattttt.m_mat[2], -mattttt.m_mat[6], -mattttt.m_mat[10]);
|
||||
vec3 cameraNormal = mattttt*vec3(0,0,-1);
|
||||
cameraNormal.normalized();
|
||||
// remove face that is notin the view ...
|
||||
etk::Vector<uint32_t> tmpIndexResult;
|
||||
etk::Vector<Face>& tmppFaces = m_listFaces.GetValue(kkk).m_faces;
|
||||
etk::Vector<uint32_t>& tmppIndex = m_listFaces.GetValue(kkk).m_index;
|
||||
if (normalModeFace == m_normalMode) {
|
||||
for(int32_t iii=0; iii<tmppFaces.Size() ; ++iii) {
|
||||
if(btDot(mattttt*m_listFacesNormal[tmppFaces[iii].m_normal[0]], cameraNormal) >= 0.0f) {
|
||||
tmpIndexResult.PushBack(iii*3);
|
||||
tmpIndexResult.PushBack(iii*3+1);
|
||||
tmpIndexResult.PushBack(iii*3+2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(int32_t iii=0; iii<tmppFaces.Size() ; ++iii) {
|
||||
if( (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[0]], cameraNormal) >= 0.0f)
|
||||
|| (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[1]], cameraNormal) >= 0.0f)
|
||||
|| (btDot(mattttt*m_listVertexNormal[tmppFaces[iii].m_normal[2]], cameraNormal) >= 0.0f) ) {
|
||||
tmpIndexResult.PushBack(iii*3);
|
||||
tmpIndexResult.PushBack(iii*3+1);
|
||||
tmpIndexResult.PushBack(iii*3+2);
|
||||
}
|
||||
}
|
||||
}
|
||||
ewol::openGL::DrawElements(GL_TRIANGLES, tmpIndexResult);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
nbElementDraw += tmpIndexResult.Size();
|
||||
nbElementDrawTheoric += m_listFaces.GetValue(kkk).m_index.Size();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << " elements [" << m_name << "]");
|
||||
EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
|
||||
#endif
|
||||
m_GLprogram->UnUse();
|
||||
ewol::openGL::Disable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
@ -186,6 +229,7 @@ void ewol::Mesh::CalculateNormaleEdge(void)
|
||||
vec3 normal(0,0,0);
|
||||
// add the vertex from all the element in the list for face when the element in the face ...
|
||||
for(int32_t jjj=0 ; jjj<tmpFaceList.Size() ; jjj++) {
|
||||
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL, normal);
|
||||
if( tmpFaceList[jjj].m_vertex[0] == iii
|
||||
|| tmpFaceList[jjj].m_vertex[1] == iii
|
||||
|| tmpFaceList[jjj].m_vertex[2] == iii) {
|
||||
|
@ -66,13 +66,7 @@ void ewol::VirtualBufferObject::RemoveContext(void)
|
||||
EWOL_INFO("VBO: Remove [" << m_uniqueId << "] OGl_Id=" << m_vbo[0]
|
||||
<< "/" << m_vbo[1]
|
||||
<< "/" << m_vbo[2]
|
||||
<< "/" << m_vbo[3]
|
||||
<< "/" << m_vbo[4]
|
||||
<< "/" << m_vbo[5]
|
||||
<< "/" << m_vbo[6]
|
||||
<< "/" << m_vbo[7]
|
||||
<< "/" << m_vbo[8]
|
||||
<< "/" << m_vbo[9]);
|
||||
<< "/" << m_vbo[3]);
|
||||
glDeleteBuffers(NB_VBO_MAX, m_vbo);
|
||||
m_exist = false;
|
||||
for (int32_t iii=0; iii<NB_VBO_MAX; iii++) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <ewol/renderer/resources/Resource.h>
|
||||
#include <ewol/renderer/openGL.h>
|
||||
|
||||
#define NB_VBO_MAX (10)
|
||||
#define NB_VBO_MAX (4)
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user