the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 85 lines 2.6 kB view raw
1#include "stdafx.h" 2#include "HugeExplosionParticle.h" 3#include "..\Minecraft.World\Random.h" 4#include "Textures.h" 5#include "Tesselator.h" 6#include "Lighting.h" 7#include "ResourceLocation.h" 8 9ResourceLocation HugeExplosionParticle::EXPLOSION_LOCATION = ResourceLocation(TN_MISC_EXPLOSION); 10 11HugeExplosionParticle::HugeExplosionParticle(Textures *textures, Level *level, double x, double y, double z, double xa, double ya, double za) : Particle(level,x,y,z,0,0,0) 12{ 13 life = 0; 14 15 this->textures = textures; 16 lifeTime = 6 + random->nextInt(4); 17 18 // rCol = gCol = bCol = random->nextFloat() * 0.6f + 0.4f; 19 20 unsigned int clr = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_HugeExplosion ); //0x999999 21 double r = ( (clr>>16)&0xFF )/255.0f, g = ( (clr>>8)&0xFF )/255.0, b = ( clr&0xFF )/255.0; 22 23 double br = random->nextFloat() * 0.6 + 0.4; 24 rCol = r * br; 25 gCol = g * br; 26 bCol = b * br; 27 28 size = 1 - (float) xa * 0.5f; 29} 30 31void HugeExplosionParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) 32{ 33 int tex = (int) ((life + a) * 15 / lifeTime); 34 if (tex > 15) return; 35 textures->bindTexture(&EXPLOSION_LOCATION); 36 37 float u0 = (tex % 4) / 4.0f; 38 float u1 = u0 + 0.999f / 4.0f; 39 float v0 = (tex / 4) / 4.0f; 40 float v1 = v0 + 0.999f / 4.0f; 41 42 float r = 2.0f * size; 43 44 float x = (float) (xo + (this->x - xo) * a - xOff); 45 float y = (float) (yo + (this->y - yo) * a - yOff); 46 float z = (float) (zo + (this->z - zo) * a - zOff); 47 48 // 4J - don't render explosion particles that are less than 3 metres away, to try and avoid large particles that are causing us problems with photosensitivity testing 49 float distSq = (x*x + y*y + z*z); 50 if( distSq < ( 3.0f * 3.0f )) return; 51 52 glColor4f(1, 1, 1, 1); 53 glDisable(GL_LIGHTING); 54 Lighting::turnOff(); 55 t->begin(); 56 t->color(rCol, gCol, bCol, 1.0f); 57 t->normal(0, 1, 0); 58 t->tex2(0x00f0); 59 t->vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u1, v1); 60 t->vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u1, v0); 61 t->vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); 62 t->vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v1); 63 t->end(); 64 glPolygonOffset(0, 0.0f); 65 glEnable(GL_LIGHTING); 66} 67 68int HugeExplosionParticle::getLightColor(float a) 69{ 70 return 0xf0f0; 71} 72 73void HugeExplosionParticle::tick() 74{ 75 xo = x; 76 yo = y; 77 zo = z; 78 life++; 79 if (life == lifeTime) remove(); 80} 81 82int HugeExplosionParticle::getParticleTexture() 83{ 84 return ParticleEngine::ENTITY_PARTICLE_TEXTURE; 85}