i add a distance animation like pan angle animation to “HoverController”

Software: Away3D 4.x

banzai, Newbie
Posted: 23 July 2012 04:02 PM   Total Posts: 9

Hello guys,
i’m ported “panAngle or tiltAngle logic” to distance

new set disatnce():

public function set distance(val:Number):void
  {
   val 
= Math.max(_minDistance, Math.min(_maxDistance, val))
   if (
_distance == val)
    return;
   
   
_distance = val;
   
   
notifyUpdate();
  
} 


new update() function:

public override function update():void
  {
   
if (_tiltAngle != _currentTiltAngle || _panAngle != _currentPanAngle || _distance != _currentDistance) {
    
    notifyUpdate
();
    
    if (
_wrapPanAngle) {
     
if (_panAngle < 0)
      
_panAngle = (_panAngle % 360) + 360;
     else
      
_panAngle = _panAngle % 360;
     
     if (
_panAngle - _currentPanAngle < -180)
      
_currentPanAngle -= 360;
     else if (
_panAngle - _currentPanAngle > 180)
      
_currentPanAngle += 360;
    
}
    
    _currentTiltAngle 
+= (_tiltAngle - _currentTiltAngle)/(steps + 1);
    
_currentPanAngle += (_panAngle - _currentPanAngle)/(steps + 1);
    
_currentDistance += (_distance - _currentDistance)/(steps +1)
    
    
//snap coords if angle differences are close
    
if ((Math.abs(tiltAngle - _currentTiltAngle) < 0.01) && (Math.abs(_panAngle - _currentPanAngle) < 0.01) && (Math.abs(_distance - _currentDistance)< 0.01)) {
     _currentTiltAngle 
= _tiltAngle;
     
_currentPanAngle = _panAngle;
     
_currentDistance = _distance;
    
}
   }
   
   
var pos:Vector3D = (lookAtObject)? lookAtObject.position : (lookAtPosition)? lookAtPosition: _origin;
   
targetObject.x = pos.x + _currentDistance*Math.sin(_currentPanAngle*MathConsts.DEGREES_TO_RADIANS)*Math.cos(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS);
   
targetObject.z = pos.z + _currentDistance*Math.cos(_currentPanAngle*MathConsts.DEGREES_TO_RADIANS)*Math.cos(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS);
   
targetObject.y = pos.y + _currentDistance*Math.sin(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS)*yFactor;
   
   
super.update();
  
} 

new constructor function declaration:

public function HoverController(targetObject:Entity = null, lookAtObject:ObjectC panAngle:Number = 0, tiltAngle:Number = 90, distance:Number = 1000, minTiltAngle:Number = -90, maxTiltAngle:Number = 90, minPanAngle:Number = NaN, maxPanAngle:Number = NaN, steps:uint = 8, yFactor:Number = 2, wrapPanAngle:Boolean = false, minDistance:Number = 0, maxDistance:Number = Infinity) 

and i also created distance max/min setter and getter functions

it would be cool if you add this upgrade to new version LOL

Note: this is not fully complete class, when i complete it all i will post it to github.

   

Richard Olsson, Administrator
Posted: 24 July 2012 08:02 AM   Total Posts: 1192   [ # 1 ]

Please go ahead and file this as a pull request on GitHub and we will look at it there, if you don’t mind. That way we don’t have to copy-paste, and you will still be credited in the Git change log.

   

Alba, Newbie
Posted: 24 July 2012 10:59 AM   Total Posts: 2   [ # 2 ]

why can’t see nothing in the attachment file

   

banzai, Newbie
Posted: 24 July 2012 11:07 AM   Total Posts: 9   [ # 3 ]

Ii uploaded *.as file, so i couldn’t guess that it will be invisible for users…
now i upload *.zip file. enjoy

   

banzai, Newbie
Posted: 24 July 2012 11:20 AM   Total Posts: 9   [ # 4 ]

i’m preparing to upload new HoverController.as with smooth motion function

moveToObject(object:ObjectContainer3D, method:String = LINEAR);
moveToPosition(point:Vector3D, method:String = LINEAR)

. also i want to remove some artifacts in this class, like double using

Math.max(_minPanAngle, Math.min(_maxPanAngle, _panAngle));

in all set/get functions

   

banzai, Newbie
Posted: 24 July 2012 03:47 PM   Total Posts: 9   [ # 5 ]
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X