Thutmose_I

Untitled

Apr 23rd, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.07 KB | None | 0 0
  1. package t1a.client.modely;
  2.  
  3. import static org.lwjgl.opengl.GL11.GL_AMBIENT_AND_DIFFUSE;
  4. import static org.lwjgl.opengl.GL11.GL_BLEND;
  5. import static org.lwjgl.opengl.GL11.GL_COLOR_MATERIAL;
  6. import static org.lwjgl.opengl.GL11.GL_COMPILE;
  7. import static org.lwjgl.opengl.GL11.GL_FRONT_AND_BACK;
  8. import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
  9. import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
  10. import static org.lwjgl.opengl.GL11.GL_TRIANGLE_STRIP;
  11. import static org.lwjgl.opengl.GL11.glBegin;
  12. import static org.lwjgl.opengl.GL11.glBlendFunc;
  13. import static org.lwjgl.opengl.GL11.glCallList;
  14. import static org.lwjgl.opengl.GL11.glColor3b;
  15. import static org.lwjgl.opengl.GL11.glColorMaterial;
  16. import static org.lwjgl.opengl.GL11.glEnable;
  17. import static org.lwjgl.opengl.GL11.glEnd;
  18. import static org.lwjgl.opengl.GL11.glEndList;
  19. import static org.lwjgl.opengl.GL11.glGenLists;
  20. import static org.lwjgl.opengl.GL11.glNewList;
  21. import static org.lwjgl.opengl.GL11.glPopAttrib;
  22. import static org.lwjgl.opengl.GL11.glPopMatrix;
  23. import static org.lwjgl.opengl.GL11.glPushAttrib;
  24. import static org.lwjgl.opengl.GL11.glPushMatrix;
  25. import static org.lwjgl.opengl.GL11.glTranslated;
  26. import static org.lwjgl.opengl.GL11.*;
  27.  
  28. import java.nio.FloatBuffer;
  29. import java.util.ArrayList;
  30. import java.util.List;
  31. import java.util.Random;
  32.  
  33. import net.minecraft.client.renderer.entity.Render;
  34. import net.minecraft.entity.Entity;
  35.  
  36. import org.lwjgl.BufferUtils;
  37.  
  38. import t1a.common.safeWorldStuff.EntityExplosion;
  39. import t1a.common.safeWorldStuff.EntityExplosion.NukeParticle;
  40. import t1a.common.safeWorldStuff.LinearAlgebra;
  41.  
  42. public class RenderExplosion extends Render {
  43.  
  44.     private FloatBuffer fb= BufferUtils.createFloatBuffer(16);
  45.     public List<NukeParticle> particles = new ArrayList<NukeParticle>();
  46.     static int callCube;
  47.     static int callTetra;
  48.     static LinearAlgebra vec;
  49.     Random r = new Random();
  50.     double scale = 2;
  51.    
  52.     public RenderExplosion(){
  53.         super();
  54.         compileTetra();
  55.     }
  56.     @Override
  57.     public void doRender(Entity entity, double d0, double d1, double d2,
  58.             float f, float f1) {
  59.        
  60.         assert(entity instanceof EntityExplosion);
  61.         EntityExplosion explosion= (EntityExplosion) entity;
  62.         particles = explosion.particles;
  63.        
  64.         glPushMatrix();
  65.         glPushAttrib(GL_BLEND);
  66.         glEnable (GL_BLEND);
  67.         glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  68.         glColor4b((byte)115, (byte)67, (byte)46, (byte)50);//TODO get this looking better colour.
  69.         glTranslated(d0, d1, d2);//trans whole thing
  70.     //*
  71.         for(NukeParticle particle : particles){
  72.             double  x = particle.x,
  73.                     y = particle.y,
  74.                     z = particle.z;
  75.         /* 
  76.             glBegin(GL_TRIANGLE_STRIP);
  77.             glVertex3d(0.5+x,y, z-0.5/1.41);
  78.             glVertex3d(x-0.5, y, z-0.5/1.41);
  79.             glVertex3d(x, y+0.5, z+0.5/1.41);
  80.             glVertex3d(x, y-0.5,z+0.5/1.41);
  81.             glVertex3d(0.5+x,y, z-0.5/1.41);
  82.             glVertex3d(x-0.5, y, z-0.5/1.41);
  83.             glEnd();
  84.             //*/
  85.            
  86.             glBegin(GL_TRIANGLE_STRIP);
  87.             glVertex3d(x+scale, y, z);
  88.             glVertex3d(x, y, z);
  89.             glVertex3d(x+scale, y+scale, z);
  90.             glVertex3d(x, y+scale, z);
  91.            
  92.  
  93.             glVertex3d(x+scale, y+scale, z+scale);
  94.             glVertex3d(x, y+scale,z+ scale);
  95.            
  96.  
  97.             glVertex3d(x+scale, y, z+scale);
  98.             glVertex3d(x, y, z+scale);
  99.  
  100.             glVertex3d(x+scale, y, z);
  101.             glVertex3d(x, y, z);   
  102.             glEnd();
  103.            
  104.             glBegin(GL_TRIANGLE_STRIP);
  105.             glVertex3d(x, y, z);
  106.             glVertex3d(x, y, z+scale);
  107.             glVertex3d(x, y+scale, z);
  108.             glVertex3d(x, y+scale, z+scale);
  109.             glEnd();
  110.            
  111.             glBegin(GL_TRIANGLE_STRIP);
  112.             glVertex3d(x+scale, y+scale, z);
  113.             glVertex3d(x+scale, y+scale, z+scale);
  114.             glVertex3d(x+scale, y, z);
  115.             glVertex3d(x+scale, y, z+scale);
  116.             glEnd();
  117.         }
  118.         //*/
  119.         glPopAttrib();
  120.         glPopMatrix();
  121.     }
  122.    
  123.     public static void compileTetra(){
  124.         callTetra= glGenLists(1);
  125.        
  126.         glNewList(callTetra, GL_COMPILE);
  127.        
  128.         glBegin(GL_TRIANGLE_STRIP);
  129.         glVertex3f(0.5f, 0, -0.5f/1.41f);
  130.         glVertex3f(-0.5f, 0, -0.5f/1.41f);
  131.         glVertex3f(0, 0.5f, 0.5f/1.41f);
  132.         glVertex3f(0, -0.5f,0.5f/1.41f);
  133.         glVertex3f(0.5f, 0, -0.5f/1.41f);
  134.         glVertex3f(-0.5f, 0, -0.5f/1.41f);
  135.         glEnd();
  136.        
  137.         glEndList();
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment