Article Preview
Buy Now
| Print: | |
| PDF: |
The Topographic Apprentice
Path Animation
Tell your Object3Ds where to go!
Issue: 3.1 (September/October 2004)
Author: Joe Nastasi
Author Bio: Joe Nastasi is the president of Pyramid Design, a software development firm and the developers of A-OK! The Wings of Mercury and FTP Suite.
Article Description: No description available.
Article Length (in bytes): 9,367
Starting Page Number: 38
RBD Number: 3118
Resource File(s):
3118.sit Updated: Wednesday, September 15, 2004 at 4:27 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
This issue, we take a detailed look at the code used for our Path Animation library.
Waypoint Class
The code in the Waypoint class is, for the most part, getter and setter methods to access the various parameters. The possible exception is the handling of the waypoint's finite states. There are four: wpStart, wpTurn, wpMove, and wpDone. Internally, the states are represented by integer values: 0, 1, 2, and 3, respectively. This allows the NextState method to change states simply by incrementing the waypoint's State property.
Sub NextState()
Self.State = Self.State + 1
// wrap around, if past last state
If Self.State > Self.wpDone Then
Self.State = Self.wpStart
End If
End Sub
Path Class
Before the path code starts to move and turn to a new waypoint, it needs to calculate how many units to move per step or call of PathAnimationClass.Update. The CalculateStepSize method calculates this double value and stores it in the StepSize property. CalculateStepSize is called during the current waypoint's wpStart state. Using the waypoint ID to gain access, it initializes the CurrentStep property to the Path's Step property. Remember, we define the number of steps between waypoints in the path file described in the last issue.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|







