Archive for December 30th, 2008
Slerp Explorer
Slerp allows you to find the quickest path from one rotation to another rotation. In Papervision3D, slerp is a static function of the Quaternion class. The following code shows all the pieces you’ll need to use slerp in your projects:
//the values from your start axis and rotation (x,y,z,rotation) startQuaternion = new Quaternion(0, 1, 0, 1); //the values from your end axis and rotation endQuaternion = new Quaternion(0, 1, 0, 1); /* the next section would go in an update event, like Event.ENTER_FRAME or TimerEvent.TIMER */ //if slerp is 0, the rotation will reflect the startQuaternion //if slerp is 1, the rotation will reflect the endQuaternion //any value between 0 and 1 will be a percentage of the rotation //between the start and end. For example, .5 would be halfway between //start and end. slerp = 0; //transition this up to 1, something like slerp += .01; //the main quaternion that you copy the rotation from quaternion = Quaternion.slerp(startQuaternion, endQuaternion, slerp); //Copies the rotation from the main quaternion into the cube's matrix cube.transform.copy3x3(quaternion.matrix);
To use this example:
- Move the axis and rotation sliders then click “set start”.
- Move the axis and rotation sliders and click “set end”
- Click “slerp from start to end” and you’ll see the cube rotate from the start rotation to the end rotation.
Focus on how the cube is rotating and how you could use that in your projects. Don’t get distracted by the reference axis.
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- FDT Super Awesome March Deal
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
- MorphController – Mighty Morphing Papervision3D
Recent Comments
- Xdragosy on Ribbons
- As on What is BasicView?
- Godie_dito on Dynamic Text on a Plane
- Angel Kaido on Following line
- bambii7 on faq
- Felipe on TweenMax – Tweening a timeline (Advanced Tweening)
- Ocatarinabelachichix on about
- Rajiv on faq
- Rajiv on 3ds max texture baking for Papervision3D
- Anupam Biswas on Maya Texture Baking
Categories
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160


