|
本帖最后由 forest37 于 2009-9-8 16:48 编辑
当数据坐标较大时(五位数),显示对象闪烁;当数据坐标很大时(七位数),显示对象显示不出来,不知道各位是否遇到这种情况,除了将所有坐标点偏移一个值,还有其他解决方法吗?代码如下,将60000换成6000000时,什么也显示不出来。
#include "stdafx.h"
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Vec3>
#include <osg/MatrixTransform>
#include <osg/Group>
#include <osgViewer/Viewer>
osg::ref_ptr<osg::Node> createTransform()
{
osg::MatrixTransform *mt = new osg::MatrixTransform();
mt->setMatrix(osg::Matrix::translate(-60000,0,0));
osg::Geode *geo=new osg::Geode;
mt->addChild(geo);
osg::Geometry* geom=new osg::Geometry;
osg::Vec3Array* vec3a= new osg::Vec3Array;
vec3a->push_back(osg::Vec3(60000.4,0,0.4));
vec3a->push_back(osg::Vec3(60000.4,0,0.6));
vec3a->push_back(osg::Vec3(60000.6,0,0.6));
vec3a->push_back(osg::Vec3(60000.6,0,0.4));
geom->setVertexArray(vec3a);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
geo->addDrawable(geom);
return mt;
}
int main(int, char **)
{
osgViewer::Viewer viewer;
viewer.setSceneData( createTransform() );
return viewer.run();
} |
|