0 like 0 dislike
331 views
I have some data sent through OSC into unreal and I would like to plot into my scene using popcorn. I see some examples on graphs but I can't figure out how to feed my data into through blueprint.

Any help would be appreciated!
by gbernal (340 points)

1 Answer

0 like 0 dislike

Hi,

If I understand you right, you want to "send" data to a particle effect, that data coming from your OSC system ?

An option you can use is using the Curve attribute sampler, and override that attribute sampler with a CurveDynamic attribute sampler in unreal. That dynamic curve lets you use the "SetCurve1D" blueprint function, where you can feed your audio data.

Here are two screenshots showing this method:

  • An effect has particles spawning and sampling "Curve_1" to define their velocity
  • In UE4, the "Curve_1" attrbute sampler pops up
  • Feed the name of the "CurveDynamic" attribute sampler (can be created as a component)
  • You can "SetCurve1D" each frame or when you want with an array of float

Few important points:

  • Data sent to this curve needs to be within [0,1] range (let us know if that is a problem)
  • The curve will be linearly interpolated (is that a problem also ?)
  • Dynamic curves can only be of 1 dimension right now, you can just create several curve attribute samplers in your effect to have several dimensions (x/y/z/...)
  • Attributes samplers can only be accessed at particle spawn, which means that this curve data cannot be read by particles over their lifetime (evolve)
  • Each time "SetValue1D" is called on the curve attribute sampler with a float array of a different size than the previous call, it will resize internal buffers. Make sure to use a fixed array size to avoid resizing each call
Hope this helps
by HugoPKFX (17.5k points)
Hi Hugo,

Yes, you are correct to understand that I  want to "send" data to a particle effect, that data coming from your OSC system ? The data is analog sensor data.

I have a scene to teach students about physiological data(i.e ECG, EDA, EMG, Body temperature to name a few) the sensors that user is wearing are talking to unreal through OSC.
 I think mapping it to 0-1 might create an issue. I have never tried to do that normally just plot values in respect to ohms or millivolts.
As long as values are floats, this can easily be fixed. Using the technique I mentioned above your values will be clamped to the [0;1] range, but we can fix that easily.
Let us know how it goes first even with the 0;1 value clamp, and if that solutions suits you but you'd like to have [-infinity;infinity] range we'll add that to the next plugin update.
Thank you
Hi,

I have tried your suggestion but it seems that I'm missing something because I don't get a proper response in unreal.

Here are some images
http://imgur.com/a/s3I9R


I followed your instruction as you can see in the images attached, but in the unreal side something is breaking.

Thank you for your help
Thank you for trying this out,

So the setup in your effect seems ok, same for your blueprint components (effect + attribute sampler).

The only things that is strange is the data sent in SetValues1D: This dynamic curve attribute samplers is expecting an array of floating point values, each value will generate a "key" on this curve. In the example you show you are only feeding a single float value, which will not work (and that's why you have this result I think).

A few questions:
- Is having a single value per frame for Osc data what you except ? If that is the case then using an attribute will work better (let me know)
- Is OnOscReceived event triggered several times within a frame ?
- What is the data type of "data" on this event ?
- The data seems to be an array, which you use a "Pop float" node to extract a value ? How does this works exactly ? Can you not convert this "data" array to a float array directly and feed that into "SetValues1D" ?

Sorry for those questions if they are obvious but I'm not used to Osc data,

Thank you
Thank you for your reply,

To answer your questions:
- Is having a single value per frame for Osc data what you except ? If that is the case then using an attribute will work better (let me know) < this might be a solution

 In a way yes. For each physiological data type. I will have a stream of Floats
coming in.
- Is OnOscReceived event triggered several times within a frame ? this keeps triggering as long as I'm sending data from my python code to unreal engine.

- What is the data type of "data" on this event ?
float
- The data seems to be an array, which you use a "Pop float" node to extract a value ? How does this works exactly ? Can you not convert this "data" array to a float array directly and feed that into "SetValues1D" ?

The OSCRx event gives: the OSC address, the OSC parameters and the IP of the sender.

The OSC parameters is an array of OSC elements. To read the content, either:

chain PopFloat/Int/Bool/String/Blob functions to get the first value, this where the issue  of passing an array comes from. I have to select my GSR value and pop it then create an array there is no way that I know that I can directly pass the array  into "SetValues1D".
It all depends on the incoming data, and if it's variable or not.

If you expecont ly 1 Value per frame, per physiological data type, then using Attributes is the way to go. On top of it you'll be able to access attributes during the particle's lifetime !

You can just create several attributes in your effect for example:
- MyDataType1
- MyDataType2
- ...
Make sure they have not "max/min" limit -> That way you can have values in the whatever range you like

Then instead of doing SetValues1D on the attribute sampler (that you can remove entirely by the way), you can do "SetAttribute" on the emitter with the correct attribute index. Attribute index being found using "FindAttributeIndex" BP node that needs the attribute name as input.

Then you can just switch on the incoming data type and do the correct SetAttribute.

This of course will only work if you expect only 1 value per frame (otherwise it will erase the previous attribute value).
Thank you for your suggestion Hugo. I have tried your suggestion, but I now get response a cross the length of the graph. http://imgur.com/a/YsghX

If GSR value goes up the all the points across the graph increase. if GSR reduces every particle decreases.

you can see it here http://imgur.com/a/I6bBy

Thanks,
Yes that's normal as the example effect I originaly made was assigning particle velocity based off a curve (which was meant to be filled with the OSC data).

But now that it uses attributes (a single value per attribute per frame), you need to change the effect so that it reacts as you wish
hmm, so I'm not following. Are you saying that the effect you suggest using curves is not applicable anymore. Am I where I started?
So what I am saying is the example I first gave with the curve attribute sampler, and the effect itself having particles assigning their id and positioning themselves on the side axis was on the asumption that you had a finite amount of floating point values, each frames, that you needed to send to the effect.

Now what I point out is that it all depends on the incoming data, and the effect you would like to create.

TLDR; To pass custom data (floating point value) to an effect, you can use Attributes.
To pass an array of data, you can use the CurveDynamic attribute sampler.

From now I don't know what effect you'd like to create based off those informations, so if you need some help on the creation of the effect it's probably better to open up a different thread

So now that you know how to feed data to popcorn, the real question is : what kind of effect you'd like to create ?
...