[DEV] add some capacity of engine
This commit is contained in:
parent
6e2e30de90
commit
eb762e5c93
@ -33,6 +33,7 @@ namespace ege {
|
||||
* @param[in] _distance distance to the eye point
|
||||
*/
|
||||
Camera(const vec3& _eye=vec3(0,0,0), float _angleZ=0, float _angleTeta=0, float _distance=10);
|
||||
// TODO : Rework this API ...
|
||||
protected:
|
||||
vec3 m_eye; //!< position where the camera see
|
||||
public:
|
||||
|
@ -42,6 +42,7 @@ void ege::resource::Mesh::init(const std::string& _fileName, const std::string&
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
|
||||
m_GLNormal = m_GLprogram->getAttribute("EW_normal");
|
||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
|
||||
m_GLMatrixPosition = m_GLprogram->getUniform("EW_MatrixPosition");
|
||||
// Link material and Lights
|
||||
@ -49,7 +50,7 @@ void ege::resource::Mesh::init(const std::string& _fileName, const std::string&
|
||||
m_light.link(m_GLprogram, "EW_directionalLight");
|
||||
}
|
||||
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=flaot "i"=integer
|
||||
m_verticesVBO = ewol::resource::VirtualBufferObject::create(4);
|
||||
m_verticesVBO = ewol::resource::VirtualBufferObject::create(5);
|
||||
|
||||
// load the curent file :
|
||||
std::string tmpName = etk::tolower(_fileName);
|
||||
@ -83,6 +84,7 @@ void ege::resource::Mesh::clean() {
|
||||
m_physics.clear();
|
||||
m_materials.clear();
|
||||
m_listFaces.clear();
|
||||
m_listColor.clear();
|
||||
m_listVertexNormal.clear();
|
||||
m_listFacesNormal.clear();
|
||||
m_listUV.clear();
|
||||
@ -117,11 +119,13 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrixPosition, 1, _positionMatrix.m_mat);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLPosition, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
// Texture :
|
||||
m_GLprogram->sendAttributePointer(m_GLtexture, 2/*u,v*/, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
m_GLprogram->sendAttributePointer(m_GLtexture, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLNormal, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
m_GLprogram->sendAttributePointer(m_GLNormal, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLColor, m_verticesVBO, MESH_VBO_COLOR);
|
||||
// draw lights :
|
||||
m_light.draw(m_GLprogram);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
@ -135,7 +139,9 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
}
|
||||
m_materials[m_listFaces.getKey(kkk)]->draw(m_GLprogram, m_GLMaterial);
|
||||
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);
|
||||
//ewol::openGL::drawElements(GL_LINE_LOOP, m_listFaces.getValue(kkk).m_index);
|
||||
ewol::openGL::drawElements(GL_LINES, 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();
|
||||
@ -172,6 +178,7 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
}
|
||||
}
|
||||
ewol::openGL::drawElements(GL_TRIANGLES, tmpIndexResult);
|
||||
//ewol::openGL::drawElements(GL_LINE_LOOP, tmpIndexResult);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
nbElementDraw += tmpIndexResult.size();
|
||||
nbElementDrawTheoric += m_listFaces.getValue(kkk).m_index.size();
|
||||
@ -255,15 +262,30 @@ void ege::resource::Mesh::generateVBO() {
|
||||
for (size_t iii=0; iii<tmpFaceList.m_faces.size() ; iii++) {
|
||||
int32_t vertexVBOId[3];
|
||||
for(size_t indice=0 ; indice<3; indice++) {
|
||||
// ghet position
|
||||
vec3 position = m_listVertex[tmpFaceList.m_faces[iii].m_vertex[indice]];
|
||||
// get Color
|
||||
etk::Color<float> color;
|
||||
if (tmpFaceList.m_faces[iii].m_color[indice] != -1) {
|
||||
color = m_listColor[tmpFaceList.m_faces[iii].m_color[indice]];
|
||||
} else {
|
||||
color = etk::color::white;
|
||||
}
|
||||
// get µNormal
|
||||
vec3 normal;
|
||||
if (m_normalMode == normalModeVertex) {
|
||||
normal = m_listVertexNormal[tmpFaceList.m_faces[iii].m_normal[indice]];
|
||||
} else {
|
||||
normal = m_listFacesNormal[tmpFaceList.m_faces[iii].m_normal[indice]];
|
||||
}
|
||||
vec2 texturepos(m_listUV[tmpFaceList.m_faces[iii].m_uv[indice]].x(),1.0f-m_listUV[tmpFaceList.m_faces[iii].m_uv[indice]].y());
|
||||
// try to find it in the list :
|
||||
// get Texture Position
|
||||
vec2 texturepos;
|
||||
if (tmpFaceList.m_faces[iii].m_uv[indice] == -1) {
|
||||
texturepos.setValue(0,0);
|
||||
} else {
|
||||
texturepos.setValue(m_listUV[tmpFaceList.m_faces[iii].m_uv[indice]].x(),1.0f-m_listUV[tmpFaceList.m_faces[iii].m_uv[indice]].y());
|
||||
}
|
||||
// Create the vectex Buffer list:
|
||||
bool elementFind = false;
|
||||
#ifdef TRY_MINIMAL_VBO
|
||||
for (int32_t jjj=0; jjj<m_verticesVBO->sizeOnBufferVec3(MESH_VBO_VERTICES); jjj++) {
|
||||
@ -283,7 +305,8 @@ void ege::resource::Mesh::generateVBO() {
|
||||
m_verticesVBO->pushOnBuffer(MESH_VBO_VERTICES, position);
|
||||
m_verticesVBO->pushOnBuffer(MESH_VBO_VERTICES_NORMAL, normal);
|
||||
m_verticesVBO->pushOnBuffer(MESH_VBO_TEXTURE, texturepos);
|
||||
vertexVBOId[indice] = m_verticesVBO->sizeOnBufferVec3(MESH_VBO_VERTICES)-1;
|
||||
m_verticesVBO->pushOnBuffer(MESH_VBO_COLOR, color);
|
||||
vertexVBOId[indice] = m_verticesVBO->bufferSize(MESH_VBO_VERTICES)-1;
|
||||
}
|
||||
}
|
||||
for(size_t indice=0 ; indice<3; indice++) {
|
||||
@ -948,3 +971,86 @@ void ege::resource::Mesh::setShape(void* _shape) {
|
||||
}
|
||||
m_pointerShape=_shape;
|
||||
}
|
||||
|
||||
int32_t ege::resource::Mesh::findPositionInList(const vec3& _pos) {
|
||||
for (size_t iii=0; iii<m_listVertex.size(); ++iii) {
|
||||
if (m_listVertex[iii] == _pos) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
m_listVertex.push_back(_pos);
|
||||
return m_listVertex.size()-1;
|
||||
}
|
||||
int32_t ege::resource::Mesh::findTextureInList(const vec2& _uv) {
|
||||
for (size_t iii=0; iii<m_listUV.size(); ++iii) {
|
||||
if (m_listUV[iii] == _uv) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
m_listUV.push_back(_uv);
|
||||
return m_listUV.size()-1;
|
||||
}
|
||||
int32_t ege::resource::Mesh::findColorInList(const etk::Color<float>& _color) {
|
||||
for (size_t iii=0; iii<m_listColor.size(); ++iii) {
|
||||
if (m_listColor[iii] == _color) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
m_listColor.push_back(_color);
|
||||
return m_listColor.size()-1;
|
||||
}
|
||||
|
||||
|
||||
void ege::resource::Mesh::addFaceIndexing(const std::string& _layerName) {
|
||||
if (m_listFaces.exist(_layerName) == false) {
|
||||
FaceIndexing empty;
|
||||
m_listFaces.add(_layerName, empty);
|
||||
}
|
||||
}
|
||||
void ege::resource::Mesh::addTriangle(const std::string& _layerName,
|
||||
const vec3& _pos1, const vec3& _pos2, const vec3& _pos3,
|
||||
const vec2& _uv1, const vec2& _uv2, const vec2& _uv3,
|
||||
const etk::Color<float>& _color1, const etk::Color<float>& _color2, const etk::Color<float>& _color3) {
|
||||
if (m_listFaces.exist(_layerName) == false) {
|
||||
EGE_ERROR("Mesh layer : " << _layerName << " does not exist in list faces ...");
|
||||
return;
|
||||
}
|
||||
// try to find position:
|
||||
int32_t pos1 = findPositionInList(_pos1);
|
||||
int32_t pos2 = findPositionInList(_pos2);
|
||||
int32_t pos3 = findPositionInList(_pos3);
|
||||
// try to find Color:
|
||||
int32_t uv1 = findTextureInList(_uv1);
|
||||
int32_t uv2 = findTextureInList(_uv2);
|
||||
int32_t uv3 = findTextureInList(_uv3);
|
||||
// try to find UV mapping:
|
||||
int32_t color1 = findColorInList(_color1);
|
||||
int32_t color2 = findColorInList(_color2);
|
||||
int32_t color3 = findColorInList(_color3);
|
||||
Face tmpFace(pos1, uv1,
|
||||
pos2, uv2,
|
||||
pos3, uv3);
|
||||
tmpFace.setColor(color1, color2, color3);
|
||||
m_listFaces[_layerName].m_faces.push_back(tmpFace);
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::addTriangle(const std::string& _layerName, const vec3& _pos1, const vec3& _pos2, const vec3& _pos3,
|
||||
const etk::Color<float>& _color1, const etk::Color<float>& _color2, const etk::Color<float>& _color3) {
|
||||
if (m_listFaces.exist(_layerName) == false) {
|
||||
EGE_ERROR("Mesh layer : " << _layerName << " does not exist in list faces ...");
|
||||
return;
|
||||
}
|
||||
// try to find position:
|
||||
int32_t pos1 = findPositionInList(_pos1);
|
||||
int32_t pos2 = findPositionInList(_pos2);
|
||||
int32_t pos3 = findPositionInList(_pos3);
|
||||
// try to find UV mapping:
|
||||
int32_t color1 = findColorInList(_color1);
|
||||
int32_t color2 = findColorInList(_color2);
|
||||
int32_t color3 = findColorInList(_color3);
|
||||
Face tmpFace(pos1, -1,
|
||||
pos2, -1,
|
||||
pos3, -1);
|
||||
tmpFace.setColor(color1, color2, color3);
|
||||
m_listFaces[_layerName].m_faces.push_back(tmpFace);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ namespace ege {
|
||||
int32_t m_GLMatrixPosition;
|
||||
int32_t m_GLNormal;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_GLColor;
|
||||
int32_t m_bufferOfset;
|
||||
int32_t m_numberOfElments;
|
||||
MaterialGlId m_GLMaterial;
|
||||
@ -62,6 +63,7 @@ namespace ege {
|
||||
protected:
|
||||
std::vector<vec3> m_listVertex; //!< List of all vertex in the element
|
||||
std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture)
|
||||
std::vector<etk::Color<float>> m_listColor; //!< List of all Color point in the mesh
|
||||
std::vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated
|
||||
std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
|
||||
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
|
||||
@ -135,6 +137,154 @@ namespace ege {
|
||||
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) {
|
||||
m_functionFreeShape = _functionFreeShape;
|
||||
};
|
||||
/**
|
||||
* @brief Add in the faces list the layer requested
|
||||
* @param[in] _layerName face index to add
|
||||
*/
|
||||
void addFaceIndexing(const std::string& _layerName);
|
||||
public:
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a colored triangle (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _color1 color of the _pos1 element
|
||||
* @param[in] _color2 color of the _pos2 element
|
||||
* @param[in] _color3 color of the _pos3 element
|
||||
*/
|
||||
void addTriangle(const std::string& _layerName, const vec3& _pos1, const vec3& _pos2, const vec3& _pos3, const etk::Color<float>& _color) {
|
||||
addTriangle(_layerName, _pos1, _pos2, _pos3, _color, _color, _color);
|
||||
}
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a colored triangle (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _color1 color of the _pos1 element
|
||||
* @param[in] _color2 color of the _pos2 element
|
||||
* @param[in] _color3 color of the _pos3 element
|
||||
*/
|
||||
void addTriangle(const std::string& _layerName, const vec3& _pos1, const vec3& _pos2, const vec3& _pos3,
|
||||
const etk::Color<float>& _color1, const etk::Color<float>& _color2, const etk::Color<float>& _color3);
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a colored quad (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _pos4 faurth point position
|
||||
* @param[in] _color color of all elements
|
||||
*/
|
||||
void addQuad(const std::string& _layerName, const vec3& _pos1, const vec3& _pos2, const vec3& _pos3, const vec3& _pos4, const etk::Color<float>& _color) {
|
||||
addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _color, _color, _color, _color);
|
||||
}
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a colored quad (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _pos4 faurth point position
|
||||
* @param[in] _color1 color of the _pos1 element
|
||||
* @param[in] _color2 color of the _pos2 element
|
||||
* @param[in] _color3 color of the _pos3 element
|
||||
* @param[in] _color4 color of the _pos4 element
|
||||
*/
|
||||
void addQuad(const std::string& _layerName, const vec3& _pos1, const vec3& _pos2, const vec3& _pos3, const vec3& _pos4,
|
||||
const etk::Color<float>& _color1, const etk::Color<float>& _color2, const etk::Color<float>& _color3, const etk::Color<float>& _color4) {
|
||||
addTriangle(_layerName, _pos1, _pos2, _pos3, _color1, _color2, _color3);
|
||||
addTriangle(_layerName, _pos1, _pos3, _pos4, _color1, _color3, _color4);
|
||||
}
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a textured colored triangle (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _color color of all elements
|
||||
* @param[in] _uv1 texture position of the _pos1 element
|
||||
* @param[in] _uv2 texture position of the _pos2 element
|
||||
* @param[in] _uv3 texture position of the _pos3 element
|
||||
*/
|
||||
void addTriangle(const std::string& _layerName,
|
||||
const vec3& _pos1, const vec3& _pos2, const vec3& _pos3,
|
||||
const vec2& _uv1, const vec2& _uv2, const vec2& _uv3,
|
||||
const etk::Color<float>& _color) {
|
||||
addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color, _color, _color);
|
||||
}
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a textured colored triangle (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _color1 color of the _pos1 element
|
||||
* @param[in] _color2 color of the _pos2 element
|
||||
* @param[in] _color3 color of the _pos3 element
|
||||
* @param[in] _uv1 texture position of the _pos1 element
|
||||
* @param[in] _uv2 texture position of the _pos2 element
|
||||
* @param[in] _uv3 texture position of the _pos3 element
|
||||
*/
|
||||
void addTriangle(const std::string& _layerName,
|
||||
const vec3& _pos1, const vec3& _pos2, const vec3& _pos3,
|
||||
const vec2& _uv1, const vec2& _uv2, const vec2& _uv3,
|
||||
const etk::Color<float>& _color1=etk::color::white, const etk::Color<float>& _color2=etk::color::white, const etk::Color<float>& _color3=etk::color::white);
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a textured colored quad (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _pos4 faurth point position
|
||||
* @param[in] _color color of all elements
|
||||
* @param[in] _uv1 texture position of the _pos1 element
|
||||
* @param[in] _uv2 texture position of the _pos2 element
|
||||
* @param[in] _uv3 texture position of the _pos3 element
|
||||
* @param[in] _uv4 texture position of the _pos4 element
|
||||
*/
|
||||
void addQuad(const std::string& _layerName,
|
||||
const vec3& _pos1, const vec3& _pos2, const vec3& _pos3, const vec3& _pos4,
|
||||
const vec2& _uv1, const vec2& _uv2, const vec2& _uv3, const vec2& _uv4,
|
||||
const etk::Color<float>& _color) {
|
||||
addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _uv1, _uv2, _uv3, _uv4, _color, _color, _color, _color);
|
||||
}
|
||||
/**
|
||||
* @not-in-doc
|
||||
* @brief draw a textured quad (usefull for debug and test)
|
||||
* @param[in] _layerName Material and face indexing layer name
|
||||
* @param[in] _pos1 First point position
|
||||
* @param[in] _pos2 Second point position
|
||||
* @param[in] _pos3 Third point position
|
||||
* @param[in] _pos4 faurth point position
|
||||
* @param[in] _uv1 texture position of the _pos1 element
|
||||
* @param[in] _uv2 texture position of the _pos2 element
|
||||
* @param[in] _uv3 texture position of the _pos3 element
|
||||
* @param[in] _uv4 texture position of the _pos4 element
|
||||
* @param[in] _color1 color of the _pos1 element
|
||||
* @param[in] _color2 color of the _pos2 element
|
||||
* @param[in] _color3 color of the _pos3 element
|
||||
* @param[in] _color4 color of the _pos4 element
|
||||
*/
|
||||
void addQuad(const std::string& _layerName,
|
||||
const vec3& _pos1, const vec3& _pos2, const vec3& _pos3, const vec3& _pos4,
|
||||
const vec2& _uv1, const vec2& _uv2, const vec2& _uv3, const vec2& _uv4,
|
||||
const etk::Color<float>& _color1=etk::color::white, const etk::Color<float>& _color2=etk::color::white, const etk::Color<float>& _color3=etk::color::white, const etk::Color<float>& _color4=etk::color::white) {
|
||||
addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color1, _color2, _color3);
|
||||
addTriangle(_layerName, _pos1, _pos3, _pos4, _uv1, _uv3, _uv4, _color1, _color3, _color4);
|
||||
}
|
||||
protected:
|
||||
int32_t findPositionInList(const vec3& _pos);
|
||||
int32_t findTextureInList(const vec2& _uv);
|
||||
int32_t findColorInList(const etk::Color<float>& _color);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -54,11 +54,11 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
vec4 tmpColor(_mainColor.r(), _mainColor.g(), _mainColor.b(), _mainColor.a());
|
||||
m_GLprogram->uniform4(m_GLMainColor, tmpColor);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLPosition, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
// Texture :
|
||||
m_GLprogram->sendAttributePointer(m_GLtexture, 2/*u,v*/, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
m_GLprogram->sendAttributePointer(m_GLtexture, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLNormal, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
m_GLprogram->sendAttributePointer(m_GLNormal, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
// draw lights :
|
||||
m_light.draw(m_GLprogram);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
|
@ -18,34 +18,61 @@ namespace ege {
|
||||
int32_t m_vertex[3];
|
||||
int32_t m_uv[3];
|
||||
int32_t m_normal[3];
|
||||
int32_t m_color[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;
|
||||
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;
|
||||
m_color[0] = -1;
|
||||
m_color[1] = -1;
|
||||
m_color[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;
|
||||
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;
|
||||
m_color[0] = -1;
|
||||
m_color[1] = -1;
|
||||
m_color[2] = -1;
|
||||
};
|
||||
void setVertex(int32_t _v1, int32_t _v2, int32_t _v3) {
|
||||
m_vertex[0] = _v1;
|
||||
m_vertex[1] = _v2;
|
||||
m_vertex[2] = _v3;
|
||||
}
|
||||
void setTexture(int32_t _t1, int32_t _t2, int32_t _t3) {
|
||||
m_uv[0] = _t1;
|
||||
m_uv[1] = _t2;
|
||||
m_uv[2] = _t3;
|
||||
}
|
||||
void setNormal(int32_t _n1, int32_t _n2, int32_t _n3) {
|
||||
m_normal[0] = _n1;
|
||||
m_normal[1] = _n2;
|
||||
m_normal[2] = _n3;
|
||||
}
|
||||
void setColor(int32_t _c1, int32_t _c2, int32_t _c3) {
|
||||
m_color[0] = _c1;
|
||||
m_color[1] = _c2;
|
||||
m_color[2] = _c3;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -19,13 +19,53 @@
|
||||
appl::Windows::Windows() {
|
||||
addObjectType("appl::Windows");
|
||||
}
|
||||
|
||||
|
||||
static std::shared_ptr<ege::resource::Mesh> createGrid(int32_t _lineCount) {
|
||||
std::shared_ptr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
|
||||
float lineSize = 0.1f;
|
||||
if (out != nullptr) {
|
||||
std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>();
|
||||
// set the element material properties :
|
||||
material->setAmbientFactor(vec4(1,1,1,1));
|
||||
material->setDiffuseFactor(vec4(0,0,0,1));
|
||||
material->setSpecularFactor(vec4(0,0,0,1));
|
||||
material->setShininess(1);
|
||||
out->addMaterial("basics", material);
|
||||
|
||||
out->addFaceIndexing("basics");
|
||||
/*
|
||||
out->addQuad("basics",
|
||||
vec3(-10,0,0), vec3(10,0,0), vec3(10,10,-lineSize), vec3(-10,10,-lineSize),
|
||||
etk::color::white, etk::color::red, etk::color::green, etk::color::blue);
|
||||
*/
|
||||
// create horizontal lines
|
||||
for (int32_t iii=-_lineCount; iii<=_lineCount; ++iii) {
|
||||
out->addQuad("basics",
|
||||
vec3(-_lineCount,iii,0), vec3(_lineCount,iii,0), vec3(_lineCount,iii,lineSize), vec3(-_lineCount,iii,lineSize),
|
||||
etk::color::white);
|
||||
}
|
||||
// create vertical lines
|
||||
for (int32_t iii=-_lineCount; iii<=_lineCount; ++iii) {
|
||||
out->addQuad("basics",
|
||||
vec3(iii,-_lineCount,0), vec3(iii,_lineCount,0), vec3(iii,_lineCount,lineSize), vec3(iii,-_lineCount,lineSize),
|
||||
etk::color::white);
|
||||
}
|
||||
|
||||
// generate the VBO
|
||||
out->generateVBO();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void appl::Windows::init() {
|
||||
ewol::widget::Windows::init();
|
||||
setTitle("example ege : MeshCreator");
|
||||
|
||||
m_env = ege::Environement::create();
|
||||
// Create basic Camera
|
||||
m_env->addCamera("basic", std::make_shared<ege::Camera>());
|
||||
m_env->addCamera("basic", std::make_shared<ege::Camera>(vec3(0,0,0),0,0,10));
|
||||
|
||||
std::shared_ptr<ege::widget::Scene> tmpWidget = ege::widget::Scene::create(m_env);
|
||||
if (tmpWidget == nullptr) {
|
||||
@ -69,6 +109,11 @@ void appl::Windows::init() {
|
||||
myMesh->generateVBO();
|
||||
m_env->addStaticMeshToDraw(myMesh);
|
||||
}
|
||||
myMesh = createGrid(10);
|
||||
if (myMesh != nullptr) {
|
||||
m_env->addStaticMeshToDraw(myMesh);
|
||||
}
|
||||
/*
|
||||
myMesh = ege::resource::Mesh::create("---");
|
||||
if (myMesh != nullptr) {
|
||||
std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>();
|
||||
@ -82,4 +127,7 @@ void appl::Windows::init() {
|
||||
myMesh->generateVBO();
|
||||
m_env->addStaticMeshToDraw(myMesh);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user