Hi,

See if I can sneak this in under the 40k limit...

// Initialise the shards array
shards = [];            

// Clear the current background plane geometery
clearGeometery();

// Make the background plane more complex (so there are more shards)
background.segmentsH = 8;
background.segmentsW = 3;
background.buildPlane(widthPixels, heightPixels);

// Initialise some variables we need for the next section
var totalFaces:int = background.geometry.faces.length;                  
var explodeForce:int = 110;

var a:Vertex3D;
var c:Vertex3D;
var b:Vertex3D;

var uvA :NumberUV;
var uvC :NumberUV;
var uvB :NumberUV;

var face:Triangle3D;
var newFace:Triangle3D;
var shard3D:Shard3D;

// Remove the background from the scene
removeChild(background);
        
// Turn off smoothing
thumbnailMaterial.smooth = false;
//thumbnailMaterial.tiled = true;

// Loop through the faces in the background plane and create a seperate shard 
from each one
for (var i:int = 0; i < totalFaces; i++)
{
        
        // Get a reference to this face
        face = background.geometry.faces[i] as Triangle3D;
        
        // Copy the vertices from this face 
        a = face.vertices[0].clone();
        b = face.vertices[1].clone();
        c = face.vertices[2].clone();
        
        // Cope the uv coordinates from this face
        uvA = face.uv0.clone();
        uvB = face.uv1.clone();
        uvC = face.uv2.clone();
        
        // Create a new face 
        newFace = new Triangle3D(this, [ a, b, c ], thumbnailMaterial, [ uvA, 
uvB, uvC ] );             
        
        // Create a new shard, using the copied vertices and new face
        shard3D = new Shard3D(thumbnailMaterial, [a, b, c], [newFace]);
        addChild(shard3D);
        
        // Offset the shard to the middle of the plane (the internal coords 
each 
        // vertex had will be relative to the plane, and so are wrong)
        shard3D.x = widthPixels / 2;
        shard3D.y = -heightPixels / 2;
        
        // Give the shard a random speed in each direction
        shard3D.speedX = Math.random() * explodeForce - explodeForce/2;
        shard3D.speedZ = Math.random() * explodeForce - explodeForce/2;
        shard3D.speedY = Math.random() * explodeForce - explodeForce/2;
        
        shard3D.rotationSpeedX = Math.random() * explodeForce / 10;
        shard3D.rotationSpeedY = Math.random() * explodeForce / 10;
        shard3D.rotationSpeedZ = Math.random() * explodeForce / 10;
        
        // Tween the shard to its new exploded position
        TweenMax.to(shard3D, 1.6, {     x:shard3D.speedX * 12,
                                                                
y:shard3D.speedY * 12,
                                                                
z:shard3D.speedZ * 12,
                                                                
rotationX:shard3D.rotationSpeedX * 5,
                                                                
rotationY:shard3D.rotationSpeedY * 5,
                                                                
rotationZ:shard3D.rotationSpeedZ * 5,
                                                                
ease:Cubic.easeOut
                                                        }); 
        
        // Store the reference to this shard
        shards[shards.length] = shard3D;
}_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to