Fixed icosphere generator

This commit is contained in:
Anuken 2025-10-08 08:14:57 +09:00
parent 65c7acb31c
commit fd0d864cb8
2 changed files with 10 additions and 4 deletions

View file

@ -8,6 +8,6 @@ uniform mat4 u_trans;
varying vec4 v_col;
void main(){
v_col = a_color;
gl_Position = u_proj * u_trans * a_position;
v_col = a_color;
gl_Position = u_proj * u_trans * a_position;
}

View file

@ -15,7 +15,7 @@ public class MeshBuilder{
public static Mesh buildIcosphere(int divisions, float radius){
MeshResult result = Icosphere.create(divisions);
Mesh mesh = begin(result.vertices.size / 3, result.indices.size, false, false);
Mesh mesh = begin(result.vertices.size / 3, result.indices.size, false, false, false);
if(result.vertices.size >= 65535) throw new RuntimeException("Due to index size limits, only meshes with a maximum of 65535 vertices are supported. If you want more than that, make your own non-indexed mesh builder.");
@ -193,6 +193,10 @@ public class MeshBuilder{
}
private static Mesh begin(int vertices, int indices, boolean normal, boolean emissive){
return begin(vertices, indices, normal, emissive, true);
}
private static Mesh begin(int vertices, int indices, boolean normal, boolean emissive, boolean color){
Seq<VertexAttribute> attributes = Seq.with(
VertexAttribute.position3
);
@ -202,7 +206,9 @@ public class MeshBuilder{
attributes.add(packNormals ? VertexAttribute.packedNormal : VertexAttribute.normal);
}
attributes.add(VertexAttribute.color);
if(color){
attributes.add(VertexAttribute.color);
}
if(emissive){
attributes.add(new VertexAttribute(4, GL20.GL_UNSIGNED_BYTE, true, "a_emissive"));