Results 1 to 5 of 5

Thread: Silly questions about <source> tags

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Silly questions about <source> tags

    I'm busy writing a collada importer for C++ (not using the colladaDom but rather a sax parser) and i cant find any info on whether data sources can be used across mesh tags or geometry tags?

    for example would the following be valid:

    Code :
    <geometry id="geometry1" name="geometry1">
     
    	<mesh>
    		<source id="verts-pos-data1">
    			<float_array id="verts-pos-data1-array" count="99"/>
    			<technique_common>
    				<accessor source="#verts-pos-data1-array" count="33" stride="3">
    					<param name="X" type="float"/>
    					<param name="Y" type="float"/>
    					<param name="Z" type="float"/>
    				</accessor>
    			</technique_common>
    		</source>		
    	<vertices id="verts1">
    		<input semantic="POSITION" source="#vert-pos-data1"/>
    	</vertices>
    	<triangles material="material1" count="10">
    		<input semantic="VERTEX" source="#vert-pos-data1" offset="0"/>	
     
     
    ...</p>
    	</triangles>
    	</mesh>
     
    	<mesh>		
    	<vertices id="verts2">
    		<input semantic="POSITION" source="#vert-pos-data1"/>
    	</vertices>
    	<triangles material="material2" count="10">
    		<input semantic="VERTEX" source="#vert-pos-data1" offset="0"/>	
     
     
    ...</p>
    	</triangles>
    	</mesh>
     
    </geometry>

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

    Re: Silly questions about <source> tags

    Generally, yes because the mechanism is URI based, however your example is demonstrating a different error, so ... "no".

    You must bind a VERTEX semantic input to a <vertices> element, so your example is flawed.

    Also, e.g. a <mesh> element requires at least one <source> and one <vertices> element. The design intention here is that the mesh contains at least the identities of all of its own vertices (POSITION semantic).

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Re: Silly questions about <source> tags

    my example was a quick job just to highlight what i meant, i should have taken the effort of putting in another source for something like normals.

    so basically meshes do not encapsulate their own sources and may use data from any source element present in the DAE file which begs the question why encapsulate data sources inside of geometric objects to start with and not simply have a library_sources element.

    okay, that kinda throws a tiny spanner in the works as i will need to link up my accessors to my data source arrays after parsing the entire file and not after parsing each accessor tag.

    thanks for the quick response!!

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

    Re: Silly questions about <source> tags

    Quote Originally Posted by coldon
    so basically meshes do not encapsulate their own sources and may use data from any source element present in the DAE file
    In theory yes and most obviously between meshes. In practice, I don't think you'll encounter such sharing.
    Quote Originally Posted by coldon
    which begs the question why encapsulate data sources inside of geometric objects to start with and not simply have a library_sources element.
    Nice catch. A <library_sources> was considered but consensus was not reached. People preferred to have their data sources co-located with their mesh, animation, etc.. Hence even the <input> elements are constrained to use URI fragments (i.e. same document).
    Quote Originally Posted by coldon
    okay, that kinda throws a tiny spanner in the works as i will need to link up my accessors to my data source arrays after parsing the entire file and not after parsing each accessor tag.
    Yes, and in general, resolution of any URI, IDREF, or sid_ref should happen after all the resources are known. I.e. any element with an id attribute could be buffered and resolved using a late-binding idiom. On first access the buffer could be marshaled and deleted.

  5. #5
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356

    Re: Silly questions about <source> tags

    Quote Originally Posted by marcus
    Quote Originally Posted by coldon
    so basically meshes do not encapsulate their own sources and may use data from any source element present in the DAE file
    In theory yes and most obviously between meshes. In practice, I don't think you'll encounter such sharing.
    I took advantage of this in the COLLADA for XNA code viewtopic.php?f=13&t=676

    Creating one source shared between all meshes. This was done in-memory.

Posting Permissions

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