Hey guys,
Lately, I have been trying to implement Openframeworks inside Unity as a Plug-in, so I searched around for a solution, and the only thing I found out was Vade’s implementation for Quartz Composer, which is really outdated. So I decided to compile Openframeworks inside a .bundle, so I could implement into Unity. I am sharing my first attempts and I will be happy, if somebody wants to upgrade on my source, because I am not really a hardcode c++ programmer. The problem I have right now is how to implement the Openframeworks pipeline (setup, update,exit) to sync with Unity, and how to share textures and etc. I would really love some input from someone who already has done this.
Here is a link to the XCode project: www.kamend.com/devel/OFUnity/OF0071Bundle.zip
You will probably have to fix some paths, to the Linked libraries, but it should work. After compiling, you should be able to add the .bundle file inside a Plugins folder in your Unity projects. There here is a sample C# script, that will get a basic functions running.
using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class OFBundle : MonoBehaviour {
[DllImport("OFBundle")]
private static extern float noiseX(float x);
private float scaleNoise;
// Use this for initialization
void Start () {
scaleNoise = UnityEngine.Random.Range(2,10);
}
// Update is called once per frame
void Update () {
scaleNoise += 0.02f;
float nX = noiseX (scaleNoise);
transform.localScale += new Vector3(nX,nX,nX);
if(scaleNoise > 20) scaleNoise = 2;
}
}
Let me know, if you have any questions or input.
Cheerz,
K