Ok if anyone is curious, this was my solution. It was actually
extremely simple.
I actually applied this to the RigidBody class in JigLib (JigLib uses
radians and not degrees), but it could easily be interpreted to use
directly on a Mesh.
/**
* Rotates the 3d object a percentage towards an ideal rotation
*
* @param ax The angle in degrees of the rotation around the x axis.
* @param ay The angle in degrees of the rotation around the y axis.
* @param az The angle in degrees of the rotation around the z axis.
* @param percent The percent to move.
*/
public function rotateTowards(ax:Number, ay:Number, az:Number,
percent:Number):void
{
var rotateX:Number = _rotationX + (degreesToRadians(ax) - _rotationX)
* percent;
var rotateY:Number = _rotationY + (degreesToRadians(ay) - _rotationY)
* percent;
var rotateZ:Number = _rotationZ + (degreesToRadians(az) - _rotationZ)
* percent;
_rotationX = rotateX;
_rotationY = rotateY;
_rotationZ = rotateZ;
setOrientation(createRotationMatrix());
}
On Jan 15, 12:59 pm, Norman McGarry <[email protected]> wrote:
> Yes, lookAt does exactly what I want, but it does it instantaneously.
> I want to gradually move it to the correct orientation. I am currently
> messing with the lookAt code to see if I can get it to move by a
> percentage, but I'm not really great with manipulating matrix
> rotations...
>
> On Jan 15, 12:53 pm, Peter Kapelyan <[email protected]> wrote:
>
> > Can you create a dummy or null Object3D that would be at the position you
> > want, then just call myCube.lookAt(myNull)? lookAt seems like it would do
> > what you want.
> > Let me know
> > -Pete
>
> > On Fri, Jan 15, 2010 at 12:51 PM, Norman McGarry
> > <[email protected]>wrote:
>
> > > Yes, I am using Away3D with JigLib physics engine. Here is the
> > > scenario to help put into perspective my goal.
>
> > > I have a bunch of cubes that get shaken around, and after you shake
> > > them up like crazy, they fall down into a particular spot to form
> > > words. I apply miniture little forces to get their position into
> > > place, and once they are close to their ideal positions, I would call
>
> > > var newOrientation:Matrix3D = Utils3D.pointTowards(0.15,
> > > cube.currentState.orientation, new Vector3D(0, 0, 1));
> > > cube.setOrientation(newOrientation);
>
> > > which would move the orientation to be face up and 15 percent closer
> > > every frame. It worked perfectly and looked pretty natural.
> > > Unfortunately switching to FP9, the Utils3D class doesn't exist.
>
> > > Any suggestions?
>
> > > Appreciate any help!
>
> > > On Jan 15, 12:32 pm, Peter Kapelyan <[email protected]> wrote:
> > > > are you planning on using away3d at all?
>
> > > > On Fri, Jan 15, 2010 at 11:56 AM, Norman McGarry <[email protected]
> > > >wrote:
>
> > > > > Hi everyone,
>
> > > > > Sorry to bother with a stupid question like this -- since I know it
> > > > > isn't the place -- but I know you are all brilliant and this might be
> > > > > a walk in the park for you guys.
>
> > > > > I was curious if anyone could show me in code how something like this
> > > > > works (or point me to some reference materials that might help me):
>
> > >http://livedocs.adobe.com/flex/3/langref/flash/geom/Utils3D.html#poin...()
>
> > > > > I'm only using the first 3 parameters and keep the last two as
> > > > > defaults, but unfortunately I am being bumped to FP9 and I have to
> > > > > come up with an alternative way to perform this.
>
> > > > > Thanks so much.
>
> > > > --
> > > > ___________________
>
> > > > Actionscript 3.0 Flash 3D Graphics Engine
>
> > > > HTTP://AWAY3D.COM
>
> > --
> > ___________________
>
> > Actionscript 3.0 Flash 3D Graphics Engine
>
> > HTTP://AWAY3D.COM