|
TNTmips Downloads Menu

|
simorbit.sml
See other
examples of TNTsim3D scripts ...
# simorbit.sml
# Script for TNTsim3D that gets the current viewer position and the position on the
# terrain at the center of the view, then orbits the viewer clockwise around that
# terrain position.
#####################################################################################
### For a script to run under TNTsim3D, it must include an instance of
### class TNTSIM3D named "TNTsim3D". The script must also be saved as an RVC
### object in the TNTsim3D Landscape File you want to run it with.
#####################################################################################
# declare class instance for TNTsim3D interface class
class TNTSIM3D TNTsim3D;
# variable declarations
class POINT3D viewer, center, orientation;
numeric roll; # roll angle from horizontal (degrees)
numeric radius; # radius of orbit (meters)
numeric heading; # heading of viewer in azimuth (counter-clockwise from north)
numeric direction; # direction of view in internal cartesian coordinate system
# (degrees clockwise from X axis)
#######################################################################
### get viewer and center positions from current scene and center projected
### onto terrain surface to get coordinates for orbit center
#######################################################################
TNTsim3D.GetScene(viewer, center, roll);
TNTsim3D.GetProjectedCenter(center);
## compute radius from center of orbit
radius = sqrt( sqr(viewer.x - center.x) + sqr(viewer.y - center.y) );
#######################################################################
### get viewer position and orientation from current scene to
### get present heading
#######################################################################
TNTsim3D.GetSceneByOrientation(viewer, orientation);
heading = orientation.z; # azimuth angle from viewer toward center in degrees
# clockwise from north
# reverse heading and convert to direction angle (counter-clockwise from x axis)
# to compute next viewer position in orbit
direction = 180 - (heading - 90);
if (direction > 0) then
direction = direction - 360;
########################################################################
### SML function name predefined in TNTsim3D, called for each frame.
########################################################################
func OnFrame()
{
# decrement direction
direction = direction - 0.2;
if (direction < 0) then
direction = direction - 360;
# compute new viewer x and y position from direction angle
viewer.x = center.x + (radius * cosd(direction) );
viewer.y = center.y + (radius * sind(direction) );
# set scene with new viewer position and center on orbit center, with roll = 0
TNTsim3D.SetScene(viewer, center, 0);
}
©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010 USA
Business & Sales: (402)477-9554 Support: (402)477-9562 Fax: (402)477-9559
Business info@microimages.com
Support support@microimages.com
Web webmaster@microimages.com
| |