Announcement

Collapse
No announcement yet.

[Solved]Mouse drag 3d rotation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Solved]Mouse drag 3d rotation

    Hello,

    I Know there is a video showing how the mouse drag 3d rotation works. i tried copying some of the code there however it never worked for me. this was a while ago. Now i actually want to use it. So how can i implement the mouse move/drag 3d rotation of mc's or the entire swf. I tried looking at the UT flash stuff but im having a hard time picking out the relevant code.

    Thank You.

    #2
    ok well i got it working i just need it to rotate the canvas on mouse drag not mouse click

    Comment


      #3
      ok i figured it out! this is how i did the rotation!

      Code:
      _global.gfxExtensions = true;
      
      var brot:Boolean = false;
      var ox:Number = 0;
      var oy:Number = 0;
      var orx:Number = 0;
      var ory:Number = 0;
      
      mainmenu.playbut._z = -500;
      mainmenu.achivebut._z = -700;
      mainmenu.score._z = -900;
      mainmenu.options._z = -1200;
      mainmenu.credits._z = -1500;
      mainmenu.walkmode._z = -1100;
      mainmenu._perspfov = 60;
      
      var idleTimeout:Number;
      
      this.onMouseMove = function () {
      	if (brot) {
      		calcRotations();
      	}
      }
      
      var mouseListener:Object = new Object;
      mouseListener.onMouseDown =  function(button : Number) {
      	if(button == 1) {
      		brot = true;
      		ox =  _root._xmouse;
      		oy =  _root._ymouse;
      		orx = mainmenu._yrotation;
      		ory = -mainmenu._xrotation;
      		
      		_root.onEnterFrame = null;
      	}
      }
      
      mouseListener.onMouseMove =  function(button : Number) {
      	if(button == 1) {
      		brot = false;
      		if (_.idleTimeout) {
      			_global.clearTimeout(_root.idleTimeout);}
      			_root.idleTimeout = _global.setTimeout(_root, "resetForIdleLoop",5000);
      	}
      }
      Mouse.addListener(mouseListener);
      
      //3d stuff
      function calcRotations():Void {
      	var rotX:Number = orx + ((_root._xmouse - ox) / 1024) * 90;
      	var rotY:Number = orx + ((_root._ymouse - oy) / 1024) * 90;
      	
      	mainmenu._yrotation = rotX;
      	mainmenu._xrotation = -rotY;
      }
      
      var xAnim:Number = 0.025;
      var yAnim:Number = 0.05;
      var xThresh:Number = 5; 
      var yThresh:Number = 10; 
      
      function rotateAboutXAxis(mc:MovieClip):Void {
      	mc._xrotation = mc._xrotation + xAnim;
      	if (mc._xrotation > xThresh || mc.xrotation < -xThresh) {
      		xAnim = -xAnim;
      	}
      }
      
      function rotateAboutYAxis(mc:MovieClip):Void {
      	mc._yrotation = mc._yrotation + yAnim;
      	if (mc._yrotation > yThresh || mc.rotation < -yThresh) {
      		yAnim = -yAnim;
      	}
      }
      
      function startIdleLoop():Void{
      	onEnterFrame = function(){
      		rotateAboutXAxis(mainmenu);
      		rotateAboutYAxis(mainmenu);
      	}
      }
      I studied that video longer and it paid off

      Comment


        #4
        It for menu rotation or camera?

        Comment


          #5
          Looking at the code and seeing as this is posted in the Scaleform forum, I´d say it´s for menu rotation

          Comment

          Working...
          X