Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:away3d/away3d-core-broomstick

Signed-off-by: Jerome <jerome@wemakedotcoms.com>
  • Loading branch information...
commit 2cefcb3b701fefbd9b2e09ae0fed310593258bc0 2 parents df9fde3 + 3f689cc
@richardolsson richardolsson authored committed
View
14 README.txt
@@ -1 +1,13 @@
-This is just a test Readme file.
+WARNING:
+this is a very, very, very experimental fork of the main Away3D Broomstick repository. Use at your own risk.
+
+Changes:
+
+//// 110606 ////
+
+CCTV Material
+implemented modifications to the API mentioned in this thread to allow context.drawToBitmap()
+http://groups.google.com/group/away3d-dev/browse_thread/thread/7b2ad43fefc688b3/54771671c04a1cde
+
+Sound3D
+Changed the return value of void to SoundChannel on Sound3D.play() to allow the implementation of Event.SOUND_COMPLETE and loop the audio attached to the Sound3D.
View
6 src/away3d/audio/Sound3D.as
@@ -1,9 +1,9 @@
package away3d.audio
{
import away3d.audio.drivers.*;
+ import away3d.containers.ObjectContainer3D;
import away3d.core.base.*;
import away3d.events.*;
- import away3d.containers.ObjectContainer3D;
import flash.geom.*;
import flash.media.*;
@@ -124,11 +124,11 @@ package away3d.audio
/**
* Start (or resume, if paused) playback.
*/
- public function play() : void
+ public function play() : SoundChannel
{
_playing = true;
_paused = false;
- _driver.play();
+ return _driver.play();
}
View
4 src/away3d/audio/drivers/ISound3DDriver.as
@@ -1,7 +1,7 @@
package away3d.audio.drivers
{
- import flash.media.*;
import flash.geom.*;
+ import flash.media.*;
public interface ISound3DDriver
{
@@ -49,7 +49,7 @@ package away3d.audio.drivers
* as invoking play() on the flash.media.Sound object used as the source sound
* for the driver.
*/
- function play() : void;
+ function play() : SoundChannel;
/**
* Temporarily pause playback. Resume using play().
View
5 src/away3d/audio/drivers/SimplePanVolumeDriver.as
@@ -27,7 +27,7 @@ package away3d.audio.drivers
}
- public function play() : void
+ public function play() : SoundChannel
{
var pos : Number;
@@ -43,7 +43,10 @@ package away3d.audio.drivers
// Start playing. If paused, resume from pause position. Else,
// start from beginning of file.
pos = _paused? _pause_position : 0;
+
_sound_chan = _src.play(pos, 0, _st3D.soundTransform);
+
+ return _sound_chan;
}
View
16 src/away3d/containers/View3D.as
@@ -13,7 +13,7 @@ package away3d.containers
import away3d.core.traverse.EntityCollector;
import away3d.filters.Filter3DBase;
import away3d.lights.LightBase;
-
+
import flash.display.Sprite;
import flash.display3D.Context3D;
import flash.display3D.Context3DTextureFormat;
@@ -312,7 +312,7 @@ package away3d.containers
/**
* Renders the view.
*/
- public function render() : void
+ public function render(present:Boolean = true) : void
{
var time : Number = getTimer();
var targetTexture : Texture;
@@ -345,14 +345,20 @@ package away3d.containers
filter.render(context, nextFilter? nextFilter.getInputTexture(context, this) : null, _camera, _depthRender);
filter = nextFilter;
}
- context.present();
+
+ // added conditional present for CCTV Material
+ // see http://groups.google.com/group/away3d-dev/browse_thread/thread/7b2ad43fefc688b3/54771671c04a1cde
+ if(present) context.present();
}
else
- _renderer.render(_entityCollector);
+ _renderer.render(_entityCollector, null, 0, 7, present);
_entityCollector.cleanUp();
- fireMouseMoveEvent();
+ // disable mouse events if we don't present. Seems to throw an error otherwise
+ // TODO figure out a better way!
+ if(present) fireMouseMoveEvent();
+
}
/**
View
10 src/away3d/core/render/RendererBase.as
@@ -7,7 +7,7 @@ package away3d.core.render
import away3d.core.sort.RenderableMergeSort;
import away3d.core.traverse.EntityCollector;
import away3d.errors.AbstractMethodError;
-
+
import flash.display3D.Context3D;
import flash.display3D.textures.TextureBase;
import flash.events.Event;
@@ -300,14 +300,14 @@ package away3d.core.render
* @param surfaceSelector The index of a CubeTexture's face to render to.
* @param additionalClearMask Additional clear mask information, in case extra clear channels are to be omitted.
*/
- arcane function render(entityCollector : EntityCollector, target : TextureBase = null, surfaceSelector : int = 0, additionalClearMask : int = 7) : void
+ arcane function render(entityCollector : EntityCollector, target : TextureBase = null, surfaceSelector : int = 0, additionalClearMask : int = 7, present:Boolean = true) : void
{
if (!_stage3DProxy) return;
if (_viewPortInvalid) updateViewPort();
if (_backBufferInvalid) updateBackBuffer();
if (!_context) return;
- executeRender(entityCollector, target, surfaceSelector, additionalClearMask);
+ executeRender(entityCollector, target, surfaceSelector, additionalClearMask, present);
}
/**
@@ -317,7 +317,7 @@ package away3d.core.render
* @param surfaceSelector The index of a CubeTexture's face to render to.
* @param additionalClearMask Additional clear mask information, in case extra clear channels are to be omitted.
*/
- protected function executeRender(entityCollector : EntityCollector, target : TextureBase = null, surfaceSelector : int = 0, additionalClearMask : int = 7) : void
+ protected function executeRender(entityCollector : EntityCollector, target : TextureBase = null, surfaceSelector : int = 0, additionalClearMask : int = 7, present:Boolean = true) : void
{
_renderableSorter.sort(entityCollector);
@@ -328,7 +328,7 @@ package away3d.core.render
draw(entityCollector);
- if (_swapBackBuffer && !target) _context.present();
+ if (_swapBackBuffer && !target && present) _context.present();
}
/**
View
190 src/away3d/materials/CCTVMaterial.as
@@ -0,0 +1,190 @@
+package away3d.materials
+{
+ import away3d.animators.data.NullAnimation;
+ import away3d.cameras.Camera3D;
+ import away3d.cameras.lenses.PerspectiveLens;
+ import away3d.containers.View3D;
+ import away3d.core.base.Object3D;
+
+ import flash.display.BitmapData;
+ import flash.display.Sprite;
+ import flash.filters.ColorMatrixFilter;
+ import flash.geom.Matrix;
+ import flash.geom.Point;
+ import flash.geom.Rectangle;
+
+
+ /**
+ * CCTV Material allows the creation of a seperate view and camera to render a scene from another angle. The render is drawn
+ * to a the bitmapdata. Map that to a plane or model and you have a CCTV like (Picture in Picture)!
+ *
+ * @author jerome@wemakedotcoms
+ *
+ */
+
+ public class CCTVMaterial extends BitmapMaterial
+ {
+
+
+ /**
+ * @author desaturate code from Ralph Hauwert
+ */
+ private static const ORIGIN : Point = new Point();
+
+ /**
+ * Desaturate color vector, by Paul Haeberli
+ *
+ * http://www.graficaobscura.com/matrix/index.html
+ */
+ private static var rl:Number = 0.3086;
+ private static var gl:Number = 0.6094;
+ private static var bl:Number = 0.0820;
+
+ private static var cmf:ColorMatrixFilter = new ColorMatrixFilter([rl,gl,bl,0,0,rl,gl,bl,0, 0,rl,gl,bl,0,0,0,0,0,1,0]);
+
+
+
+ private var _matrix:Matrix;
+ private var _view:View3D;
+ private var _camera:Camera3D;
+ private var _cameraTarget:Object3D
+ private var _container:Sprite;
+ private var _bmd:BitmapData;
+ private var _greyscale:Boolean;
+ private var _border:uint;
+
+
+ public function CCTVMaterial(view:View3D, w:int, h:int, container:Sprite, cctvCamera:Camera3D = null, materialWidth:int = 128, materialHeight:int = 128)
+ {
+
+ super(new BitmapData(materialWidth, materialHeight, false, 0x000000), true, false, false);
+
+ _border = 0;
+
+ _container = container;
+
+ _matrix = new Matrix;
+ _matrix.scale( materialWidth / w, materialHeight / h );
+
+ _camera = cctvCamera || new Camera3D();
+
+ if( !cctvCamera ) PerspectiveLens( _camera.lens ).fieldOfView = 100;
+
+ _view = new View3D( view.scene, _camera );
+ _view.backgroundColor = view.backgroundColor;
+ _view.x = -w;
+ _view.width = w;
+ _view.height = h;
+
+ _bmd = new BitmapData(w, h, transparent, 0x000000);
+
+ // hack
+ _container.addChild( _view );
+ _view.visible = false;
+
+ }
+
+
+
+ public function update():void
+ {
+ // update the camera target
+ if(_cameraTarget) camera.lookAt( _cameraTarget.position );
+
+ // render the CCTV view
+ _view.render(false);
+
+ // no context? Bolt!
+ if(!_view.renderer.context) return;
+
+ _bmd.lock();
+ bitmapData.lock();
+
+ // draw to temp bitmap
+ _view.renderer.context.drawToBitmapData( _bmd );
+
+ // Draw to material
+ bitmapData.draw( _bmd, _matrix, null, null, new Rectangle(_border, _border, bitmapData.width - _border*2, bitmapData.height - _border*2), smooth );
+ if(_greyscale) bitmapData.applyFilter(bitmapData, bitmapData.rect, ORIGIN, cmf );
+ updateTexture();
+
+ _bmd.unlock();
+ bitmapData.unlock();
+
+ _view.renderer.context.present();
+
+ }
+
+ override public function dispose(deep:Boolean):void
+ {
+
+ if( _container && _container.contains( _view ) ) _container.removeChild( _view );
+
+ _bmd.dispose();
+ _camera.dispose( deep );
+ _view.dispose();
+
+ _matrix = null;
+ _bmd = null;
+ _camera = null;
+ _cameraTarget = null;
+ _view = null;
+ _container = null;
+
+ super.dispose( deep );
+
+ }
+
+ public function get camera():Camera3D
+ {
+ return _camera;
+ }
+
+ public function set camera(value:Camera3D):void
+ {
+ _camera = value;
+ }
+
+ public function get view():View3D
+ {
+ return _view;
+ }
+
+ public function set view(value:View3D):void
+ {
+ _view = value;
+ }
+
+ public function get greyscale():Boolean
+ {
+ return _greyscale;
+ }
+
+ public function set greyscale(value:Boolean):void
+ {
+ _greyscale = value;
+ }
+
+ public function get cameraTarget():Object3D
+ {
+ return _cameraTarget;
+ }
+
+ public function set cameraTarget(value:Object3D):void
+ {
+ _cameraTarget = value;
+ }
+
+ public function get border():uint
+ {
+ return _border;
+ }
+
+ public function set border(value:uint):void
+ {
+ _border = value;
+ }
+
+
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.