Scripting added to SimPHY

The long awaited feature finally makes its place in simphy. Now it includes scripting support on world events

like onStart, onStop, onUpdate  or there is a collision between objects etc.

SimPHY is now more power-full and more robust

SimPHY supports javascript syntax for scripting. All the objects and joints created are available as javascript variables to deal with.


Scripts are added using small editor (thanks to jsyntaxpane), which check for error, once script is saves and possibly highlights error if any. if the script is error free then it will be running whenever associated event occurs.

for example on collision event the following code exchanges colors/textures of colliding objects and displays their name in console window.

function onCollision(body1, body2, time){
    var brush = body2.getBrush();
    body2.setBrush(body1.getBrush());
    body1.setBrush(brush);
    Console.println(body1.getName() +" collides with "+body2.getName()+" at t=" +time +"sec");
}
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply