I call this in draw (more, but this is where it goes from good to bad):
stImplementation->convertToAppropriateType(gTangibleList.getTangibles());
const vector<ofxDTangibleBase *> tangs4 = gTangibleList.getTangibles();
printf("break\n");
I call the 2nd line from above also at the last line of the method convertToAppropriateType.
If i look there at const vector<ofxDTangibleBase *> then it contains 1 object.
There everything is still ok. If you look on the first attachment you can see next, previous are NULL and className is STSequencer just like there suppose to.
After that nothing get’s excecuted anymore untill where in draw again.
There i also get the vector<ofxDTangibleBase *> with still 1 object, like it should be. The pointer to the object is also the same. But if we look now at next, previous and className then it’s totally messed up.
How is this possible?
here is the method:
void STImplementation::convertToAppropriateType(const vector<ofxDTangibleBase *> &tangibles) {
printf("break in convertToAppropriateType\n");
for (int i = tangibles.size()-1; i >= 0; i--) {
ofxDTangibleBase &t = *tangibles[i];
float minimumSimilarityRequired = 0.75;
// in the end we check if simularity
// is close enough to create whatever
// closestType is
STTypes closestType = UNDEFINED;
float closestColorSimilairityValue = 0;
ofColor cSequencer(255, 0, 0);
ofColor cSample(0, 255, 0);
float colorSimilarityV ;
// sequencer
colorSimilarityV = colorSimilarity(t.getColor(), cSequencer);
if(colorSimilarityV > closestColorSimilairityValue) {
closestColorSimilairityValue = colorSimilarityV;
closestType = SEQUENCER;
}
// sample
colorSimilarityV = colorSimilarity(t.getColor(), cSample);
if(colorSimilarityV > closestColorSimilairityValue) {
closestColorSimilairityValue = colorSimilarityV;
closestType = SAMPLE;
}
if(closestColorSimilairityValue >= minimumSimilarityRequired) {
switch (closestType) {
case SEQUENCER:
{
printf("SEQUENCER\n");
STSequencer sequencer(t);
ofxDTangibleBase *pBase = &t;
gTangibleList.removeTangible(pBase, "ofxDTangibleBase in sequencer part");
STSequencer *pSeq = &sequencer;
gTangibleList.addTangible(pSeq);
}
break;
case SAMPLE:
{
printf("SAMPLE\n");
STSample sample(t);
ofxDTangibleBase *pBase = &t;
gTangibleList.removeTangible(pBase, "ofxDTangibleBase in sample part");
STSample *pSam = &sample;
gTangibleList.addTangible(pSam);
}
break;
default:
break;
}
}
else {
// it could be that the color is not trackable anymore
// but maybe we new what tangible it was before
// so we can decide here to keep it
// or to remove it
// or to add it to a unfocus list
// untill it get's focus again within a certain time
// TODO
// ...
}
}
const vector<ofxDTangibleBase *> tangs4 = gTangibleList.getTangibles();
printf("break\n");
}

