55 osgViewer
登录

osgViewer

作者: osgChina 发布于2018-10-19 17:04:27 分类 : 用户指南

osgviewer是一个非常重要的例子,当初书写它的本意是示例如何书写一个viewer,现在它成为一个功能完备的应用程序了。

环境变量

要确认osg相关的环境变量设置正确,主要是osgviewer所在的目录要加到path中等等。

运行

使用如下命令:

osgviewer cow.osg

会打开一个全屏的牛.

参数

可以使用--help打印出:

osgviewer --help

Options:


--dem <filename>

Load an image/DEM and render it on a HeightField

--display <type>

MONITOR | POWERWALL | REALITY_CENTER | EAD_MOUNTED_DISPLAY

--help-all

Display all command line, env vars and keyboard & mouse bindigs

--help-env

Display environmental variables available

--help-keys

Display keyboard & mouse bindings available

--image ;filename>

Load an image and render it on a quad

--rgba

Request a RGBA color buffer visual

--run-till-elapsed-time

Specify the about of time to run

--run-till-frame-number <integer>

Specify the number of frame to run

--stencil

Request a stencil buffer visual

--stereo

Use default stereo mode which is ANAGLYPHIC if not overriden by environmental variable

--stereo <mode>

ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE | ON | OFF

-O <option_string>

Provide an option string to reader/writers used to load databases

-c <filename>

Specify camera config file

-e <extension>

Load the plugin associated with handling files with specified extension

-h or --help

Display command line paramters

-l <library>

Load the plugin

-p <filename>

Specify camera path file to animate the camera through the loaded scene

键盘和鼠标操作

点击h键可以查看键鼠帮助信息

osgviewer --help-keys

Keyboard and Mouse Bindings:


1

Select 'Trackball' camera manipulator (default)

2

Select 'Flight' camera manipulator

3

Select 'Drive' camera manipulator

4

Select 'Terrain' camera manipulator

5

Select 'UFO' camera manipulator

Drive: Space

Reset the viewing position to home

Drive: a

Use mouse middle,right mouse buttons for speed

Drive: q

Use mouse y for controlling speed

Escape

Exit the application

Flight: Space

Reset the viewing position to home

Flight: a

No yaw when banked

Flight: q

Automatically yaw when banked (default)

O [=PrnScn?=]

Write camera images to "saved_image*.rgb"

Trackball: +

When in stereo, increase the fusion distance

Trackball: -

When in stereo, reduse the fusion distance

Trackball: Space

Reset the viewing position to home

UFO:

Please see http://www.openscenegraph.org/html/UFOCameraManipulator.html

UFO: H

Reset the viewing position to home

Z

If recording camera path stop recording camera path, save to "saved_animation.path"


Then start viewing from being on animation path

b

Toggle backface culling

f

Toggle fullscreen

h

Display help

l

Toggle lighting

s

Toggle instrumention

t

Toggle texturing

v

Toggle block and vsync

w

Toggle polygon fill mode between fill, line (wire frame) and points

z

Start recording camera path.

环境变量设置

使用下面命令可以查看osgviewer相关的环境变量:

osgviewer --help-env

Environmental Variables:


OSG_COMPUTE_NEAR_FAR_MODE <mode>

DO_NOT_COMPUTE_NEAR_FAR | COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES | COMPUTE_NEAR_FAR_USING_PRIMITIVES

OSG_DISPLAY_TYPE <type>

MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY

OSG_EYE_SEPARATION <float>

physical distance between eyes

OSG_FILE_PATH <path>[:path]..

Paths for locating datafiles

OSG_LIBRARY_PATH <path>[:path]..

Paths for locating libraries/ plugins

OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS <int>

maximum number of graphics contexts to be used with applications.

OSG_NEAR_FAR_RATIO <float>

Set the ratio between near and far planes - must greater than 0.0 but less than 1.0.

OSG_OPTIMIZER "<type> [<type>]"

OFF | DEFAULT | FLATTEN_STATIC_TRANSFORMS | REMOVE_REDUNDANT_NODES | COMBINE_ADJACENT_LODS | SHARE_DUPLICATE_STATE | MERGE_GEOMETRY | SPATIALIZE_GROUPS | COPY_SHARED_NODES | TRISTRIP_GEOMETRY | OPTIMIZE_TEXTURE_SETTINGS

OSG_SCREEN_DISTANCE <float>

physical distance between eyes and screen

OSG_SCREEN_HEIGHT <float>

physical screen height

OSG_SPLIT_STEREO_AUTO_ADJUST_ASPECT_RATIO <mode>

OFF | ON Default to ON to compenstate for the compression of the aspect ratio when viewing in split screen stereo. Note, if you are setting fovx and fovy explicityly OFF should be used.

OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING <mode>

LEFT_EYE_LEFT_VIEWPORT | LEFT_EYE_RIGHT_VIEWPORT

OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION <float>

number of pixels between viewports

OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING <mode>

LEFT_EYE_TOP_VIEWPORT | LEFT_EYE_BOTTOM_VIEWPORT

OSG_SPLIT_STEREO_VERTICAL_SEPARATION <float>

number of pixels between viewports

OSG_STEREO <mode>

OFF | ON

OSG_STEREO_MODE <mode>

QUAD_BUFFER | ANAGLYPHIC | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE

PRODUCER_CAMERA_CONFIG_FILE <filename>

specify the default producer camera config to use when opening osgProducer based applications.