Esempio n. 1
0
        inline void init_towbar()
        {
            body_s_ = findFirstNode((tow_visual_object_)->root(),"body_s");
            body_b_ = findFirstNode((tow_visual_object_)->root(),"body_b");
            body_a_ = findFirstNode((tow_visual_object_)->root(),"body_a");

            osg::ComputeBoundsVisitor cbvs;
            body_s_->accept( cbvs );
            const osg::BoundingBox bb_s = cbvs.getBoundingBox();

            osg::ComputeBoundsVisitor cbvb;
            body_b_->accept( cbvb );
            const osg::BoundingBox bb_b = cbvb.getBoundingBox();

            osg::ComputeBoundsVisitor cbva;
            body_a_->accept( cbva );
            const osg::BoundingBox bb_a = cbva.getBoundingBox();

            osg::ComputeBoundsVisitor cbv;
            (tow_visual_object_)->root()->accept( cbv );
            const osg::BoundingBox bb_ = cbv.getBoundingBox();

            radius_   = abs(bb_.yMax() - bb_.yMin())/2.0;//(*tow_visual_object_)->root()->getBound().radius();

            radius_s_ = abs(bb_s.yMax() - bb_s.yMin())/2.0;//body_s_->getBound().radius();
            radius_a_ = abs(bb_a.yMax() - bb_a.yMin())/2.0;//body_a_->getBound().radius(); 
            radius_b_ = abs(bb_b.yMax() - bb_b.yMin())/2.0;//body_b_->getBound().radius();
        }
Esempio n. 2
0
std::vector<unsigned int> bTree::findGreater(Index ind, bool equal){
    unsigned int i;
    std::vector<unsigned int> res;
    bTreeNode cur = findFirstNode(ind);

    for (i = 0; i < cur.valNum; ++i)
    {
       if(cur.indexList[i]>=ind) 
           break;
    }
    if(i>=cur.valNum)
    {
        freeNode(cur);
        if(cur.ptrList.back()==0)
            return res;
        cur = assignNode(cur.ptrList.back());
        i = 0;
    }
    while(true)
    {
        if(equal || cur.indexList[i]!=ind)
            res.push_back(cur.ptrList[i]);
        i++;
        if(i>=cur.valNum)
        {
            if(cur.ptrList[i]==0)
                break;
            freeNode(cur);
            cur = assignNode(cur.ptrList[i]);
            i = 0;
        }
    }
    freeNode(cur);
    return res;
}
Esempio n. 3
0
std::vector<unsigned int> bTree::findAll(Index ind){
    unsigned int i;
    std::vector<unsigned int> res;
    bTreeNode cur = findFirstNode(ind);

    for (i = 0; i < cur.valNum; ++i)
    {
       if(cur.indexList[i]==ind) 
           break;
    }
    if(i>=cur.valNum)
    {
        freeNode(cur);
        if(cur.ptrList.back()==0)
            return res;
        cur = assignNode(cur.ptrList.back());
        if(cur.indexList.front()!=ind)
            return res;
        i = 0;
    }
    while(cur.indexList[i]==ind)
    {
        res.push_back(cur.ptrList[i++]);
        if(i==cur.valNum)
        {
            if(cur.ptrList[i]==0)
                break;
            freeNode(cur);
            cur = assignNode(cur.ptrList[i]);
            i = 0;
        }
    }
    freeNode(cur);
    return res;
}
Esempio n. 4
0
bool ossimXmlNode::getChildTextValue(ossimString& value,
                                     const ossimString& relPath)const
{
    ossimRefPtr<ossimXmlNode> node = findFirstNode(relPath);
    if(node.valid())
    {
        value = node->getText();
    }

    return node.valid();
}
Esempio n. 5
0
ossimRefPtr<ossimXmlNode> ossimXmlNode::addNode(const ossimString& relPath,
        const ossimString& text)
{
    //
    // Make a copy to manipulate:
    //
    ossimString relXpath (relPath);
    if (relXpath.empty())
        return 0;

    //
    // First verify that this is not an absolute path:
    //
    if (relXpath[static_cast<std::string::size_type>(0)] ==
            XPATH_DELIM[static_cast<std::string::size_type>(0)])
    {
        ossimNotify(ossimNotifyLevel_WARN) << "WARNING: ossimXmlNode::findChildNodes\n"
                                           << "Only relative XPaths can be searched from a node. "
                                           << "Returning null list...\n";
        return 0;
    }

    //
    // Read the desired tag from the relative xpath
    //
    ossimString desiredTag (relXpath);
    if (relXpath.contains(XPATH_DELIM))
    {
        desiredTag = relXpath.before(XPATH_DELIM);
    }
    ossimString subPath (relXpath.after(XPATH_DELIM));

    ossimRefPtr<ossimXmlNode> node = findFirstNode(desiredTag);

    if(!node.valid())
    {
        if(subPath.empty())
        {
            node = addChildNode(desiredTag, text);
        }
        else
        {
            node = addChildNode(desiredTag, "");
        }
    }
    if(!subPath.empty())
    {
        return node->addNode(subPath, text);
    }

    return node;
}
Esempio n. 6
0
void bTree::insertIndex(Index ind){
    unsigned int i;
    bTreeNode cur = findFirstNode(ind);

    for (i = 0; i < cur.valNum; ++i)
    {
        if (ind<cur.indexList[i])
            break; 
    }
    cur.dirty = true;
    //if(i==cur.valNum)
        //cur.indexList.push_back(ind);
    //else
        //cur.indexList.insert(cur.indexList.begin()+i,ind);

    //std::cout<<"num:"<<cur.valNum<<std::endl;

    if (cur.valNum>0)
        cur.indexList.insert(cur.indexList.begin()+i,ind);
    else
        cur.indexList.push_back(ind);
    cur.valNum++;
    cur.ptrList.insert(cur.ptrList.begin()+i,ind.getTuple());
    
    //std::cout<<ind.getInt()<<std::endl;
    //cur.testOutput();
    //std::cout<<std::endl;

    if (cur.isFull())
    {
        bTreeNode newNode = createNode(LEAF);
        unsigned int half = cur.valNum/2;
        newNode.valNum = cur.valNum - half;
        for (i = 0; i < newNode.valNum; ++i)
        {
            newNode.indexList.push_back(cur.indexList[i+half]);
            newNode.ptrList.push_back(cur.ptrList[i+half]);
        }
        newNode.ptrList.push_back(cur.ptrList.back());
        newNode.parentPtr = cur.parentPtr;
        cur.indexList.erase(cur.indexList.begin()+half,cur.indexList.end());
        cur.ptrList.erase(cur.ptrList.begin()+half,cur.ptrList.end());
        cur.ptrList.push_back(newNode.blockNo);
        cur.valNum = half;
        freeNode(newNode);
        freeNode(cur);
        insertNode(newNode.parentPtr,newNode.blockNo,findPath.back(),newNode.indexList.front());
    }
    else
        freeNode(cur);
    return;
}
Esempio n. 7
0
Task 
TaskList::find(std::function<bool(QDomElement)> predicate) const
{
    if (m_element.isNull()) {
        return Task{};
    }

    auto found = findFirstNode(m_element.childNodes(), predicate);
    if (!found.isNull()) {
        return Task{m_dataSource, found};
    }
    return Task{};
}
Esempio n. 8
0
ossimRefPtr<ossimXmlNode> ossimXmlNode::addNode(const ossimString& relPath,
                                                const ossimString& text)
{
   if (relPath.empty())
      return 0;
   
   //
   // First verify that this is not an absolute path:
   //
   if (relPath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_WARN) << "WARNING: ossimXmlNode::addNode\n"
         << "Only relative XPaths can be searched from a node. "
         << "Returning null list...\n";
      }
      return 0;
   }
   
   //
   // Read the desired tag from the relative xpath
   //
   const std::string::size_type delim_pos = relPath.find(XPATH_DELIM);
   const ossimString desiredTag = relPath.substr(0,delim_pos);
   
   ossimRefPtr<ossimXmlNode> node = findFirstNode(desiredTag);
   
   if(!node.valid())
   {
      // No XPATH_DELIM character found, or XPATH_DELIM at the end of xpath
      if (delim_pos==std::string::npos || delim_pos == relPath.size()-1) 
      {
         node = addChildNode(desiredTag, text);
      }
      else
      {
         node = addChildNode(desiredTag, "");
      }
   }
   if (delim_pos != std::string::npos && delim_pos != relPath.size()-1) // XPATH_DELIM character found!
   {
      const ossimString subPath   = relPath.substr(delim_pos+1, std::string::npos);
      return node->addNode(subPath, text);
   }
   
   return node;
}
    void InstancesManagerImpl::commitInstancesPositions()
    {
        bool bCommit = false;
        size_t instCounter=0;

        if(animDataLoaded_)
        {
            instancesNodes_.erase(std::remove_if(instancesNodes_.begin(), instancesNodes_.end(),
                [](const InstancedNodesVectorType::value_type& v){return v.second && (v.second->getNumParents()==0) && v.parented;})
                , instancesNodes_.end());

            for ( size_t idx = 0; idx < instancesNodes_.size(); ++idx )
            {
                auto & nd = instancesNodes_[idx];
                auto & inst_data = instancesData_[idx];
                if(!nd.second)
                {
                    nd.second = findFirstNode(nd.first,"phys_ctrl",FindNodeVisitor::not_exact,osg::NodeVisitor::TRAVERSE_PARENTS);
                }

                if(nd.second && nd.second->getNumParents()>0)
                {
                    nd.parented  = true;
                    osg::Matrixf matrix = nd.second->asTransform()->asMatrixTransform()->getMatrix();
                    osg::Matrixf modelMatrix = osg::Matrixf::scale(/*instancesData_[idx].getScale()*/srcScale_) 
                        * osg::Matrix::rotate(srcQuat_ * matrix.getRotate())
                        * osg::Matrixf::translate(matrix.getTrans());

                    instancesData_[idx] = modelMatrix;

                    float * data = (float*)instTextureBuffer_->getImage(0)->data( idx  *4u);
                    memcpy(data, instancesData_[idx].ptr(), 16 * sizeof(float));
                    bCommit = true;
                    instCounter++;
                }

            } 
        }
        else
        {
            instCounter = 	instancesData_.size();
            float * data = (float*)instTextureBuffer_->getImage(0)->data(0);

            if (instNum_!=instCounter)
                memcpy(data, instancesData_[0].ptr(), 16 * sizeof(float) * instCounter );
        }


        if(instNum_!=instCounter || bCommit)
        {
            instTextureBuffer_->getImage(0)->dirty();

            instGeode_->setNodeMask(instCounter>0?REFLECTION_MASK:0);

            for(unsigned i=0;i<instGeode_->getNumDrawables(); ++i)
            { 
                instGeode_->getDrawable(i)->dirtyBound();

                if (instNum_!=instCounter)
                {
                    auto geometry = instGeode_->getDrawable(i)->asGeometry();
                    // first turn on hardware instancing for every primitive set
                    for (unsigned int j = 0; j < geometry->getNumPrimitiveSets(); ++j)
                    {
                        geometry->getPrimitiveSet(j)->setNumInstances(instCounter);
                    }
                }

            }
        }

        instNum_ = instCounter;

    }
Esempio n. 10
0
void assignSlots(uint32_t slot, Node *table, symtab_t *symbols, symtab_t *block)
{
  while (slot)
	switch (table[slot].type) {
	case node_fcndef:
	case node_fcnexpr: {
		fcnDeclNode *fd = (fcnDeclNode *)(table + slot);
		fd->symbols.depth = symbols->depth + 1;
		assignSlots(fd->body, table, &fd->symbols, block);
		return;
	}

	case node_endlist:
	case node_list: {
		listNode *ln;

		do {
			ln = (listNode *)(table + slot);
			assignSlots(ln->elem, table, symbols, block);
			slot -= sizeof(listNode) / sizeof(Node);
		} while (ln->hdr->type == node_list);

		return;
	}

	case node_neg:
	case node_enum:
	case node_incr:
	case node_typeof:
	case node_return:  {
		exprNode *en = (exprNode *)(table + slot);
		slot = en->expr;
		continue;
	}

	case node_ternary: {
		ternaryNode *tn = (ternaryNode *)(table + slot);
		assignSlots(tn->condexpr, table, symbols, block);
		assignSlots(tn->trueexpr, table, symbols, block);
		slot = tn->falseexpr;
		continue;
	}

	case node_lor:
	case node_land:
	case node_math:
	case node_access:
	case node_opassign:
	case node_assign: {
		binaryNode *bn = (binaryNode *)(table + slot);
		assignSlots(bn->left, table, symbols, block);
		slot = bn->right;
		continue;
	}
	case node_ifthen: {
		ifThenNode *iftn = (ifThenNode *)(table + slot);
		assignSlots(iftn->condexpr, table, symbols, block);
		assignSlots(iftn->thenstmt, table, symbols, block);
		slot = iftn->elsestmt;
		continue;
	}
	case node_elem: {
		binaryNode *bn = (binaryNode *)(table + slot);
		slot = bn->right;
		continue;
	}
	case node_array: {
		arrayNode *an = (arrayNode *)(table + slot);
		slot = an->exprlist;
		continue;
	}
	case node_obj: {
		objNode *on = (objNode *)(table + slot);
		slot = on->elemlist;
		continue;
	}
	case node_while:
	case node_dowhile: {
		whileNode *wn = (whileNode *)(table + slot);
		assignSlots(wn->cond, table, symbols, block);
		slot = wn->stmt;
		continue;
	}
	case node_forin: {
		forInNode *forn = (forInNode*)(table + slot);
		block = &forn->symbols;

		// set our baseIdx after parent's frameIdx

		if (block->parent)
			block->baseIdx = block->parent->baseIdx + block->parent->frameIdx;
		else
			block->baseIdx = symbols->frameIdx;

		assignSlots(forn->var, table, symbols, block);
		assignSlots(forn->expr, table, symbols, block);

		slot = forn->stmt;
		continue;
	}
	case node_for: {
		forNode *forn = (forNode*)(table + slot);
		block = &forn->symbols;

		// set our baseIdx after parent's frameIdx

		if (block->parent)
			block->baseIdx = block->parent->baseIdx + block->parent->frameIdx;
		else
			block->baseIdx = symbols->frameIdx;

		assignSlots(forn->init, table, symbols, block);
		assignSlots(forn->cond, table, symbols, block);
		assignSlots(forn->incr, table, symbols, block);

		slot = forn->stmt;
		continue;
	}
	case node_var: {
		symNode *sym = (symNode *)(table + slot);
		stringNode *sn = (stringNode *)(table + sym->name);
		symbol_t *symbol = lookupSymbol(&sn->str, symbols, block);

		if (!symbol) {
			firstNode *fn = findFirstNode(table, slot);
			fprintf(stderr, "%s: Symbol not found: %s line = %d node = %d\n", fn->script, sn->str.val, (int)sym->hdr->lineNo, slot);
			exit(1);
		}

		if (symbol->scoped)
			sym->hdr->flag |= flag_scope;

		sym->level = symbols->depth - symbol->depth;
		sym->frameIdx = symbol->frameIdx;
		return;
	}
	case node_block: {
		blkEntryNode *be = (blkEntryNode *)(table + slot);

		// prepare for nested stmt block scope

		block = &be->symbols;

		// set our baseIdx after parent's frameIdx

		if (block->parent)
			block->baseIdx = block->parent->baseIdx + block->parent->frameIdx;
		else
			block->baseIdx = symbols->frameIdx;

		slot = be->body;
		continue;
	}
	case node_pipe:
	case node_fcncall: {
		fcnCallNode *fc = (fcnCallNode *)(table + slot);
		assignSlots(fc->args, table, symbols, block);

		symNode *sym = (symNode *)(table + fc->name);

		if (sym->hdr->type != node_var) {
			assignSlots(fc->name, table, symbols, block);
			return;
		}

		stringNode *sn = (stringNode *)(table + sym->name);
		symbol_t *symbol = lookupSymbol(&sn->str, symbols, block);

		if (symbol) {
			sym->level = symbols->depth - symbol->depth;
			sym->frameIdx = symbol->frameIdx;
			return;
		}

		firstNode *fn = findFirstNode(table, slot);
		fprintf(stderr, "%s: Function not found: %s line = %d node = %d\n", fn->script, sn->str.val, (int)sym->hdr->lineNo, slot);
		exit(1);
	}
	default:
		if (hoistDebug)
			fprintf(stderr, "node %d type %d assignment skipped\n", slot, (int)table[slot].type);
		return;
	}
}
Esempio n. 11
0
void bTree::deleteIndex(Index ind){
    unsigned int i;
    bTreeNode cur = findFirstNode(ind);

    for (i = 0; i < cur.valNum; ++i)
    {
        if (ind<=cur.indexList[i] && ind>=cur.indexList[i])
            break; 
    }
    if(i == cur.valNum)
        return;
    cur.dirty = true;
    cur.indexList.erase(cur.indexList.begin()+i);
    cur.ptrList.erase(cur.ptrList.begin()+i);
    cur.valNum--;

    if(cur.type != ROOT && cur.valNum<(cur.maxNum+1)/2)
    {
        bTreeNode left,right;
        unsigned int path = findPath.back();
        bTreeNode temp = findBro(cur);
        if(temp.type == INIT)
        {
            freeNode(cur);
            return;
        }
        if(temp.indexList.front()<cur.indexList.front())
        {
            left = temp;
            right = cur;
        }
        else
        {
            left = cur;
            right = temp;
            path++;
        }
        left.dirty = true;
        right.dirty = true;
        if(left.valNum + right.valNum <= left.maxNum)
        {
            left.ptrList.pop_back();
            unsigned int i;
            for (i = 0; i < right.valNum; ++i)
            {
                left.indexList.push_back(right.indexList[i]);
                left.ptrList.push_back(right.ptrList[i]);
            }
            left.ptrList.push_back(right.ptrList.back());
            left.valNum+=right.valNum;
            freeNode(left);
            cleanNode(right);
            deleteNode(right.parentPtr,path);
        }
        else
        {
            unsigned int half = (left.valNum + right.valNum) / 2;
            unsigned int i;
            for (i = left.valNum; i < half; ++i)
            {
                left.indexList.push_back(right.indexList[i-left.valNum]);
                left.ptrList.insert(left.ptrList.end()-1,right.ptrList.back());
                left.valNum++;
                right.indexList.erase(right.indexList.begin());
                right.ptrList.erase(right.ptrList.begin());
                right.valNum--;
            }
            for (i = left.valNum-1; i >= half; --i)
            {
                right.indexList.insert(right.indexList.begin(),left.indexList.back());
                right.ptrList.insert(right.ptrList.begin(),left.ptrList[left.valNum-1]);
                right.valNum++;
                left.indexList.erase(left.indexList.end()-1);
                left.ptrList.erase(left.ptrList.end()-2);
                left.valNum--;
            }
            bTreeNode temp = assignNode(right.parentPtr);
            temp.dirty = true;
            temp.indexList[path-1] = right.indexList.front();
            freeNode(temp);
            freeNode(left);
            freeNode(right);
        }
    }
    else
        freeNode(cur);

    return;
}
Esempio n. 12
0
int main( int argc, char **argv )
{
    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);
	

    // set up the usage document, in case we need to print out how to use this program.
    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting between various input and output databases formats.");
    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
    arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
    //arguments.getApplicationUsage()->addCommandLineOption("--formats","List supported file formats");
    //arguments.getApplicationUsage()->addCommandLineOption("--plugins","List database olugins");


    // if user request help write it out to cout.
    if (arguments.read("-h") || arguments.read("--help"))
    {
        osg::setNotifyLevel(osg::NOTICE);
        usage( arguments.getApplicationName().c_str(), 0 );
        //arguments.getApplicationUsage()->write(std::cout);
        return 1;
    }

    if (arguments.read("--help-env"))
    {
        arguments.getApplicationUsage()->write(std::cout, osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE);
        return 1;
    }

    if (arguments.read("--plugins"))
    {
        osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
        for(osgDB::FileNameList::iterator itr = plugins.begin();
            itr != plugins.end();
            ++itr)
        {
            std::cout<<"Plugin "<<*itr<<std::endl;
        }
        return 0;
    }

    std::string plugin;
    if (arguments.read("--plugin", plugin))
    {
        osgDB::outputPluginDetails(std::cout, plugin);
        return 0;
    }

    std::string ext;
    if (arguments.read("--format", ext))
    {
        plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
        osgDB::outputPluginDetails(std::cout, plugin);
        return 0;
    }

    if (arguments.read("--formats"))
    {
        osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
        for(osgDB::FileNameList::iterator itr = plugins.begin();
            itr != plugins.end();
            ++itr)
        {
            osgDB::outputPluginDetails(std::cout,*itr);
        }
        return 0;
    }

    if (arguments.argc()<=1)
    {
        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
        return 1;
    }

    FileNameList fileNames;
    OrientationConverter oc;
    bool do_convert = false;

    if (arguments.read("--use-world-frame"))
    {
        oc.useWorldFrame(true);
    }

    std::string str;
    while (arguments.read("-O",str))
    {
        osgDB::ReaderWriter::Options* options = new osgDB::ReaderWriter::Options;
        options->setOptionString(str);
        osgDB::Registry::instance()->setOptions(options);
    }

    while (arguments.read("-e",ext))
    {
        std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
        osgDB::Registry::instance()->loadLibrary(libName);
    }

    std::string libName;
    while (arguments.read("-l",libName))
    {
        osgDB::Registry::instance()->loadLibrary(libName);
    }

    while (arguments.read("-o",str))
    {
        osg::Vec3 from, to;
        if( sscanf( str.c_str(), "%f,%f,%f-%f,%f,%f",
                &from[0], &from[1], &from[2],
                &to[0], &to[1], &to[2]  )
            != 6 )
        {
            float degrees;
            osg::Vec3 axis;
            // Try deg-axis format
            if( sscanf( str.c_str(), "%f-%f,%f,%f",
                    &degrees, &axis[0], &axis[1], &axis[2]  ) != 4 )
            {
                usage( argv[0], "Orientation argument format incorrect." );
                return 1;
            }
            else
            {
                oc.setRotation( degrees, axis );
                do_convert = true;
            }
        }
        else
        {
            oc.setRotation( from, to );
            do_convert = true;
        }
    }

    while (arguments.read("-s",str))
    {
        osg::Vec3 scale(0,0,0);
        if( sscanf( str.c_str(), "%f,%f,%f",
                &scale[0], &scale[1], &scale[2] ) != 3 )
        {
            usage( argv[0], "Scale argument format incorrect." );
            return 1;
        }
        oc.setScale( scale );
        do_convert = true;
    }

    float simplifyPercent = 1.0;
    bool do_simplify = false;
    while ( arguments.read( "--simplify",str ) )
    {
        float nsimp = 1.0;
        if( sscanf( str.c_str(), "%f",
                &nsimp ) != 1 )
        {
            usage( argv[0], "Scale argument format incorrect." );
            return 1;
        }
        std::cout << str << " " << nsimp << std::endl;
        simplifyPercent = nsimp;
        osg::notify( osg::INFO ) << "Simplifying with percentage: " << simplifyPercent << std::endl;
        do_simplify = true;
    }

    while (arguments.read("-t",str))
    {
        osg::Vec3 trans(0,0,0);
        if( sscanf( str.c_str(), "%f,%f,%f",
                &trans[0], &trans[1], &trans[2] ) != 3 )
        {
            usage( argv[0], "Translation argument format incorrect." );
            return 1;
        }
        oc.setTranslation( trans );
        do_convert = true;
    }


    FixTransparencyVisitor::FixTransparencyMode fixTransparencyMode = FixTransparencyVisitor::NO_TRANSPARANCY_FIXING;
    std::string fixString;
    while(arguments.read("--fix-transparency")) fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
    while(arguments.read("--fix-transparency-mode",fixString))
    {
         if (fixString=="MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
         if (fixString=="MAKE_ALL_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_ALL_STATESET_OPAQUE;
    };

    bool pruneStateSet = false;
    while(arguments.read("--prune-StateSet")) pruneStateSet = true;

    osg::Texture::InternalFormatMode internalFormatMode = osg::Texture::USE_IMAGE_DATA_FORMAT;
    while(arguments.read("--compressed") || arguments.read("--compressed-arb")) { internalFormatMode = osg::Texture::USE_ARB_COMPRESSION; }

    while(arguments.read("--compressed-dxt1")) { internalFormatMode = osg::Texture::USE_S3TC_DXT1_COMPRESSION; }
    while(arguments.read("--compressed-dxt3")) { internalFormatMode = osg::Texture::USE_S3TC_DXT3_COMPRESSION; }
    while(arguments.read("--compressed-dxt5")) { internalFormatMode = osg::Texture::USE_S3TC_DXT5_COMPRESSION; }

    bool smooth = false;
    while(arguments.read("--smooth")) { smooth = true; }

    bool addMissingColours = false;
    while(arguments.read("--addMissingColours") || arguments.read("--addMissingColors")) { addMissingColours = true; }

    bool do_overallNormal = false;
    while(arguments.read("--overallNormal") || arguments.read("--overallNormal")) { do_overallNormal = true; }

    bool enableObjectCache = false;
    while(arguments.read("--enable-object-cache")) { enableObjectCache = true; }

    // any option left unread are converted into errors to write out later.
    arguments.reportRemainingOptionsAsUnrecognized();

    // report any errors if they have occurred when parsing the program arguments.
    if (arguments.errors())
    {
        arguments.writeErrorMessages(std::cout);
        return 1;
    }

    for(int pos=1;pos<arguments.argc();++pos)
    {
        if (!arguments.isOption(pos))
        {
            fileNames.push_back(arguments[pos]);
        }
    }

    if (enableObjectCache)
    {
        if (osgDB::Registry::instance()->getOptions()==0) osgDB::Registry::instance()->setOptions(new osgDB::Options());
        osgDB::Registry::instance()->getOptions()->setObjectCacheHint(osgDB::Options::CACHE_ALL);
    }

    std::string fileNameOut("converted.osg");
    if (fileNames.size()>1)
    {
        fileNameOut = fileNames.back();
        fileNames.pop_back();
    }

    osg::Timer_t startTick = osg::Timer::instance()->tick();

    osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles(fileNames);

    if (root.valid())
    {
        osg::Timer_t endTick = osg::Timer::instance()->tick();
        osg::notify(osg::INFO)<<"Time to load files "<<osg::Timer::instance()->delta_m(startTick, endTick)<<" ms"<<std::endl;
    }


    if (pruneStateSet)
    {
        PruneStateSetVisitor pssv;
        root->accept(pssv);
    }

    if (fixTransparencyMode != FixTransparencyVisitor::NO_TRANSPARANCY_FIXING)
    {
        FixTransparencyVisitor atv(fixTransparencyMode);
        root->accept(atv);
    }

    if ( root.valid() )
    {

        if (smooth)
        {
            osgUtil::SmoothingVisitor sv;
            root->accept(sv);
        }

        if (addMissingColours)
        {
            AddMissingColoursToGeometryVisitor av;
            root->accept(av);
        }
 		
        auto to_lower = std::bind(&boost::to_lower_copy<std::string>,std::placeholders::_1,std::locale());

        // all names to lower
        Utils::CommonVisitor<osg::Node> names_lower(
            [=](osg::Node& n)->void {
                n.setName(to_lower(n.getName()));
        }); 

        root->accept(names_lower);

        // optimize the scene graph, remove rendundent nodes and state etc.
        osgUtil::Optimizer optimizer;

        FindNodeVisitor::nodeNamesList list_name;
        
        for(int i=0; i<sizeof(do_not_optimize::names)/sizeof(do_not_optimize::names[0]);++i)
        {
            list_name.push_back(do_not_optimize::names[i]);
        }
        

        FindNodeVisitor findNodes(list_name,FindNodeVisitor::not_exact); 
        root->accept(findNodes);

        const FindNodeVisitor::nodeListType& wln_list = findNodes.getNodeList();

        for(auto it = wln_list.begin(); it != wln_list.end(); ++it )
        {
            optimizer.setPermissibleOptimizationsForObject(*it,0);
        }

        optimizer.optimize(root.get(), 
            osgUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS |
            osgUtil::Optimizer::REMOVE_REDUNDANT_NODES |
            osgUtil::Optimizer::SHARE_DUPLICATE_STATE |
            osgUtil::Optimizer::MERGE_GEOMETRY |
            osgUtil::Optimizer::MERGE_GEODES |
            osgUtil::Optimizer::STATIC_OBJECT_DETECTION );

        boost::filesystem::path pathFileOut(fileNameOut); 
        std::string base_file_name = pathFileOut.parent_path().string() + "/" + pathFileOut.stem().string();

        cg::point_3 offset;

        bool res = generateBulletFile(base_file_name + ".bullet", root, offset);

        if (res)
        {
            osg::notify(osg::NOTICE)<<"Data written to '"<< base_file_name + ".bullet"<<"'."<< std::endl;
        }
        else
        {
            osg::notify(osg::NOTICE)<< "Error Occurred While Writing to "<< base_file_name + ".bullet"<< std::endl;
        }
        
        osg::Group* newroot =  dynamic_cast<osg::Group*>(findFirstNode(root,"Root")); 
        if(newroot==nullptr)
        {
            newroot = new osg::Group; 
            newroot->setName("Root");
            newroot->addChild( root ); 
            root = newroot;
        }

        std::ofstream filelogic( base_file_name + ".stbin", std::ios_base::binary );
        std::ofstream logfile  ( base_file_name + std::string("_structure") + ".txt" );

        heilVisitor  hv(filelogic, logfile, offset);
        hv.apply(*root.get());


        if( do_convert )
            root = oc.convert( root.get() );

        FIXME(Without textures useless)
#if 0 
        const std::string name = pathFileOut.stem().string();

        osgDB::FilePathList fpl_;
        fpl_.push_back(pathFileOut.parent_path().string() + "/");
        std::string mat_file_name = osgDB::findFileInPath(name+".dae.mat.xml", /*fpl.*/fpl_,osgDB::CASE_INSENSITIVE);

        MaterialVisitor::namesList nl;
        nl.push_back("building");
        nl.push_back("default");
        nl.push_back("tree");
        nl.push_back("ground"); 
        nl.push_back("concrete");
        nl.push_back("mountain");
        nl.push_back("sea");
        nl.push_back("railing");
        nl.push_back("panorama");
        nl.push_back("plane");
        //nl.push_back("rotor"); /// �ללללללללללללל נאסךמלוםעאנטע� ט הטםאלטקוסךטי ףבתועס�

        MaterialVisitor mv ( nl, std::bind(&creators::createMaterial,sp::_1,sp::_2,name,sp::_3,sp::_4),creators::computeAttributes,mat::reader::read(mat_file_name));
        root->accept(mv);
#endif

        if (internalFormatMode != osg::Texture::USE_IMAGE_DATA_FORMAT)
        {
            std::string ext = osgDB::getFileExtension(fileNameOut);
            CompressTexturesVisitor ctv(internalFormatMode);
            root->accept(ctv);
            ctv.compress();

            osgDB::ReaderWriter::Options *options = osgDB::Registry::instance()->getOptions();
            if (ext!="ive" || (options && options->getOptionString().find("noTexturesInIVEFile")!=std::string::npos))
            {
                ctv.write(osgDB::getFilePath(fileNameOut));
            }
        }

        // scrub normals
        if ( do_overallNormal )
        {
            DefaultNormalsGeometryVisitor dngv;
            root->accept( dngv );
        }

        // apply any user-specified simplification
        if ( do_simplify )
        {
            osgUtil::Simplifier simple;
            simple.setSmoothing( smooth );
            osg::notify( osg::ALWAYS ) << " smoothing: " << smooth << std::endl;
            simple.setSampleRatio( simplifyPercent );
            root->accept( simple );
        }

        osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut,osgDB::Registry::instance()->getOptions());
        if (result.success())
        {
            osg::notify(osg::NOTICE)<<"Data written to '"<<fileNameOut<<"'."<< std::endl;
        }
        else if  (result.message().empty())
        {
            osg::notify(osg::NOTICE)<<"Warning: file write to '"<<fileNameOut<<"' not supported."<< std::endl;
        }
        else
        {
            osg::notify(osg::NOTICE)<<result.message()<< std::endl;
        }

    }
    else
    {