[pymunk] deformable terrain
-
- Posts: 28
- Joined: Sun Nov 06, 2011 1:38 am
- Contact:
[pymunk] deformable terrain
It doesn't look like pymunk wraps the chipmunk pro features like deformable terrain. Are there plans to include that at some point? Are there any code examples of deformable or destructible terrain in pymunk that I can look at?
-
- Posts: 206
- Joined: Tue Aug 21, 2007 3:12 pm
- Contact:
Re: [pymunk] deformable terrain
Correct, pymunk only wraps the standard chipmunk.
Simple answer to why is because I dont have it and no one has asked me about it before.
I dont think its impossible to wrap Pro, but it might require a little bit of thinking for how to handle any arrays/bitmaps/other in python land in a easy and quick way. (I have not looked at it at all)
Simple answer to why is because I dont have it and no one has asked me about it before.
I dont think its impossible to wrap Pro, but it might require a little bit of thinking for how to handle any arrays/bitmaps/other in python land in a easy and quick way. (I have not looked at it at all)
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
-
- Posts: 28
- Joined: Sun Nov 06, 2011 1:38 am
- Contact:
Re: [pymunk] deformable terrain
I think AutoGeometry would be a great feature for pymunk. I think one would use numpy arrays, since you can set their dtype and get a ctype pointer for it.
In the meantime, I'll look into http://docs.opencv.org/modules/imgproc/ ... ndcontours. I'll let some event trigger pyglet to dump its buffer (perhaps filtered) into a numpy array, get the contours, remove the old static shapes from the space and then construct and add the new shapes. From this I'll be able to tell you if getting a binary bitmap in python in real time is reasonable.
I guess the advantage of having chipmunk do it is that it would handle the shapes more efficiently. But I'm using subclassed shapes anyway, so that might negate chipmunks inherent efficiency in dealing with its own datatypes. I have very little idea of what I'm talking about.
In the meantime, I'll look into http://docs.opencv.org/modules/imgproc/ ... ndcontours. I'll let some event trigger pyglet to dump its buffer (perhaps filtered) into a numpy array, get the contours, remove the old static shapes from the space and then construct and add the new shapes. From this I'll be able to tell you if getting a binary bitmap in python in real time is reasonable.
I guess the advantage of having chipmunk do it is that it would handle the shapes more efficiently. But I'm using subclassed shapes anyway, so that might negate chipmunks inherent efficiency in dealing with its own datatypes. I have very little idea of what I'm talking about.
-
- Posts: 206
- Joined: Tue Aug 21, 2007 3:12 pm
- Contact:
Re: [pymunk] deformable terrain
You might want to look into wrapping it yourself. If you only use the wrapping yourself you can optimize it for your use case and limit its scope to your code. A good starting point would be to check the Advanced part of pymunk docs for a (somewhat limited) overview. And then the auto generated wrapping (_chipmunk.py) and the hand-wrapped (_chipmunk_ffi.py) for stuff the generator could not handle.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
-
- Posts: 28
- Joined: Sun Nov 06, 2011 1:38 am
- Contact:
Re: [pymunk] deformable terrain
I think this would be quite an intensive project for me. I would like to look into it though. My first issue is that I cant find anything about autogeometry in the ChipmunkPro 6.1.4 Trial code. Is it not part of the trial version?
-
- Posts: 28
- Joined: Sun Nov 06, 2011 1:38 am
- Contact:
Re: [pymunk] deformable terrain
FYI, I accomplished what I wanted using the opencv package, which has bindings to c level code that does marching squares and polygon simplification. Its supposedly pretty fast, but it isn't being called all that often anyways so it definitely works in real time. I have can hold and manipulate the data as numpy arrays, which is pretty fast.
Here's a video (clearly, I have no openGL ability): http://vimeo.com/65191479
Here's a video (clearly, I have no openGL ability): http://vimeo.com/65191479
-
- Posts: 1
- Joined: Sat May 04, 2013 1:26 pm
- Contact:
Re: [pymunk] deformable terrain
Thanks for those informations offonoff ! I'm currently trying to make some destructible terrain game, but I didn't know about opencv or any other API, so my implementation is pure python... I guess you'll get much better performance than me.
Here's a video : http://www.youtube.com/watch?v=D0NeLUjbrrU
Here's a video : http://www.youtube.com/watch?v=D0NeLUjbrrU
-
- Posts: 28
- Joined: Sun Nov 06, 2011 1:38 am
- Contact:
Re: [pymunk] deformable terrain
That's pretty cool! So you use marching squares to determine contours and make the ground out of pymunk.Segments? Since terrain manipulation is so infrequent, I don't think performance is a huge concern. So long as you are marching squares, simplifying the contours and then using segments to make the ground, I don't think it matters how fast the operation is. An advantage of OpenCV is that it gives you hierarchy data about the contours. In this video my program distinguishes between open air, caves, and freed bodies.
http://vimeo.com/65915091
PS: I'm documenting what I learn and do and I'll be posting the deformable terrain part within the week: http://pyratesarecool.appspot.com/Pygle ... k_tutorial
http://vimeo.com/65915091
PS: I'm documenting what I learn and do and I'll be posting the deformable terrain part within the week: http://pyratesarecool.appspot.com/Pygle ... k_tutorial
Who is online
Users browsing this forum: No registered users and 30 guests