|
|
@ -124,6 +124,69 @@ void ofxSurfaceManager::clear() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ofxSurfaceManager::saveXmlSettings(string fileName) |
|
|
|
{ |
|
|
|
xmlSettings.clear(); |
|
|
|
|
|
|
|
// save surfaces
|
|
|
|
xmlSettings.addTag("surfaces"); |
|
|
|
xmlSettings.pushTag("surfaces"); |
|
|
|
for ( int i=0; i<surfaces.size(); i++ ) { |
|
|
|
|
|
|
|
xmlSettings.addTag("surface"); |
|
|
|
xmlSettings.pushTag("surface", i); |
|
|
|
ofxBaseSurface* surface = surfaces[i]; |
|
|
|
|
|
|
|
xmlSettings.addTag("vertices"); |
|
|
|
xmlSettings.pushTag("vertices"); |
|
|
|
vector<ofVec3f>* vertices = &surface->getVertices(); |
|
|
|
for ( int j=0; j<vertices->size(); j++ ) { |
|
|
|
xmlSettings.addTag("vertex"); |
|
|
|
xmlSettings.pushTag("vertex", j); |
|
|
|
ofVec3f* vertex = &(*vertices)[j]; |
|
|
|
xmlSettings.addValue("x", vertex->x); |
|
|
|
xmlSettings.addValue("y", vertex->y); |
|
|
|
|
|
|
|
// we don't need z as it will be 0 anyways
|
|
|
|
|
|
|
|
xmlSettings.popTag(); // vertex
|
|
|
|
} |
|
|
|
xmlSettings.popTag(); // vertices
|
|
|
|
|
|
|
|
xmlSettings.addTag("texCoords"); |
|
|
|
xmlSettings.pushTag("texCoords"); |
|
|
|
vector<ofVec2f>* texCoords = &surface->getTexCoords(); |
|
|
|
for ( int j=0; j<texCoords->size(); j++ ) { |
|
|
|
xmlSettings.addTag("texCoord"); |
|
|
|
xmlSettings.pushTag("texCoord", j); |
|
|
|
ofVec2f* texCoord = &(*texCoords)[j]; |
|
|
|
xmlSettings.addValue("x", texCoord->x); |
|
|
|
xmlSettings.addValue("y", texCoord->y); |
|
|
|
xmlSettings.popTag(); // texCoord
|
|
|
|
} |
|
|
|
xmlSettings.popTag(); // texCoords
|
|
|
|
|
|
|
|
xmlSettings.addTag("source"); |
|
|
|
xmlSettings.pushTag("source"); |
|
|
|
|
|
|
|
xmlSettings.addValue("source-type", "image"); |
|
|
|
xmlSettings.addValue("source-name", getSurfaceSourceName(surface)); |
|
|
|
//xmlSettings.addValue("source-path", "/root/etc/image.jpg");
|
|
|
|
|
|
|
|
xmlSettings.popTag(); // source
|
|
|
|
|
|
|
|
xmlSettings.popTag(); // surface
|
|
|
|
} |
|
|
|
xmlSettings.popTag(); // surfaces
|
|
|
|
|
|
|
|
xmlSettings.save(fileName); |
|
|
|
} |
|
|
|
|
|
|
|
void ofxSurfaceManager::loadXmlSettings(string fileName) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ofxBaseSurface* ofxSurfaceManager::selectSurface(int index) |
|
|
|
{ |
|
|
|
if ( index >= surfaces.size() ) { |
|
|
@ -167,7 +230,12 @@ string ofxSurfaceManager::getSelectedSurfaceSourceName() |
|
|
|
return "none"; |
|
|
|
} |
|
|
|
|
|
|
|
ofTexture* tex = selectedSurface->getTexture(); |
|
|
|
return getSurfaceSourceName( selectedSurface ); |
|
|
|
} |
|
|
|
|
|
|
|
string ofxSurfaceManager::getSurfaceSourceName(ofxBaseSurface *surface) |
|
|
|
{ |
|
|
|
ofTexture* tex = surface->getTexture(); |
|
|
|
for ( int i=0; i<loadedImageSources.size(); i++ ) { |
|
|
|
if (tex == &loadedImageSources[i]->getTextureReference()) { |
|
|
|
return loadedImageSourceNames[i]; |
|
|
|