Lemur like physics engine

Hello,

I'd like to ask wether there are any plans to include a lemur like physics engine, for example for XY pads, in order let the ball bounce off the wall etc.

Would be really nice, what do you think?

Hi, there's no such plan currently, to be honest it's unlikely to happen.

Hi @mks

have a look at the templates of one of our valued members here (Multixy with extra features).
You might need to continue developing by yourself in order to make it useful, but everything one needs is already there.
Best

Nice thank you, looks interesting yes. I'm probably not skiled enough to develop it much further with scripting etc. I wonder if you consider adding kind of regular modulation options like LFOs or Envelopes. Might be enough for what I can imagine.

Hi,
I just wanted to let you know, that I needed something very simple, but similar and I did a rough .js sketch that is working.
Basically it is an imaginary "bouncing ball" within a 800x800 square very similar to this
that triggers two knobs by its x and y values.

The custom module would look like this:

var sentBounce = false;
//if width/height changes, the way is longer, so it has similar impact as speed values have
var width = 800;
var height = 800;
// start value for the imaginary bouncer
var x = 80;
var y = 80;
//speed for bouncer
var vx = 20;
var vy = 25;
//update interval in milli seconds, also has impaaact on speed, but more on smoothness
updateInterval = 100;

module.exports = {
    oscOutFilter: function (data) {
        // Filter outgoing osc messages
        var { address, args, host, port, clientId } = data

        // bouncing x/y coordinates
        if (address === '/bouncer') {
            if (sentBounce == true) { sentBounce = false } else { sentBounce = true }
            console.log(sentBounce);
        }

        if (sentBounce) {

            setInterval(function () {
                // bouncing ball from here
                //https://www.geeksforgeeks.org/how-to-build-a-bounce-ball-with-html-and-javascript/

                if (x > width)
                    vx = 0 - vx;

                if (x < 0)
                    vx = 0 - vx;

                if (y > height)
                    vy = 0 - vy;

                if (y < 0)
                    vy = 0 - vy;

                x = x + vx;
                y = y + vy;
                y = y + vy;
                receive('/receiveBounceX', x / width);
                receive('/receiveBounceY', y / height);
                // console.log(x);
                // console.log(y);
            }, updateInterval)

        }
        return { address, args, host, port }
    }
}

I setup one button and two knobs in O-S-C with following params:

button:
osc -> address -> /bouncer
osc-> target -> your serverIP

one knob:
osc -> address -> /receiveBounceX
osc-> target -> your serverIP

and the other knob
osc -> address -> /receiveBounceY
osc-> target -> your serverIP

Maybe this can help anyone.
Have a nice day!

#######
UPDATE on February 21st 2023:
Issue: the timer could not be stopped
Solution: use setInterval() on a variable and stop the interval by using clearInterval() with passing the variable to it. And since we are in a custom class, we need to use "this" on the variable.

Instead use this code:

module.exports = {
    oscOutFilter: function (data) {
        // Filter outgoing osc messages
        var { address, args, host, port, clientId } = data

        if (address === '/bouncer') {

            var value = args[0].value

            if (sentBounce == 1) {
                this.bouncing = setInterval(function () {

                    if (x > width)
                        vx = 0 - vx;

                    if (x < 0)
                        vx = 0 - vx;

                    if (y > height)
                        vy = 0 - vy;

                    if (y < 0)
                        vy = 0 - vy;

                    x = x + vx;
                    y = y + vy;
                    y = y + vy;

                    receive('/receiveBounceX', x / width);
                    receive('/receiveBounceY', y / height);

                }, updateInterval) // every 10 m

            } 
          else { clearInterval(this.startBouncer) }
        }

        return { address, args, host, port }

    },

}
1 Like

I just wanted to join in on this feature request. I love the Multiball object from Lemur so I really wish to have something similar in OSC :slight_smile: