Exemplo n.º 1
0
//----------------------------------------------------------------------------
bool SEColladaScene::LoadScene(domVisual_sceneRef spDomVisualScene)
{
    // Create Swing Engine scene graph's root.
    // Save the scene name instead of scene id.
    m_spSceneRoot = SE_NEW SENode;
    xsNCName strSceneName = spDomVisualScene->getName();
    m_spSceneRoot->SetName(strSceneName);

    ToolSystem::DebugOutput("SEColladaScene::Loading Collada Scene %s", 
        (const char*)strSceneName);

    // Recurse through the scene, load and add nodes.
    domNode_Array& rDomNodeArray = spDomVisualScene->getNode_array();
    int iTopLevelNodeCount = (int)rDomNodeArray.getCount();
    for( int i = 0; i < iTopLevelNodeCount; i++ )
    {
        SENode* pNode = LoadNode(rDomNodeArray[i], m_spSceneRoot);
        if( pNode )
        {
            const char* acNodeName = pNode->GetName().c_str();
            m_Nodes[acNodeName] = pNode;
        }
    }

    // Finally add the scene root node.
    m_Nodes[strSceneName] = m_spSceneRoot;

    // Update Swing Engine scene graph.
    m_spSceneRoot->UpdateRS();
    m_spSceneRoot->UpdateGS();

    return true;
}
Exemplo n.º 2
0
void Plugin::ReadScene(domVisual_sceneRef scene)
{
    LOG_DEBUG << "Reading Collada Scene " << scene->getName() << std::endl;

    // recurse through the scene, read and add nodes
    _root = (scene->getNode_array().getCount() > 1) ? new Object() : NULL;
    for (unsigned int i = 0; i < scene->getNode_array().getCount(); i++)
    {
        ReadNode(scene->getNode_array()[i], _root);
    }

/*
    // for each skin controller find the nodes needed for skinning
    for (int i=0; i<Controllers.size(); i++)
    {       // for each controller
        CrtController * controller = Controllers[i];
        if (controller->type==CrtController_Skin_Types)
        {
            CrtSkin * skin = (CrtSkin *) controller;
            if (skin->JointsType == CrtJoint::CrtJointsType_SID)
            {       // bind joints using SID
                for(size_t j=0; j<Controllers[i]->skeletons.size(); j++)
                {       // for each skeletons
                        string skeleton_id = Controllers[i]->skeletons[j];
                        CrtNode * node = Nodes[skeleton_id];
                        if (node)
                                skin->FindJointNodes( node );
                }
            } else if (skin->JointsType == CrtJoint::CrtJointsType_ID)
            {       // bind joints using ID
                skin->FindJointNodes( SceneRoot );
            }
        }
    }
*/
}
Exemplo n.º 3
0
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);
  }
}