---
title: "ubuntu下学习OpenSceneGraph(一)"
author: "NickWar"
date: "2010-11-14T22:16:00Z"
tags: []
slug: "ubuntu-openscenegraph"
draft: false
lastmod: "2012-04-20T20:55:17Z"
id: 1492353
url: "https://nickwar.iteye.com/blog/1492353"
---

&lt;!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --&gt;

虚拟机上安装了Ubuntu10.10 Cd版，想在学习OpenSceneGraph的同时学习使用Linux，自我感觉在使用中学习，应该更有效果。

安装编译好的OpenSceneGraph

首先，在Ubuntu中的命令行状态下输入Sudo Synaptic，在软件包管理器中搜索OpenSceneGraph,找到之后选择openscenegraph和openscenegraph-examples然后安装，如下图：

![新立得软件包管理器](http://hi.csdn.net/attachment/201011/14/4846_1289743770WhwV.png)

&lt;!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --&gt;

安装完成后，就可以在命令行下输入osgversion，然后会显示当前安装的版本信息，

OpenSceneGraph Library 2.8.3

目前的ubuntu上的版本是2.8.3。

然后使用osgviewer cow.osg,可以查看osg模型

![osg经典的奶牛模型](http://hi.csdn.net/attachment/201011/14/4846_1289743771rAPr.png)

&lt;!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --&gt;

注，有可能提示未加载任何模型，意思就是找不到模型文件，此时，可以使用全路径来指定cow.osg的地址

此模型文件位于osgexample中。

还有一种方法，就是设置环境变量，OSG\_FILE\_PATH，

osgviewer在加载模型的时候会搜索这个路径，在linux下设置环境变量的方法较多，我使用的是修改profile文件，在命令行下输入sudo vim /etc/profile

然后在最上面添加一行 export OSG\_FILE\_PATH="/home/nickwar/Public/QSGExamples/Data"

保存后，再在命令行下输入source /etc/profile

这样环境变量就生效了，此时，再使用osgviewer加载模型就不会有问题了。