###################### # # PAN1.SML # # Demonstration of movie generation from 3D display # with viewer position fixed and view point (view center) # rotating around the viewer to produce a panning view. # Both 2D and 3D views are copied into each movie frame. # Current viewer position and view center positions are shown # by symbols in each 2D frame. # # Script uses input DEM for surface, an input raster drape layer # (can be the DEM itself), and a vector drape layer. # # Viewer position is fixed at a constant altitude above the center of the group. # Initial view center position is set at the southern extents of the # group due south of the center. View center position is rotated # around the viewer position in one complete circle using an angle increment # computed from the movie time and frame rate. # # 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$ = "MPEG"; # 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 = 10; ###### Get RVC objects to load raster Surface, RastDrape; vector VecDrape; print("Select raster to use for surface"); GetInputRaster(Surface); print("Select raster to use for drape layer"); GetInputRaster(RastDrape); print("Select vecter to use for drape layer"); GetInputVector(VecDrape); ##### 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 numeric size; size = 256; # Zoom out factor for 2D view numeric zoomfactor; zoomfactor = 1.0; # 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$); # 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$); # Add layers to group GroupQuickAddRasterVar(group,Surface,1); GroupQuickAddRasterVar(group,RastDrape,0); GroupQuickAddVectorVar(group,VecDrape); # 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 frame for movie numeric x2d, y2d, x3d, y3d, w, h; x2d = 0; y2d = 0; x3d = size; y3d = 0; w = 2 * size; h = size; # Font size numeric fontsize; fontsize = 12; # Create frame print("Creating frame for movie"); class Frame frame; frame = FrameCreate(w,h); #Create graphics context (GC) for frame print("Creating GC from frame and activate it"); ActivateGC(FrameCreateGC(frame)); DrawTextSetHeightPixels(fontsize); DrawUseStyleObject(styleFilename$,styleObjectname$); ######## Set some more movie parameters # Initialize 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; # Calculate number of frames and angle increment for pan numeric numFrames; numeric deltaAngle; numFrames = time * rate; deltaAngle = -360.0 / numFrames; ###### Calculate initial center and viewer positions class VIEWPOINT3D vp; vp = view3d.ViewPoint; class POINT3D pt; # 3D point variable reused for assigning initial viewer and view center positions pt.x = group.Center.x; pt.y = group.Center.y; pt.z = 5000; vp.SetViewerPosition(pt); pt.x = group.Center.x; pt.y = group.Extents.y1; pt.z = 0; vp.SetCenter(pt); ViewRedraw(view3d); class POINT2D point; # 2D point for location symbols ###### Start recording movie to file MovieStart(movie,filename$); # Loop for each frame numeric i; for i = 1 to numFrames { SetStatusMessage(sprintf("Processing frame %d of %d",i,numFrames)); # Rotate viewer position around center with deltaAngle increment vp.RotateCenter(deltaAngle); # 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 string string$ = sprintf("Frame %d of %d",i,numFrames); DrawTextSimple(string$,0,fontsize); # Add frame to movie MovieAddFrame(movie,frame); } # End of main processing loop # Stop and Exit movie MovieStop(movie); MovieExit(movie); # Close dialogs DialogClose(dialog2d); DialogClose(dialog3d); print("END");