#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 映射实例

http://blog.163.com/[email protected]/blog/static/113437502201023193711255/

相关文章:

  • 2021-05-21
  • 2021-07-21
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-08-20
猜你喜欢
  • 2021-11-25
  • 2021-12-26
  • 2022-12-23
  • 2021-06-26
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案