Skip to content

Box2D-GR32 Cloth simulation #4

@GoogleCodeExporter

Description

@GoogleCodeExporter
转自:
http://graphics32.org/news/newsgroups.php?
art_group=graphics32.general&article_id=10440

I have done a cloth simulation using Box2D and Graphics 32. It works pretty
well when drawing the cloth using splines and circles (for the cloth grid
nodes). It's also quite effective at filling the cloth with a bitmap image
and TBitmapPolygonFiller.

One thing that doesn't work properly or only half-works is projective
mapping of the bitmap image onto the cloth grid using
TProjectiveTransformation. This could be to do with my code, but it's more
likely to do with the fact that TProjectiveTransformation doesn't handle
non-convex rectangles. I see now why this kind of application (mapping
bitmaps onto animated shapes) is usually done with triangles -- you can't
have a non-convex triangle.

The source is available at:

http://www.anti-philosophy.co.uk/graphics/box2dclothsrc.zip

This uses GR32, Delphi Box2D V2.1, and VPR. The necessary Box2D files are
included in the source folder, but you are strongly recommended to at least
take a look at the full Delphi Box2D package (and its extensive suite of
demo programs using OpenGL). The author of the Delphi port has recently
converted the latest version of Box2D and has also added several highly
impressive new controllers for simulating explosions, ropes, and wind. I've
added a Spring controller which is included in the source for the Cloth
demo.

The full Delphi Box2D package is at

http://sourceforge.net/projects/box2d-delphi/

You can download a compiled version (500k) of the demo from:

www.anti-philosophy.co.uk\graphics\box2dclothtest.zip

See Readme.txt for instructions.

I am sure the projective mapping code can be improved and it may also be
possible to fix it to work with non-convex rectangles. The other solution
would be to adapt TProjectiveTransformation for triangles. I hope somebody
does take a look at the code and suggests improvements (I am off on holiday
from Monday so if anyone does take the project further I won't be able to 
respond
until May 10th).

Simon

Original issue reported on code.google.com by delphidoc@gmail.com on 4 May 2010 at 1:31

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions