Extending Geo: Scripting & Plugins
My personal programmer's perspective tells me that the biggest
benefit of Geo is its ability to be extended. Geo ships with an
extensive C++ SDK that can be used to create plug-ins. Many third-party
plug-ins are available, or you can create your own. For small
expansion tasks, Geo includes GeoScript, a LUA based scripting
language that can be used to automate repetitive tasks or create new
features specific to your requirements.
GeoScript
Here I will simply list some scripts which are coming with Geo. They give quite a good idea about what the scripts can do:
|
File Name |
Description |
|---|---|
|
Performance & Optimization |
|
|
Select Single Point Polys.gs |
Select all Polys that have only 1 vert |
|
Delete NAN-Value Verts |
Remove bogus Vertex data |
|
Utility |
|
|
Select By Name.gs |
GeoScript Example of traversing the selection list looking for a named node |
|
Multi File Flight Load.gs |
Scan for flight files in a particular directory & load them all up. |
|
Fix Names.gs |
Simple GeoScript Example that goes throught the scene graph looking & node names & fixes any names containing forward or backward slashes. These could cause problems - for example when exporting to hie which uses the node name to build supporting filenames. |
|
Custom Workflow |
|
|
Set External Units Transform.gs |
It is possible to load a flt file with externals referenced in a different units than those of the master file (ie the terrain in meters and the building file in feet). This script runs through a db and looks for externals - comparing their units to the units of the master file. If different a scale transformation is applied to the external. |
|
Reset Flt Shade Model.gs |
This GeoScript Example Traverses the current selection list - looking for polygons that are flagged as having a shademodel of type LIT_GOURAUD. **IF** the poly does NOT have its [x]Use Vertex Colors flag set we will change it LIT. This case does come up when loading OpenFlight(TM) files. |
|
Import File.gs |
GeoScript Example of importing a third-party supported file format |
|
Flt2Radar |
Example of batch mode processing in GeoScript: Load all OpenFlight(TM) files in a directory & batch convert them to Camber Corporation's Radar Toolkit format. |
Geo ships with about 70 scripts, most of them are fully functional scripts for solving specific problems. There are also some example scripts for new starters. Let's have a close look at one of these scripts :
1://============================================================ 2:// NAME: Multi File Flight Load 3:// 4:// DESCRIPTION: Scan for flight files in a particular 5:// directory & load them all up. 6:// 7:// AUTHOR: Andy Bushnell 8:// 9:// ---------------------------------------------------------- 10:// 11:// COPYRIGHT NOTICE: 12:// 13:// Copyright (c) 1998-2003 Carbon Graphics Llc, 14:// ALL RIGHTS RESERVED 15:// 16://============================================================ 17: 18: 19:function main() 20: 21: // turn popups off 22: geoGui:popUps( false ) 23: 24: //------------------------------------------------------------ 25: // Change the directory below to where the files-to-change are 26: // located 27: //------------------------------------------------------------ 28: chdir("c:/dev/tmp"); // <<=== CHANGE DIRECTORY 29: // OR 30: // Get Directory from Directory Browser 31: // Then call chdir 32: 33: //-------------------------------------------------------------- 34: // 't' is a LUA table object - an array of Lua Strings 35: //------------------------------------------------------------ 36: t = dir(); 37: 38: //------------------------------------------------------------- 39: // process each file returned in the LUA-table 't'. Loop 40: // through all files - acting on each one in turn 41: // ----------------------------------------------------------- 42: for i=1,table.getn(t) do 43: 44: // ------------------------------------------------------- 45: // Look for any flt files in the list 46: // ------------------------------------------------------- 47: if strstr(t[i],".flt") then 48: 49: // --------------------------------------------------- 50: // Import the file. The Import command keys off the 51: // extension to know which loader to use. If extension 52: // is .xyz (for example) Geo looks for an ".xyz" 53: // format loader plugin. 54: // --------------------------------------------------- 55: geoApp:import( t[i] ) 56: 57: end 58: 59: end 60: 61: // turn popups back on 62: geoGui:popUps( true ) 63: 64:end 65: 66: 67:// call main function 68:main()
Plugin SDK
The plugin SDK, consisting of include files and library files as expected, allows even more deeper access to Geo's inner workings. The Src directory includes several plugin examples source code, but what's even more cool is the PluginGenerator. The PluginGenerator can be used to quickly autogenerate the basic cpp, h and dsp files which you would need for a plugin. This way you can quickly start developing export, import or interactive tool plugins.
Most commercial modules and extension to Geo are built using the plugin interface.