OIV环境配置

11 篇文章 0 订阅

OIV环境配置

前言:为了学习Open Inventor,选择了VS 2005 + QT + COIN3D的环境进行学习,为了能编译第一个OIV程序,需要配置环境。本人的讨论需要你以前做了如下工作:

1、  VS 2005开发环境;

2、  QT环境,下载QT源代码编译,并安装QT官方提供的与VS2005的插件。

一、        搭建COIN3D开发环境

1、  要搭建Coin3D开发环境,最好的办法是从官方网站下载Coin3D的源代码,自行编译。很多时候官方提供的安装版本,只能适应某一部分编译环境。官方网站为:

http://www.coin3d.org/

目前为止最新版本为3.12版。包括Coin3D,Quarter在内的程序包。

2、  将下载到安装文件解压到固定目录,比如E:/ Coin-3.1.2E:/ Quarter-1.0.0

3、  为了能够编译正常,需要设置需要的环境变量:

QTDIR

D:/QT/qt4.6.2

COINDIR

E:/ Coin-3.1.2

其中QTDIRQT的安装目录,COINDIRCOIN3D目录。

4、  编译Coin3D。打开目录Coin-3.1.2/ build/msvc8中工程文件,选择DLL(Debug)类型编译工程Coin3即可。编译完成后,编译coin3_install工程,该工程将自动拷贝编译生成的DLLBin目录,拷贝生成的LIBLib目录。

5、  编译Quarter。打开目录E:/ Quarter-1.0.0/build/msvc8中工程文件,选择DLL(Debug)类型编译。编译过程中不如编译Coin3D顺利,问题和解决方法如下;

1>     提示inttypes.h头文件无法找到。这是由于VS2005中缺少C99标准提供的该头文件。下载该头文件,并放入VC安装目录Include目录中即可。

2>     过多提示warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss。中文意思是:该文件包含不能在当前代码页中表示的字符,请将文件保存为Unicode格式,以防止数据丢失。

一般来说,这个警告没有什么影响。要想去掉这个警告的方法有:

A、 文件为Unicode格式;

B、 Project -> Properties -> Configuration Properties -> C/C++ -> Advance  Disable Specific Warnings 中添加相应的警告编号:4819

C、 或找出不符合Unicode格式的文件,然后在该文件的开始处加入下面的语句:

# pragma warning (disable:4819)

3>     提示错误:C2086: 'int WINGDIAPI' : redefinition……,重复定义。解决这个问题修改gl-headers.h中定义为

#include <windows.h>

将这个头文件,放入#include <GL/gl.h>之前即可。

4>     提示无法找到GL/glext.h头文件。下载该头文件,放入*/crosoft Visual Studio 8/VC/PlatformSDK/Include/gl目录中。

若无法下载以上需要的头文件,可以给我发送邮件 zhouwei6006@sina.com

6、  编译工程quarter1_install。该工程自动将编译生成的Quarter1.DLLLIB文件拷入E:/ Coin-3.1.2对应目录中。

二、        第一个Coin3D程序

1、  新建QT4程序,选择Console程序,并在main.cpp中输入以下代码:

#include <QtGui/QApplication>

 

#include <Inventor/nodes/SoBaseColor.h>

#include <Inventor/nodes/SoCone.h>

#include <Inventor/nodes/SoSeparator.h>

 

#include <Quarter/Quarter.h>

#include <Quarter/QuarterWidget.h>

 

using namespace SIM::Coin3D::Quarter;

 

int main(int argc, char ** argv)

{

  QApplication app(argc, argv);

  // Initializes Quarter library (and implicitly also the Coin and Qt

  // libraries).

  Quarter::init();

 

  // Make a dead simple scene graph by using the Coin library, only

  // containing a single yellow cone under the scenegraph root.

  SoSeparator * root = new SoSeparator;

  root->ref();

 

  SoBaseColor * col = new SoBaseColor;

  col->rgb = SbColor(1, 1, 0);

  root->addChild(col);

 

  root->addChild(new SoCone);

 

  // Create a QuarterWidget for displaying a Coin scene graph

  QuarterWidget * viewer = new QuarterWidget;

  viewer->setSceneGraph(root);

 

  // make the viewer react to input events similar to the good old

  // ExaminerViewer

  viewer->setNavigationModeFile(QUrl("coin:///scxml/navigation/examiner.xml"));

 

  // Pop up the QuarterWidget

  viewer->show();

  // Loop until exit.

  app.exec();

  // Clean up resources.

  root->unref();

  delete viewer;

 

  Quarter::clean();

 

  return 0;

}

2、  为了能够使第一个Coin3D程序能够编译成功,需要进行如下设置:

1>     工程属性设置 à [C/C++] à [Additional Include Directories] 中增加:

$(COINDIR)/include

[C/C++] à [Preprocessor] 中增加:

COIN_DLL

QUARTER_DLL

2>     工程属性设置 à [Linker] à [Additional Library Directories] 中增加:

$(COINDIR)/lib

[Input] 中增加

coin3d.lib

quarter1d.lib

3、  Coin3D/Bin目录下的Coin3D.dllquarter1d.dll拷入Debug目录。程序即可运行。

PS3.12版的Coin3D源代码存在BUG,拖动窗口出现死机问题,修改此问题,只需要修改Coin-3.1.2/src/projectors/sbspheresheetprojector.cpp183行为:

// let sphere and hyperbolic sheet meet at 45?

 meetdist =  this->sphere.getRadius() * (float) cos(M_PI / 4.0);

在行中间回车即可。

Coin3D

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值