Skip to content

Instantly share code, notes, and snippets.

@StillManic
Created June 21, 2015 19:51
Show Gist options
  • Save StillManic/3f76777486b36e5b3b95 to your computer and use it in GitHub Desktop.
Save StillManic/3f76777486b36e5b3b95 to your computer and use it in GitHub Desktop.
@Override
public List<BakedQuad> getGeneralQuads()
{
if (quads == null)
{
quads = new LinkedHashSet<BakedQuad>();
LinkedHashSet<Face> faces = new LinkedHashSet<Face>();
Iterator<Element> elementIterator = this.model.getMatLib().getElements().values().iterator();
while (elementIterator.hasNext())
{
Element e = elementIterator.next();
if (e.isVisible()) faces.addAll(e.getFaces());
}
for (Face f : faces)
{
buffer.clear();
String texture = this.model.getMatLib().library.get(f).getName();
TextureAtlasSprite sprite = this.textures.get("missingno");
if (this.model.getMatLib().materials.get(texture).isWhite())
sprite = ModelLoader.White.instance;
else
sprite = this.textures.get(texture);
putVertexData(f.verts[0], f.texCoords != null ? f.texCoords[0] : null, f.norms != null ? f.norms[0] : f.getNormal(), sprite);
putVertexData(f.verts[1], f.texCoords != null ? f.texCoords[1] : null, f.norms != null ? f.norms[1] : f.getNormal(), sprite);
putVertexData(f.verts[2], f.texCoords != null ? f.texCoords[2] : null, f.norms != null ? f.norms[2] : f.getNormal(), sprite);
putVertexData(f.verts[3], f.texCoords != null ? f.texCoords[3] : null, f.norms != null ? f.norms[3] : f.getNormal(), sprite);
buffer.flip();
int[] data = new int[VERTICES_IN_QUAD * format.getNextOffset() / BYTES_IN_INT];
buffer.asIntBuffer().get(data);
quads.add(new ColoredBakedQuad(data, -1, EnumFacing.getFacingFromVector(f.getNormal().normal.x, f.getNormal().normal.y, f.getNormal().normal.z)));
}
}
List<BakedQuad> quadList = new ArrayList<BakedQuad>();
quadList.addAll(quads);
return quadList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment