Professional Documents
Culture Documents
Pregunta 4 - Mateo Jacome
Pregunta 4 - Mateo Jacome
Spacebrew:
Spacebrew.Event:
using UnityEngine;
using System;
using System.Collections;
SpacebrewClient sbClient;
GameObject sbCubo;
// Use this for initialization
void Start()
{
print("Iniciando Programa");
GameObject go = GameObject.Find("SpacebrewObject");
sbCubo = GameObject.Find("cubo");
sbClient = go.GetComponent<SpacebrewClient>();
sbClient.addEventListener(this.gameObject, "rotacionX");
sbClient.addEventListener(this.gameObject, "rotacionY");
sbClient.addEventListener(this.gameObject, "rotacionZ");
if (_msg.name == "rotacionY")
{
sbCubo.transform.rotation = Quaternion.Euler(0, Convert.ToInt32(_msg.value), 0);
}
if (_msg.name == "rotacionX")
{
sbCubo.transform.rotation = Quaternion.Euler(Convert.ToInt32(_msg.value), 0, 0);
}
if (_msg.name == "rotacionZ")
{
sbCubo.transform.rotation = Quaternion.Euler(Convert.ToInt32(_msg.value), 0, Convert.ToInt32(_msg.value));
}
}
}
Processing:
ControlP5 cp5;
Spacebrew sb;
PImage img;
String servidor="nidospacebrew.herokuapp.com";
String nombre="mateo";
int puerto=80;
void setup(){
size(1000,500);
cp5.addKnob("A2").setPosition(700,430).setRadius(30).setMin(0).setMax(1023).setDecimalPrecision(0);
cp5.addKnob("A1").setPosition(600,430).setRadius(30).setMin(0).setMax(1023).setDecimalPrecision(0);
cp5.addKnob("A0").setPosition(500,430).setRadius(30).setMin(0).setMax(1023).setDecimalPrecision(0);
cp5.addToggle("Pin13").setPosition(600,30).setSize(50,30);
background(255);
sb.send("A0", value);
println(value);
sb.send("A1", value);
println(value);
sb.send("A2", value);
println(value);
sb.send("Pin13", value);
println(value);