Here's a simple example of how to connect Arduino to the (open source) Cry Engine 3 which is used for Crysis 2.
Arduino to Cry Engine 3 from baka on Vimeo.
Saw some guy on the crydev.net forum working on this and thought it was pretty interesting so I gave it a try.
Processing writes data from a potmeter (connected to Arduino Uno) to an .xml file every 50 miliseconds. Cry Engine then reads the .xml files and acts to whatever you've put in the flowgraph(s)
Assuming you already have some very basic knowledge with Arduino / processing / Cry Engine here's how to get it done:
- get the proxml library for processing from HERE and install it following the instructions
- get the processing library for Arduino HERE and install it following the instructions
- upload the standard firmata sketch to Arduino (File > Examples > Firmata > Standard Firmata)
- connect potmeter to Arduino ( analog port 0 if you want to use the same code as below)
- Save the following sketch in the game folder inside the Engine Map. Mind that the sketch saves the .xml file inside the “data” folder which is inside the sketch folder!
The XML file will look like this:
The pot meter position will be a number somewhere between 0 and 24 since the Cry Engine usually works with a 24 hour system.
Now you'll want to create a flowgraph in Cry Engine which reads this .xml file and does something - in this case change the Time Of Day setting in-game. If you've never worked with the engine's flowgraph editor I suggest you follow some tutorials on YouTube (there's a ton of them) untill you understand the basics. Then you can simply build the following flowgraph (and of course edit it to your own needs)
You can place the sketch folder anywhere you like, just be sure to put in the right path on the OpenDocument node. This can be done by clicking on the node and editing its contents somewhere on the right (in my case the sketch folder is called “XML_WIN” – as you can see in the picture)
Main credits go to this guy at the crydev forums who posted the initial idea and code, I wanted to try it myself and show it to the processing community ;)