feat: triangle fan triangulation
This commit is contained in:
@@ -15,15 +15,21 @@ void GLMesh::init()
|
||||
|
||||
initBuffers();
|
||||
|
||||
vertexPosData = {
|
||||
-0.5f, -0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f,
|
||||
0.5f, 0.5f, 0.0f
|
||||
};
|
||||
std::vector<int> foo = {0,1,2,3,4};
|
||||
for(int i=1;i+1<foo.size();++i)
|
||||
{
|
||||
indexData.push_back(foo.at(0));
|
||||
indexData.push_back(foo.at(i));
|
||||
indexData.push_back(foo.at(i+1));
|
||||
}
|
||||
// indexData =
|
||||
// {
|
||||
// 0, 1, 2, 1, 2, 3
|
||||
// };
|
||||
|
||||
// store data in the buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexPosData.size()*sizeof(GLfloat), vertexPosData.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData.size()*sizeof(GLint), indexData.data(), GL_STATIC_DRAW);
|
||||
|
||||
|
||||
// unbind vertex array
|
||||
@@ -33,12 +39,6 @@ void GLMesh::init()
|
||||
void GLMesh::initBuffers()
|
||||
{
|
||||
|
||||
|
||||
indexData =
|
||||
{
|
||||
0, 1, 2, 1, 2, 3
|
||||
};
|
||||
|
||||
// create buffer of vertices
|
||||
glGenBuffers(1, &vertexBuffer);
|
||||
// set purpose
|
||||
@@ -51,7 +51,6 @@ void GLMesh::initBuffers()
|
||||
|
||||
glGenBuffers(1, &indexBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData.size()*sizeof(GLint), indexData.data(), GL_STATIC_DRAW);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -149,10 +149,11 @@ std::unique_ptr<GLMesh> ViewportGLWidget::meshFromGeo(std::unique_ptr<enzo::geo:
|
||||
|
||||
std::shared_ptr<ga::Attribute> PAttr = geometry->getAttribByName(ga::AttrOwner::POINT, "P");
|
||||
ga::AttributeHandleVector3 PAttrHandle = ga::AttributeHandleVector3(PAttr);
|
||||
PAttrHandle.addValue(bt::Vector3(-0.5f, -0.5f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(0.5f, -0.5f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(0.0f, 0.5f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(0.5f, 0.5f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(1.0f, -1.0f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(-1.0f, -1.0f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(-1.0f, 1.0f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(0.0f, 2.0f, 0.0f));
|
||||
PAttrHandle.addValue(bt::Vector3(1.0f, 1.0f, 0.0f));
|
||||
|
||||
mesh->setPosBuffer(PAttrHandle.getData());
|
||||
// mesh->setPosBuffer(std::vector<bt::Vector3>{
|
||||
|
||||
Reference in New Issue
Block a user