Results 1 to 7 of 7

Thread: trouble finding sampler "OUTPUT" data

  1. #1

    trouble finding sampler "OUTPUT" data

    I'm trying to figure out how to drill into the <animation> object and extract the data for each sampler. The code below is my loop to run through all the samplers and extract the position data from the "OUTPUT" array into a domListOfFloats.

    I've found that the sampler gets loaded and read correctly, but that it always fails the check against the semantic "OUTPUT." The output array of floats is the one I need--the one with the 4x4 matrices. This code is almost line-for-line the copy of my geometry extraction code, and that works just fine. What do I need to do differently to get the right data out of the sampler?

    Code :
       for (int currentSampler = 0; currentSampler < numSamplers; currentSampler++) {
          domSource* source;
     
          // Get current sampler
          domSampler *sampler = animation->getSampler_array()[currentSampler];
     
     
          domInputLocal_Array inputArray = sampler->getInput_array();
          domInputLocalRef inputRef = inputArray[currentSampler]; 
     
          // Resolve the element
          inputRef->getSource().resolveElement();
          daeElement* element = inputRef->getSource().getElement();
     
          source = (domSource*)element;
     
          // Get the accessor
          domAccessorRef accessor = source->getTechnique_common()->getAccessor();
     
          // Extract the data
     
          if (strcmp(inputRef->getSemantic(), "OUTPUT") == 0) {
             samplerData = source->getFloat_array()->getValue();
             stride = (int)accessor->getStride();
             numSamples = (int)accessor->getCount();
          }

    Something interesting I found was that, if I remove the if statement from around the last block, my function successfully returns the data from the "INPUT" attribute inside <animation>. I assume that's the default setting?

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Your code looks correct to me. I would try stepping through the code in a debugger and making sure there is in fact an <input semantic="OUTPUT" .../> element in the array you're iterating over.

    Steve

  3. #3
    I'm certain there is. I've opened the .dae file that we're using, and I can see it at the bottom. Looks like this:

    Code :
          <sampler id="joint2.matrix_joint2_transform-sampler">
            <input semantic="INPUT" source="#joint2.matrix_joint2_transform-input"/>
            <input semantic="OUTPUT" source="#joint2.matrix_joint2_transform-output"/>
            <input semantic="INTERPOLATION" source="#joint2.matrix_joint2_transform-interpolations"/>
          </sampler>

    Is there something else I need to do in my code to specify that it's the OUTPUT array I want to tap?

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    If you step through your code in a debugger you can probably figure out what's going wrong.

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    I just wrote some test code for this. There's definitely something fishy going on. Every <input> reports that its semantic is "OUTPUT", which certainly isn't right. I'll let you know what I figure out.

    Steve

  6. #6
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Actually, scratch that last post. I had a bug in my indexing. But I found what was wrong with your code.
    Code :
    // Get current sampler
    domSampler *sampler = animation->getSampler_array()[currentSampler];
     
    domInputLocal_Array inputArray = sampler->getInput_array();
    domInputLocalRef inputRef = inputArray[currentSampler];
    You're using the same index into the <input> array that you're using for the <sampler> array. The sampler contains an array of <input>s so you have to iterate over them separately.

    Also, to avoid making a copy of the <input> array, use a reference variable:
    domInputLocal_Array& inputArray = sampler->getInput_array();

  7. #7
    Unfortunately, I can't break and debug because we're running the plugin from within Refinery, and not from within the IDE. But, you were dead right about the need for a separate loop. It works just fine now, thank you very much!

Posting Permissions

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