Skip to content

Commit

Permalink
DMX-light v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbourgeois committed Sep 20, 2018
1 parent db03fca commit 0c93117
Show file tree
Hide file tree
Showing 14 changed files with 577 additions and 80 deletions.
330 changes: 314 additions & 16 deletions Assets/Main.unity

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/Materials/QuadMat.mat
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ Material:
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 0, g: 0.12941177, b: 0.12941177, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
20 changes: 18 additions & 2 deletions Assets/Scripts/ArtNetControllable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@

public class ArtNetControllable : Controllable {

[OSCProperty]
[Header("Settings")]

[OSCProperty(isInteractible = false)]
public string DeviceIP;

[OSCProperty]
[OSCProperty(isInteractible = false)]
public int ListeningPort;

[OSCProperty]
public int StartChannel;

[Header("Values")]

[OSCProperty(isInteractible = false)]
public int ColorRed;

[OSCProperty(isInteractible = false)]
public int ColorGreen;

[OSCProperty(isInteractible = false)]
public int ColorBlue;
}
49 changes: 21 additions & 28 deletions Assets/Scripts/ArtNetReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,9 @@

public class ArtNetReceiver : MonoBehaviour {

int colorR;
int colorG;
int colorB;

public bool BreakThread, Running;

public string DeviceIP;

static readonly object lockObject = new object();

private int _listeningPort;
private int _listeningPort = 5999;
public int ListeningPort
{
get
Expand All @@ -29,12 +21,20 @@ public int ListeningPort
set
{
_listeningPort = value;
Init();
}
}

public Material Mat;
public int StartChannel;

public int ColorRed;
public int ColorGreen;
public int ColorBlue;

public bool Running;

static readonly object lockObject = new object();

private bool BreakThread;
private UdpClient udp;
private Thread receiverThread;

Expand All @@ -49,11 +49,8 @@ void Start()

void Update()
{
Mat.color = new Color((colorR /255.0f), (colorG /255.0f), (colorB /255.0f));

if(!Running)
if(!Running)
{
BreakThread = false;
receiverThread = new Thread(new ThreadStart(ThreadMethod));
receiverThread.Start();
}
Expand All @@ -62,19 +59,16 @@ void Update()

private void OnApplicationQuit()
{
receiverThread.Abort();
}

private void Init() {
udp.Client.ReceiveTimeout = 10;
BreakThread = true;
}

private void ThreadMethod()
{
Running = true;
udp = new UdpClient(6002);
Debug.Log("Port : " + ListeningPort);
//Init();
udp = new UdpClient(5999);
//udp.Client.ReceiveTimeout = 1000; //1sec

while (true)
{
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Expand All @@ -85,15 +79,14 @@ private void ThreadMethod()
*not being accessed from multiple threads at thesame time*/
lock (lockObject)
{
//if (BreakThread)
// break;
if (BreakThread)
break;

colorR = receiveBytes[18];
colorG = receiveBytes[19];
colorB = receiveBytes[20];
ColorRed = receiveBytes[17 + StartChannel];
ColorGreen = receiveBytes[18 + StartChannel];
ColorBlue = receiveBytes[19 + StartChannel];
}
}
BreakThread = false;
Running = false;
}
}
9 changes: 3 additions & 6 deletions Assets/Scripts/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
public class InputManager : MonoBehaviour {

public GameObject Canvas;

// Update is called once per frame
void Update () {
if (Input.touchCount > 0)
Canvas.SetActive(!Canvas.activeInHierarchy);


public void ToggleUI()
{
Canvas.SetActive(!Canvas.activeInHierarchy);
}
}
14 changes: 14 additions & 0 deletions Assets/Scripts/MaterialInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MaterialInterface : MonoBehaviour {

public Material QuadMaterial;
public ArtNetReceiver Receiver;

// Update is called once per frame
void Update () {
QuadMaterial.color = new Color((Receiver.ColorRed / 255.0f), (Receiver.ColorGreen / 255.0f), (Receiver.ColorBlue / 255.0f));
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/MaterialInterface.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Assets/Scripts/UselessButNiceScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UselessButNiceScript : MonoBehaviour {

public Material MyMaterial;
private Text textComponent;

// Use this for initialization
void Start () {
textComponent = GetComponent<Text>();
}

// Update is called once per frame
void Update () {
textComponent.color = MyMaterial.color;
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/UselessButNiceScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Textures.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Textures/logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions Assets/Textures/logo2.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ GraphicsSettings:
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
Expand Down
Loading

0 comments on commit 0c93117

Please sign in to comment.