多纹理,贴到一个面

本文介绍了一种当单张纹理图片过大时(超过30M),如何通过分割纹理和使用纹理融合的方法来解决这一问题。具体介绍了如何利用SoGroup、SoTextureUnit等组件进行纹理映射,并提供了实际代码示例。

由于一张纹理的大小不能超过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/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值