Table of Contents
Scripting SapphireWindow functionsShowWndYou can open the Sapphire 3D renderer window using the following ZeoScript command: Sapphire.ShowWnd ShowWndEx
HideWndYou can close the Sapphire 3D renderer window using the following ZeoScript command: Sapphire.HideWnd ToggleWndYou can toggle open/close the Sapphire 3D renderer window using the following ZeoScript command: Sapphire.ToggleWnd If the window is open, it will be closed, and if it is closed, it will be opened. IsShown
GetHWND
EditHFYou can open the Sapphire 3D renderer window in heightfield editor mode using the following ZeoScript command: Sapphire.EditHF EditAMYou can open the Sapphire 3D renderer window in attributes map editor mode using the following ZeoScript command: Sapphire.EditAM EditAMYou can open the Sapphire 3D renderer window in texture map editor mode using the following ZeoScript command: Sapphire.EditTX RenderFrame
ScreenCapTo take a screen capture from Sapphire, use the following script command: Sapphire.ScreenCap "myimagefile.bmp" …where in the above example, “myimagefile.bmp” is the destination filename of the screen capture. If no path is given, the file will be written in L3DT's current working directory. Common image formats are supported (BMP/JPG/PNG/TGA/etc.). To allow the user to enter the filename using a file-save dialog, use the following script command: Sapphire.ScreenCap <z:file.SaveDlg "bmp" NULL "Bitmap image (*.bmp)|*.bmp|JPEG image (*.jpg)|*.jpg|"> To add more formats to the file selection dialog, edit the filter string above. ScreenCap2
State functionsIsPaused
SetPauseYou can pause the the Sapphire 3D renderer window using the following ZeoScript command: Sapphire.SetPause true To un-pause the renderer, use the following command: Sapphire.SetPause false SetMouseMode
You can set the mouse mode in the Sapphire 3D renderer using the // set to the default cursor (no tool, no capture) Sapphire.SetMouseMode 0 // set to the camera pan mode Sapphire.SetMouseMode 1 // set to the heightfield brush tools: Sapphire.SetMouseMode 2 // set to the attributes map brush tools: Sapphire.SetMouseMode 3 GetBrushRadius
SetBrushRadius
RefreshHF
RefreshTX
Camera functionsGetPos3dv
GetPosX
GetPosY
GetPosZ
SetPos3dYou can set the position of the camera in Sapphire using the following ZeoScript command: Sapphire.Camera.SetPos3d 100 200 300 … where, in the above example, 100 is the X coordinate (east/west), 200 is the Y coordinate (north/south), and 300 is the Y coordinate (up/down). Obviously, you'd want to replace the 100/200/300 numbers with the actual camera coordinates you want to use. Decimal values are allowed. The camera coordinates are in reduced terrain vertex units, so X=100 Y=200 would put the camera on the 100th vertex in the east direction, and the the 200th vertex in the Y direction. The Z coordinate is also scaled by the horizontal scale of the heighfield, so a Z coordinate of 300 would put the camera at an altitude of 3,000m when using a 10m-resolution heightfield. SetElevTo set the elevation (up/down angle) of the camera, use the following ZeoScript command: Sapphire.Camera.SetElev 45 …where in the above example, 45 is the camera elevation angle measured in degrees above the horizon. A value if 0 is horizontal, 90 is straight up, and -90 is straight down. Decimal values are allowed. GetElev
SetAzimTo set the azimuth (heading angle) of the camera, use the following ZeoScript command: Sapphire.Camera.SetAzim 135 …where in the above example, 135 is the camera heading angle measured in degrees clockwise from north. A value if 0 is due north, 90 is east, 180 is south, and 270 is west. Decimal values are allowed. GetAzim
LookAt
Settings/configuration functionsEditRendererCfgYou can open the renderer settings dialog box for Sapphire using the following ZeoScript command: Sapphire.Settings.EditRendererCfg EditHardwareCfgYou can open the hardware settings dialog box for Sapphire using the following ZeoScript command: Sapphire.Settings.EditHardwareCfg Help functionsOpenWikiYou can open a web-browser and automatically navigate to the Sapphire wiki page / userguide using the following ZeoScript command: Sapphire.Help.OpenWiki Multi-threading considerations
OpenGL is a state engine1), which means that it's a shockingly bad idea to try to make OpenGL do two things at once, such as call OpenGL functions from two threads. Consequently, users must be careful not to call Sapphire script commands that affect the OpenGL state from within calculation threads (e.g. inside Particular functions that must not, under any circumstances, be called from threads other than the main application thread include:
However, if you simply must call Sapphire functions from a thread, there is a work-around. The procedure is:
Plese note that 'Sapphire.SetPause true' is a blocking function, and will pause Sapphire's rendering before it returns, whereas 'Sapphire.SetPause false' is non-blocking, and may not resume frame rendering before it returns. Isn't multithreading fun! 1)
…at least OpenGL 1.x and 2.x are state engines. OpenGL 3.x may be a different story.
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|