PDA

View Full Version : kotsoft does soft bodies


kotsoft
12-28-2007, 01:40 PM
http://kotsoft.googlepages.com/softbody.html

well, somebody was coming over to my house yesterday, so in the morning, i ran down, and started coding, and prepared a demo for them.
so this isn't much, no collisions yet, but i'll see if i can add some more to this engine by the end of winter break.

edit: woops, spelled soft bodies incorrectly. :) could one of the mods change it?

Treacle109
12-28-2007, 02:54 PM
Nice... should get rid of those lines that come out though, and ive been told that its quite hard to get good collisions in java but ive never tried it...

kotsoft
12-28-2007, 03:48 PM
yeah, those lines are just for debugging purposes.

and it's hard to get good collisions whenever you're doing it yourself. it's only easy when you're using a prebuilt physics engine.

however, i do already have a collision detection algorithm.

the good thing about this physics engine is it does everything in linear time, so no O(n^2).

muffinmonkey
12-28-2007, 04:43 PM
Potential

that was to symbolise that this has big potential
you see now?

Love the way of making shapes
but I can't really say about the physics because you can't really do enough to see them

Z3R052
12-28-2007, 05:10 PM
Making large complicated objects makes it spazz out.

kotsoft
12-28-2007, 05:16 PM
yeah, that bug comes from me treating every line segment as having the same mass. to lessen these kinds of errors for now, try to keep all segments roughly the same length, and instead of doing long straight lines, go with more little lines.

kotsoft
12-30-2007, 04:30 AM
here's a movie of the simulation now with area preservation. the area preservation was used in my blob simulator from before, and basically, it just calculates the current area of the polygon, and moves all the points enough for it to be the initial area. as you can see, it works ok with all the line segments roughly the same size. i'm trying to get different sized line segments but right now it keeps on glitching up.
http://youtube.com/watch?v=gZJ88f1Djgg

muffinmonkey
12-30-2007, 08:37 AM
that looks so nice
when can we play with it?

STEVIE G
12-31-2007, 03:59 PM
Looks good and solid. What source material did you use to build the system if you don't mind me asking? I'm always interested in the theory behind these things.

kotsoft
12-31-2007, 04:15 PM
well, this was just a little extra to my blob physics, which preserved area within the polygon and the edges are springs. this just tries to make all the angles of the polygon the same as the initial angles. so for this i just googled some vector things since i haven't really gone in depth with vectors yet, and looked up how to find the angle between two vectors, and how to rotate a vector a few degrees. a problem with me still being in high school is i don't understand most of the physics papers online. i think it might be similar to "Position based dynamics" though. i'm not sure because i wasn't able to understand it. :)

MrGreed
01-01-2008, 02:26 AM
Very nicely done.

What?
01-09-2008, 06:44 AM
Very nicely done.

I second that!

STEVIE G
01-09-2008, 05:47 PM
well, this was just a little extra to my blob physics, which preserved area within the polygon and the edges are springs. this just tries to make all the angles of the polygon the same as the initial angles. so for this i just googled some vector things since i haven't really gone in depth with vectors yet, and looked up how to find the angle between two vectors, and how to rotate a vector a few degrees. a problem with me still being in high school is i don't understand most of the physics papers online. i think it might be similar to "Position based dynamics" though. i'm not sure because i wasn't able to understand it. :)

Ah ... so you're not really preserving volume ... just angles - I have similar constraints in Stramash which limit rotation at a min/max angle, so by setting the min/max angle to get the same I can do the same as you ... cheers, excellent!

kotsoft
01-09-2008, 07:00 PM
Ah ... so you're not really preserving volume ... just angles - I have similar constraints in Stramash which limit rotation at a min/max angle, so by setting the min/max angle to get the same I can do the same as you ... cheers, excellent!

actually, i am preserving volume. in fact, my method has an almost exact volume preservation method so when you take the area after the update step, % error is very, very close to 0.

STEVIE G
01-09-2008, 08:16 PM
How are you preserving the volume? How do you calculate the volume of an arbitrary shape?

kotsoft
01-09-2008, 10:04 PM
well, in the 2d case, volume is just area, so i use a simple area of polygon calculation, and tutorials for area can be found all over the nets.

futuramaguy42
01-11-2008, 11:15 PM
Are you going to update this?

I really like it, but would like to see some collisions and bug fixes.

Dan
01-15-2008, 01:00 PM
I watched the first video of yours on the program, not the head one. And I think my Java is broken or something... cause when I play it the lines remain straight, and everytime it touches the ground, random lines start jutting out from the corner of whatever I made. And when I try to make a circle or something with many lines, it collapses into a heap...

muffinmonkey
01-15-2008, 03:27 PM
I watched the first video of yours on the program, not the head one. And I think my Java is broken or something... cause when I play it the lines remain straight, and everytime it touches the ground, random lines start jutting out from the corner of whatever I made. And when I try to make a circle or something with many lines, it collapses into a heap...

yeah, it does that

jaybud4
02-03-2008, 07:38 PM
I think I broke it...
http://img.photobucket.com/albums/v139/jaybud4/Whoops.png
You have to realize that 90% of the lines in this picture are in fact the "debugging" lines mentioned above.
EDIT: Wow... Just, wow.
http://img.photobucket.com/albums/v139/jaybud4/MoreBroken.png

kotsoft
02-03-2008, 10:15 PM
well, actually, i know that it's buggy, but i've decided to put my efforts elsewhere. :)

Treacle109
02-09-2008, 07:47 PM
my head started to hurt understanding u two guys earlier :confused: