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?
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?
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.
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.
Actually, scratch that last post. I had a bug in my indexing. But I found what was wrong with your 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();
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!