2016年12月5日 星期一

Unreal: Light Mechanism

since: 2016/12/05
update: 2016/12/14


A. 前置準備
     1. 採用 I touchs: Unreal: VR Template A ~ D 步驟, 完成基本專案設置

     2. 加入點光源到場景裡:

     3. 加入觸發空間到場景裡:

-----------------------------------------------------------------------------------------------

B. After Game BeginPlay 10 second, Turn Off Light (Set Visibility False)
     > Level Blueprint

-----------------------------------------------------------------------------------------------

C. Trigger Volume: Turn Light On / Off

     > Level Blueprint
    1. Check Property (default is right)

    2. Add On Actor Begin/End Overlap

    3. 結果:

    4. Trigger Volume: Turn Light On / Off

-----------------------------------------------------------------------------------------------

D. Turn On Light to Dark (Intensity = 0)

     > Level Blueprint

    1. add  "Set Intensity" node:

    2. Turn On Light to Dark

-----------------------------------------------------------------------------------------------

E.
Trigger Volume: Timeline Light Up / Down


     > Level Blueprint

    1. "Timeline_LightIntensity_Up" Node

    2. "Timeline_LightIntensity_Down" Node

    3. Trigger Volume: Timeline Light Up / Down

-----------------------------------------------------------------------------------------------

F. Unreal: OSC Received set Light Intensity


    1. Send from Processing:

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

int receivePort = 8001;

// osc target
String sendIP = "127.0.0.1";
int sendPort = 8000;

//@add ######
float myIntensity = 0.0;
float maxIntensity = 5000.0;
boolean isUp = true;


void setup() {
  size(400, 400);
  frameRate(25);

  /* start oscP5, listening for incoming messages */
  oscP5 = new OscP5(this, receivePort);

  myRemoteLocation = new NetAddress(sendIP, sendPort);
}

void draw() {
  background(0); 
  sendOSC();
}

void sendOSC() { 

  /* in the following different ways of creating osc messages are shown by example */
  OscMessage myMessage = new OscMessage("/position");

  /* add an float to the osc message */
  myMessage.add(myIntensity);

  /* send the message */
  oscP5.send(myMessage, myRemoteLocation);


  // tune Intensity
  // light isUp

  if (isUp) {
    if (myIntensity < maxIntensity) {
      myIntensity += 100;
    } else {
      myIntensity = maxIntensity;
      isUp = false;
    }
  // light isDown 
  } else {

    if (myIntensity > 0.0) {
      myIntensity -= 100;
    } else {
      myIntensity = 0.0;
      isUp = true;
    }
  }
}


    2. Receieved from Unreal:
     > Level Blueprint

-----------------------------------------------------------------------------------------------

G. Branch Send OSC:
    1. Branch Send OSC:

    2. Map Branch Send OSC:

-----------------------------------------------------------------------------------------------

H. Depending on The Situation, Send OSC

    1. float to integer: Truncate

    2. integer minus integer

    3. Add Variable: lastOSCValue

    4. Type: Integer; default value: 0

    5. Map Branch: When LastOSCValue Changed, Then Send OSC(int: 0 ~ 255)

-----------------------------------------------------------------------------------------------

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。