(ps the graphics in the test link were from someone i helped on actionscript.org so not mine) 'Door' concept are great for setting up a scene of planes, as you may have seen in one of my other posts.

On 22 Apr 2010, at 22:22, Justin Lawerance Mills wrote:

Ok this is haXe but concepts are similar...

You can cut the bitmap up by modifying this
       /**
        *  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;


       }

I have a Door class ( it still needs work ), it allows you to easily work with planes, you can use it for creating structures, although probably adds overhead and almost overkill for a class and is far from complete, I have an as3 papervision version somewhere that was more finished, ( see test http://www.justinfront.net/demos/treepopup.swf ) the link should give you an idea on its use. Anyway here is my current haXe one but I need to do more work on it probably could be implemented better.


package zpartan.generic.views.away;

/*
* Copyright (c) 2010, Justinfront Ltd, (  JLM at Justinfront dot net )
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Justinfront Ltd nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Justinfront Ltd 'AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Justinfront Ltd BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
   import away3dlite.core.base.Mesh;
   import away3dlite.containers.ObjectContainer3D;

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


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

   enum Orientation
   {
       X;
       Y;
   }

   class Door extends ObjectContainer3D
   {


       public var rotate( _get_rotate, _set_rotate ): Float;


       private function _get_rotate():Float
       {
           switch( _orientationRotation )
           {
               case X:
                   return _get_rotation_X();
               case Y:
                   return _get_rotation_Y();
           }
       }


       private function _set_rotate( val: Float ):Float
       {

           switch( _orientationRotation )
           {
               case X:
                   return _set_rotation_X( val );
               case Y:
                   return _set_rotation_Y( val );
           }
       }


       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: Mesh )
       {

           _doorNob.addChild( doorNob );

       }


       public function addLeg( doorleg: Mesh )
       {

           _doorLeg.addChild( doorleg );

       }

       private var _holder:                ObjectContainer3D;
       public var _hi:                     Float;
       public var _wide:                   Float;

       private var _orientationRotation:   Orientation;
       public var _doorNob:                ObjectContainer3D;
       private var _doorLeg:               ObjectContainer3D;


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

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

           switch( opening_ )
           {
               case left:
                   _orientationRotation    =   Orientation.Y;
                   _doorNob.x      +=   _wide/2;
                   _doorLeg.x      +=   _wide;

               case right:
                   _orientationRotation    =   Orientation.Y;
                   _doorNob.x      -=   _wide/2;
                   _doorLeg.x      -=   _wide;

               case top:
                   _orientationRotation    =   Orientation.X;
                   _doorNob.y      -=   _hi/2;
                   _doorLeg.y      -=   _hi;

               case bottom:
                   _orientationRotation    =   Orientation.X;
                   _doorNob.y      +=   _hi/2;
                   _doorLeg.y      +=   _hi;

           }

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

           addChild( _holder );

       }


   }







On 22 Apr 2010, at 13:07, Colir wrote:

Hi,
I asking me what is the better approach to fold a bitmap like in this
website :
http://www.bloodstream.com.br/

in my case i want to fold and unfold a bitmap in two piece (like some
alarm clock)

Do you think is better to use 2 plan with each one have a part of the
bitmap,
or  i can fold directly a plan ? how ? must use AS3Dmod ?

Thanks for you help


--
Subscription settings: http://groups.google.com/group/away3d-dev/subscribe?hl=en


Reply via email to