hello,
I’ve got a triangle and I would like to modifiy it’s vertex positions.
I got a little helper class that stores a
LVector3& mPosition
whenever I move that position I want the corrisponding vertex in the triangle to move as well.
hence I was thinking the mPosition should simply reference one of the vertices in the triangle.
IS that a good approach ?
I have not been able to figure out how to get the reference off each of my vertices in the triangle.
I thought I could parse the vertices like this and simply store the reference to it. But it’s all in “const” domain so it wouldnt really work.
void cAWNavMeshObject::InitVertexInterface()
{
PT(Geom) geom = mDebugGeometry->mMeshGeom;
CPT(GeomVertexData) vData = geom->get_vertex_data();
GeomVertexReader vertex = GeomVertexReader(vData, "vertex");
for (int i = 0; i < geom->get_num_primitives(); ++i)
{
CPT(GeomPrimitive) prim = geom->get_primitive(i);
for (int p = 0; p < prim->get_num_primitives(); ++p)
{
int start = prim->get_primitive_start(p);
int end = prim->get_primitive_end(p);
for (int i = start; i < end; ++i)
{
int vertID = prim->get_vertex(i);
vertex.set_row(vertID);
const LVecBase3f& v = vertex.get_data3f();
// I would store the reference here into my helper class...
}
}
}
}
As you can see here the resulting vertex “v” is const and throughout the parsing of the Geom get_vertex_data() returns a CPT as well.
any ideas how I could do this ?
the goal is to have a little box at each vertex position ( hence the helper class ) and whenever I move the box I want it to reflect in the rendered geometry vertex.