A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Slicing Triangles / Shatter effect

  1. #1
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378

    Slicing Triangles / Shatter effect

    Please take a look at this first:

    http://board.flashkit.com/board/show....php?p=3818672

    In effect what I'm doing is taking a random point in a box of the center maybe 25 pixels in from each side of the stage at random. This is my control point. Then I run a few loops a populate an array with points that run along the edges of the stage. These are the other two corners of each triangle to slice. I literally grabbed the code directly out of render's "sloppy" fla with minimal comments, but I've run into an issue. I'm fairly certain that I could get each shattered piece to rotate correctly to give it that "feel" of each piece spinning wildly away from the epicenter of the shatter. The problem lies in grabbing said triangles at all. In my tests, I've basically ripped render's code with hopes of eventually manipulating it to my needs, but 95% of the time I don't get an output bmd and when I do, it's skewed terribly.

    What I'd basically like to do is grab the entire "stage" into a bitmap and shatter that. As a reference, after I slice all the triangles but before I move any of them, you shouldn't be able to tell a difference between the original stage and all the pieces. I've read that a bit of quality is lossed in renders method so is this not possible?



    You can see in the first picture what the stage might look like. In the second example I've added lines to show you what the pieces would look like, where the focal point of the shatter is, and how I went about generating points around the outside. In reality the lines wouldn't be there so before and after I slice the triangles (but before they're moved), both states would look like the first image.

    I eventually would like to take normals of some of those tangent lines and split each triangle up again into smaller segments, but I don't want to get ahead of myself because I'm still not convinced this will work right. I have a copy of a DistortImage class I found a while back that I could use to spin the pieces, but not a convenient working way to slice them all without distortion.
    Last edited by ImprisonedPride; 03-28-2009 at 02:34 AM.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  2. #2
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    Never an easy task with you, IP Well, since I am up early I thought I'd give a lazy solution. Make a mask, the size of each triangle, and have n copies of the whole image with masks flying around. Not good for performance but no skewing and quick'n'dirty.
    Streets Of Poker - Heads-Up Texas Hold'em Poker Game

  3. #3
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Come on phreax, you ought to know by now IP never leaves anything static... everything must be unique! Since it's going to be shattering every couple of minutes I want it to be random...

    Quote Originally Posted by phreax
    Never an easy task with you, IP
    You can't advance unless you are willing to ask the tough questions.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  4. #4
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    You can do it randomly and dynamic though! dynamically create an MC for each triangle, "fill" it using graphics lineTo and use the MCs as masks for duplicates of the bitmap...still holding on to my lazy approach *LOL*
    Streets Of Poker - Heads-Up Texas Hold'em Poker Game

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