Skip to content

Commit

Permalink
Mesh: add a constructor that takes a float array
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 2, 2023
1 parent 561e7f4 commit a5bca19
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/src/main/java/com/github/stephengold/vsport/Mesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ public Mesh(Topology topology, Collection<Integer> indices,
assert mutable;
}

/**
* Instantiate a mutable mesh with the specified topology and vertex
* positions, but no indices, colors, normals, or texture coordinates.
*
* @param topology the desired topology (not null)
* @param positionsArray vertex positions (not null, not empty, length a
* multiple of 3, unaffected)
*/
public Mesh(Topology topology, float... positionsArray) {
this(topology, positionsArray.length / numAxes);
Validate.require(
positionsArray.length % numAxes == 0, "length a multiple of 3");

this.positionBuffer = VertexBuffer.newInstance(numAxes, positionsArray);
}

/**
* Instantiate a mutable mesh with the specified topology and vertex
* positions, but no indices, colors, normals, or texture coordinates.
Expand Down

0 comments on commit a5bca19

Please sign in to comment.