コード例 #1
0
ファイル: Scene.cpp プロジェクト: veter-team/daeview
void 
Scene::readScene(domVisual_sceneRef scene)
{
  const std::string scene_name = CheckString(scene->getName());
  std::ostringstream os;
  os << "Reading Collada scene '" << scene_name << "'";
  os << std::ends;
	this->scene_graph.printStatusMessage(os.str()); 	

  bool inserted;
  SceneGraph::IdVertexMap::iterator pos;
  SceneGraph::node_id_map_t node_id = get(SceneGraph::node_info_t(), this->scene_graph.node_graph);
  tie(pos, inserted) = this->scene_graph.id_vertex_map.insert(std::make_pair(scene->getId(), SceneGraph::Vertex()));
  if(inserted)
  {
    this->scene_graph.root = add_vertex(this->scene_graph.node_graph);
    node_id[this->scene_graph.root].id = scene->getId();
    node_id[this->scene_graph.root].sid = "";
    pos->second = this->scene_graph.root;
    this->scene_graph.all_nodes.insert(scene->getID(), Node());
    this->scene_graph.all_nodes.find(scene->getID())->name = scene_name;
  } else
    this->scene_graph.root = pos->second;

	// recurse through the scene, read and add nodes 
  const domNode_Array &nodes = scene->getNode_array();
	for(size_t i = 0; i < nodes.getCount(); ++i)
	{
		this->readNode(nodes.get(i), this->scene_graph.root);
	}

  // calculate bounding boxes for font elements
  for(int j = 0; j < this->scene_graph.all_nodes.size(); ++j)
  {
    Node *n = this->scene_graph.all_nodes.getAtIndex(j);
    if(n->is_font_node)
      n->calcBoundingBox(this->scene_graph.all_geometries);
  }
}