Physics for concave shapes

In my game, you try to catch small, falling spheres inside of other objects. Some are easy to implement the physics for. e.g., to catch one in a glass tube, I simply rendered two invisible rectangles that represented the walls of the tube, and one for the floor.

That was easy, but now I want to use more complex shapes, starting with a semi-circular bowl. Am I pretty much relegated to the same approach, i.e. drawing invisible rects that represent the physical surface of the bowl? [import]uid: 58455 topic_id: 11466 reply_id: 311466[/import]

Nevermind. I found the Physics Editor. What a wonderful product. [import]uid: 58455 topic_id: 11466 reply_id: 41569[/import]

im trying to do the same thing did u make it work? [import]uid: 47760 topic_id: 11466 reply_id: 41572[/import]

Yes. Get the Physics Editor. Best $20 I’ve spent in a while.

http://www.physicseditor.de/

Here are my spheres in the glass bowl. Would have taken me hours to get this working with my own code.

[import]uid: 58455 topic_id: 11466 reply_id: 41573[/import]

i have the trial but how do you use it ?

like once i have the file of the object physics what do i do with it ?

or do i have to buy the full thing? [import]uid: 47760 topic_id: 11466 reply_id: 41588[/import]

Look at the Corona example at the link below, which assumes that you export to a file called shapedefs.lua.

http://www.physicseditor.de/features/ [import]uid: 58455 topic_id: 11466 reply_id: 41598[/import]

i think i almost got it but i’m probably doing something wrong cause i get an error Runtime error

C:\Users\master\Desktop\final\shapedefs.lua:70: bad argument #1 to ‘unpa
ck’ (table expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘unpack’
C:\Users\master\Desktop\final\shapedefs.lua:70: in function ‘get’
C:\Users\master\DeRuntime error: C:\Users\master\Desktop\final\shapedefs
.lua:70: bad argument #1 to ‘unpack’ (table expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘unpack’
C:\Users\master\Desktop\final\shapedefs.lua:70: in function ‘get’
C:\Users\master\Desktop\final\mai

i dont have an mai file in that folder so idk what that is
and heres line 69-74

[lua]function physics:get(name)
return unpack(self.data[name])
end

return physics;
end
[import]uid: 47760 topic_id: 11466 reply_id: 41630[/import]

I don’t know what that mai file is, but that code you showed looks corrupted. Don’t edit what is published from PE. Get rid of that and shapedefs.lua and start over.

Add image in PE, use the Shape tracer tool to trace the image, move the anchor points around if your shape is concave, then Publish to shapedefs.lua in your project directory.

There is a code example in shapedefs.lua itself that shows you how to use it from your code, but don’t edit shapedefs.lua. It will get overwritten every time you modify/add shapes.

[import]uid: 58455 topic_id: 11466 reply_id: 41679[/import]

Hi lifes_a_glitch

getting the same error as you do shapedefs.lua:283: bad argument #1 to ‘unpack’

and thats the file from physics editor!! u knw whats wrong, did u figure it out? [import]uid: 130366 topic_id: 11466 reply_id: 108858[/import]