Author Topic: Spencer's Projector  (Read 35208 times)

0 Members and 2 Guests are viewing this topic.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Spencer's Projector
« on: January 11, 2013, 05:26:22 pm »

Hey everyone! This is kind of a LaserBoy specific carry over from the PL thread about the Specer's Gifts Laser Projector and the idea to use a LaserBoy frame set effect to correct for mis drawn images as a result of bad firmware in the internal DAC of that projector.

http://www.photonlexicon.com/forums/showthread.php/18298-Laser-Projector-(Red-Green-Purple)-quot-Laser-3D-Party-Light-quot-from-Spencer-s

I post it here because the LaserBoy Forum has a text "code" format widget that does not mangle C/C++ code! :)

Copy this and paste it into the file LaserBoy_frame_set_effects.cpp. Scroll down to the bottom of the file and register this function's name like all the others and compile!

Code: [Select]
//############################################################################
// NOTE: The frame set effect named "spencer" is for the specific purpose of creating
// an invalid form of the ILDA file format in an attept to correct the behaviour
// of a specific laser projector that is known to have a built in DAC with bad firmware!
// It is NOT intended to produce any valuable special effect for any other purpose!
//############################################################################
int spencer(LaserBoy_frame_set* p_frame_set)
{
    bool                in_blank = false;
    int                 frame_count,
                        vertex_count;
    LaserBoy_frame      frame(p_frame_set->p_space);
    LaserBoy_frame_set  out  (p_frame_set->p_space);
    //------------------------------------------------------------------------
    for(frame_count = 0; frame_count < p_frame_set->number_of_frames(); frame_count++)
    {
        if(p_frame_set->at(frame_count).number_of_vertices() >= 2)
        {
            frame += p_frame_set->at(frame_count).at(0);
            for(vertex_count = 0; vertex_count < p_frame_set->at(frame_count).number_of_vertices() - 1; vertex_count++)
            {
                frame += p_frame_set->at(frame_count).at(vertex_count);
                frame.back().r = p_frame_set->at(frame_count).at(vertex_count + 1).r;
                frame.back().g = p_frame_set->at(frame_count).at(vertex_count + 1).g;
                frame.back().b = p_frame_set->at(frame_count).at(vertex_count + 1).b;
                frame.back().c = p_frame_set->at(frame_count).at(vertex_count + 1).c;
                frame.back().k = p_frame_set->at(frame_count).at(vertex_count + 1).k;
               
                if(    p_frame_set->at(frame_count).at(vertex_count + 1).is_blank()
                       // if the next vrtx (not added yet) is blank
                    && in_blank == false // we're not already in blank
                  )
                {
                    in_blank = true; // we're now in a blank
                    frame += p_frame_set->at(frame_count).at(vertex_count + 1); // add the next vrtx
                    frame.back().unblank(); // unblank it
                    // it will be added again as a blank in the next itteration of the for loop.
                }
                else if(p_frame_set->at(frame_count).at(vertex_count + 1).is_lit())
                // we're out of blank
                {
                    in_blank = false;
                }
            }
            frame += p_frame_set->at(frame_count).back(); // double the last vrtx
            frame += p_frame_set->at(frame_count).back(); // save_as_ild handles setting the last vrtx bit.
        }
        out += frame;
        frame.clear();
    }
    //------------------------------------------------------------------------
    out.save_as_ild(LASERBOY_ILD_SHARE + "spencer.spn");
    return LASERBOY_OK;
}

//############################################################################


James.  :)
« Last Edit: January 11, 2013, 05:42:27 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #1 on: January 13, 2013, 01:04:04 am »
I could also add a line or two to make sure that every frame gets promoted to 3D format 0. That would just be a matter of adding some number to every Z value. It might be best to only do that if the frame tests positive for is_2D().
« Last Edit: January 13, 2013, 01:06:25 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #2 on: January 13, 2013, 04:12:32 pm »

Like this:

Code: [Select]
//############################################################################
// NOTE: The frame set effect named "spencer" is for the specific purpose of creating
// an invalid form of the ILDA file format in an attept to correct the behaviour
// of a specific laser projector that is known to have a built in DAC with bad firmware!
// It is NOT intended to produce any valuable special effect for any other purpose!
//############################################################################
int spencer(LaserBoy_frame_set* p_frame_set)
{
    bool                in_blank = false;
    int                 frame_count,
                        vertex_count;
    LaserBoy_frame      frame(p_frame_set->p_space);
    LaserBoy_frame_set  out  (p_frame_set->p_space);
    //------------------------------------------------------------------------
    for(frame_count = 0; frame_count < p_frame_set->number_of_frames(); frame_count++)
    {
        if(p_frame_set->at(frame_count).number_of_vertices() >= 2)
        {
            frame += p_frame_set->at(frame_count).at(0);
            for(vertex_count = 0; vertex_count < p_frame_set->at(frame_count).number_of_vertices() - 1; vertex_count++)
            {
                frame += p_frame_set->at(frame_count).at(vertex_count);
                frame.back().r = p_frame_set->at(frame_count).at(vertex_count + 1).r;
                frame.back().g = p_frame_set->at(frame_count).at(vertex_count + 1).g;
                frame.back().b = p_frame_set->at(frame_count).at(vertex_count + 1).b;
                frame.back().c = p_frame_set->at(frame_count).at(vertex_count + 1).c;
                frame.back().k = p_frame_set->at(frame_count).at(vertex_count + 1).k;
               
                if(    p_frame_set->at(frame_count).at(vertex_count + 1).is_blank()
                       // if the next vrtx (not added yet) is blank
                    && in_blank == false // we're not already in blank
                  )
                {
                    in_blank = true; // we're now in a blank
                    frame += p_frame_set->at(frame_count).at(vertex_count + 1); // add the next vrtx
                    frame.back().unblank(); // unblank it
                    // it will be added again as a blank in the next itteration of the for loop.
                }
                else if(p_frame_set->at(frame_count).at(vertex_count + 1).is_lit())
                // we're out of blank
                {
                    in_blank = false;
                }
            }
            frame += p_frame_set->at(frame_count).back(); // double the last vrtx
            frame += p_frame_set->at(frame_count).back(); // save_as_ild handles setting the last vrtx bit.
        }
    //------------------------------------------------------------------------
        // if this frame is 2D format 1 promote it to 3D format 0.
        if(frame.is_2D())
            for(vertex_count = 0; vertex_count < frame.number_of_vertices(); vertex_count++)
                frame.at(vertex_count).z = 1000; // force it to 3D
    //------------------------------------------------------------------------
        out += frame;
        frame.clear();
    }
    //------------------------------------------------------------------------
    out.save_as_ild(LASERBOY_ILD_SHARE + "spencer.spn");
    return LASERBOY_OK;
}


//############################################################################
« Last Edit: January 13, 2013, 06:10:09 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #3 on: January 16, 2013, 12:43:59 pm »

This is a working version of LaserBoy with an untested "spencer" frame set effect.


I don't normally post beta versions, but I will make an exception.


Please try this out and let me know how it works!


Pictures are always a plus!


James.
« Last Edit: January 16, 2013, 12:45:46 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline Jeff F

  • Newbie
  • *
  • Posts: 2
  • Milliwatts: 0
    • View Profile
Re: Spencer's Projector
« Reply #4 on: January 16, 2013, 05:59:02 pm »
On my stock Spencer's laser it has definitely helped with those stray lines. Woo-hoo!  O0

But, and I'm probably missing something, it doesn't seem to help with when you apply an effect... which I think makes sense because the drawing order probably changes so the correction would have to change too?  Maybe?

I'll try to get some before and after pictures posted once I have the graphic I'm working on done.

Thanks again James!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #5 on: January 16, 2013, 06:01:01 pm »
Make all your frames with effects first. Then optimize all that. THEN apply the spencer effect! :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline Jeff F

  • Newbie
  • *
  • Posts: 2
  • Milliwatts: 0
    • View Profile
Re: Spencer's Projector
« Reply #6 on: January 16, 2013, 07:02:45 pm »
Heh... see... I said I was probably missing something! ;)

Can't wait to play around with this later!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #7 on: January 16, 2013, 07:51:48 pm »
Looking forward to seeing what you come up with! :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline tribble

  • Newbie
  • *
  • Posts: 20
  • Milliwatts: 0
    • View Profile
Re: Spencer's Projector
« Reply #8 on: January 20, 2013, 10:43:31 am »
OK, here are some samples from the 1-16 version:


As-drawn:



ILDA format:



ildadump.cpp spencerizer format:



LaserBoy spencer frame set filter format:



So! Getting closer!


I think in my original code I failed to correctly consider the "return to home" process, or my code for making the final vector light is incorrect. I am seeing in come places the last vector fail to light.


Thanks for the beta! I especially like how you don't have to go through the 6voqt^o dance to get a 3D frame when using the spencer output filter. That is nice. :)




Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #9 on: January 20, 2013, 11:00:51 am »
Did you look at the spencer effect in code? It's pretty simple. You can probably tweak it to do exactly what your C code does.
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline tribble

  • Newbie
  • *
  • Posts: 20
  • Milliwatts: 0
    • View Profile
Re: Spencer's Projector
« Reply #10 on: February 02, 2013, 11:13:57 am »
Well, I spent a few hours today trying again to set up an environment in which I can build LaserBoy, but no dice yet.


I downloaded and installed wx-Dev-C++, per DogP, but I can't get it to see the SDL libraries to the linker is failing.


I found a dirent.h for Visual Studio, but VS compiler does not like a lot of the C++ constructs that are accepted by the gcc compiler. So, that's kinds of a dead end unless I want to rewrite all of those bits.


I compared my spencerizer code with the code above, and I think it would be tedious but not terribly difficult to translate the effects. There are multiple transformations that need to occur; entering a blanking sequence, leaving a blanking sequence, ending a frame, and beginning a frame. Those would each have to be handled as they are in the ildadump.cpp code. I thought about trying to translate without compiling, but I figured that would not work out in the end. I'll need to be able to compile and test it to see if I'm interpreting your structures correctly.


So, it's going to take another while before I can submit an updated spencer frame effect.  :-[

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Spencer's Projector
« Reply #11 on: February 02, 2013, 12:36:13 pm »
You should just get regular old Dev-C++. That's what I've been using ever since I started working with libSDL in Windows. I could not get SDL libs to link in wxDev-C++ either.

http://www.bloodshed.net/devcpp.html

If you look at the code section I wrote for the spencer effect, you will see that it knows when it is entering and exiting a blank segment. Beginning and end of frame is kinda' built into the frame set and frame objects.

If you want to try to edit the code and send it to me to compile, I'd be glad to do that.

James.  :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.7 © 2008-2024, SimplePortal