コード例 #1
0
ファイル: WriteVisitor.cpp プロジェクト: jothikannan/osg
// use to convert draw array quads to draw elements triangles
JSONObject* WriteVisitor::createJSONDrawElements(osg::DrawArrays* drawArray)
{
    if (_maps.find(drawArray) != _maps.end())
        return _maps[drawArray]->getShadowObject();

    if (drawArray->getMode() != GL_QUADS) {
        osg::notify(osg::WARN) << "" << std::endl;
        return 0;
    }

    osg::ref_ptr<osg::DrawElementsUShort> de = new osg::DrawElementsUShort(GL_TRIANGLES);

    for (int i = 0; i < drawArray->getCount()/4; ++i) {
        int base = drawArray->getFirst() + i*4;
        de->push_back(base + 0);
        de->push_back(base + 1);
        de->push_back(base + 3);

        de->push_back(base + 1);
        de->push_back(base + 2);
        de->push_back(base + 3);
    }
    JSONDrawElements<osg::DrawElementsUShort>* json = new JSONDrawElements<osg::DrawElementsUShort>(*de);
    json->addUniqueID();
    _maps[drawArray] = json;
    return json; 
}
コード例 #2
0
ファイル: WriteVisitor.cpp プロジェクト: jothikannan/osg
JSONObject* WriteVisitor::createJSONDrawElementsUByte(osg::DrawElementsUByte* de)
{
    if (_maps.find(de) != _maps.end())
        return _maps[de]->getShadowObject();

    JSONDrawElements<osg::DrawElementsUByte>* json = new JSONDrawElements<osg::DrawElementsUByte>(*de);
    json->addUniqueID();
    _maps[de] = json;
    return json;
}
コード例 #3
0
ファイル: WriteVisitor.cpp プロジェクト: 3dcl/osg
JSONObject* WriteVisitor::createJSONDrawElementsUByte(osg::DrawElementsUByte* de, osg::Geometry* geom)
{
    if (_maps.find(de) != _maps.end())
        return _maps[de]->getShadowObject();

    JSONDrawElements<osg::DrawElementsUByte>* json = new JSONDrawElements<osg::DrawElementsUByte>(*de);
    json->addUniqueID();
    _maps[de] = json;
    if(geom && _mergeAllBinaryFiles) {
        setBufferName(json, geom);
    }
    return json;
}