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); return getAttribLocation(DefaultAttribute.a_texCoord);
case NORMAL: case NORMAL:
return getAttribLocation(DefaultAttribute.a_normal); return getAttribLocation(DefaultAttribute.a_normal);
case TANGENT:
return getAttribLocation(DefaultAttribute.a_tangent);
case BINORMAL:
return getAttribLocation(DefaultAttribute.a_binormal);
default: default:
return super.getVertexElementLocation(type); return super.getVertexElementLocation(type);
} }

View File

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