diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
| commit | 058a2edd75debbd0297f92572316daa704bd379f (patch) | |
| tree | ad303f091f9a08b209b91eb34a9fcad996a3de69 /src/simulation/elements/PHOT.cpp | |
| parent | e3594aba9e05c6865d396418c028049cda92c2f3 (diff) | |
| parent | 7a21ae192fe19868539956f3fe28e62b2c7c4429 (diff) | |
| download | powder-058a2edd75debbd0297f92572316daa704bd379f.zip powder-058a2edd75debbd0297f92572316daa704bd379f.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/simulation/elements/PHOT.cpp')
| -rw-r--r-- | src/simulation/elements/PHOT.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp new file mode 100644 index 0000000..ac8c5c8 --- /dev/null +++ b/src/simulation/elements/PHOT.cpp @@ -0,0 +1,141 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PHOT PT_PHOT 31 +Element_PHOT::Element_PHOT() +{ + Identifier = "DEFAULT_PT_PHOT"; + Name = "PHOT"; + Colour = PIXPACK(0xFFFFFF); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = -0.99f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = -1; + + Temperature = R_TEMP+900.0f+273.15f; + HeatConduct = 251; + Description = "Photons. Travel in straight lines."; + + State = ST_GAS; + Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PHOT::update; + Graphics = &Element_PHOT::graphics; +} + +//#TPT-Directive ElementHeader Element_PHOT static int update(UPDATE_FUNC_ARGS) +int Element_PHOT::update(UPDATE_FUNC_ARGS) + { + int r, rt, rx, ry; + float rr, rrr; + parts[i].pavg[0] = x; + parts[i].pavg[1] = y; + if (!(parts[i].ctype&0x3FFFFFFF)) { + sim->kill_part(i); + return 1; + } + if (parts[i].temp > 506) + if (1>rand()%10) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); + rrr = (rand()%360)*3.14159f/180.0f; + rr = (rand()%128+128)/127.0f; + parts[r>>8].vx = rr*cosf(rrr); + parts[r>>8].vy = rr*sinf(rrr); + sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + if ((r&0xFF)==PT_ISZS && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[r>>8].vx = rr*cosf(rrr); + parts[r>>8].vy = rr*sinf(rrr); + sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + } + r = pmap[y][x]; + if((r&0xFF) == PT_QRTZ && r)// && parts[i].ctype==0x3FFFFFFF) + { + float a = (rand()%360)*3.14159f/180.0f; + parts[i].vx = 3.0f*cosf(a); + parts[i].vy = 3.0f*sinf(a); + if(parts[i].ctype == 0x3FFFFFFF) + parts[i].ctype = 0x1F<<(rand()%26); + parts[i].life++; //Delay death + } + //r = pmap[y][x]; + //rt = r&0xFF; + /*if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN || rt==PT_PBCN) { + if (!parts[r>>8].ctype) + parts[r>>8].ctype = PT_PHOT; + }*/ + + return 0; +} + + + +//#TPT-Directive ElementHeader Element_PHOT static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS) + +{ + int x = 0; + *colr = *colg = *colb = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + + *firea = 100; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode &= ~PMODE_FLAT; + *pixel_mode |= FIRE_ADD | PMODE_ADD; + return 0; +} + + +Element_PHOT::~Element_PHOT() {}
\ No newline at end of file |
