A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: sparking some interest

  1. #21
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    actually, this isnt done with the grid system
    it's done using sweep n' prune

    i started implementing the grid, but it got really messy - especially in blitz3d which is not object oriented

    so i went with sweep n prune, as suggested by bouncer, and as you can see its really good

    i also optimized the constraints a little bit with the method suggested in jakobsen's article (using newton's root approx. with initial guess of the rest length and one iteration)
    Last edited by ozmic66; 01-09-2006 at 07:31 PM.

  2. #22
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    I've been looking into this Sweep n' Prune method.... As I understand, this is similar to grid-based collision, except it is based on intersecting/overlapping axises. If these one of these axises overlap, then a collision is possible, and more tests are run, correct? Otherwise, the system goes on. I also understand that the system needs to sort the objects out - I forgot what the paper said about how - and tests them in that order.

    By the looks of the graphs with frames per second calculations/collisions/etc. - in addition to your own demo of this method - I think you've convinced me that this may be the way to go, as far as collision detection is concerned. Do you have any useful links I could look at to begin implementing this?

  3. #23
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Hey opethrock

    just to clarify... the graph i posted is of the grid system, and the demo is of the sweep n' prune (i should have said that earlier)

    also, i might try combining the two and see what happens, but right now i'm happy with what i have

    here's how the sweep works

    let's say all your particles are stored in an array called particles[]

    1. first calc. the bounding box of each particle
    (for ex.: particles[i].bbLeft, particles[i].bbRight, particles[i].bbTop, etc...

    2. now sort all of the particles by the value of their bbLeft, from small to large
    here you could use insertion sort, as usually the objects' positions won't
    change that much from frame to frame

    3. loop through the sorted array and checking:
    for(i=0;i<particles.length;i++){
    for(j=0;j<particles.length;j++){
    if(particles[i].bbRight<particles[j].bbLeft){
    break;
    }
    //if bb's overlap on y axis{
    // check the particles for collisions
    //}
    }
    }


    small note: i know all of this thanx to Bouncer (gamedev.net) so i must give credit where it is due

    and that's it
    simple and powerfull, which is why i prefered it over the grid, which can get messy
    Last edited by ozmic66; 01-10-2006 at 01:49 PM.

  4. #24
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    In looking into the Sweep n' Prune method, I found a bunch of graphs comparing it to 'regular' Collision Detection, which compared collisions, FPS, etc. So I'm the one who should be clarifying.

    I love how concise that code is. lol Makes it loads simpler for me to implement elementary collisions.

  5. #25
    Junior Member
    Join Date
    Dec 2005
    Posts
    22
    Thats brilliant ozmic66! Theres a huge speed difference. By the way, if you want OOP, then you might want to look into blitzmax. At the moment, it's only 2D but a 3D module is currently being worked on, but not sure when the 3d module is coming out.

  6. #26
    Flash programmer
    Join Date
    Jul 2005
    Location
    Sweden
    Posts
    48
    Here's my ragdoll with an angular constraint that was finished yesterday . It still needs some work though, I guess that I should move two particles in the relaxAngle function, but I'll do that some other time.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center