[DEV] add tools function for resource colored 3d object
This commit is contained in:
parent
d0e8e519a8
commit
6e571ae742
2
external/ege
vendored
2
external/ege
vendored
@ -1 +1 @@
|
||||
Subproject commit 8ec1d2833cbacba4ea4dec7819017a0e0a3a06f3
|
||||
Subproject commit fd45ef5f7766191491cb4f70f6b38a8c898548d7
|
@ -158,3 +158,74 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::resource::Colored3DObject::drawSphere(float _radius,
|
||||
int _lats,
|
||||
int _longs,
|
||||
mat4& _transformationMatrix,
|
||||
const etk::Color<float>& _tmpColor) {
|
||||
int i, j;
|
||||
std::vector<vec3> EwolVertices;
|
||||
for(i = 0; i <= _lats; i++) {
|
||||
btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar) (i - 1) / _lats);
|
||||
btScalar z0 = _radius*sin(lat0);
|
||||
btScalar zr0 = _radius*cos(lat0);
|
||||
|
||||
btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar) i / _lats);
|
||||
btScalar z1 = _radius*sin(lat1);
|
||||
btScalar zr1 = _radius*cos(lat1);
|
||||
|
||||
//glBegin(GL_QUAD_STRIP);
|
||||
for(j = 0; j < _longs; j++) {
|
||||
btScalar lng = 2 * SIMD_PI * (btScalar) (j - 1) / _longs;
|
||||
btScalar x = cos(lng);
|
||||
btScalar y = sin(lng);
|
||||
vec3 v1 = vec3(x * zr1, y * zr1, z1);
|
||||
vec3 v4 = vec3(x * zr0, y * zr0, z0);
|
||||
|
||||
lng = 2 * SIMD_PI * (btScalar) (j) / _longs;
|
||||
x = cos(lng);
|
||||
y = sin(lng);
|
||||
vec3 v2 = vec3(x * zr1, y * zr1, z1);
|
||||
vec3 v3 = vec3(x * zr0, y * zr0, z0);
|
||||
|
||||
EwolVertices.push_back(v1);
|
||||
EwolVertices.push_back(v2);
|
||||
EwolVertices.push_back(v3);
|
||||
|
||||
EwolVertices.push_back(v1);
|
||||
EwolVertices.push_back(v3);
|
||||
EwolVertices.push_back(v4);
|
||||
}
|
||||
}
|
||||
draw(EwolVertices, _tmpColor, _transformationMatrix);
|
||||
}
|
||||
|
||||
void ewol::resource::Colored3DObject::drawSquare(const vec3& _size,
|
||||
mat4& _transformationMatrix,
|
||||
const etk::Color<float>& _tmpColor){
|
||||
std::vector<vec3> tmpVertices;
|
||||
static int indices[36] = { 0,1,2, 3,2,1, 4,0,6,
|
||||
6,0,2, 5,1,4, 4,1,0,
|
||||
7,3,1, 7,1,5, 5,4,7,
|
||||
7,4,6, 7,2,3, 7,6,2};
|
||||
vec3 vertices[8]={ vec3(_size[0],_size[1],_size[2]),
|
||||
vec3(-_size[0],_size[1],_size[2]),
|
||||
vec3(_size[0],-_size[1],_size[2]),
|
||||
vec3(-_size[0],-_size[1],_size[2]),
|
||||
vec3(_size[0],_size[1],-_size[2]),
|
||||
vec3(-_size[0],_size[1],-_size[2]),
|
||||
vec3(_size[0],-_size[1],-_size[2]),
|
||||
vec3(-_size[0],-_size[1],-_size[2])};
|
||||
tmpVertices.clear();
|
||||
for (int32_t iii=0 ; iii<36 ; iii+=3) {
|
||||
// normal calculation :
|
||||
//btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]);
|
||||
//normal.normalize ();
|
||||
tmpVertices.push_back(vertices[indices[iii]]);
|
||||
tmpVertices.push_back(vertices[indices[iii+1]]);
|
||||
tmpVertices.push_back(vertices[indices[iii+2]]);
|
||||
}
|
||||
draw(tmpVertices, _tmpColor, _transformationMatrix);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,15 @@ namespace ewol {
|
||||
mat4& _transformationMatrix,
|
||||
bool _updateDepthBuffer=true,
|
||||
bool _depthtest=true);
|
||||
public:
|
||||
void drawSphere(float _radius,
|
||||
int _lats,
|
||||
int _longs,
|
||||
mat4& _transformationMatrix,
|
||||
const etk::Color<float>& _tmpColor);
|
||||
void drawSquare(const vec3& _size, // halph size
|
||||
mat4& _transformationMatrix,
|
||||
const etk::Color<float>& _tmpColor);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -380,15 +380,13 @@ void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
if (false == m_elementList[_idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
//EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _vbo->getElementSize(_index) << " element on oglID=" << _vbo->getGL_ID(_index) << " VBOindex=" << _index);
|
||||
EWOL_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _vbo->getElementSize(_index) << " element on oglID=" << _vbo->getGL_ID(_index) << " VBOindex=" << _index);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index));
|
||||
checkGlError("glBindBuffer", __LINE__);
|
||||
/*
|
||||
EWOL_ERROR(" id=" << m_elementList[_idElem].m_elementId);
|
||||
EWOL_ERROR(" eleme size=" << _vbo->getElementSize(_index));
|
||||
EWOL_ERROR(" jump sample=" << _jumpBetweenSample);
|
||||
EWOL_ERROR(" offset=" << _offset);
|
||||
*/
|
||||
EWOL_VERBOSE(" id=" << m_elementList[_idElem].m_elementId);
|
||||
EWOL_VERBOSE(" eleme size=" << _vbo->getElementSize(_index));
|
||||
EWOL_VERBOSE(" jump sample=" << _jumpBetweenSample);
|
||||
EWOL_VERBOSE(" offset=" << _offset);
|
||||
glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
|
||||
_vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a)
|
||||
GL_FLOAT, // the type of each element
|
||||
|
Loading…
x
Reference in New Issue
Block a user