开发者

C++/CLI osg : Create Array element osg::ref_ptr<osg::Vec3Array>

开发者 https://www.devze.com 2023-03-20 00:18 出处:网络
Now I make osg::Vec3 type Line: publicosg::ref_ptr<osg::Vec3Array> _pointArray; loadVec3(); CreateLine(_pointArray);

Now I make osg::Vec3 type 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() );
}

This time, I must draw 2lines from samefile.

Value that written in file is invisible center line,

Y coordinate visible line is same clearance(+/-190.0) from center line.

I changed the code to the following, but I get the error:

ERROR C2440

How can I solve this error?

public  osg::ref_ptr<osg::Vec3Array> _pointArrayL;
public  osg::ref_ptr<osg::Vec3Array> _pointArrayR;
public  std::li开发者_高级运维st< 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;
    }
}


It doesn't look to me like *v2 would be valid; v2 is a std::list object, so taking the address of it does not make sense. Perhaps you meant:

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

Though looking at your code, I am not sure what the point of having v is at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消