Results 1 to 6 of 6

Thread: How to split the scene in some parts?

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    15

    How to split the scene in some parts?

    Hello all,

    I have a big collada files that contains meshs.
    I'm trying to split it in some smaller parts, but there is a strange bug in final files.

    This is my code:

    Code :
    	FCollada::Initialize();
    	FCDocument*	document_loaded = FCollada::NewTopDocument();	
    	FCollada::LoadDocumentFromFile(document_loaded, fullpath.c_str());	
     
    	FUObjectRef<FCDocument> global_document = FCollada::NewTopDocument();	
    	FCDSceneNode* global_top = global_document->AddVisualScene();
    	FCDSceneNode* global_second = global_top->AddChildNode();
     
    	int global_counter = -1;
    	for (int i=0; i<(int)parser.meshs.size(); i++){
    		if (parser.meshs[i].m_bneedtosave == true){
    				string save_id = parser.meshs[i].meshDaeID;
    				FCDGeometry* geometry = document_loaded->GetGeometryLibrary()->FindDaeId(save_id.c_str());
    				if (!geometry) cout << " NULL " <<  save_id << endl;
     
    				global_document->GetGeometryLibrary()->AddEntity(geometry);
    				global_counter++;
    				FCDEntity* global_entity = (FCDEntity*)global_document->GetGeometryLibrary()->GetEntity(global_counter);
     
    				FCDSceneNode *node = global_second->AddChildNode();
    				node->AddInstance(global_entity);
    				global_document->GetVisualSceneLibrary()->AddEntity(node);
    		}
    	}
    	global_top->AddInstance(global_second);
    	if (!FCollada::SaveDocument(global_document, FC("./global.dae"))) cout << " fail to save global document"<< endl;
    	else {
    	}
    	FCollada::Release();




    Now I have the meshs that 'need to save'
    But in the global.dae, I have a stragne format, some things like this:





    Code :
    <?xml version="1.0" encoding="utf-8"?>
    <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
      <asset>
        <created>2009-07-31T08:12:35Z</created>
        <modified>2009-07-31T08:14:58Z</modified>
      </asset>
     
      <library_geometries>
        <geometry id="geoid1007" name="geoid1007">
          <mesh>
          ... data ...
          </mesh>
        </geometry>
      </library_geometries>
     
      <library_visual_scenes>
        <visual_scene id="VisualSceneNode">
          <instance_node url="#VisualSceneNode1"/>
            <node id="VisualSceneNode1" type="NODE">
     
              <node id="VisualSceneNode2" type="NODE">
                <instance_geometry url="#geoid1007"/>
              </node>
     
              <node id="VisualSceneNode3" type="NODE">
                <instance_geometry url="#geoid1009"/>
              </node>
     
              ... data ...
     
          </node>
        </visual_scene>
     
        <node id="VisualSceneNode2" type="NODE">
          <instance_geometry url="#geoid1007"/>
        </node>
     
        <node id="VisualSceneNode3" type="NODE">
          <instance_geometry url="#geoid1009"/>
        </node>
        ... data ...
      </library_visual_scenes>
      <scene>
        <instance_visual_scene url="#VisualSceneNode"/>
      </scene>
    </COLLADA>



    Can some one tell me how to fix this bug?

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: How to split the scene in some parts?

    Quote Originally Posted by luyen

    Code :
                FCDSceneNode *node = global_second->AddChildNode();
                node->AddInstance(global_entity);
    Code :
      <library_visual_scenes>
        <visual_scene id="VisualSceneNode">
          <instance_node url="#VisualSceneNode1"/>

    Can some one tell me how to fix this bug?
    I'm not sure which FCollada call you are making that is creating the <instance_node> there, but it's not a valid child of <visual_scene>.

    That's probably your problem.

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    15

    Re: How to split the scene in some parts?

    I'm using FCollada from feelingsoftware:
    http://www.feelingsoftware.com/content/ ... 6/lang,en/


    Can someone shows me how to make in right fotmat?

    My new code is:

    Code :
    	FCollada::Initialize();
    	FCDocument*	document_loaded = FCollada::NewTopDocument();	
    	FCollada::LoadDocumentFromFile(document_loaded, fullpath.c_str());	
     
     
    	FUObjectRef<FCDocument> global_document = FCollada::NewTopDocument();	
    	FCDSceneNode* global_top = global_document->AddVisualScene();
     
    	int global_counter = -1;
    	for (int i=0; i<(int)parser.meshs.size(); i++){
    		if (parser.meshs[i].m_bneedtosave == true){
    				string save_id = parser.meshs[i].meshDaeID;
    				FCDGeometry* geometry = document_loaded->GetGeometryLibrary()->FindDaeId(save_id.c_str());
    				if (!geometry) cout << " NULL " <<  save_id << endl;
     
    				global_document->GetGeometryLibrary()->AddEntity(geometry);
    				global_counter++;
    				FCDEntity* global_entity = (FCDEntity*)global_document->GetGeometryLibrary()->GetEntity(global_counter);
     
    				FCDSceneNode* global_second = global_top->AddChildNode();
    				global_second->AddInstance(global_entity);
    				global_top->AddInstance(global_second);
    		}
    	}
    	if (!FCollada::SaveDocument(global_document, FC("./global.dae"))) cout << " fail to save global document"<< endl;
    	FCollada::Release();





    And I got a file like this:

    Code :
    ........................................
     
          </mesh>
        </geometry>
      </library_geometries>
      <library_visual_scenes>
        <visual_scene id="VisualSceneNode">
          <instance_node url="#VisualSceneNode1"/>
     
    ........................................................
     
          <instance_node url="#VisualSceneNode1464"/>
          <instance_node url="#VisualSceneNode1465"/>
          <node id="VisualSceneNode1" type="NODE">
            <instance_geometry url="#geoid1007"/>
          </node>
          <node id="VisualSceneNode2" type="NODE">
            <instance_geometry url="#geoid1009"/>
          </node>
     
    ..................................
     
          <node id="VisualSceneNode1464" type="NODE">
            <instance_geometry url="#geoid979"/>
          </node>
          <node id="VisualSceneNode1465" type="NODE">
            <instance_geometry url="#geoid983"/>
          </node>
        </visual_scene>
      </library_visual_scenes>
      <scene>
        <instance_visual_scene url="#VisualSceneNode"/>
      </scene>
    </COLLADA>


    I don't know if it was in right format, but at least the viewer (Deep Exploration 5.0.2) can show it


    Thanks,

    Quote Originally Posted by marcus
    Quote Originally Posted by luyen

    Code :
                FCDSceneNode *node = global_second->AddChildNode();
                node->AddInstance(global_entity);
    Code :
      <library_visual_scenes>
        <visual_scene id="VisualSceneNode">
          <instance_node url="#VisualSceneNode1"/>

    Can some one tell me how to fix this bug?
    I'm not sure which FCollada call you are making that is creating the <instance_node> there, but it's not a valid child of <visual_scene>.

    That's probably your problem.

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: How to split the scene in some parts?

    Your output is still invalid because you can't have <instance_node> as a child of <visual_scene>.

    Try using the Coherency Checker that is part of the COLLADA Refinery project on sourceforge to test your output.

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    15

    Re: How to split the scene in some parts?

    Now I have the same result on the screen of Deep Exploration, but my file format changed to:

    Code :
     
    ...........................................
     
        </geometry>
      </library_geometries>
      <library_visual_scenes>
        <visual_scene id="VisualSceneNode">
          <node id="VisualSceneNode1" type="NODE">
            <instance_geometry url="#geoid1007"/>
          </node>
          <node id="VisualSceneNode2" type="NODE">
            <instance_geometry url="#geoid1009"/>
          </node>
          <node id="VisualSceneNode3" type="NODE">
            <instance_geometry url="#geoid1011"/>
          </node>
     
    ...........................................
     
        </visual_scene>
      </library_visual_scenes>
      <scene>
        <instance_visual_scene url="#VisualSceneNode"/>
      </scene>
    </COLLADA>

    Hope that it's ok

  6. #6
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: How to split the scene in some parts?

    Yes that looks valid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •