Question DMX plugin

amc85

New member
Joined
Jun 27, 2017
Messages
1
Programming Experience
Beginner
I'm working on a project trying to sync up lights in Unity game engine with real world lights controlled via DMX. I'm currently working on faking it by animating the Unity light to match a real world light as a kind of first phase prototype but I wanted to gain a bit of knowledge on what would be involved in doing it for real i.e. creating a plugin for Unity that could use incoming DMX data to control elements of the scene

I'm an animator so I am a total novice when it comes to programming (I know a very small amount of python) and would not be attempting to write any code myself but I would like to try and understand how this would be achieved.

Is C# the right language for this? I assume so given unity plugins are written in C#, a better question might be is this possible in C#? I believe ArtNet is a protocol for sending DMX data over ip networks. Does anyone have any experience with ArtNet? Would it be necessary to us ArtNet to communicate with Unity? How big of a task would it be to write a plugin such as this for someone with the necessary experience?
 
DMX communicates over EIA-485 which is a serial scheme and it looks like your hardware interface will be USB-485 adapter. Most likely it'll use a standard serial port to USB driver so you just have to talk to a serial port. That's fairly easy from Visual Studio using callbacks (you start a separate thread which monitors the serial port until a condition you set is met then it calls your code to deal with the contents). I've never used unity for serial comms but I imagine its probably the same thing.

The only thing that should really be different from a VS C# program and a Unity program is delays in processing. My VS apps were always event driven so the computer is doing virtually nothing and my comms thread returns and gets processed pretty much instantly. Unity uses a game loop which, even if empty, uses a fairly significant amount of CPU time (About 15% of my total CPU time on a 4gig 8 core) so there may be delays in the comms processing (probably something like 10-50ms).

Of course if you have enough buffer space and super-duper fast response time isn't needed then you could always just pull the bytes out of the buffer every game loop and store them in a variable until you've got a complete packet (may take several loops to get the entire thing) then process the information.

There is a bit of a learning curve, depending on which way you want to handle it but its not too bad.
 
Back
Top Bottom