PHOT and GLAS effects?

  • Videogamer555
    2nd Jan 2012 Member 0 Permalink
    How does GLAS pass PHOT? I thought I could use tpt.create(x,y,"phot") where x and y correspond to a pixel already occupied by GLAS because I thought GLAS behaved to PHOT as NONE behaved to most other particles and would act as an empty container but being technically a different medium than none (my plan was to turn GLAS into a lasing medium but first I need to know how to spawn PHOT in GLAS to simulate the "stimulated emission" of a laser). However I can't spawn PHOT inside glass with tpt.create. Please help here.

    Oh, and how do I assign a color to a photon using Lua commands? TMP CTYPE and LIFE don't seem to work.
  • ArtMaster
    2nd Jan 2012 Banned 0 Permalink
    This post is hidden because the user is banned
  • jacksonmj
    2nd Jan 2012 Developer 0 Permalink
    Delete the glass, create the photon, then recreate the glass? (The method the C code uses to create photons on top of glass (e.g. from neutrons passing through glass) doesn't use the create_part function)

    Photon colour is set with ctype. Bits 0-11 add blue, bits 9-20 add green, bits 18-29 add red.
    So ctype = 0xF would be blue, ctype=0xF000 would be green, 0xF0000F would be purple.
  • ArtMaster
    2nd Jan 2012 Banned 0 Permalink
    This post is hidden because the user is banned
  • Videogamer555
    2nd Jan 2012 Member 0 Permalink

    jacksonmj:

    Delete the glass, create the photon, then recreate the glass? (The method the C code uses to create photons on top of glass (e.g. from neutrons passing through glass) doesn't use the create_part function)

    Photon colour is set with ctype. Bits 0-11 add blue, bits 9-20 add green, bits 18-29 add red.
    So ctype = 0xF would be blue, ctype=0xF000 would be green, 0xF0000F would be purple.


    So is there any way to create photons in glass using Lua in the same manner that the original C code does? Because I want to be able to create Photons on glass using Lua code like that to simulate "stimulated emission" which is so key to the working of a LASER. I don't want to have to change any of the existing update function of the glass.

    And are you sure that it's 12 bits per color channel not the normal 8 bits per color channel?
  • jacksonmj
    2nd Jan 2012 Developer 0 Permalink
    Here is the code it uses instead of calling create_part to get a new particle. pfree and parts_lastActiveIndex are not accessible from Lua. So not in the same manner, no. The reason I suggested "Delete the glass, create the photon, then recreate the glass" was that there aren't many other ways of doing it at the moment.
    if (pfree == -1)
    return;
    i = pfree;
    pfree = parts[i].life;
    if (i>parts_lastActiveIndex) parts_lastActiveIndex = i;
    parts[i].type = PT_PHOT;



    Yes, I'm sure. 12 bits which overlap. Source code for calculating PHOT colour (cpart is a pointer to the current particle):
    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;