Landscape* DynamicModelNoColor::_imageToLandscape(Image* img) { Landscape* land = new Landscape(); float begin = 0; bool color = img->at(0); uint i = 0; for (i = 0; i < img->size(); i++) { if ((bool)img->at(i) != color) { if (color) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI)); } begin = i; color = img->at(i); } } if (color) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI)); } return land; }
Landscape* CCmodel::_imageToLandscape(Image* img) { Landscape* land = new Landscape(); int lastPixelColor = img->at(0); int lastObjBegin = 0; uint i = 0; for (; i < img->size(); ++i) { if (img->at(i) == lastPixelColor) continue; if (img->at(i) != BLACK && lastPixelColor != BLACK) { lastPixelColor = img->at(i); continue; } LandscapeElem* object = new LandscapeElem(lastPixelColor == BLACK, ((((lastObjBegin + i - 1) / 2.) - VIEW_ANGLE / 2) / 360.) * 2 * PI, ((float)(i - lastObjBegin) / 360.) * 2 * PI); land->push_back(object); lastObjBegin = i; lastPixelColor = img->at(i); } LandscapeElem* object = new LandscapeElem(lastPixelColor == BLACK, ((((lastObjBegin + i - 1) / 2.) - VIEW_ANGLE / 2) / 360.) * 2 * PI, ((float)(i - lastObjBegin) / 360.) * 2 * PI); land->push_back(object); return land; }
Landscape* DynamicModelColor::_imageToLandscape(Image* img) { Landscape* land = new Landscape(); float begin = 0; int currColor = img->at(0); uint i = 0; for (i = 0; i < img->size(); i++) { if (img->at(i) != currColor) { if (currColor == RED) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUERED, SATRED, VALUERED)); } else if (currColor == BLUE) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUEBLUE, SATBLUE, VALUEBLUE)); } else if (currColor == GREEN) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUEGREEN, SATGREEN, VALUEGREEN)); } begin = i; currColor = img->at(i); } } if (currColor == RED) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUERED, SATRED, VALUERED)); } else if (currColor == BLUE) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUEBLUE, SATBLUE, VALUEBLUE)); } else if (currColor == GREEN) { land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI, (i - begin) / 360. * PI, HUEGREEN, SATGREEN, VALUEGREEN)); } return land; }