작가/코드

Processing ESP Template

yuhyje 2014. 9. 10. 22:39


Processing

ESP Template



복붙해서 사용하면 되는 이에스피템플릿


int screenWidth = 15360;     // total width

int screenHeight = 8192;      // total height

int clientNum = 16;              // total number of clients

int portNum = 10101;         // port number for OSC     // 뭐지?

String[] ipList;                     // ip list for each clients

// 클라이언트마다 IP 가 할당되어 있나?

// 스트링인 걸 보니 140.56.67.8 이런 식의 IP 가 들어가나봐

int[] clientsDisplayX;    // client display left-upper corner x-coordinate

int[] clientsDisplayY;    // client display left-upper corner y-coordinate

int[] clientDisplayWidth;        // client display width

int[] clientDisplayHeight;       // client display height

// 각 클라이언트의 디스플레이에 접근할 수 있도록 만들어 주는 변수들

ESPServer mServer;


vlid setup()

{

  size(400, 400); // 뭐지?

  

  ipList = new String[clientNum];

  clientsDisplayX = new int[clientNum];

  clientsDisplayY = new int[clientNum];

  clientsDisplayWidth = new int[clientNum];

  clientsDisplayHeight = new int[clientNum];

      // 클라이언트 IP 리스트는 16개여야 하므로 모든 배열의 크기는 clientNum


  for (int i = 1; i <= 16; i++)      // 각 클라이언트의 넘버는 0~15 가 아니라 1~16

    {

    ipList[i-1] = "128.128.11." + i;      // 클라이언트[1]IP = 128.128.11.1

    if (i % 2 == 0) {

      clientsDisplayX[i-1] = 7680;

    }           // 짝수 클라이언트면 X 좌표 = 7680

    else {

      clientsDisplayX[i-1] = 0;

    }          // 홀수 클라이언트면 X 좌표 = 0


    clientsDisplayY[i-1] = 8192 - int((i+1) /2) * 1024;     // 맨 아랫줄이 클라이언트 1과 클라이언트 2

 

    clientsDisplayWidth[i-1] = 7680;     // 각 클라이언트의 가로는 1280*6 = 7680

    clientsDisplayHeight[i-1] = 1024;    // 각 클라이언트의 세로는 1024*1 = 1024

  }


mServer = new ESPServer(screenWidth, screenHeight, clientNum, portNum, ipList, 

clientsDisplayX, clientsDisplayY, clientsDisplayWidth, clientsDisplayHeight);

// mServer 초기화

 

  frameRate(20);     // 실행 빈도

 

  background(0);     // 일단 바탕은 검정

 

  while (mServer.getTCPClientLength () != 16) {

  }     // 이건 뭘까?

  ///////////////////////////////////////////////////

  //   Code from here 

  ///////////////////////////////////////////////////

}

 

void draw() {

 

  mServer.mFrameStart();

 

  ///////////////////////////////////////////////////

  //   draw code here for a frame

  ///////////////////////////////////////////////////

 

  mServer.mFrameEnd();

}