public GcmfVertex(ObjMtlVertex vtx) { this.Position = vtx.Position; this.Normal = vtx.Normal; this.PrimaryTexCoord = vtx.TexCoord; /* OBJ considers (0,0) to be the top left, GMA and OpenGL consider it to be the bottom left. * See http://stackoverflow.com/a/5605027 (Thanks to Tommy @ StackOverflow). */ if (this.PrimaryTexCoord.HasValue) { this.PrimaryTexCoord = new Vector2(this.PrimaryTexCoord.Value.X, 1 - this.PrimaryTexCoord.Value.Y); } }
public GcmfVertex(ObjMtlVertex vtx) { if (vtx.Position.W != 1.0f) { throw new InvalidGmaFileException("The W component of the vertex position must be 1 if present."); } this.Position = new Vector3(vtx.Position.X, vtx.Position.Y, vtx.Position.Z); this.Normal = vtx.Normal; if (vtx.TexCoord.HasValue) { if (vtx.TexCoord.Value.Z != 0.0f) { throw new InvalidGmaFileException("The W component of the texture coordinate must be 0 if present."); } /* OBJ considers (0,0) to be the top left, GMA and OpenGL consider it to be the bottom left. * See http://stackoverflow.com/a/5605027 (Thanks to Tommy @ StackOverflow). */ this.PrimaryTexCoord = new Vector2(vtx.TexCoord.Value.X, 1 - vtx.TexCoord.Value.Y); } }