mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-03 19:06:27 +01:00
some attrib stuff
This commit is contained in:
parent
3820e11954
commit
576165e3d6
4 changed files with 89 additions and 16 deletions
|
@ -7,4 +7,6 @@ public interface IVertexAttrib {
|
||||||
VertexAttribSpec attribSpec();
|
VertexAttribSpec attribSpec();
|
||||||
|
|
||||||
int getDivisor();
|
int getDivisor();
|
||||||
|
|
||||||
|
int getBufferIndex();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.simibubi.create.foundation.render.gl.attrib;
|
||||||
|
|
||||||
|
public enum ModelVertexAttributes implements IVertexAttrib {
|
||||||
|
VERTEX_POSITION("aPos", CommonAttributes.VEC3),
|
||||||
|
NORMAL("aNormal", CommonAttributes.NORMAL),
|
||||||
|
TEXTURE("aTexCoords", CommonAttributes.UV),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final VertexAttribSpec spec;
|
||||||
|
|
||||||
|
ModelVertexAttributes(String name, VertexAttribSpec spec) {
|
||||||
|
this.name = name;
|
||||||
|
this.spec = spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String attribName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexAttribSpec attribSpec() {
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDivisor() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBufferIndex() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +1,20 @@
|
||||||
package com.simibubi.create.foundation.render.gl.attrib;
|
package com.simibubi.create.foundation.render.gl.attrib;
|
||||||
|
|
||||||
public enum RotatingVertexAttributes implements IVertexAttrib {
|
public enum RotatingVertexAttributes implements IVertexAttrib {
|
||||||
VERTEX_POSITION("aPos", CommonAttributes.VEC3),
|
INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3),
|
||||||
NORMAL("aNormal", CommonAttributes.VEC3),
|
LIGHT("aLight", CommonAttributes.LIGHT),
|
||||||
TEXTURE("aInstancePos", CommonAttributes.VEC3),
|
NETWORK_COLOR("aNetworkTint", CommonAttributes.RGB),
|
||||||
INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3, 1),
|
SPEED("aSpeed", CommonAttributes.FLOAT),
|
||||||
LIGHT("aLight", CommonAttributes.LIGHT, 1),
|
OFFSET("aOffset", CommonAttributes.FLOAT),
|
||||||
NETWORK_COLOR("aNetworkTint", CommonAttributes.RGB, 1),
|
AXIS("aAxis", CommonAttributes.NORMAL),
|
||||||
SPEED("aSpeed", CommonAttributes.FLOAT, 1),
|
|
||||||
OFFSET("aOffset", CommonAttributes.FLOAT, 1),
|
|
||||||
AXIS("aAxis", CommonAttributes.NORMAL, 1),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final VertexAttribSpec spec;
|
private final VertexAttribSpec spec;
|
||||||
private final int divisor;
|
|
||||||
|
|
||||||
RotatingVertexAttributes(String name, VertexAttribSpec spec) {
|
RotatingVertexAttributes(String name, VertexAttribSpec spec) {
|
||||||
this(name, spec, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
RotatingVertexAttributes(String name, VertexAttribSpec spec, int divisor) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.divisor = divisor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,6 +29,11 @@ public enum RotatingVertexAttributes implements IVertexAttrib {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDivisor() {
|
public int getDivisor() {
|
||||||
return divisor;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBufferIndex() {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.simibubi.create.foundation.render.gl.attrib;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class VertexFormat2 {
|
||||||
|
|
||||||
|
private final ArrayList<Class<? extends Enum<? extends IVertexAttrib>>> allAttributes;
|
||||||
|
|
||||||
|
public VertexFormat2(ArrayList<Class<? extends Enum<? extends IVertexAttrib>>> allAttributes) {
|
||||||
|
this.allAttributes = allAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stream<IVertexAttrib> getAttributeStream() {
|
||||||
|
return (Stream<IVertexAttrib>) allAttributes.stream().flatMap(it -> Arrays.stream(it.getEnumConstants()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private final ArrayList<Class<? extends Enum<? extends IVertexAttrib>>> allAttributes;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
allAttributes = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <A extends Enum<A> & IVertexAttrib> Builder addAttributes(Class<A> attribEnum) {
|
||||||
|
allAttributes.add(attribEnum);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VertexFormat2 build() {
|
||||||
|
return new VertexFormat2(allAttributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue