Skip to content

Commit

Permalink
Revert "Revert "added stars to asset manager""
Browse files Browse the repository at this point in the history
This reverts commit c07e59d.
  • Loading branch information
eternauta1337 committed May 17, 2012
1 parent c07e59d commit 42ae049
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 37 deletions.
29 changes: 4 additions & 25 deletions development/flash/src/com/away3d/gloop/gameobjects/Star.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.away3d.gloop.gameobjects
import com.away3d.gloop.gameobjects.components.MeshComponent;
import com.away3d.gloop.gameobjects.components.VertexAnimationComponent;
import com.away3d.gloop.gameobjects.events.GameObjectEvent;
import com.away3d.gloop.screens.AssetManager;
import com.away3d.gloop.sound.SoundManager;
import com.away3d.gloop.sound.Sounds;

Expand All @@ -34,31 +35,9 @@ package com.away3d.gloop.gameobjects

private function initVisual() : void
{
var geom : Geometry;
var mat : ColorMaterial;

geom = Geometry(AssetLibrary.getAsset('StarFrame0_geom')).clone();
mat = new ColorMaterial(0x3DF120);
/* TODO: share materials?
cannot share materials between differently animated entities ( would need to improve Away3D for this )
dave says that you actually can
David Lenaerts: you can, you just need to be sure that you don't assign the material when either of the targets still has a differeny animation
David Lenaerts: easiest thing to do is to decouple the material until everything else is set
* */

_meshComponent = new MeshComponent();
_meshComponent.mesh = new Mesh(geom, mat);

_animComponent = new VertexAnimationComponent(_meshComponent.mesh);
_animComponent.addSequence('seq', [
Geometry(AssetLibrary.getAsset('StarFrame0_geom')),
Geometry(AssetLibrary.getAsset('StarFrame1_geom')),
Geometry(AssetLibrary.getAsset('StarFrame2_geom')),
Geometry(AssetLibrary.getAsset('StarFrame3_geom')),
Geometry(AssetLibrary.getAsset('StarFrame4_geom')),
], 600);
_animComponent.play('seq');

_meshComponent = new MeshComponent();
_meshComponent.mesh = AssetManager.instance.starMesh.clone() as Mesh;
_animComponent = AssetManager.instance.starAnimationComponent;
}

override public function reset():void {
Expand Down
70 changes: 58 additions & 12 deletions development/flash/src/com/away3d/gloop/screens/AssetManager.as
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ package com.away3d.gloop.screens
private var _tempLight:PointLight;
private var _tempLightPicker:StaticLightPicker;

public var gloopSplatAnimMesh:Mesh;
public var gloopStdAnimMesh:Mesh;
public var gloopSplatAnimation:VertexAnimationComponent;
public var gloopStdAnimation:VertexAnimationComponent;

public var cannonMesh:Mesh;
public var cannonBody:Mesh;
public var cannonFrame0:Geometry;
public var cannonFrame1:Geometry;
public var cannonAnimationState:VertexAnimationState;
public var cannonAnimation:VertexAnimationComponent;

public function AssetManager() {
}

Expand All @@ -76,10 +64,54 @@ package com.away3d.gloop.screens
initializeGloopSplat();
initializeCannonVisual();
initializeCannonAnimation();
initializeStarVisual();
initializeStarAnimation();
doComplete();

}

// ---------------------------------------------------------------------
// STARS
// ---------------------------------------------------------------------

public var starMesh:Mesh;
public var starAnimationComponent:VertexAnimationComponent;

private function initializeStarVisual():void {
var geom : Geometry;
var mat : ColorMaterial;

geom = Geometry( AssetLibrary.getAsset('StarFrame0_geom') ).clone();
mat = new ColorMaterial(0x3DF120);
mat.lightPicker = _tempLightPicker;

starMesh = new Mesh(geom, mat);
_scene.addChild( starMesh );
}

private function initializeStarAnimation():void {
starAnimationComponent = new VertexAnimationComponent( starMesh );
starAnimationComponent.addSequence('seq', [
Geometry(AssetLibrary.getAsset('StarFrame0_geom')),
Geometry(AssetLibrary.getAsset('StarFrame1_geom')),
Geometry(AssetLibrary.getAsset('StarFrame2_geom')),
Geometry(AssetLibrary.getAsset('StarFrame3_geom')),
Geometry(AssetLibrary.getAsset('StarFrame4_geom')),
], 600);
starAnimationComponent.play('seq');
}

// ---------------------------------------------------------------------
// CANNON
// ---------------------------------------------------------------------

public var cannonMesh:Mesh;
public var cannonBody:Mesh;
public var cannonFrame0:Geometry;
public var cannonFrame1:Geometry;
public var cannonAnimationState:VertexAnimationState;
public var cannonAnimation:VertexAnimationComponent;

private function initializeCannonVisual():void {
var tex : BitmapTexture;
var bodyMat:DefaultMaterialBase;
Expand Down Expand Up @@ -127,10 +159,20 @@ package com.away3d.gloop.screens
cannonAnimation.play( 'fire' );
}

// ---------------------------------------------------------------------
// GLOOP
// ---------------------------------------------------------------------

public var smileMat:TextureMaterial;
public var sadMat:TextureMaterial;
public var ouchMat:TextureMaterial;
public var yippeeMat:TextureMaterial;

public var gloopSplatAnimMesh:Mesh;
public var gloopStdAnimMesh:Mesh;
public var gloopSplatAnimation:VertexAnimationComponent;
public var gloopStdAnimation:VertexAnimationComponent;

private function initializeGloopFly():void {
var smile_grin_tex : BitmapTexture;
var sad_tex : BitmapTexture;
Expand Down Expand Up @@ -212,6 +254,10 @@ package com.away3d.gloop.screens
gloopSplatAnimation.play( 'splat' );
}

// ---------------------------------------------------------------------
// UTILS
// ---------------------------------------------------------------------

public static function get instance():AssetManager {
if( !_instance ) {
_instance = new AssetManager();
Expand Down

0 comments on commit 42ae049

Please sign in to comment.