Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Papervision 3d e zoom

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    8

    Papervision 3d e zoom

    Ciao a tutti.
    Mi chiamo Maurizio e scrivo in preda ad una certa disperazione.
    Premetto che non so molto di programmazione etc

    http://www.studioentourage.it/demo/

    Ho usato swift3d per avere questa clip in papervision3d, pero' il cliente mi chiede
    di limitare lo zoom, perche' adesso con il mouse e i bottoni va all'infinito se uno vuole.
    C'e' qualcuno che puo' aiutarmi per sistemare questo problema?
    Ho praovato ad i vari file as, pero' non ci capisco granche'.... :-(
    Se e' troppo complicato posso pagare il lavoro.

    Grazie mille in anticipo a tutti i programmatori

    maurizio

  2. #2
    senza vedere il codice è dura
    Photogallery Flash Gratis - http://www.flashfiles.biz -
    Template in Flash con pannello di Amministrazione e deeplinking Guarda il template qui

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    8
    gia' :)

    questo e' il main


    Codice PHP:
    package
    {
        
    import flash.display.*;
        
    import flash.events.*;
        
    import flash.utils.Dictionary;

        
    import org.papervision3d.cameras.*;
        
    import org.papervision3d.materials.*;
        
    import org.papervision3d.objects.*;
        
    import org.papervision3d.scenes.*;
        
    import org.papervision3d.core.*;
        
    import org.papervision3d.core.proto.*;
        
    import org.papervision3d.events.FileLoadEvent;


        public class 
    ERMain extends Sprite
        
    {
            
    // Member variables
            
    public  var mCamera                        :Camera3D;
            public  var 
    mCollada                    :Collada;
            public var  
    mSceneCenter                :Number3D;

            private var 
    mContainer                    :Sprite;

            private var 
    mRadius                        :Number;
            private var 
    mRootNode                    :DisplayObject3D;
            private var 
    mRotationAnchor                :Number3D;

            private var 
    mScene                        :Scene3D;

            private var 
    mTarget                        :DisplayObject3D;

            private var 
    mWheelZoomAmount            :Number                1.10;

            
    // Constructor for the ERMain class
            
    public function ERMain()
            {
                
    stage.quality "HIGH";
                
    stage.scaleMode "noScale";

                
    // 3D redraw mechanism as the 3D scene is manipulated
                
    this.addEventListenerEvent.ENTER_FRAMEEROnEnterFrame );

                
    // Set the event handlers for the mouse to the stage so we will
                // handle all mouse events not just those that click on a display
                // object in this class.  These event handlers handle the interactive
                // rotation and mouse wheel zooming.
                
    stage.addEventListener(MouseEvent.MOUSE_DOWNERMouseDownHandler);
                
    stage.addEventListener(MouseEvent.MOUSE_UPERMouseUpHandler);
                
    stage.addEventListener(MouseEvent.MOUSE_WHEELERMouseWheelHandler);

                
    mRotationAnchor = new Number3D;

                
    // Perform the 3D initialization.
                
    ERInitialize();
            }


            
    // This method creates and initializes the 3D scene.
            
    private function ERInitialize():void
            
    {
                
    // Create canvas movieclip and center it
                
    this.mContainer = new Sprite();
                
    addChildthis.mContainer );
                
    this.mContainer.275;
                
    this.mContainer.200;

                
    // Create Scene
                
    this.mScene = new Scene3Dthis.mContainer );
                
    mTarget = new DisplayObject3D ( );


                
    // Create Camera.  Camera is based on selected Swift 3D
                // camera at the time of export.
                
    mCamera = new Camera3D();
                
    mCamera.909.351;
                
    mCamera.0;
                
    mCamera.= -2066.61;

                
    mTarget.909.351;
                
    mTarget.0;
                
    mTarget.= -2066.61;

                
    mCamera.zoom 7.2458;
                
    mCamera.focus 50;
                
    mCamera.target mTarget;

                
    // Establish the scene center to ensure all rotations
                // occur about that center.
                
    mSceneCenter = new Number3D;
                
    mSceneCenter.909.351;
                
    mSceneCenter.0;
                
    mSceneCenter.= -479.805;

                
    // Below is the solid color material list.  Papervision3D Version 1.5 does not import solid
                // colors so we place them here to ensure that they will be displayed.

                
    var lMaterialsList:MaterialsList = new MaterialsList();
                
    lMaterialsList.addMaterial ( new ColorMaterial 0x737373100 ), "mSurfaceIndex01");


                
    mCollada = new Collada("16 swift.dae"lMaterialsList0.01);
                
    mCollada.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONEEROnFileLoaded);

                
    mRootNode mScene.addChildmCollada"mRootNode" );
            }

            
    // The next three functions will turn all of the materials to double sided.
            
    private function EROnFileLoadedevent :Event ):void
            
    {
                var 
    lMaterialsList:MaterialsList mCollada.getMaterialsList ( );
                if ( 
    lMaterialsList )
                {
                    for 
    each ( var lMaterial:MaterialObject3D in lMaterialsList.materialsByName )
                        
    lMaterial.doubleSided true;
                }

                var 
    lChildren:Dictionary Dictionary (mCollada.children);
                
    ERProcessChildrenMaterials lChildren );
            }

            private function 
    ERProcessChildrenMaterials aChildren:Dictionary ):void
            
    {
                if ( 
    aChildren )
                {
                    for 
    each ( var lChild:DisplayObject3D in aChildren )
                        
    ERProcessChildMaterials lChild );
                }

                var 
    lChildren:Dictionary Dictionary (mCollada.children);
            }

            private function 
    ERProcessChildMaterialsaChild:DisplayObject3D ):void
            
    {
                if ( 
    aChild )
                {
                    if ( 
    aChild.materials )
                    {
                        for 
    each ( var lMaterial:MaterialObject3D in aChild.materials.materialsByName )
                            
    lMaterial.doubleSided true;
                    }

                    var 
    lChildren:Dictionary Dictionary (aChild.children);
                    
    ERProcessChildrenMaterials lChildren );
                }
            }

            
    // Rendering method to display changes as the scene is manipulated.
            
    private function EROnEnterFrameevent :Event ):void
            
    {
                
    this.mScene.renderCameramCamera );
            }

            
    // When the mouse is pressed anywhere on the stage, set up for
            // rotational manipulation and add the mouse move event handler. 
            // The rotational system is just like Swift 3D's trackballs.  When
            // the mouse is within the ball, the scene tracks like it is inside
            // a ball and when the mouse is outside the ball, it spins around the
            // axis perpendicular to the screen.
            
    private function ERMouseDownHandler(event:MouseEvent):void
            
    {
                if ( 
    mScene.container.mScene.container.)
                    
    mRadius mScene.container.x;
                else
                    
    mRadius mScene.container.y;

                
    mRotationAnchor.mScene.container.mouseX;
                
    mRotationAnchor.mScene.container.mouseY;

                var 
    lValue:Number = (mRadius mRadius) - (mRotationAnchor.mRotationAnchor.x) - (mRotationAnchor.mRotationAnchor.y);
                if ( 
    lValue )
                    
    mRotationAnchor.0;
                else
                    
    mRotationAnchor.Math.sqrtlValue );

                
    stage.addEventListener(MouseEvent.MOUSE_MOVEERMouseMoveHandler);
            }

            
    // This mouse move handler calculates the incremental rotation between the mouse
            // down or last mouse move event and the current mouse move event.  It then rotates
            // the Papervision3D scene appropriate to that incremental rotation.
            
    private function ERMouseMoveHandler(event:MouseEvent):void
            
    {
                var 
    lCurrentPosition:Number3D = new Number3D;
                var 
    lLastPosition:Number3D = new Number3D;
                var 
    lAxis:Number3D = new Number3D;
                var 
    lCosAngle:Number;
                var 
    lAngle:Number;
                var 
    lTranslationMatrix:Matrix3D;
                var 
    lRotationMatrix:Matrix3D;

                
    lCurrentPosition.mScene.container.mouseX;
                
    lCurrentPosition.mScene.container.mouseY;

                var 
    lValue:Number = (mRadius mRadius) - (lCurrentPosition.lCurrentPosition.x) - (lCurrentPosition.lCurrentPosition.y);
                if ( 
    lValue )
                    
    lCurrentPosition.0;
                else
                    
    lCurrentPosition.Math.sqrtlValue );

                
    lLastPosition mRotationAnchor;
                
    mRotationAnchor = new Number3D lCurrentPosition.xlCurrentPosition.ylCurrentPosition.);

                
    lLastPosition.normalize ( );
                if ( 
    lLastPosition.== )
                    
    lCurrentPosition.0;
                
    lCurrentPosition.normalize ( );
                if ( 
    lCurrentPosition.== )
                    
    lLastPosition.0;
                
    lAxis Number3D.cross lLastPositionlCurrentPosition );
                
    lAxis.normalize ( );
                
    lCosAngle Number3D.dot lLastPositionlCurrentPosition );
                
    lAngle Math.acoslCosAngle );

                
    ERRotateScene lAxislAngle );

                
    event.updateAfterEvent();
            }

            
    // The mouse up handler terminates the interactive rotation mode by 
            // removing the mouse move handler.
            
    private function ERMouseUpHandler(event:MouseEvent):void
            
    {
                
    stage.removeEventListener(MouseEvent.MOUSE_MOVEERMouseMoveHandler);
            }

            
    // The mouse wheel handler zooms in or out of the scene depending on
            // the mouse wheel spin direction (positive or negative values).
            
    private function ERMouseWheelHandler(event:MouseEvent):void
            
    {
                if ( 
    event.delta )
                    
    mCamera.zoom *= mWheelZoomAmount;
                else
                    
    mCamera.zoom /= mWheelZoomAmount;
            }

            public function 
    ERZoomInSceneaZoomAmount:Number ):void
            
    {
                
    mCamera.zoom *= aZoomAmount;
            }

            public function 
    ERZoomOutSceneaZoomAmount:Number ):void
            
    {
                
    mCamera.zoom /= aZoomAmount;
            }

            
    // The ERRotateScene method is used by both the interactive rotation code
            // and the button based rotation code.
            
    public function ERRotateScene aAxis:Number3DaAngle:Number ):void
            
    {
                var 
    lTranslationMatrix:Matrix3D;
                var 
    lRotationMatrix:Matrix3D;
                var 
    lAxis:Number3D aAxis.clone ( );

                
    lTranslationMatrix Matrix3D.translationMatrix( -mSceneCenter.x, -mSceneCenter.ymSceneCenter.);
                
    this.mCollada.transform Matrix3D.multiplylTranslationMatrixthis.mCollada.transform );

                
    lAxis.= - lAxis.x;
                
    Matrix3D.rotateAxis (  mCamera.transformlAxis );
                
    lRotationMatrix Matrix3D.rotationMatrixlAxis.xlAxis.ylAxis.zaAngle );
                
    this.mCollada.transform Matrix3D.multiplylRotationMatrixthis.mCollada.transform );

                
    lTranslationMatrix Matrix3D.translationMatrixmSceneCenter.xmSceneCenter.y, -mSceneCenter.);
                
    this.mCollada.transform Matrix3D.multiplylTranslationMatrixthis.mCollada.transform );
            };
        }


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.