把纹理和模型一起打成.IV包

本文介绍了一个使用Open Inventor创建包含纹理的3D场景并将其保存为IV文件的例子。通过定义坐标、纹理和面集来构建基本的3D几何形状。

添加纹理,创建iv文件.

//------------例子---------------

int _tmain(int argc, _TCHAR* argv[])
{

//
Widget myWindow = SoXt::init(argv[0]);
if (myWindow == NULL)
exit(1);

SoSeparator *root = new SoSeparator;
root->ref();

SoTexture2 *texture=new SoTexture2;
texture->filename="照片001.jpg";
root->addChild(texture);

SoCoordinate3 *coord=new SoCoordinate3;
coord->point.set1Value(0,0,0,0);
coord->point.set1Value(1,0,1,0);
coord->point.set1Value(2,1,1,0);
coord->point.set1Value(3,1,0,0);
root->addChild(coord);


SoFaceSet *face=new SoFaceSet;
face->numVertices.setValue(4);
root->addChild(face);


// Set up viewer:
SoXtExaminerViewer *myViewer = new SoXtExaminerViewer(myWindow);
myViewer->setSceneGraph(root);
myViewer->setTitle("Examiner Viewer");
myViewer->show();

SoXt::show(myWindow);
SoXt::mainLoop();

SbString ivFile;
ivFile="demo.iv";
SoWriteAction wa;
wa.getOutput()->setBinary(true);
wa.getOutput()->openFile(ivFile.getString());
wa.apply(root);
wa.getOutput()->closeFile();

root->unref();

return 0;
}

http://tanghg678.blog.163.com/blog/static/1292320520070883216195/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值