Sunday, March 22, 2009

Sphere Rotation

The first thing I did after getting all the Papervision and general project setup is creating a Sphere and make it rotate based on users input (Mouse RollOver) over the same Sphere surface.

Using InteractiveScene3DEvent.renderHitData object we can tell the X and Y values of where the mouse hit on the surface of the sphere. These values are then used to affect the rotationX and rotationY properties of the Sphere.

In the MouseOver and/or MouseMove handler:

var locX:Number = e.renderHitData.x-x;
var locY:Number = e.renderHitData.y-y;

sphere.rotationX -= locY/10;
sphere.rotationY += locX/10;

Divided by 10 just because the values are too big otherwise.




You'll recognize a problem with this way of doing this though. Rotations are done around the sphere's local axis X & Y. and what I really need is a rotation over a global axis based on a vertex defined by the user interaction with the surface of the sphere. This is what I'll work on next.

1 comment:

  1. Borgata Hotel Casino & Spa, Atlantic City - JT Hub
    Hotel. JT Hub offers 전라남도 출장안마 the 천안 출장마사지 best 과천 출장샵 Borgata hotel casino and spa, 경산 출장샵 as well as the finest in entertainment. It's located 여주 출장마사지 off of the busy Atlantic City

    ReplyDelete