Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorlee_plenty
- CommentTimeDec 6th 2009
Hi,
I'm trying to build a 3D version of the GravityWell. I've used to code provided in the 2D example and used 3D classes instead. I've also looked at the version of sandersnake 3D Globe example. But unfortunatly, even though the code compiles, it doesn't show anything. I've pasted the code below. Could someone tell me what I'm doing wrong?
This is the Main.as:
package
{
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.Rectangle;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.renderers.*;
[SWF(width='400', height='400', frameRate='61', backgroundColor='#000000')]
public class Main extends Sprite
{
private var emitter:Emitter3D;
public function Main()
{
emitter = new GravityWells();
var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 400, 400 ), true );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) );
renderer.addEmitter( emitter );
addChild( renderer );
emitter.start();
}
}
}
This is the GravityWell.as
package
{
import flash.geom.Point;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.threeD.actions.*;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.initializers.*;
import org.flintparticles.threeD.zones.*;
import org.flintparticles.threeD.geom.*;
public class GravityWells extends Emitter3D
{
public function GravityWells()
{
counter = new Random(0, 100);
addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
addInitializer( new Position( new SphereZone ( new Point3D(200, 200, 0), 200, 0) ) );
addAction( new Move() );
addAction( new GravityWell(50, new Point3D(200, 200, 0), 200) );
addAction ( new DeathZone( new SphereZone ( new Point3D(200, 200, 0), 200, 0) ) );
}
}
} -
- CommentAuthorlee_plenty
- CommentTimeDec 14th 2009 edited
Got it! I think it was because somehow my emitter was not on the right spot....I think. Anyway, with this piece it works as intended:
Main.as:
package
{
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.Rectangle;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.renderers.*;
import org.flintparticles.threeD.geom.*;
import org.flintparticles.threeD.renderers.controllers.*;
[SWF(width='400', height='400', frameRate='61', backgroundColor='#000000')]
public class Main extends Sprite
{
private var emitter:Emitter3D;
public function Main()
{
emitter = new GravityWells();
var renderer:PixelRenderer = new PixelRenderer( new Rectangle( -200, -200, 400, 400 ) );
//var renderer:BitmapRenderer = new BitmapRenderer( new Rectangle( -200, -200, 400, 400 ), false );
renderer.camera.dolly( -300 );
renderer.camera.lift( 100 );
renderer.camera.target = new Point3D(400, 400, 0);
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) );
renderer.addEmitter( emitter );
renderer.x = 200
renderer.y = 200;
addChild( renderer );
emitter.position = new Point3D(200, 200, 0);
emitter.start();
var orbitter:OrbitCamera = new OrbitCamera( stage, renderer.camera );
orbitter.start();
}
}
}
GravityWells.as:
package
{
import flash.geom.Point;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.displayObjects.Dot;
import org.flintparticles.threeD.actions.*;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.initializers.*;
import org.flintparticles.threeD.zones.*;
import org.flintparticles.threeD.geom.*;
public class GravityWells extends Emitter3D
{
public function GravityWells()
{
counter = new Random(0, 500);
//counter = new Blast( 500 );
//addInitializer( new ImageClass( Dot, 1 ) );
addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
addInitializer( new Position( new SphereZone ( new Point3D(200, 200, 0), 200, 0) ) );
addAction( new Move() );
addAction( new GravityWell(50, new Point3D(400, 400, 0)) );
addAction ( new DeathZone( new SphereZone ( new Point3D(400, 400, 0), 200, 10), true ) );
}
}
} -
- CommentAuthorlee_plenty
- CommentTimeDec 14th 2009 edited
- -
- CommentAuthorRichard
- CommentTimeDec 17th 2009
Glad you found the answer. Three-D is so much more complicated because of camera position, lens angle etc.
1 to 4 of 4
