Results 1 to 5 of 5

Thread: Extracting vertex positions in DOM 2.0 [FIXED]

  1. #1
    Junior Member
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    3

    Extracting vertex positions in DOM 2.0 [FIXED]

    I'm having a little problem with getting my vertex data from a document exported from Blender using the 1.4 schema.

    I'm using the Collada DOM 2.0 to load the document. When I want to extract the vertex info from a set of triangles, I store the domSource element associated with the input (positions, normals, texture etc.).

    The problem I'm having is that my position input references a vertex element, which in turn references the actual elements containing the vertex floats.

    So my domSource* instance represents the following in the xml;


    Code :
    - <vertices id="glass10_body-Geometry-Vertex">
      <input semantic="POSITION" source="#glass10_body-Geometry-Position" /> 
      </vertices>

    So given the domSource element that represents this in the database, how can I get the source element that contains the actual float data?

  2. #2
    Junior Member
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    3
    I've actually fixed this problem, sorry for the wasted post!

    I downloaded the source package to look at the RT viewer, and saw that it also processes the vertices on the mesh as well as the triangle inputs. Of course, the vertices contain only one input in this case, which are the positions, fixing my issue.

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Yeah, it's important to keep in mind that all of the <input> elements in a <triangles> (or similar) may reference the <vertices> element, not just position data. I don't know if RT does this, but I recommend writing a utility function to take an <input> and drill down to the appropriate <source>, passing through <vertices> if necessary. Use that function to read all the geometric data from a primitive, so that your importer works whether the <input> points to a <vertices> or directly to a <source>.

    Steve

  4. #4
    Junior Member
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    3
    Thanks for that Steve.

    I actually did this yesterday in pretty much the same way that the RT view does it. I first get the sources in the triangle inputs, and then over-write those from the inputs in the <vertices> elements.

    I guess it would probably be more "correct" to just directly find the source element that the vertex links to, but I couldn't find a way of doing this.

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    I guess it would probably be more "correct" to just directly find the source element that the vertex links to, but I couldn't find a way of doing this.
    If you have a domVertices element, you could iterate through the <input>s and get all the referenced <source>s like this:
    Code :
    for (size_t i = 0; i < vertices->getInput_array().getCount(); i++) {
        domSource* source = daeSafeCast<domSource>(vertices->getInput_array()[i]->getSource().getElement());
    }
    Anyway, the important thing is you found something that works.

    Steve

Posting Permissions

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