|
楼主 |
发表于 2009-7-3 17:37:39
|
显示全部楼层
如何将动态的场景正确的渲染到纹理的对应位置呢?
现在不使用奶牛(纹理拉伸的厉害,辨不清具体)
1.创建一个矩形Geometry,将Images/primitives.gif添加为纹理。
Geometry坐标:
osg::Vec3Array* vc= new osg::Vec3Array();
vc->push_back(osg::Vec3(0.0f,0.0f,0.0f));
vc->push_back(osg::Vec3(1.0f,0.0f,0.0f));
vc->push_back(osg::Vec3(1.0f,0.0f,1.0f));
vc->push_back(osg::Vec3(0.0f,0.0f,1.0f));
纹理坐标
osg::Vec2Array* vt= new osg::Vec2Array();
vt->push_back(osg::Vec2(0.0f,0.0f));
vt->push_back(osg::Vec2(1.0f,0.0f));
vt->push_back(osg::Vec2(1.0f,1.0f));
vt->push_back(osg::Vec2(0.0f,1.0f));
2.创建一个新的纹理,加入到StateSet,将新的纹理坐标设为和Images/primitives.gif图片相同大小。(作为混合纹理贴图,大小617×512,纹理坐标与第一个纹理相同)
3.创建Camera,临时创建一个彩色矩形框,将矩形框的内容渲染到刚才新增的纹理。
问题如图所示:1.渲染到纹理的时候如何保证全覆盖到纹理? 2.颜色怎么反了? |
|