现在我制作osg :: Vec3类型Line:
public osg::ref_ptr<osg::Vec3Array> _pointArray;
loadVec3();
CreateLine(_pointArray);
void loadVec3()
{
//read cordinate from csv file par 1 line`
while ((line = streamReader->ReadLine()) != nullptr)
{
//divide
array<String^>^ values = line->Split(',');
//cordinate value x,y,z
double x = (values->Length > 0) ? double::Parse(values[0]) : 0.0;
double y = (values->Length > 1) ? double::Parse(values[1]) : 0.0;
double z = (values->Length > 2) ? double::Parse(values[2]) : 0.0;
osg::Vec3 pos(x, y, z);
_pointArray->push_back(pos);
count++;
}
}
void CreateLine(osg::ref_ptr<osg::Vec3Array>& v2)
{
// Create an object to store geometry in.
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
// Create an array of four vertices.
osg::ref_ptr<osg::Vec3Array> v = v2;
geom->setVertexArray( v.get() );
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
}
这一次,我必须从同一个文件中画出2行
写入文件的值是不可见的中心线,
Y坐标可见线与中心线的间隙相同(+/- 190.0)。
我将代码更改为以下内容,但是我收到错误:
错误C2440
如何解决此错误?
public osg::ref_ptr<osg::Vec3Array> _pointArrayL;
public osg::ref_ptr<osg::Vec3Array> _pointArrayR;
public std::list< osg::ref_ptr<osg::Vec3Array>> _pointArrayList;
void loadVec3()
{
//read cordinate from csv file par 1 line
while ((line = streamReader->ReadLine()) != nullptr)
{
//divide
array<String^>^ values = line->Split(',');
//cordinate value x,y,z
double x1 = (values->Length > 0) ? double::Parse(values[0]) : 0.0;
double y1 = (values->Length > 1) ? double::Parse(values[1] + 190.0) : 0.0;
double z1 = (values->Length > 2) ? double::Parse(values[2]) : 0.0;
osg::Vec3 posL(x1, y1, z1);
double x2 = (values->Length > 0) ? double::Parse(values[0]) : 0.0;
double y2 = (values->Length > 1) ? double::Parse(values[1]) -190.0 = : 0.0;
double z2 = (values->Length > 2) ? double::Parse(values[2]) : 0.0;
osg::Vec3 posR(x2, y2, z2);
count++;
}
_pointList.push_back(
_pointList.push_back(posR);
}
void CreateLine(std::list<osg::ref_ptr<osg::Vec3Array>> v2)
{
// Create an object to store geometry in.
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
// Create an array of four vertices.
std::list<osg::ref_ptr<osg::Vec3Array>>::iterator it = v2.begin();
while( it != v2.end() ) // stil end of list
{
osg::ref_ptr<osg::Vec3Array> v = *v2;<<<<<<<<<<<<<<<<<<<<<<<<<**ERROR**
geom->setVertexArray( v.get() );
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( geom.get() );
++it;
}
}
答案 0 :(得分:0)
我不认为* v2会有效; v2是一个std :: list对象,所以取其地址没有意义。也许你的意思是:
osg::ref_ptr<osg::Vec3Array>* v = &v2;
虽然看着你的代码,但我不确定v的重点是什么。