IZ_BOOL CColladaAnimation::ReadJoint(domNodeRef pNode) { domNodeType type = pNode->getType(); if (type == NODETYPE_JOINT) { SJoint sJoint; sJoint.name = pNode->getName(); for (size_t n = 0; n < pNode->getContents().getCount(); n++) { domElement* pContent = pNode->getContents().get(n); daeString strType = pContent->getTypeName(); if (izanagi::tool::CString::CmpStr(strType, "node")) { // terminate... continue; } SJointTransform sTransform; sTransform.type = GetTransformType(strType); switch (sTransform.type) { case E_TRANSFROM_TYPE_TRANSLATE: GetTransform<domTranslate, 3>(pContent, sTransform); break; case E_TRANSFROM_TYPE_QUARTANION: GetTransform<domRotate, 4>(pContent, sTransform); break; case E_TRANSFROM_TYPE_SCALE: GetTransform<domScale, 3>(pContent, sTransform); break; default: VRETURN(IZ_FALSE); break; } sJoint.transforms.push_back(sTransform); } if (!sJoint.transforms.empty()) { m_Joints.push_back(sJoint); } } size_t nChildNodeCnt = pNode->getNode_array().getCount(); for (size_t n = 0; n < nChildNodeCnt; n++) { domNodeRef node = pNode->getNode_array().get(n); VRETURN(ReadJoint(node)); } return IZ_TRUE; }
/*! Add a transform node to the OpenSG tree representing this <node>. Also finalizes transform animations. */ void ColladaNode::appendStackedXForm(TransformationElement *transformElement, domNodeRef node) { OSG_ASSERT(getGlobal()->getOptions()->getFlattenNodeXForms()); StackedTransformUnrecPtr bottomTrans(NULL); if(_bottomN != NULL) { if(_bottomN->getCore()->getType().isDerivedFrom(StackedTransform::getClassType())) { bottomTrans = dynamic_cast<StackedTransform*>(_bottomN->getCore()); } else { bottomTrans = StackedTransform::create(); NodeUnrecPtr xformN = makeNodeFor(bottomTrans); setName(xformN, node->getName()); _bottomN->addChild(xformN); } } else { bottomTrans = StackedTransform::create(); _bottomN = makeNodeFor(bottomTrans); setName(_bottomN, node->getName()); } bottomTrans->pushToTransformElements(transformElement); if(_topN == NULL) { _topN = _bottomN; } }
SceneGraph::Vertex Scene::readNode(const domNodeRef node, SceneGraph::Vertex &parent) { // just to experiment with fonts bool is_font_node = false; std::string::size_type pos = std::string(node->getId()).find(SceneGraph::font_name); if(pos != std::string::npos) is_font_node = true; SceneGraph::IdVertexMap::iterator findnode = this->scene_graph.id_vertex_map.find(node->getId()); if(findnode != this->scene_graph.id_vertex_map.end()) return findnode->second; this->scene_graph.printStatusMessage(std::string(" reading scene node ") + node->getID()); size_t i; // Insert new node and connect to parent SceneGraph::NodeInfo new_node_info = {node->getId(), CheckString(node->getSid())}; this->scene_graph.insertNode(parent, CheckString(node->getName()), node->getId(), CheckString(node->getSid())); SceneGraph::node_id_map_t node_id_map = get(SceneGraph::node_info_t(), this->scene_graph.node_graph); // Read node transformations const SceneGraph::NodeInfo &parent_node_info = node_id_map[parent]; const Node *parent_node = this->scene_graph.all_nodes.find(parent_node_info.id.c_str()); Node ¤t_node = *this->scene_graph.all_nodes.find(new_node_info.id.c_str()); current_node.is_font_node = is_font_node; SceneGraph::Vertex node_vertex = this->scene_graph.id_vertex_map.find(new_node_info.id)->second; this->readNodeTranforms(current_node, *parent_node, node); // Process Instance Geometries const domInstance_geometry_Array &geom_instances = node->getInstance_geometry_array(); for(i = 0; i < geom_instances.getCount(); ++i) this->readInstanceGeometry(current_node, geom_instances[i]); // Process Instance Lights const domInstance_light_Array &lia = node->getInstance_light_array(); for(i = 0; i < lia.getCount(); ++i) this->readInstanceLight(current_node, lia[i]); if(!current_node.instance_lights.empty()) this->scene_graph.light_nodes.push_back(new_node_info.id); // Process Instance Cameras const domInstance_camera_Array &ica = node->getInstance_camera_array(); for(i = 0; i < ica.getCount(); ++i) this->readInstanceCamera(current_node, ica[i]); // Read in each child and recursively it's children const domNode_Array &nodes = node->getNode_array(); for(i = 0; i < nodes.getCount(); i++) this->readNode(nodes[i], node_vertex); // Read children <instance_nodes>, can be 0 or more const domInstance_node_Array &instance_nodes = node->getInstance_node_array(); for(i = 0; i < instance_nodes.getCount(); i++) { domInstance_node *instance_node = instance_nodes[i]; domNode *urlnode = (domNode*)(domElement*)instance_node->getUrl().getElement(); if(urlnode) this->readNode(urlnode, node_vertex); } return node_vertex; }