공부한거 까먹을까봐 내가 그냥 이해하기 쉽게만 정리해놓았음
import megamu.shapetween.*;
import oscP5.*;
import netP5.*;
import processing.opengl.*;
import foetus.*;
import processing.core.*;
import processing.core.PApplet.RegisteredMethods;
import java.util.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
// Messages:
// "/Gradient/TopColor" iii
// "/Gradient/BottomColor" iii
public Foetus f;
FoetusParameter m_TopR;
FoetusParameter m_TopG;
FoetusParameter m_TopB;
FoetusParameter m_BotR;
FoetusParameter m_BotG;
FoetusParameter m_BotB;
//파라미터 형식 (파라미터, value, 주소, 태그)
void setup()
{
// When run as a synth, setup() is never called!->신스돌때 셋업 함수 절대 호출안되염!
// put the necessary initialization code in a method named initializeFoetus().->그니깐 초기화 코드 가능하면 이니셜라이즈풰투스에 하셈
// The necessary Processing initialization calls are called by Mother, and so should be left out from
// initializeFoetus(). ->프로세싱 초기화는 머더에 의해 불려진뎅.
// Finally, for the synth to work as a processing sketch within the PDE, call initializeFoetus() from within
// setup().
->신스가 일하게 하기위해선 이니셜라이즈페투스를 셋업서 포함하여 호출해야함
size(400, 300, OPENGL);
frameRate(24);
initializeFoetus();
//->바로 여기서!
}
void initializeFoetus()
{
noStroke();
// Instantiate foetus object here
f = new Foetus(this);
//이걸 전화기라고 생각하련다
// Register messages that synth responds to (see OSC documentation)
// This is here done automatically by the FoetusParameter constructors.
m_TopR = new FoetusParameter(f, 1.0, "/TopRed", "f");
m_TopG = new FoetusParameter(f, 0, "/TopGreen", "f");
m_TopB = new FoetusParameter(f, 0, "/TopBlue", "f");
m_BotR = new FoetusParameter(f, 0, "/BotRed", "f");
m_BotG = new FoetusParameter(f, 0, "/BotGreen", "f");
m_BotB = new FoetusParameter(f, 0, "/BotBlue", "f");
//각각의 알쥐비를 가져다줄 전화기들
}
void draw()
{
pushMatrix();
beginShape(QUADS);
fill(m_TopR.getValue()*255, m_TopG.getValue()*255, m_TopB.getValue()*255);
//각각의 값을 가져와 *255를 해주면 색깔로 표현이 되겠지여~
vertex(0, 0);
vertex(width - 1, 0);
fill(m_BotR.getValue()*255, m_BotG.getValue()*255, m_BotB.getValue()*255);
vertex(width - 1, height - 1);
//원래 가로세로 길이에서 -1만큼 작게 네모를 그리넹~>
vertex(0, height - 1);
endShape();
popMatrix();
}
/**
* This method is called when an OSC message is received by the synth.
*/
//리씨브 받는곳
void oscEvent(OscMessage theOscMessage)
{
//주소확인
if (theOscMessage.checkAddrPattern("/TopRed") == true)
{
/* check if the typetag is the right one. */
//태그가 이게 맞으면 일을하셈
if (theOscMessage.checkTypetag("f"))
{
m_TopR.setValue(theOscMessage.get(0).floatValue());
return;
}
}
else if (theOscMessage.checkAddrPattern("/TopGreen") == true)
{
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("f"))
{
m_TopG.setValue(theOscMessage.get(0).floatValue());
return;
}
}
else if (theOscMessage.checkAddrPattern("/TopBlue") == true)
{
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("f"))
{
m_TopB.setValue(theOscMessage.get(0).floatValue());
return;
}
}
else if (theOscMessage.checkAddrPattern("/BotRed") == true)
{
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("f"))
{
m_BotR.setValue(theOscMessage.get(0).floatValue());
return;
}
}
else if (theOscMessage.checkAddrPattern("/BotGreen") == true)
{
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("f"))
{
m_BotG.setValue(theOscMessage.get(0).floatValue());
return;
}
}
else if (theOscMessage.checkAddrPattern("/BotBlue") == true)
{
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("f"))
{
m_BotB.setValue(theOscMessage.get(0).floatValue());
return;
}
}
}