How to get Indices for all Vertices in a model

Hey,
I am trying to get all the Indices for all Vertices in a skp model. I am using SketchUp SDK with C++. I am able to get the indices for each face. But that’s not what I want. I am actually trying to parse it and load it in unreal. Hence, I need all the indices for all vertices.
This is what I get - Indices for each face(They repeat itself)

This is something what I need (It was when I was parsing obj files)

A SketchUp model is organized as a hierarchy of Sketchup::Entities / SUEntitiesRef (either at top-level or in component definitions). It is not a single mesh. The API and SDK give access to vertices per face/edge, starting from zero for each. That means the vertex index lists of two given faces both have an index 0 but for a different vertices.

If by “this” you mean a single index list for all (triangulated) faces of a model, you need to create a function to map indices to new indices (The repetition in your example indicates that you just concatenated them without remapping).

If your model contains component instances, you need to merge them (simulate “Explode” in the SketchUp program), considering their transformation and that they may have multiple occurences (instance paths):

  1. Get all vertices and positions of the selected component definition.
  2. Get all instance paths of the component you are currently working on
    [Model, ComponentInstance1, NestedComponentInstance2, SelectedComponentInstance], …
  3. For each instance path, multiply the transformations of the involved parent component instances.
  4. Apply the transformation to the vertex positions and insert them as new positions into your merged mesh.
  5. Map (a copy of) the original vertex indices to point to the new positions. Then insert these new indices to your merged mesh’s indices.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.