Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Nick on January 07, 2013, 03:01:53 pm

Title: [Lua] Rope Physics
Post by: Nick on January 07, 2013, 03:01:53 pm
Hi

Here is another video of a script I made today (I didn't really work long on it, so it's not really complete and useable) that i wanted to show you.
It is a rope physics script that can be downloaded below.

The video description tells more about it, everyone can use it if they want, feel free, but as I told you, it is not really working as it should be. For example the gravity seems to work perfectly as you look, but in the code it's a total mess :)

Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 07, 2013, 03:03:18 pm
It looks pretty :3 I'm going to waste so much time playing with dat rope :D
Title: Re: [Lua] Rope Physics
Post by: Levak on January 07, 2013, 03:17:05 pm
Now try this on calc and cry =(
Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 07, 2013, 03:29:14 pm
Why make a physics engine if it performs poorly on the actual platform/hardware it should be running on :/
Title: Re: [Lua] Rope Physics
Post by: Levak on January 07, 2013, 03:39:11 pm
Why make a physics engine if it performs poorly on the actual platform/hardware it should be running on :/
TI's logic.
Title: Re: [Lua] Rope Physics
Post by: Nick on January 07, 2013, 04:21:33 pm
Now try this on calc and cry =(
Damn, i thought it would be faster, but no..you're right
Title: Re: [Lua] Rope Physics
Post by: leafy on January 07, 2013, 05:19:30 pm
Hm, it looks like that isn't true segmented rope physics though - each individual segment doesn't appear to affect the forces on the other segments (for example, when you yank the rope the ball doesn't fly upwards)
Title: Re: [Lua] Rope Physics
Post by: DJ Omnimaga on January 07, 2013, 05:24:53 pm
It reminds me a bit some bosses in SUper Metroid for the Super Nintendo. Now if only Lua was faster...
Title: Re: [Lua] Rope Physics
Post by: Nick on January 07, 2013, 05:40:40 pm
Hm, it looks like that isn't true segmented rope physics though - each individual segment doesn't appear to affect the forces on the other segments (for example, when you yank the rope the ball doesn't fly upwards)
that's what i meant with it seems to work at first sight, but it isn't really what it should be :)
Title: Re: [Lua] Rope Physics
Post by: Adriweb on January 07, 2013, 06:27:23 pm
Chipmunk's physics engine allow you to create such a thing, actually, it's just a matter of having joints.
Pretty much the same thing as : http://developer.coronalabs.com/content/chains (not the same eaxc syntax, but pivot/pin(?) joints on the bodies and boom there you go.

Now with the speed, it's still slow on the calc, but it's worth trying, just to test what rope physics give, with chipmunk.
Title: Re: [Lua] Rope Physics
Post by: Nick on January 08, 2013, 02:13:26 am
Chipmunk's physics engine allow you to create such a thing, actually, it's just a matter of having joints.
Pretty much the same thing as : http://developer.coronalabs.com/content/chains (not the same eaxc syntax, but pivot/pin(?) joints on the bodies and boom there you go.

Now with the speed, it's still slow on the calc, but it's worth trying, just to test what rope physics give, with chipmunk.
that's exactly what I did, there's no difference I guess
Title: Re: [Lua] Rope Physics
Post by: Adriweb on January 08, 2013, 02:28:22 am
Good :)

(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
Title: Re: [Lua] Rope Physics
Post by: Nick on January 08, 2013, 02:36:09 am
(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)
how do you mean lose time?

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
It'll be way better, I'm sure of that, but I never tried chipmunk on calc (still 3.1)
Title: Re: [Lua] Rope Physics
Post by: Adriweb on January 08, 2013, 06:02:00 am
(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)
how do you mean lose time?
Because it's so fun I keep moving the rope around my screen and watch it unfold, instead of working. (Poor me :D)

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
It'll be way better, I'm sure of that, but I never tried chipmunk on calc (still 3.1)
Jim can quickly code that and test, I'm sure. (/me runs ?)
Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 08, 2013, 10:51:36 am
It works a little bit nice when I reduced the timer to 0.04 instead of 0.01 and instead of drawing 500 segments with length 1, drawing 6 segments of length 25. But it still doesn't work as we all would like it to.
Title: Re: [Lua] Rope Physics
Post by: Alex on January 08, 2013, 12:59:09 pm
Good work. But it's very slow on calc :-(
Title: Re: [Lua] Rope Physics
Post by: Nick on January 08, 2013, 01:14:25 pm
Good work. But it's very slow on calc :-(
I know, that's the sad part about it, you may even call it disturbing/frustrating/horrible/throw-your-calc-out-of-the-window slow... but there's nothing I/we can do about it, I don't think I can really optimise the code
Title: Re: [Lua] Rope Physics
Post by: Alex on January 09, 2013, 06:58:49 am
Ok. But you can use the chipmunks physic program include in OS 3.2 or no?
Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 09, 2013, 07:11:07 am
Yes. You put
Code: [Select]
require 'physics' on the top of your script.
Title: Re: [Lua] Rope Physics
Post by: Nick on January 09, 2013, 07:20:09 am
Ok. But you can use the chipmunks physic program include in OS 3.2 or no?

Yes. You put
Code: [Select]
require 'physics' on the top of your script.

But this will not work with this script, not at all. You'll have to write your own script for that, I guess you should read this (http://education.ti.com/media/4A9A2F6B391A49E4BE07B606F699189A/ti-nspire_scripting_api_reference_guide_en.pdf).
Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 09, 2013, 10:47:16 am
Ok. But you can use the chipmunks physic program include in OS 3.2 or no?

Yes. You put
Code: [Select]
require 'physics' on the top of your script.

But this will not work with this script, not at all. You'll have to write your own script for that, I guess you should read this (http://education.ti.com/media/4A9A2F6B391A49E4BE07B606F699189A/ti-nspire_scripting_api_reference_guide_en.pdf).
What do you mean will not work?
Code: [Select]
require 'physics'  or require "physics" allows you to use the physics engine. You can even be more specific by putting
Code: [Select]
platform.apilevel = "2.0" at the very top of your script
Title: Re: [Lua] Rope Physics
Post by: Nick on January 09, 2013, 11:57:33 am
Did you read my whole sentence? I said this will not work with this script
Title: Re: [Lua] Rope Physics
Post by: Adriweb on January 09, 2013, 05:39:40 pm
ElementCoder : the fact of writing "require 'physics'" makes the Lua interpreter know you're going to use the Physics Engine API provided in version 3.2, it doesn't mean that it will automagically know you're making physics by yourself and will convert them to Chipmunk's (P.E. base) code. You'd have to rewrite everything in terms of the specific API.
Title: Re: [Lua] Rope Physics
Post by: ElementCoder on January 10, 2013, 01:33:44 pm
I understand that adriweb. There was a simple misunderstanding between me and Nick which is now solved :) I didn't mean to say "require 'physics'" converts your code to Chipmunk, I thought he meant that putting that above his script made everything crash but it was just that he wrote it for 3.1 and not for 3.2.
Title: Re: [Lua] Rope Physics
Post by: Nick on January 10, 2013, 03:04:34 pm
I understand that adriweb. There was a simple misunderstanding between me and Nick which is now solved :)
Yeah, we met up last week to hold a little streefight. Sadly enough he won, so I had to crawl to the hospital alone, leaving a trail of mixed blood and spit.
It was hard to see myself that way, but it was worth it. I tried, and that's what matters.
I used to say "There no such thing as trying. You do, or you do not.", but I had to reconsider that, apparently it wasn't completely true.

Until the day I was able to move again, it went through my head. How would I be able to face ElementCoder again? I haven't seen him since, I did not look for him though. One day, I shall regain my powers and revive to my strong and powerful self, leaving all that had happened between us behind, and start over again, with a clean slate.
Title: Re: [Lua] Rope Physics
Post by: Adriweb on January 10, 2013, 04:07:51 pm
Wat o_O
Title: Re: [Lua] Rope Physics
Post by: lkj on January 10, 2013, 04:35:24 pm
lol  XD

looking nice btw