Add prims that re-use vertices? (one vertex per point)

   770   0   0
User Avatar
Member
1 posts
Joined: Sept. 2021
Offline
Is there a way to add a primitive without adding new vertices? My goal is to export a bunch of triangulated cubes that use 8 vertices each for an unlit effect. The hexahedron primitive type has 8 vertices, but not after it exports as triangles.

This vex is in the right direction, but it ends up with 6 vertices where I'd like 4 (one vertex per point).

int pts[];
push(pts, addpoint(0,{0,0,0}));
push(pts, addpoint(0,{0,1,0}));
push(pts, addpoint(0,{0,1,1}));
push(pts, addpoint(0,{0,0,1}));

void AddTriangulatedQuad(int pt0, pt1, pt2, pt3){
    int triangle0 = addprim(0,'poly');
    addvertex(0, triangle0, pt0);
    addvertex(0, triangle0, pt1);
    addvertex(0, triangle0, pt2);
    int triangle1 = addprim(0,'poly');
    addvertex(0, triangle1, pt0);
    addvertex(0, triangle1, pt2);
    addvertex(0, triangle1, pt3);
}

AddTriangulatedQuad(pts[0], pts[1], pts[2], pts[3]);
  • Quick Links