LaserBoy
Hardware => Lasers => Topic started by: James 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 (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!
//############################################################################
// 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. :)
-
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().
-
Like this:
//############################################################################
// 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;
}
//############################################################################
-
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.
-
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!
-
Make all your frames with effects first. Then optimize all that. THEN apply the spencer effect! :)
-
Heh... see... I said I was probably missing something! ;)
Can't wait to play around with this later!
-
Looking forward to seeing what you come up with! :)
-
OK, here are some samples from the 1-16 version:
As-drawn:
(http://www.likesgadgets.com/489143/Drawing.png)
ILDA format:
(http://www.likesgadgets.com/489143/CRW_3942-ilda.jpg)
ildadump.cpp spencerizer format:
(http://www.likesgadgets.com/489143/CRW_3943-mjw-spencer.jpg)
LaserBoy spencer frame set filter format:
(http://www.likesgadgets.com/489143/CRW_3944-lb-spencer.jpg)
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. :)
-
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.
-
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. :-[
-
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. :)