use of com.builtbroken.mc.client.json.models.ModelData in project Engine by VoltzEngine-Project.
the class ModelState method render.
@Override
public boolean render(boolean subRender) {
TextureData textureData = getTexture();
ModelData data = getModel();
if (data != null && data.getModel() != null) {
//Starts rendering by storing previous matrix
GL11.glPushMatrix();
if (!subRender) {
//Scales object by value
if (scale != null) {
GL11.glScaled(scale.x(), scale.y(), scale.z());
} else if (parentState instanceof IModelState && ((IModelState) parentState).getScale() != null) {
GL11.glScaled(((IModelState) parentState).getScale().x(), ((IModelState) parentState).getScale().y(), ((IModelState) parentState).getScale().z());
}
//Rotates object, needs to be handled after scaling
if (rotation != null) {
GL11.glRotated(rotation.pitch(), 1, 0, 0);
GL11.glRotated(rotation.yaw(), 0, 1, 0);
GL11.glRotated(rotation.roll(), 0, 0, 1);
} else if (parentState instanceof IModelState && ((IModelState) parentState).getRotation() != null) {
GL11.glRotated(((IModelState) parentState).getRotation().pitch(), 1, 0, 0);
GL11.glRotated(((IModelState) parentState).getRotation().yaw(), 0, 1, 0);
GL11.glRotated(((IModelState) parentState).getRotation().roll(), 0, 0, 1);
}
//Moves the object
if (offset != null) {
GL11.glTranslated(offset.x(), offset.y(), offset.z());
} else if (parentState instanceof IModelState && ((IModelState) parentState).getOffset() != null) {
GL11.glTranslated(((IModelState) parentState).getOffset().x(), ((IModelState) parentState).getOffset().y(), ((IModelState) parentState).getOffset().z());
}
}
//Render parent
GL11.glPushMatrix();
if (parentState instanceof IModelState) {
if (renderParent) {
((IModelState) parentState).render(true);
} else if (parts == null && parentState instanceof ModelState && ((ModelState) parentState).renderParent) {
if (((ModelState) parentState).parentState instanceof IModelState) {
((IModelState) ((ModelState) parentState).parentState).render(true);
}
}
}
GL11.glPopMatrix();
//Binds texture
if (textureData != null) {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureData.getLocation());
} else {
//Backup texture bind, if no texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(SharedAssets.GREY_TEXTURE);
}
//Render model
data.render(renderOnlyParts, getPartsToRender());
//Ends render by restoring previous matrix(rotation, position, etc)
GL11.glPopMatrix();
return true;
}
return false;
}
Aggregations