#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();
http://blog.163.com/zhangmwen@126/blog/static/113437502201023193711255/