home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


ORBITSP.sml

See other examples of SML movie scripts ...


######################
#
# ORBITSP.SML
#
# Demonstration of movie generation from 3D display using spiral 
# orbit path. Both 2D and 3D views are copied into each movie frame.
#
# View center is fixed at center of group.  Viewer position is computed
# from size of group.  Two complete orbits are made.  The first starts
# beyond the edge of group and spirals inward and downward; the second
# spirals outward and upward.
#
# Script uses an input DEM for the surface layer, an input raster drape
# layer, and an input vector drape layer.
#
# Requires TNTmips Version 6.5
#
#####################

clear();

#### Set movie format, frame rate, and recording time

# Movie format (Possible values : "MPEG"(All platform) or "AVI"(Windows only) 
string format$;
format$ = "AVI";

# Frame rate 
# Possible values : 
#   "MOVIE_FRAMERATE_23_976"  23.976 (24000/1001) fps - NTSC encapsulated film rate
#   "MOVIE_FRAMERATE_24"		24 fps - Standard international cinema film rate
#   "MOVIE_FRAMERATE_25"   	25 fps - PAL (625/50) video frame rate
#   "MOVIE_FRAMERATE_29_970"  29.97 (30000/1001) fps - NTSC video frame rate
#   "MOVIE_FRAMERATE_30"   	30 fps - NTSC drop-frame (525/60) video frame rate
#   "MOVIE_FRAMERATE_50"   	50 fps - Double frame rate / progressive PAL
#   "MOVIE_FRAMERATE_59_940"  59.94 (60000/1001) fps - Double frame rate NTSC
#   "MOVIE_FRAMERATE_60"   	60 fps - Double frame rate drop-frame NTSC
string framerate$;
framerate$ = "MOVIE_FRAMERATE_24";

# Recording time
numeric time;
time = 60;

###### Get RVC objects to load
raster Surface, RastDrape;
vector VectDrape;

print("Select raster to use for surface");
GetInputRaster(Surface);

print("Select raster to use for first drape layer");
GetInputRaster(RastDrape);

print("Select vector to use for second drape layer");
GetInputVector(VectDrape);

###### RVC style object to draw center point and viewer point

string styleFilename$;
string styleObjectname$;
GetInputObject("Style","Select style object for center and viewer point symbols:", 
	styleFilename$, styleObjectname$);
string viewer$;
viewer$ = "VIEWER";
string center$;
center$ = "CENTER";

######## Create display group with 2d and 3d views

print("START");

# Size of squared 2D view and 3D view
# Should be evenly divisible by 8
numeric size;
size = 400;

# Zoom out factor for 2D view
numeric zoomfactor;
zoomfactor = 1.8;

# Create group
print("Creating Group");
class GRE_GROUP group;
group = GroupCreate();

# Create flags to create view without iconbar, scrollbars, status line and scale/position line
# This is important to maintain fixed window size for movie generation
string flags$;
flags$ = "NoScalePosLine,NoIconBar,NoScrollbars,NoStatusLine";

# Create dialog and 2D view
print("Creating dialog and 2D view");
class XmForm dialog2d;
class GRE_VIEW view2d;
dialog2d = CreateFormDialog("VIEW 2D");
view2d = GroupCreateView(group,dialog2d,"",size,size,flags$);
view2d.BackgroundColor.red = 67;
view2d.BackgroundColor.green = 100;
view2d.BackgroundColor.blue = 100;

# Create dialog and 3D view
print("Creating dialog and 3D view");
class XmForm dialog3d;
class GRE_VIEW3D view3d;
dialog3d = CreateFormDialog("VIEW 3D");
view3d = GroupCreate3DView(group,dialog3d,"",size,size,flags$);
view3d.BackgroundColor.red = 67;
view3d.BackgroundColor.green = 100;
view3d.BackgroundColor.blue = 100;

# Add layers to group
GroupQuickAddRasterVar(group,Surface,1);
GroupQuickAddRasterVar(group,RastDrape,0);
GroupQuickAddVectorVar(group,VectDrape);

# Open both views
DialogOpen(dialog2d);
DialogOpen(dialog3d);

# Full redraw of both views
ViewRedrawFull(view2d);
ViewRedrawFull(view3d);
ViewZoomOut(view2d,zoomfactor,1);

####### Set up parameters for movie frame

# Destination of each view in final frame for movie
numeric x2d, y2d, x3d, y3d, w, h;
x2d = 0;
y2d = 0;
x3d = size;
y3d = 0;
w = 2 * size;
h = size;

# Create text strings for annotation in frame
string frameTitle$;
string frameTitle2$;
frameTitle$ = "Mount St. Helens Flow Hazard Zonation";
frameTitle2$ = "and Survey Station Locations";

# Font size
numeric fontsize;
fontsize = 16;

# Define color for text annotation in frame
class Color black;
black.red = 0;
black.green = 0;
black.blue = 0;

# Creating frame
print("Creating frame for movie");
class Frame frame;
frame = FrameCreate(w,h);

# Create graphics context (GC) for frame
numeric fontsize;
print("Creating GC from frame and activate it");
ActivateGC(FrameCreateGC(frame));
DrawTextSetHeightPixels(fontsize);
DrawUseStyleObject(styleFilename$,styleObjectname$);

######## Set some more movie parameters

# Initiale Movie
print("Initializing Movie");
class Movie movie;
movie = MovieInit();

# Check framerate and force it to "MOVIE_FRAMERATE_24" if it is invalid
numeric rate;
rate = 24;
if (framerate$ == "MOVIE_FRAMERATE_23_976") rate = 23.976;
if (framerate$ == "MOVIE_FRAMERATE_25") rate = 25.0;
if (framerate$ == "MOVIE_FRAMERATE_29_970") rate = 29.970;
if (framerate$ == "MOVIE_FRAMERATE_30") rate = 30.0;
if (framerate$ == "MOVIE_FRAMERATE_50") rate = 50.0; 
if (framerate$ == "MOVIE_FRAMERATE_59_940") rate = 59.940; 
if (framerate$ == "MOVIE_FRAMERATE_60") rate = 60.0;
if (rate == 24.0) framerate$ = "MOVIE_FRAMERATE_24";

# Set Movie Parameters
print("Setting Movie Parameters");
MovieSetFormat(movie,format$);
MovieSetFrameRate(movie,framerate$);
MovieSetFrameWidth(movie,w);
MovieSetFrameHeight(movie,h);

# Make Output File
string ext$;
ext$ = MovieGetFileExt(movie);
string filename$;
filename$ = GetOutputFileName("","Make filename for movie",ext$);
printf("Filename = %s\n",filename$);

# Check recording time
if (time <= 1.0) time = 1.0;

##### Get georeference for surface layer and reset to group projection

class Georef georef;
georef = GetLastUsedGeorefObject(Surface);
GeorefSetProjection(georef,group.Projection);

# Find map coordinates and surface elevation at center of group
# and define as view point (center)
class POINT3D center;
center.x = group.Center.x;
center.y = group.Center.y;

numeric objx;
numeric objy;
MapToObject(georef,center.x,center.y,Surface,objx,objy);
center.z = Surface[objy,objx];

##### Set up viewpoint and viewer position parameters

class VIEWPOINT3D vp;
vp = view3d.ViewPoint;
vp.SetCenter(center);

class POINT3D pt;			# viewer position
class POINT2D point;		# 2D point for location symbols

# Set initial viewer position north of center just beyond group extents
# and 10000 m higher than center point 
pt.x = group.Center.x;
pt.y = group.Extents.y2 + 0.6 * (group.Extents.y2 - group.Center.y);
pt.z = center.z + 10000;
vp.SetViewerPosition(pt);

# Calculate spiral orbit parameters
numeric numFrames = time * rate;
numeric deltaAngle = -360.0 / numFrames * 2;
numeric tx = vp.ViewPos.x - vp.CenterPoint.x;
numeric ty = vp.ViewPos.y - vp.CenterPoint.y;
numeric distance = 4 * sqrt(tx * tx + ty * ty) / 5 / numFrames * 2;
numeric height = (vp.ViewPos.z - vp.CenterPoint.z) / numFrames * 2;

###### Start recording movie to file
MovieStart(movie,filename$);

# Loop for each frame
numeric i, azimuth;
for i = 1 to numFrames {
	SetStatusMessage(sprintf("Processing frame %d of %d",i,numFrames));

	# Rotate viewer position around center with deltaAngle increment
	vp.RotateViewerPosition(deltaAngle);

	if (i <= numFrames / 2) {
	# Move viewer position closer and higher to center point
		azimuth = vp.AzimAngle * 180 / PI; # make it in degrees
		vp.MoveViewerPosition(azimuth,0,distance,"m");
		vp.MoveViewerPosition(0,90,height,"m");
		}
	else {
	# Move viewer position farther and lower from center point
		azimuth = vp.AzimAngle * 180 / PI + 180; # make it in degrees
		vp.MoveViewerPosition(azimuth,0,distance,"m");
		vp.MoveViewerPosition(0,-90,height,"m");
		}

	# ViewRedrawDirect(view3d,"NoBlankScreen");
	# This new function	added after release of TNTmips 6.5
	# can redraw the view without blanking it first.  Use of
	# this function eliminates "flashing" of the view as the
	# movie is initially rendered.  It has no effect on the
	# output movie file.  For 6.5 release version, use the
	# function in the next statement.

	ViewRedraw(view3d);

	# Copy 2d view and 3d view to destination frame
	FrameCopyFromView(frame,view2d,0,0,size,size,x2d,y2d);
	FrameCopyFromView(frame,view3d,0,0,size,size,x3d,y3d);

	# Draw center point in 2d view
	point.x = vp.CenterPoint.x;
	point.y = vp.CenterPoint.y;
	point = TransPoint2D(point,ViewGetTransMapToView(view2d,group.Projection));
	point = TransPoint2D(point,ViewGetTransViewToScreen(view2d));
	DrawSetPointStyle(center$);
	DrawPoint(point.x,point.y);

	# Draw viewer position point in 2d view
	point.x = vp.ViewPos.x;
	point.y = vp.ViewPos.y;
	point = TransPoint2D(point,ViewGetTransMapToView(view2d,group.Projection));
	point = TransPoint2D(point,ViewGetTransViewToScreen(view2d));
	DrawSetPointStyle(viewer$);
	DrawPoint(point.x,point.y);

	# Draw text to top of frame
	DrawTextSetColors(black);
	DrawTextSimple(frameTitle$,5,fontsize);
	DrawTextSimple(frameTitle2$,5,2.2*fontsize);

	# Add frame to movie
	MovieAddFrame(movie,frame);
}											# Emd of main processing loop

# Stop and Exit movie
MovieStop(movie);
MovieExit(movie);

# Close dialogs
DialogClose(dialog2d);
DialogClose(dialog3d);

print("END");


 

 


Back Home ©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

25 March 2009

page update: 26 May 11