Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. public class RenderRadiationBubble extends Render<EntityRadiationBubble> {
  2.  
  3. private RenderHelper.UsableModel model;
  4.  
  5. protected RenderRadiationBubble(RenderManager renderManager) {
  6. super(renderManager);
  7. model = RenderHelper.LoadOBJ(new ResourceLocation(AncientAddinMod.MODID, "models/sphere.obj"));
  8. }
  9.  
  10. public void doRender(EntityRadiationBubble entity, double x, double y, double z, float entityYaw, float partialTicks) {
  11. GlStateManager.pushMatrix();
  12. GlStateManager.scale(1, 1, 1);
  13. GlStateManager.translate(x, y, z);
  14. GlStateManager.color(0, 1.0f, 0, 1.0f);
  15. RenderHelper.DrawModel(model);
  16. GlStateManager.popMatrix();
  17. }
  18.  
  19. @Nullable
  20. protected ResourceLocation getEntityTexture(EntityRadiationBubble entity) {
  21. return TextureMap.LOCATION_BLOCKS_TEXTURE;
  22. }
  23.  
  24. }
  25.  
  26. public class RenderHelper {
  27.  
  28. public static class UsableModel {
  29. private IBakedModel Model;
  30. private VertexFormat VFormat;
  31.  
  32. private UsableModel(IBakedModel bm, VertexFormat fmt) {
  33. Model = bm;
  34. VFormat = fmt;
  35. }
  36. }
  37.  
  38. public static UsableModel LoadOBJ(ResourceLocation loc) {
  39. IBakedModel fres = null;
  40. try {
  41. IModel tmp = OBJLoader.INSTANCE.loadModel(loc);
  42. fres = tmp.bake(tmp.getDefaultState(), DefaultVertexFormats.POSITION_TEX_NORMAL, ModelLoader.defaultTextureGetter());
  43. } catch (Exception e) {
  44. e.printStackTrace();
  45. }
  46. return (new UsableModel(fres, DefaultVertexFormats.POSITION_TEX_NORMAL));
  47. }
  48.  
  49. public static void DrawModel(UsableModel model) {
  50. Tessellator t = Tessellator.getInstance();
  51. VertexBuffer vb = t.getBuffer();
  52. vb.begin(GL11.GL_QUADS, model.VFormat);
  53. for (BakedQuad q : model.Model.getQuads(null, null, 0)) {
  54. vb.addVertexData(q.getVertexData());
  55. }
  56. t.draw();
  57. }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement