katopz

Thanks for the links I have probably looked at them already. If you need help getting started on haXe let me know I can even send you a basic project that loads flash swf with assets and some xml so that you don't have to mess with swfmill and have some code to experiment with and set up for a site.

But my main problem was if you try to put a plane into one of the example files - "Basic_InteractiveObjects.hx" with a picture in it you will notice the image is always upside down!

I have resorted to rotating the whole scene by 180 degrees ( or rotating each plane in previous attempt ), I am not sure I would have found this in any tutorial, and I am using latest haXe version from the svn maybe I need to add a handle to the camera but seem as though its default should be different.

I found the bug (pan tilt )mentioned earlier today was also present in the haXe build, I have modified my local version to match the away3d change mentioned on the mailing list, but still have to use the scene rotation 180.

Transparency on MovieMaterial does not seem to work for me ( ? ) so I am using BitmapMaterial, but I really am not keen on manually modifying the bitmapDataFill every frame so would be nice to get to the bottom of this... but as I have found in other engines - if you know how to hack with the basic 3D classes you don't need the fancy ones.

I do have a haXe specific issue remaining in regard to my Door class which is nearly right now ( swapped Object3D for ContainerObject3D and mesh... although not ideal that Plane does not derive from ContainerObject3D ) and Door is very useful for connecting planes together for popup or limbs, but I will post that on the haXe list as I have a problem defining Dynamic setter getter properties in a way I can tween.

Cheers

;j






On 18 Mar 2010, at 08:27, katopz wrote:

for hover cam try this
http://www.brighthub.com/hubfolio/matthew-casperson/articles/ 66547.aspx

for plane 1:1 with flash native try
http://code.google.com/p/away3d/source/browse/trunk/fp10/Examples/Away3DLite/as/src/ExPlane.as

i suggest you try explore examples here to see what lite can do
http://code.google.com/p/away3d/source/browse/#svn/branches/lite/bin

and try request if you need some feature add to lite

btw, i know 0% of haxe sry :)

hth

On 18 March 2010 14:49, Justin Lawerance Mills <[email protected]> wrote:
Hi

I have been using the away3dlite haxe version. I have not downloaded from the svn today but I think I downloaded it in the last couple of weeks or so, I will try updating, but is the latest haXe away3Dlite online the most recent ver that devs have? But I seem to be struggling to get a scene laid out of planes, of images something that I have my own as3 code for in papervision but I am wary of trying to use an as3 engine in haxe, and where possible I prefer to use haXe and if I use papervision I loose the flash10 advantage, I may try sandy but again it does not take advantage of flash10 and I want as much on screen as I can, but away3Dlite does seem to be more tricky to setup than pv or sandy, but maybe just my lack of use?

I am using hover camera as its what is used in the example I took apart. Maybe someone can comment on some of my issues below and save me hours of experimentation!

Issues:

1) Hover camera does not seem to be easy to set up so that all the planes are facing it and orientated correctly, what do I need to bear in mind, what is the best way to make sure it is setup to face the right way with correct orientation... is it simpler to just use a standard camera. 2) MovieMaterial, I am not sure how to set it up for animation ( not tried yet ) and I have been having problems with getting transparency so I copied the pixels and used the bitmapdata for a BitmapMaterial, but the image seems to be upsidedown. I am also having problems with the inner MovieClip that is scaled messing up the Material ( guess extensive use of cacheAsBitmap and maybe a third layer of movieclip will help )? 3) Plane - I am taking x and y from movieclips loaded in at run time from a swf, but the coordinates seem wrong. Its like the scene is compleatly flipped. Also I really want to find an easy way to take initial 2D scales change the Z of the item then reapply scale so that it is more or less the same as the original 2D layout... any clever equations for this?? Or should I just put edit controls on screen and trace out settings to code back into haXe, I know a 3d package maybe the way to go... but I don't have time to learn blender or sketch up better. 4) The scene seems to take a long time to start is this specific to the haXe away3dlite version? 5) What should I be setting yUp to... I am not completely sure what it means.

Enclosed is some of the code, its fairly rough test code at the moment and not standalone its not really opensource but I suspect anyone that can set it up could create from scratch anyway and not yet has anything fancy in there, and I will probably change some of the classes to composite and use hsl. If the generic Door class is fixed and it seems useful either as code or concept feel free to add it to away, I have found it a useful concept but not tried it in away yet, feel free to advise if there is a better/lighter approach to doors - I prefer to get stuff working and looking right - and then optimize.

Anyway any thoughts?

Cheers

;j

// not yet used or tested
package net.justinfront.views;


   import away3dlite.core.base.Object3D;

   import flash.display.DisplayObject;
   import flash.geom.Rectangle;


   enum Open
   {
       left;
       right;
       top;
       bottom;
   }



   class Door extends Object3D
   {


       public var rotate( _get_rotate, _set_rotate ): Float;


       private var _get_rotate:Dynamic;
       private var _set_rotate:Dynamic;

       private function _get_rotation_X():Float
       {
           return _holder.rotationX;
       }

       private function _set_rotation_X( val: Float ):Float
       {

           _holder.rotationX    = val;
           return val;

       }


       private function _get_rotation_Y():Float
       {
           return _holder.rotationY;
       }

       private function _set_rotation_Y( val: Float ):Float
       {

           _holder.rotationY    = val;
           return val;

       }



       public function addNob( doorNob: Object3D )
       {

           _doorNob.addChild( doorNob );

       }


       public function addLeg( doorleg: Object3D )
       {

           _doorLeg.addChild( doorleg );

       }

       private var _holder:                Object3D;
       private var _hi:                    Float;
       private var _wide:                  Float;
       private var _mc:                    DisplayObject;
       private var _orientationRotation:   String;
       private var _doorNob:               Object3D;
       private var _doorLeg:               Object3D;


       /**
       *       @Constructor
       */
       public function new( rectangle_: Rectangle, opening_: Open )
       {

           super();
           _hi     = rectangle_.height;
           _wide   = rectangle_.width;
           _doorNob = new Object3D();
           _doorLeg = new Object3D();

           switch( opening_ )
           {
               case left:
                   _orientationRotation    =   'rotationY';
                   _get_rotate   = _get_rotation_Y;
                   _set_rotate   = _set_rotation_Y;
                   _doorNob.x      +=   _wide/2;
                   _doorLeg.x      +=   _wide;

               case right:
                   _orientationRotation    =   'rotationY';
                   _get_rotate   = _get_rotation_Y;
                   _set_rotate   = _set_rotation_Y;
                   _doorNob.x      -=   _wide/2;
                   _doorLeg.x      -=   _wide;

               case top:
                   _orientationRotation    =   'rotationX';
                   _get_rotate   = _get_rotation_X;
                   _set_rotate   = _set_rotation_X;
                   _doorNob.y      -=   _hi/2;
                   _doorLeg.y      -=   _hi;

               case bottom:
                   _orientationRotation    =   'rotationX';
                   _get_rotate   = _get_rotation_X;
                   _set_rotate   = _set_rotation_X;
                   _doorNob.y      +=   _hi/2;
                   _doorLeg.y      +=   _hi;

           }

           _holder = new Object3D();
           _holder.addChild( _doorNob );
           _holder.addChild( _doorLeg );

           addChild( _holder );

       }


   }



// used for quick testing
package net.justinfront.views;

   import flash.display.BitmapData;
   import away3dlite.primitives.Plane;
   import away3dlite.core.base.Object3D;
   import away3dlite.materials.MovieMaterial;
   import away3dlite.materials.BitmapMaterial;
   import flash.geom.Point;
   import flash.display.DisplayObject;
   import flash.display.MovieClip;

   import flash.geom.Rectangle;


   class MC_3D extends Plane
   {


       public var mc:              DisplayObject;
       public var mcMaterial:      BitmapMaterial;
       public var hi:              Float;
       public var wide:            Float;


       /**
        *      @Constructor
        */
//(material:Material = null, width:Number = 100, height:Number = 100, segmentsW:int = 1, segmentsH:int = 1, yUp:Boolean = true)
       public function new(
                               segmentsW:      Int             = 0,
                               segmentsH:      Int             = 0,
                               movieAsset:     DisplayObject   = null,
transparent: Bool = false, animated: Bool = false, precise: Bool = false,
                               rect:           Rectangle       = null
                           )
       {

var mat: BitmapMaterial = new BitmapMaterial( copyToBitmapWithTransparency( cast( movieAsset, MovieClip ) ));
                                                               /*,
                                                               rect,
animated, transparent
                                                           );*/
           mat.smooth = true;

           var wide_:   Float          = movieAsset.width;//*.5;
           var hi_:     Float          = movieAsset.height;//*.5;
          // mat.interactive             = true;
           mat.repeat                  = false;

//(material:Material = null, width:Number = 100, height:Number = 100, segmentsW:int = 1, segmentsH:int = 1, yUp:Boolean = true) super( mat, wide_, hi_, segmentsW, segmentsH, false );/// yUp??
           // ?yUp:Bool = true)


           // put on instance for later ref
           mcMaterial                  = mat;
           mc                          = movieAsset;
           hi                          = hi_;
           wide                        = wide_;

       }

       /**
        *  used for copying a movie to a bitmapdata object
        */
public function copyToBitmapWithTransparency( mc: MovieClip ): BitmapData
       {

           mc.cacheAsBitmap                = true;

           var wide:       Int             = Std.int( mc.width );
           var hi:         Int             = Std.int( mc.height );
           var point:      Point           = new Point( 0, 0);
var rect: Rectangle = new Rectangle( 0 , 0, wide, hi); var abitmap: BitmapData = new BitmapData( wide, hi, true, 0x00000 );
           abitmap.draw( mc );
abitmap.copyPixels( abitmap, rect, point, abitmap, point, false );

           return abitmap;


       }
   }


package net.justinfront.views;
import away3dlite.cameras.HoverCamera3D;
import away3dlite.containers.Scene3D;
import away3dlite.containers.View3D;
import away3dlite.core.base.Mesh;
import away3dlite.containers.ObjectContainer3D;
import away3dlite.core.base.SortType;
import away3dlite.core.render.BasicRenderer;
import away3dlite.core.render.Renderer;
import away3dlite.events.MouseEvent3D;
import away3dlite.materials.WireColorMaterial;
import away3dlite.materials.BitmapFileMaterial;
import away3dlite.primitives.Plane;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.Lib;
import net.hires.debug.Stats;
import flash.display.StageQuality;
import away3dlite.materials.Material;
import flash.display.BitmapData;
import flash.display.GraphicsBitmapFill;
import flash.filters.ColorMatrixFilter;
import fl.motion.DynamicMatrix;
import fl.motion.ColorMatrix;
import fl.motion.AdjustColor;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.filters.BlurFilter;
import away3dlite.events.MaterialEvent;
import net.justinfront.views.MC_3D;
import flash.display.DisplayObject;
import net.justinfront.utils.LoadedLib;
import flash.geom.Rectangle;
import net.justinfront.views.Door;
import flash.geom.Vector3D;

class PopupScene extends Sprite
{
   // JLM at justinfront dot net

   //engine variables
   private var scene:          Scene3D;
   private var camera:         HoverCamera3D;
   private var renderer:       Renderer;
   private var view:           View3D;

   private var _swfLayout:     LoadedLib;

   //navigation variables
   private var move:               Bool;
   private var lastPanAngle:       Float;
   private var lastTiltAngle:      Float;
   private var lastMouseX:         Float;
   private var lastMouseY:         Float;

   private var _centre:            ObjectContainer3D;


   private var _mountains:             MovieClip;
   private var _waterfall:             MovieClip;

   private var _mountains3D:           MC_3D;
   private var _waterfall3D:           MC_3D;

//public static function main(){ Lib.current.addChild( new PopupScene() ); }
   public function new( swfLayout_: LoadedLib )
   {
       super();

       _swfLayout = swfLayout_;

       move = false;

       //if (stage != null) init();
       //addEventListener( Event.ADDED_TO_STAGE, init );

   }


   public function init( ?e: Event ):Void
   {
       initEngine();
       initObjects();
       initListeners();
       onEnterFrame(null);

   }


   private function initEngine():Void
   {

       scene               = new Scene3D();
       //scene.y             = 400;
       camera              = new HoverCamera3D();
       camera.focus        = 20;
       camera.distance     = 400;

       //camera.lookAt(new Vector3D(0, 0, 0), new Vector3D(0, 1, 0));


       //camera.minTiltAngle = -30;
       //camera.maxTiltAngle = 40;
       //camera.tiltAngle    = 33;
       camera.hover( true );

       renderer            = new BasicRenderer();
       view                = new View3D();
       view.scene          = scene;
       view.camera         = camera;
       view.renderer       = renderer;
       addChild( view );
       var stats: Stats    = new Stats();
       addChild( stats );
       stats.x = 800 - stats.width;

       //stats.alpha = 0.5;
   }


   private function initObjects():Void
   {

       _centre         = new ObjectContainer3D();

       //_centre.z       -= 720 + 1100;

       scene.addChild( _centre );

       var tempX: Float;
       var tempY: Float;

       _mountains = _swfLayout.createMovieByInstance( '_mountains' );
       //addChild( _mountains );
       tempX = _mountains.x;
       tempY = _mountains.y;
       _mountains.x = 0;
       _mountains.y = 0;
       //var mountains3D: MC_3D = createMC_3D( _mountains, false );
//_mountains3D = new Door( new Rectangle( 0, 0, _mountains.width, _mountains.height ), Open.bottom );
       //_mountains3D.addNob( mountains3D );
       _mountains3D = createMC_3D( _mountains, false );
       _mountains3D.x = tempX;
       _mountains3D.y = tempY;
       _mountains3D.z = -100;
       scene.addChild( _mountains3D );

       _waterfall = _swfLayout.createMovieByInstance( '_waterfall' );
       //addChild( _waterfall );
       tempX = _waterfall.x;
       tempY = _waterfall.y;
       _waterfall.x = 0;
       _waterfall.y = 0;
       //var waterfall3D: MC_3D = createMC_3D( _waterfall, false );
//_waterfall3D = new Door( new Rectangle( 0, 0, _mountains.width, _mountains.height ), Open.bottom );
       //_waterfall3D.addNob( waterfall3D );
       _waterfall3D = createMC_3D( _waterfall, false );
       _waterfall3D.x = tempX;
       _waterfall3D.y = tempY;
       _waterfall3D.z = -100;
       //_waterfall3D.rotate = 90;
       //_waterfall3D.rotationX = 90;
       scene.addChild( _waterfall3D );


   }


private function createMC_3D( mc: DisplayObject, animated: Bool ):MC_3D
   {
       // 3, 3 relates to grid of elements
return new MC_3D( 3, 3, mc, /*transparent:*/ true, / *animated:*/ animated, /*precise:*/ true );

   }



   /**
    * Initialise the listeners
    */
   private function initListeners():Void
   {

scene.addEventListener( MouseEvent3D.MOUSE_UP, onSceneMouseUp );

addEventListener( Event.ENTER_FRAME, onEnterFrame ); stage.addEventListener( MouseEvent.MOUSE_DOWN, onMouseDown ); stage.addEventListener( MouseEvent.MOUSE_UP, onMouseUp ); stage.addEventListener( Event.RESIZE, onResize );

       onResize();

   }

   /**
    * Mouse up listener for the 3d scene
    */
   private function onSceneMouseUp( e: MouseEvent3D ):Void
   {
       /*
       if (Std.is(e.object, Mesh)) {
           var mesh:Mesh = Lib.as(e.object, Mesh);
           mesh.material = new WireColorMaterial();
       }
       */
   }

   /**
    * Navigation and render loop
    */
   private function onEnterFrame( ?event: Event=null ):Void
   {

       if( move )
       {

camera.panAngle = 0.1*( stage.mouseX - lastMouseX ) + lastPanAngle;//0.3 camera.tiltAngle = 0.1*( stage.mouseY - lastMouseY ) + lastTiltAngle;

       }

       camera.hover();


       view.render();

   }


   /**
    * Mouse down listener for navigation
    */
   private function onMouseDown( ?event: MouseEvent=null ):Void
   {

       lastPanAngle    = camera.panAngle;
       lastTiltAngle   = camera.tiltAngle;
       lastMouseX      = stage.mouseX;
       lastMouseY      = stage.mouseY;
       move            = true;

       stage.addEventListener( Event.MOUSE_LEAVE, onStageMouseLeave );

   }


   /**
    * Mouse up listener for navigation
    */
   private function onMouseUp( event: MouseEvent ):Void
   {

       move = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);

   }


   /**
    * Mouse stage leave listener for navigation
    */
   private function onStageMouseLeave( event: Event ):Void
   {

       move = false;
stage.removeEventListener( Event.MOUSE_LEAVE, onStageMouseLeave );

   }


   /**
    * Stage listener for resize events
    */
   private function onResize( ?event: Event ):Void
   {

       view.x = stage.stageWidth / 2;
       view.y = stage.stageHeight / 2;

   }

}



--
katopz
http://www.sleepydesign.com


To unsubscribe from this group, send email to away3d-dev+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to