由于一张纹理的大小不能超过30M,把文理分开贴在模型上面,我应该怎么来设置纹理的坐标,可以采用以下函数能实现!
实现方法
1 把图片分割为多个,同时把面也分割多个。
2 使用纹理融合
对第2种举例(测试通过)
//texture1
SoGroup *tg1=new SoGroup;
SoTextureUnit *texUnit1 = new SoTextureUnit ;
texUnit1->unit.setValue(0);
texUnit1->mappingMethod = SoTextureUnit::IMAGE_MAPPING ;
SoTexture2Transform *texturetrans1 = new SoTexture2Transform;
texturetrans1->scaleFactor.setValue(2.0,1.0);
texturetrans1->center.setValue(0.0,0.0);
SoTexture2 *texture1 = new SoTexture2;
texture1->filename="./1.bmp";
texture1->wrapS =SoTexture2::CLAMP_TO_BORDER ;
texture1->wrapT =SoTexture2::CLAMP_TO_BORDER ;
texture1->enableBorder.setValue(FALSE);
texture1->borderColor.setValue(1.0f,1.0f,1.0f,0.0f);
tg1->addChild(texUnit1);
tg1->addChild(texturetrans1);
tg1->addChild(texture1);
root->addChild(tg1);
//texture2
SoGroup *tg2=new SoGroup;
SoTextureUnit *texUnit2 = new SoTextureUnit ;
texUnit2->unit.setValue(1);
texUnit2->mappingMethod = SoTextureUnit::IMAGE_MAPPING ;
SoTexture2Transform *texturetrans2 = new SoTexture2Transform;
texturetrans2->scaleFactor.setValue(2.0,1.0);
texturetrans2->center.setValue(1.0,0.0);
SoTexture2 *texture2 = new SoTexture2;
texture2->filename="./2.bmp";
texture2->wrapS =SoTexture2::CLAMP_TO_BORDER ;
texture2->wrapT =SoTexture2::CLAMP_TO_BORDER ;
texture2->enableBorder.setValue(FALSE);
texture2->borderColor.setValue(1.0f,1.0f,1.0f,1.0f);
tg2->addChild(texUnit2);
tg2->addChild(texturetrans2);
tg2->addChild(texture2);
root->addChild(tg2);
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);
coord->point.set1Value(4,2,1,0);
coord->point.set1Value(5,2,0,0);
coord->point.set1Value(6,1,0,0);
coord->point.set1Value(7,1,1,0);
root->addChild(coord);
SoFaceSet *face=new SoFaceSet;
face->numVertices.set1Value(0,4);
face->numVertices.set1Value(1,4);
root->addChild(face);
http://tanghg678.blog.163.com/blog/static/1292320520070128244225/