2011-07-14 93 views
-1

現在我使OSG :: VEC3型線:C++/CLI OSG:創建陣列元件OSG :: ref_ptr <OSG :: Vec3Array繼承>

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()); 
} 

這一次,我必須從中samefile 2lines 。
寫入文件中的值爲不可見中心線,
Y座標可見線與中心線距離相同(+/- 190.0)。

我改變了代碼以下,但我得到的錯誤:

ERROR 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

它在我看來不像* v2是有效的; v2是一個std :: list對象,所以取其地址是沒有意義的。也許你的意思是:

osg::ref_ptr<osg::Vec3Array>* v = &v2; 

雖然看着你的代碼,我不知道v有什麼意義。