about grable's verlet code and circ-to-line colls
BlitzMax Forums/BlitzMax Programming/about grable's verlet code and circ-to-line colls
| ||
hello all. I've been hugely impressed by grable's simple verlet code http://www.blitzbasic.com/codearcs/codearcs.php?code=1769 probably like many others! and would like to get something working out of it. it seems to me in order to go on, we need circle-to-circle collisions (between particles), but, most importantly, circle-to-line collisions, for collisions between particles and "background" lines, like platforms, ground etc. I suck at it, but gave it a try. I am not a programmer and not familiar with these things though. first, I explored circle-line collisions and line-line collisions. the idea (have no clue how sound it is) is that if a particle collides with a line, project it to outside the line (hopefully on the proper side!). if it doesnt, check its path on this step (oldx,y to newx,y) and see if you get a collision between path line and static line. If those collide, project the particle at the proper spot. (got the proper side working too!) contains functions found in the archives. I modified some so they return a x,y array, or -1,-1 if no collision is happening. use 1,2 to set x,y of line, 3,4 to set x,y of path the circle at mousepoint is the size we're testing. here's my testbed code: (how do I put the code in those neat boxes so they dont take up all this space?) ---------------------------------------------------- then I modified grable's code. created a new object, staticline and staticgroup, to contain the lines. there are also other mdifications in here, you will see a rope hanging ready to be tinkered, plus you can make a constraint soft or hard by pressing 1-6 while making it (1-rubbery, 6-as solid as it gets). you can also use arrow keys to move previously selected verlet. I sort of got the collision working but have no idea what I'm doing wrong. particles go through the lines at high-ish speeds and they also seem to develop a force pushing them left! any pointers or help greatly appreciated. I believe some solid collision code on grable's example can result in a nice and simple verlet engine that can be quite useable! best of all, if we can get grable to properly do it for us!! ;-) cheers to all and merry christmas. modified grable's verlet example code: |
| ||
To post code in code boxes, look at this link http://www.blitzmax.com/faq/faq_entry.php?id=2 Search for the "code goes here" part, you'll see it! |