diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2013-08-29 16:19:07 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2013-08-29 16:19:07 (GMT) |
| commit | bebe9bd8fd0e4b73fdeb9ea0218bda704e0a6fad (patch) | |
| tree | 1761908c99d6848aede291df5de67fff5b32a425 /src/simulation/elements/FILT.cpp | |
| parent | c59b6d04660b1ac41d8f83f7b84218d13d9d29b8 (diff) | |
| download | powder-bebe9bd8fd0e4b73fdeb9ea0218bda704e0a6fad.zip powder-bebe9bd8fd0e4b73fdeb9ea0218bda704e0a6fad.tar.gz | |
Add a way for photons to set the colour of FILT (major version bump required)
Also add some new FILT modes, and make FILT modes affect BIZR and
BRAY colour in the same way as they affect photon colour. Photons
passing next to DTEC will set the colour of all FILT in a straight
line starting from any FILT adjacent to the DTEC (a bit like an
ARAY beam), and the exact colour of the photon will be used for
FILT interactions instead of the colour based on temperature.
FILT tmp=4: red shift, tmp=5: blue shift. Size of shift determined
by FILT temperature. tmp=6: FILT has no effect on photon colour
(possible before by using invalid tmp modes, but here's a supported
method of doing it. Invalid tmp modes should be automatically replaced
in existing saves).
Also, FILT mode is now described in the HUD.
Diffstat (limited to 'src/simulation/elements/FILT.cpp')
| -rw-r--r-- | src/simulation/elements/FILT.cpp | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/src/simulation/elements/FILT.cpp b/src/simulation/elements/FILT.cpp index d6b82f2..62c3afc 100644 --- a/src/simulation/elements/FILT.cpp +++ b/src/simulation/elements/FILT.cpp @@ -48,21 +48,17 @@ Element_FILT::Element_FILT() //#TPT-Directive ElementHeader Element_FILT static int graphics(GRAPHICS_FUNC_ARGS) int Element_FILT::graphics(GRAPHICS_FUNC_ARGS) - { - int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); - if (temp_bin < 0) temp_bin = 0; - if (temp_bin > 25) temp_bin = 25; - cpart->ctype = 0x1F << temp_bin; + int x, wl = Element_FILT::getWavelengths(cpart); *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; + *colr += (wl >> (x+18)) & 1; + *colb += (wl >> x) & 1; } for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; + *colg += (wl >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *cola = 127; *colr *= x; @@ -73,5 +69,56 @@ int Element_FILT::graphics(GRAPHICS_FUNC_ARGS) return 0; } +//#TPT-Directive ElementHeader Element_FILT static int interactWavelengths(Particle* cpart, int origWl) +// Returns the wavelengths in a particle after FILT interacts with it (e.g. a photon) +// cpart is the FILT particle, origWl the original wavelengths in the interacting particle +int Element_FILT::interactWavelengths(Particle* cpart, int origWl) +{ + const int mask = 0x3FFFFFFF; + int filtWl = getWavelengths(cpart); + switch (cpart->tmp) + { + case 0: + return filtWl; //Assign Colour + case 1: + return origWl & filtWl; //Filter Colour + case 2: + return origWl | filtWl; //Add Colour + case 3: + return origWl & (~filtWl); //Subtract colour of filt from colour of photon + case 4: + { + int shift = int((cpart->temp-273.0f)*0.025f); + if (shift<=0) shift = 1; + return (origWl << shift) & mask; // red shift + } + case 5: + { + int shift = int((cpart->temp-273.0f)*0.025f); + if (shift<=0) shift = 1; + return (origWl >> shift) & mask; // blue shift + } + case 6: + return origWl; // No change + default: + return filtWl; + } +} + +//#TPT-Directive ElementHeader Element_FILT static int getWavelengths(Particle* cpart) +int Element_FILT::getWavelengths(Particle* cpart) +{ + if (cpart->ctype) + { + return cpart->ctype; + } + else + { + int temp_bin = (int)((cpart->temp-273.0f)*0.025f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + return (0x1F << temp_bin); + } +} Element_FILT::~Element_FILT() {} |
