Palleon::CEmbedRemoteCall CWorldEditor::ProcessSetMap(const Palleon::CEmbedRemoteCall& rpc) { try { auto mapId = boost::lexical_cast<uint32>(rpc.GetParam(WORLDEDITOR_PARAM_MAPID)); CreateMap(mapId); return MakeSuccessRpc(); } catch(...) { return MakeFailureRpc(); } }
//!*************************************************************** //! @details: //! initializes the game and subsystems //! //! @return: //! void //! //!*************************************************************** void Game::Init() { // load the game map CreateMap(); // initialize the cameras and view InitView(); // initialize the user input CreateInput(); // prep the engine for running m_engine->initializePumping(); }
double GenMap(int w, int h, int cellSize) { //int cellSize = 16; //int w = 40; //int h = 100; double map = CreateMap(w*cellSize,h*cellSize,cellSize); //map = CreateMap(w*cellSize,h*cellSize,cellSize); SetCellMap(map, 4*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 5*cellSize, 1); SetCellMap(map, 5*cellSize, 6*cellSize, 1); SetCellMap(map, 5*cellSize, 7*cellSize, 1); SetCellMap(map, 4*cellSize, 7*cellSize, 1); SetCellMapRegion(map, (w/2)*cellSize, 0*cellSize, 2*cellSize, (h*0.75)*cellSize, 1); return map; }
ribi::foam::PatchFieldType ribi::foam::PatchFieldTypes::ToType(const std::string& s) { if (m_map.right.empty()) m_map = CreateMap(); assert(!m_map.right.empty()); #ifndef NDEBUG if(m_map.right.count(s) != 1) { TRACE("ERROR"); TRACE(s); TRACE(m_map.right.count(s)); } #endif assert(m_map.right.count(s) == 1); const PatchFieldType t = m_map.right.find(s)->second; return t; }
CWorldEditor::CWorldEditor(bool isEmbedding) : m_elapsed(0) , m_mousePosition(0, 0) { CGlobalResources::GetInstance().Initialize(); CreateWorld(); Palleon::CGraphicDevice::GetInstance().AddViewport(m_mainViewport.get()); Palleon::CGraphicDevice::GetInstance().AddViewport(m_overlayViewport.get()); if(!isEmbedding) { m_debugOverlay = std::make_shared<CDebugOverlay>(); //CFileManager::SetGamePath("F:\\FFXIV_10_Copy"); CreateMap(0xA09B0002); } }
void TTSelector::Begin(TTree *){ TString option = GetOption(); TObjArray *strobj = option.Tokenize(" "); gTrigger = ((TObjString*)strobj->At(0))->GetString().Atoi(); gMode = ((TObjString*)strobj->At(1))->GetString().Atoi(); CreateMap(); TString filedir=ginFile; filedir.Remove(filedir.Last('.')-4); fFile = new TFile(goutFile,"RECREATE"); fTree = new TTree("M","Tree for GSI Prt Analysis"); fEvent = new TPrtEvent(); fTree->Branch("TPrtEvent", "TPrtEvent", &fEvent, 64000, 2); TFile f(gcFile); TIter nextkey(f.GetListOfKeys()); TKey *key; while ((key = (TKey*)nextkey())) { TGraph *gr = (TGraph*)key->ReadObj(); TString name = gr->GetName(); Int_t channel = name.Atoi(); gGr[channel]= new TGraph(*gr); } f.Close(); if(gMode == 1){ TFile f2(gtFile); TIter nextkey2(f2.GetListOfKeys()); TKey *key2; while ((key2 = (TKey*)nextkey2())) { TGraph *gr = (TGraph*)key2->ReadObj(); TString name = gr->GetName(); Int_t channel = name.Atoi(); gGrDiff[channel]= new TGraph(*gr); } f2.Close(); } std::cout<<"Initialization successful"<<std::endl; }
//================================================================================= void CMazeView::New(int w,int h) { //将迷宫显示区域置于大地图的右下方 m_x = ( w - PM_I+1) *64; m_MaxX = ( w - PM_I +1) *64; m_y = ( h - PM_J +1) *64; m_MaxY = ( h - PM_J +1) *64; CreateMap(w,h,&m_Exit); MarkMap(); CAnimCtrl::New(); if(m_Exit.x==0) { m_ExitCtrl.New(&LeftExitBmp,0,0,g_LeftExitFrm,FRAME_REPEAT); } else { m_ExitCtrl.New(&UpExitBmp,0,0,g_UpExitFrm,FRAME_REPEAT); } }
bool C4MapScriptHost::InitializeMap(C4SLandscape *pLandscape, C4TextureMap *pTexMap, C4MaterialMap *pMatMap, uint32_t iPlayerCount, std::unique_ptr<CSurface8> *pmap_fg_surface, std::unique_ptr <CSurface8>* pmap_bg_surface) { // Init scripted map by calling InitializeMap in the proper scripts. If *pmap_surface is given, it will pass the existing map to be modified by script. assert(pmap_fg_surface); assert(pmap_bg_surface); this->pTexMap = pTexMap; this->pMatMap = pMatMap; // Don't bother creating surfaces if the functions aren't defined if (!LayerPrototype->GetFunc(PSF_InitializeMap)) { C4PropList *scen_proplist = ::GameScript.ScenPropList._getPropList(); if (!scen_proplist || !scen_proplist->GetFunc(PSF_InitializeMap)) return false; } // Create proplist as script context std::unique_ptr<C4MapScriptMap> map(CreateMap()); // Drawing on existing map or create new? if (*pmap_fg_surface && *pmap_bg_surface) { // Existing map map->SetSurfaces(std::move(*pmap_fg_surface), std::move(*pmap_bg_surface)); } else { assert(!*pmap_fg_surface && !*pmap_bg_surface); // No existing map. Create new. int32_t map_wdt,map_hgt; pLandscape->GetMapSize(map_wdt, map_hgt, iPlayerCount); if (!map->CreateSurface(map_wdt, map_hgt)) return false; } C4AulParSet Pars(C4VPropList(map.get())); C4Value result = map->Call(PSF_InitializeMap, &Pars); if (!result) result = ::GameScript.Call(PSF_InitializeMap, &Pars); // Map creation done. if (result) { map->ConvertSkyToTransparent(); } std::tie(*pmap_fg_surface, *pmap_bg_surface) = map->ReleaseSurfaces(); return !!result; }
void TestGmInterface() { int cellSize = 10; double map = CreateMap(10*cellSize,10*cellSize,cellSize); SetCellMap(map, 4*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 5*cellSize, 1); SetCellMap(map, 5*cellSize, 6*cellSize, 1); SetCellMap(map, 5*cellSize, 7*cellSize, 1); SetCellMap(map, 4*cellSize, 7*cellSize, 1); double pathFinder = CreatePathFinder(map); double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, 8.0*cellSize, 3.0*cellSize); double n = static_cast<int>(GetNPath(path)); DestroyMap(map); DestroyPathFinder(pathFinder); DestroyPath(path); }
static int CloneOption( const char *name) { ATTRIBUTES a; if (FileStat(name) != 2) { return RetError(1,"file '%s' exists, give new (non-existing) name",name); } if (DefaultCloneAttr(&a)) return 1; a.cloneCreation = TRUE; switch(MakeCloneMenu(&a, name)) { case 0: return 1; case 1: return CreateMap(name, &a); case 2: fprintf(stderr,"No map created\n"); return 0; } POSTCOND(FALSE); return 1; }
DrawingClass::DrawingClass (int w, int h, Interface *interface) { al_init(); mDisplay = al_create_display(w, h); al_set_window_title(mDisplay, "Tower Defense"); mEventQueue = al_create_event_queue(); mTimer = al_create_timer (1.0/((float)ConstFps)); mInterface = interface; al_init_font_addon(); al_init_ttf_addon(); al_init_primitives_addon(); al_install_mouse(); al_install_keyboard(); assert(al_install_audio()); assert(al_init_acodec_addon()); assert(al_reserve_samples(1)); al_init_image_addon(); al_register_event_source(mEventQueue, al_get_display_event_source(mDisplay)); al_register_event_source(mEventQueue, al_get_timer_event_source(mTimer)); al_register_event_source(mEventQueue, al_get_mouse_event_source()); al_register_event_source(mEventQueue, al_get_keyboard_event_source()); float tileSize = interface->GetTileSize(); mBigFont = al_load_font("DejaVuSans.ttf", tileSize, 0); mFont = al_load_font("DejaVuSans.ttf", tileSize/2, 0); mSmallFont = al_load_font("DejaVuSans.ttf", tileSize/4, 0); mMusic = 0; // mBackground = al_create_bitmap(tileSize, tileSize); mBackground = al_load_bitmap("Images/grass.png"); /* al_set_target_bitmap(mBackground); * al_draw_filled_circle(tileSize/2, tileSize/2, tileSize/2, al_map_rgb(0, 255, 0)); * al_set_target_bitmap(al_get_backbuffer(mDisplay)); */ CreateMap(); }
game CreateGame() { game G = NULL; G = malloc(sizeof(Game)); if(G) { G->print = CursesPrint; G->pc = NULL; G->ZombieListHead = NULL; G->win = NULL; int y, x; getmaxyx(stdscr, y, x ); G->win = newwin( y, x, 0, 0 ); G->arena = NULL; int status_height = 0; G->arena = CreateSubwindow(G->win, y-status_height, x, 0, 0 ); G->status = NULL; G->status = CreateSubwindow(G->win, status_height, x, y-status_height, 0 ); G->gameMap = CreateMap(G); InitMap(G->gameMap); return G; } else { fprintf( L, "Fatal error: failed to assign memory in CreateGame().\n" ); exit(EXIT_FAILURE); } }
static int SetOption( const char **names, int nrNames, const ATTRIBUTES *opt) { ATTRIBUTES a; MAP **maps; int i; if (DefaultCloneAttr(&a)) return 1; if (FileStat(names[0]) == 2) { /* non-existing */ MergeOptAttr(&a, opt); if (nrNames > 1) return RetError(1,"-s: only one new map or multiple existing maps allowed"); if (a.nrRows == MV_UINT4 || a.nrCols == MV_UINT4) return RetError(1,"-s: -R and/or -C not specified"); return CreateMap(names[0], &a); } else { /* set all */ if (opt->nrRows != MV_UINT4 || opt->nrCols != MV_UINT4) return RetError(1,"-s: can not change number of rows or columns of an existing map"); if (opt->valueScale != VS_UNDEFINED) return RetError(1,"-s: can not change data type of an existing map"); maps = OpenCopyOrSetMaps(&a,FALSE,names,nrNames); if (maps == NULL) return 1; for(i=0; i < nrNames; i++) SetAndCloseMap(maps[i], opt); Free(maps); return 0; } }
void ResourceManager::Init() { AddMesh( MODEL_UNIT_SWORD, MESH_KEY_UNIT_SWORD ); AddMesh( MODEL_UNIT_PIKE, MESH_KEY_UNIT_PIKE ); AddMesh( MODEL_UNIT_ARROW, MESH_KEY_UNIT_ARROW ); AddMesh( MODEL_UNIT_KNIGHT, MESH_KEY_UNIT_KNIGHT ); AddMesh( MODEL_UNIT_GUARD, MESH_KEY_UNIT_GUARD ); AddMesh( MODEL_UNIT_KING, MESH_KEY_UNIT_KING ); AddMesh( MODEL_CORPS_DESTROY_A, MESH_KEY_CORPS_DESTROY_ENEMY ); AddMesh( MODEL_CORPS_DEFENSE_A, MESH_KEY_CORPS_DEFENSE_ENEMY ); AddMesh( MODEL_CORPS_RUSH_A, MESH_KEY_CORPS_RUSH_ENEMY ); AddMesh( MODEL_CORPS_DESTROY_B, MESH_KEY_CORPS_DESTROY_MINE ); AddMesh( MODEL_CORPS_DEFENSE_B, MESH_KEY_CORPS_DEFENSE_MINE ); AddMesh( MODEL_CORPS_RUSH_B, MESH_KEY_CORPS_RUSH_MINE ); AddMap( HEIGHT_MAP, HEIGHT_TEX, MAP_KEY_TEST ); CreateMap( MAP_KEY_TEST ); ////////////////////////////////////////////////////////////////////////// // 쿼드트리를 적용하기 위해 하이트 맵은 2^n 형태의 크기로 만들어야 합니다. // // 주의! 실제 하이트맵 크기는 한 변이 2^n + 1 사이즈여야 합니다! ////////////////////////////////////////////////////////////////////////// InitGroundMesh( 128, 128 ); CreateRawGround( 128, 128, 5.0f ); if ( FAILED( InitHeightMap( HEIGHT_MAP, 5.0f ) ) ) { m_IsMapForQuadTreeReady = false; } else { m_IsMapForQuadTreeReady = true; } MapManager::GetInstance()->SetPixelSize( 5.0f ); m_MapSize = 640; m_IsMapReady = true; InitSkyBoxMesh( 640 ); SetSkyBoxTexture( SPRITE_SKYBOX_BACK, SKY_BOX_BACK ); SetSkyBoxTexture( SPRITE_SKYBOX_FRONT, SKY_BOX_FRONT ); SetSkyBoxTexture( SPRITE_SKYBOX_LEFT, SKY_BOX_LEFT ); SetSkyBoxTexture( SPRITE_SKYBOX_RIGHT, SKY_BOX_RIGHT ); SetSkyBoxTexture( SPRITE_SKYBOX_TOP, SKY_BOX_TOP ); SetSkyBoxTexture( SPRITE_SKYBOX_BOTTOM, SKY_BOX_BOTTOM ); InitCursor( CURSOR_MAX, MouseManager::GetInstance()->GetMousePositionX(), MouseManager::GetInstance()->GetMousePositionY() ); CreateCursorImage( SPRITE_CURSOR_DEFAULT, CURSOR_DEFAULT ); CreateCursorImage( SPRITE_CURSOR_ATTACK, CURSOR_ATTACK ); CreateCursorImage( SPRITE_CURSOR_CLICK, CURSOR_CLICK ); CreateCursorImage( SPRITE_CURSOR_OVER_CORPS, CURSOR_OVER_CORPS ); CreateCursorImage( SPRITE_CURSOR_UNRECHEABLE, CURSOR_UNRECHEABLE ); CreateCursorImage( SPRITE_CURSOR_CAMERA_ROTATING, CURSOR_CAMERA_ROTATING ); CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE, CURSOR_CORPS_MOVABLE ); CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE_CLICK, CURSOR_CORPS_MOVABLE_CLICK ); CreateCursorImage( SPRITE_CURSOR_OVER_PICKED_CORPS, CURSOR_OVER_PICKED_CORPS ); m_ISCursorReady = true; CreateSprite(); ShaderCreate( SHADER_TYPE_MAX ); ShaderImport( SELECT_SHADER, SHADER_SELECT ); ShaderImport( FIGHT_SHADER, SHADER_FIGHT ); ShaderImport( MAP_SHADER, SHADER_MAP ); MeshTextureCreateBySize( CORPS_TEXTURE_MAX ); MeshTextureImport( SPRITE_CORPS_TYPE_ARROW, CORPS_TEXTURE_ARROW ); MeshTextureImport( SPRITE_CORPS_TYPE_GUARD, CORPS_TEXTURE_GUARD ); MeshTextureImport( SPRITE_CORPS_TYPE_KING, CORPS_TEXTURE_KING ); MeshTextureImport( SPRITE_CORPS_TYPE_KNIGHT, CORPS_TEXTURE_KNIGHT ); MeshTextureImport( SPRITE_CORPS_TYPE_PIKE, CORPS_TEXTURE_PIKE ); MeshTextureImport( SPRITE_CORPS_TYPE_SWORD, CORPS_TEXTURE_SWORD ); }
bool OCVLbp::CalculateOpenCV(int /*f*/, int l) { static const string msg = "OCVLbp::CalculateOpenCV() : "; featureVector fv; if (LabelVerbose()) cout << msg << "starting" << endl; bool ok = true; if (spoints.empty()) CreateSPoints(); if (!ok || spoints.empty() || (spoints.size() != options.nneighbors)) { cerr << msg << "Missing or wrong pixel neighborhood." << endl; return false; } if (options.lbptype == CSLBP) { if (options.neighborhood != LBP_CIRCULAR) { cerr << msg << "CS-LBP requires (currently) a circular neighborhood" << endl; return false; } else if (options.mapping != LBP_MAPPING_NONE) { cerr << msg << "CS-LBP is not compatible with any mappings" << endl; return false; } } if ((options.mapping != LBP_MAPPING_NONE) && lbp_map.mapsize == 0) CreateMap(); // lbp_image = // ocv_image_(Rect(options.crop.x0, options.crop.y0, // ocv_image_.cols-options.crop.x0-options.crop.x1, // ocv_image_.rows-options.crop.y0-options.crop.y1)); lbp_image = ocv_image_; if (options.write_image) { string sn; if ((size_t)l<RegionDescriptorCount()) sn = RegionDescriptor(l).first; else sn = ToStr(l); //string oname = "lbp-"+BaseFileName()+"-"+ToStr(f)+"-"+ToStr(l)+".jpg"; string oname = "lbp-"+BaseFileName()+"_"+sn+".jpg"; imwrite(oname, lbp_image); } if (blocktypes.empty()) blocktypes.push_back(BLOCKS_1x1); CreateBlocks(); MatND storedhist; list<pair<Rect,lbp_block_type> >::const_iterator i; for (i = lbp_blocks.begin(); i!=lbp_blocks.end(); i++) { MatND hist; Mat blockimg = lbp_image(i->first); CalculateLbp(blockimg, hist); if (i->second == BLOCK_STORE) storedhist = hist; else if (i->second == BLOCK_SUBTRACT) hist -= storedhist; if (options.normalize_histogram != HISTNORM_NONE) { Scalar sumhist = sum(hist); hist /= sumhist[0]; } if (options.normalize_histogram == HISTNORM_CAPPED) { for (int ii=0; ii<hist.rows; ii++) if (hist.at<float>(ii)>0.2) hist.at<float>(ii) = 0.2; Scalar sumhist = sum(hist); hist /= sumhist[0]; } for (int ii=0; ii<hist.rows; ii++) fv.push_back(hist.at<float>(ii)); } SetVectorData(l, fv); if (LabelVerbose()) cout << msg << "ending" << endl; return true; }
/* checks that do not require a map to be created will send transfer error messages on fail */ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) { const MapEntry *entry = sMapStore.LookupEntry(mapid); if(!entry) return false; const char *mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; if(entry->IsDungeon()) { if (entry->IsRaid()) { // GMs can avoid raid limitations if(!player->isGameMaster() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID)) { // can only enter in a raid group Group* group = player->GetGroup(); if (!group || !group->isRaidGroup()) { // probably there must be special opcode, because client has this string constant in GlobalStrings.lua // TODO: this is not a good place to send the message player->GetSession()->SendAreaTriggerMessage("You must be in a raid group to enter %s instance", mapName); DEBUG_LOG("MAP: Player '%s' must be in a raid group to enter instance of '%s'", player->GetName(), mapName); return false; } } } //The player has a heroic mode and tries to enter into instance which has no a heroic mode MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->map_type == MAP_RAID)); if (!mapDiff) { bool isRegularTargetMap = player->GetDifficulty(entry->IsRaid()) == REGULAR_DIFFICULTY; //Send aborted message // FIX ME: what about absent normal/heroic mode with specific players limit... player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, isRegularTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); return false; } if (!player->isAlive()) { if(Corpse *corpse = player->GetCorpse()) { // let enter in ghost mode in instance that connected to inner instance with corpse uint32 instance_map = corpse->GetMapId(); do { if(instance_map==mapid) break; InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(instance_map); instance_map = instance ? instance->parent : 0; } while (instance_map); if (!instance_map) { WorldPacket data(SMSG_CORPSE_IS_NOT_IN_INSTANCE); player->GetSession()->SendPacket(&data); DEBUG_LOG("MAP: Player '%s' doesn't has a corpse in instance '%s' and can't enter", player->GetName(), mapName); return false; } DEBUG_LOG("MAP: Player '%s' has corpse in instance '%s' and can enter", player->GetName(), mapName); } else { DEBUG_LOG("Map::CanEnter - player '%s' is dead but doesn't have a corpse!", player->GetName()); } } if (!player->isGameMaster()) { InstanceData* i_data = ((InstanceMap*)CreateMap(mapid, player))->GetInstanceData(); if (i_data && i_data->IsEncounterInProgress()) { player->SendTransferAborted(mapid, TRANSFER_ABORT_ZONE_IN_COMBAT); return false; } } } return true; }
int main() { cout<<"Enter the name of a file to load: "; string fname = "hits.txt"; cout<<fname<<endl; //cin>>fname; cout<<"Loading "<<fname<<"...\n\n"; imap rmap; try { rmap = CreateMap(LinearizeFile(fname)); } catch(string error) { cout<<error<<endl; return 1; } cout<<endl; int i=0; string s=""; do { cout<<"Please select a menu option: "<<endl; cout<<"1)Link Information in date range"<<endl; cout<<"2)Information about all links"<<endl; cout<<"3)Link barchart for last 12 months"<<endl; cout<<"4)Display contents of imap"<<endl; cout<<"5)Quit the program"<<endl; cout<<"Option (1,2,3,4,5): "; cin>>s; i = atoi(s.c_str()); cout<<endl; switch(i) { case 1: link_info_in_date_range(rmap); cout<<endl; break; case 2: info_about_all_links(rmap); cout<<endl; break; case 3: link_barchart(rmap); cout<<endl; break; case 4: display_map(rmap); cout<<endl; break; } } while(i!=5); return 0; }
/*! \param[in] src_img1 Input image 1 \param[in] src_points1 Points on the image 1 \param[in] src_img2 Input image 2 \param[in] src_points2 Points on the image 2, which must be corresponded to src_point1 \param[out] dst_img Morphed output image \param[out] dst_points Morphed points on the output image \param[in] shape_ratio blending ratio (0.0 - 1.0) of shape between image 1 and 2. If it is 0.0, output shape is same as src_img1. \param[in] color_ratio blending ratio (0.0 - 1.0) of color between image 1 and 2. If it is 0.0, output color is same as src_img1. If it is negative, it is set to shape_ratio. */ void ImageMorphing(const cv::Mat& src_img1, const std::vector<cv::Point2f>& src_points1, const cv::Mat& src_img2, const std::vector<cv::Point2f>& src_points2, cv::Mat& dst_img, std::vector<cv::Point2f>& dst_points, float shape_ratio = 0.5, float color_ratio = -1) { // Input Images cv::Mat SrcImg[2]; SrcImg[0] = src_img1; SrcImg[1] = src_img2; // Input Points std::vector<cv::Point2f> SrcPoints[2]; SrcPoints[0].insert(SrcPoints[0].end(), src_points1.begin(), src_points1.end()); SrcPoints[1].insert(SrcPoints[1].end(), src_points2.begin(), src_points2.end()); // Add 4 corner points of image to the points cv::Size img_size[2]; for(int i=0; i<2; i++){ img_size[i] = SrcImg[i].size(); float w = img_size[i].width - 1; float h= img_size[i].height - 1; SrcPoints[i].push_back(cv::Point2f(0,0)); SrcPoints[i].push_back(cv::Point2f(w,0)); SrcPoints[i].push_back(cv::Point2f(0,h)); SrcPoints[i].push_back(cv::Point2f(w,h)); } // Morph points std::vector<cv::Point2f> MorphedPoints; MorphPoints(SrcPoints[0], SrcPoints[1], MorphedPoints, shape_ratio); // Generate Delaunay Triangles from the morphed points int num_points = MorphedPoints.size(); cv::Size MorphedImgSize(MorphedPoints[num_points-1].x+1,MorphedPoints[num_points-1].y+1); cv::Subdiv2D sub_div(cv::Rect(0,0,MorphedImgSize.width,MorphedImgSize.height)); sub_div.insert(MorphedPoints); // Get the ID list of corners of Delaunay traiangles. std::vector<cv::Vec3i> triangle_indices; GetTriangleVertices(sub_div, MorphedPoints, triangle_indices); // Get coordinates of Delaunay corners from ID list std::vector<std::vector<cv::Point2f>> triangle_src[2], triangle_morph; TransTrianglerPoints(triangle_indices, SrcPoints[0], triangle_src[0]); TransTrianglerPoints(triangle_indices, SrcPoints[1], triangle_src[1]); TransTrianglerPoints(triangle_indices, MorphedPoints, triangle_morph); // Create a map of triangle ID in the morphed image. cv::Mat triangle_map = cv::Mat::zeros(MorphedImgSize, CV_32SC1); PaintTriangles(triangle_map, triangle_morph); // Compute Homography matrix of each triangle. std::vector<cv::Mat> homographyMats, MorphHom[2]; SolveHomography(triangle_src[0], triangle_src[1], homographyMats); MorphHomography(homographyMats, MorphHom[0], MorphHom[1], shape_ratio); cv::Mat trans_img[2]; for(int i=0; i<2; i++){ // create a map for cv::remap() cv::Mat trans_map_x, trans_map_y; CreateMap(triangle_map, MorphHom[i], trans_map_x, trans_map_y); // remap cv::remap(SrcImg[i], trans_img[i], trans_map_x, trans_map_y, cv::INTER_LINEAR); } // Blend 2 input images float blend = (color_ratio < 0) ? shape_ratio : color_ratio; dst_img = trans_img[0] * (1.0 - blend) + trans_img[1] * blend; dst_points.clear(); dst_points.insert(dst_points.end(), MorphedPoints.begin(), MorphedPoints.end() - 4); }
void CGameFactory::CreateNewGame( const GDModel::CGameInitialisationData& data, CMapView *mapView, const CTerrainType * defaultTerrainType ) { CreateModel( data ); CreateMap( data, mapView, defaultTerrainType ); }
int Workout() { Enum(); CreateMap(); return hungary(Rowl, Coll, g_list); }
void CNewMapConfigDlg::OnOK() { CreateMap(); CDialogEx::OnOK(); }