Re: Adding modular functionality to the RGB knobs in the demo
Status: Alpha
Brought to you by:
cwalther
From: Jonathan M. <jon...@gm...> - 2011-11-19 17:11:36
|
Hi Christian! Thank you. The more I thought about it, it seemed like maybe it would be easier for me to just erase the knobs all together and go with buttons. I appreciate your help, but even aside from the math of moving the wheels, there are also programming aspects that I'm not familiar with, such as where to tie the audio tracks to the dial settings. If I make buttons, and then either learn to make a hotspot map or perhaps just add a bunch of handles, then I think I can work within my present knowledge. The only thing I'm uncertain I can do is make the correct combination of buttons in node 18 trigger the key appearing in node 16. Still, with enough elbow grease I think I can reason it out. Nonetheless, trying to make sense of your code (with the aid of the comments) is helping me get a better handle on the math involved, though I still have to look up some of the programming vernacular. Jonathan On Fri, Nov 18, 2011 at 12:12 PM, Christian Walther <cwa...@gm...> wrote: > IndianaScones wrote: > > I am attempting to change the behavior of the RGB knobs in the building. > > Instead of a smooth range of motion, I would like to make them each have > 4 > > settings (when you click and drag a knob, it jumps through each of the 4 > > settings). Each of these settings will play a different looped audio > track. > > The key in the doorway behind you (when at the controls) will be > invisible > > at first, but it will appear when you have set the knobs to the correct > > combination. > > > > Here is an example of what I'm trying to accomplish (the settings with > > asterisks would be the secret combination): > > http://old.nabble.com/file/p32859425/screen.jpg > > > > ... > > > > It may be a lot of help to ask for (I don't know), but if someone can > even > > point me in the right direction, I would greatly appreciate it. When I > look > > at all that stuff in node 18 dealing with the RGB controls, I am > completely > > lost. > > I understand - there is a bit of math involved in moving something on a > circle, and then there is the animated gauge and all that adding more > complexity to the script of node 18. > > Here's a replacement mousestilldown function for the red knob that snaps > the knob to five regularly spaced positions on its circle, and hopefully > makes things a bit clearer with the comments: > > onmousestilldown = function() > -- center of the circle > local x0, y0 = 219, 422 > -- mouse location relative to the center of the circle > local x, y = pipmak.mouseloc() > x = x - x0 > y = y - y0 > -- if the mouse is exactly in the center, treat it as > slightly above > if x == 0 and y == 0 then y = -1 end > -- angle, clockwise from the top, in radians ([0..2*pi)) > local a = math.atan2(x, -y) > -- angle in fifth-circles ([0..5)) > a = a/(2*math.pi)*5 > -- round to the closest whole number > a = math.floor(a + 0.5) > -- convert back to radians > a = a/5*2*math.pi > -- convert from angle back to coordinates ([-1..1]) > x = math.sin(a) > y = -math.cos(a) > -- place the knob: center of the knob on a circle of radius > 21 around the center coordinates, therefore its top left corner 8 pixels > offset from that horizontally and vertically > redknob:moveto(x0 + x*21 - 8, y0 + y*21 - 8) > end > > To have irregularly spaced positions, as you depict, instead of rounding > the angle to the nearest whole number, you need to check if it's inside > each of the five ranges individually, and then snap it to the respective > position. > > Does that help? > > -Christian > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > Pipmak-Users mailing list > Pip...@li... > news://news.gmane.org/gmane.games.devel.pipmak.user > https://lists.sourceforge.net/lists/listinfo/pipmak-users > |