open inventor 映射实例

#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTexture2.h>
#include <Inventor/nodes/SoTexture2Transform.h>
#include <Inventor/nodes/SoTextureCoordinatePlane.h>
#include <Inventor/nodes/SoTranslation.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoTextureCoordinateEnvironment.h>
#include <Inventor/nodes/SoComplexity.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>

int main(int, char **argv)
{
HWND myWindow = SoWin::init(argv[0]);
if(myWindow == NULL) exit(1);

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

//选择作为纹理的图片
SoTexture2 *faceTexture = new SoTexture2;
root->addChild(faceTexture);
faceTexture->filename.setValue("me.rgb");

SoMaterial *myMaterial = new SoMaterial;
myMaterial->diffuseColor.setValue(0.95f, 0.95f, 0.95f);
myMaterial->specularColor.setValue(1.0f/3, 1.0f/3, 1.0f/3);
myMaterial->shininess.setValue(0.9f);
root->addChild(myMaterial);

SoComplexity *com = new SoComplexity;
com->value.setValue(1.0f);
com->textureQuality.setValue(1.0f);
root->addChild(com);

SoTexture2Transform *tran = new SoTexture2Transform;
tran->scaleFactor.setValue(SbVec2f(4.0f, 4.0f));
tran->translation.setValue(0.1f, 0.1f);
root->addChild(tran);

SoTextureCoordinateEnvironment *texPlane1 = new SoTextureCoordinateEnvironment;
root->addChild(texPlane1);
root->addChild(new SoCube);

SoTranslation *trans = new SoTranslation;
trans->translation.setValue(2.5f, 0.0f, 0.0f);
root->addChild(trans);

SoWinExaminerViewer *myViewer = new SoWinExaminerViewer(myWindow);
myViewer->setSceneGraph(root);
myViewer->setBackgroundColor(SbColor(0.92f, 0.92f, 0.92f));
myViewer->setTitle("texture coordinate plane");

myViewer->show();

SoWin::show(myWindow);
SoWin::mainLoop();

return 0;
}
open inventor 映射实例 - Vincent Zhang - Projects by Vincent

http://blog.163.com/zhangmwen@126/blog/static/113437502201023193711255/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值