bump mapping vertex attributes

This commit is contained in:
Vadim Lopatin 2016-04-06 09:39:42 +03:00
parent f5db3da85f
commit 31f2c79271
2 changed files with 16 additions and 1 deletions

View File

@ -143,6 +143,10 @@ class Effect : GLProgram {
return getAttribLocation(DefaultAttribute.a_texCoord);
case NORMAL:
return getAttribLocation(DefaultAttribute.a_normal);
case TANGENT:
return getAttribLocation(DefaultAttribute.a_tangent);
case BINORMAL:
return getAttribLocation(DefaultAttribute.a_binormal);
default:
return super.getVertexElementLocation(type);
}

View File

@ -119,6 +119,10 @@ enum VertexElementType : ubyte {
POSITION = 0,
NORMAL,
COLOR,
TANGENT,
BINORMAL,
BLENDWEIGHTS,
BLENDINDICES,
TEXCOORD0,
TEXCOORD1,
TEXCOORD2,
@ -168,11 +172,16 @@ struct VertexElement {
this(VertexElementType type, ubyte size = 0) {
if (size == 0) {
// autoassign default size
switch(type) with (VertexElementType) {
case POSITION:
case NORMAL:
case TANGENT:
case BINORMAL:
size = 3;
break;
case BLENDWEIGHTS:
case BLENDINDICES:
case COLOR:
size = 4;
break;
@ -503,7 +512,9 @@ class Mesh : RefCountedObject {
}
static Mesh createCubeMesh(vec3 pos, float d=1, vec4 color = vec4(1,1,1,1)) {
Mesh mesh = new Mesh(VertexFormat(VertexElementType.POSITION, VertexElementType.COLOR, VertexElementType.TEXCOORD0));
Mesh mesh = new Mesh(VertexFormat(VertexElementType.POSITION, VertexElementType.COLOR, VertexElementType.TEXCOORD0
//, VertexElementType.TANGENT, VertexElementType.BINORMAL
));
mesh.addCubeMesh(pos, d, color);
return mesh;
}