ComputeIconMasks(IconTaskCtx& ctx) : ctx(ctx) { // clamp the icon size iconSizecv = cv::Size( clamp(ctx.iconSize.width(), IconTask::IconSizeMin, IconTask::IconSizeMax), clamp(ctx.iconSize.height(), IconTask::IconSizeMin, IconTask::IconSizeMax)); // inner size = icon size without border (fixed to 1px) innerSize = QSize(iconSizecv.width - 2, iconSizecv.height - 2); innerSizecv = cv::Size(innerSize.width(), innerSize.height()); if (ctx.applyROI) { labels = ctx.roi_labels; } else { labels = ctx.full_labels; } scale = scaleToFit(labels.size(), innerSizecv); // offset into icon rect dx = 0.5 * (float(iconSizecv.width) - labels.cols*scale); dy = 0.5 * (float(iconSizecv.height) - labels.rows*scale); // affine trafo matrix trafo = cv::Mat1f::zeros(2,3); trafo(0,0) = scale; trafo(1,1) = scale; trafo(0,2) = dx; trafo(1,2) = dy; // rect of the transformed mask in the icon drect = QRectF(dx, dy, labels.cols*scale, labels.rows*scale); // rect of the border around the transformed mask brect = QRectF(drect.left(), drect.top(), drect.width()-1, drect.height()-1); // GGDBGM("desired icon size " << iconSizecv << endl); // GGDBGM("scale " << scale << endl); // GGDBGM("dx " << dx << endl); // GGDBGM("dy " << dy << endl); // GGDBGM("scaled mask size " << innerSizecv << endl); }
void CSolidView::OnCargarTgcmesh() { // TODO: Agregue aquí su código de controlador de comandos OPENFILENAME ofn; char szFile[256], szFileTitle[256]; unsigned int i; char szFilter[256]; strcpy(szFilter,"Archivos de Mesh(*.xml)|*.xml"); szFile[0] = '\0'; for(i=0;szFilter[i]!='\0';++i) if(szFilter[i]=='|') szFilter[i]='\0'; // Set all structure members to zero. memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hInstance = AfxGetApp()->m_hInstance; ofn.hwndOwner = AfxGetMainWnd()->m_hWnd; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile= szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER; if (GetOpenFileName( &ofn )) { escena.ReleaseResources(); CString fname(ofn.lpstrFile); fname.Replace('\\','/'); p_robot = NULL; int nro_mesh = escena.LoadMesh((char *)(LPCSTR)fname); if(nro_mesh!=-1) { if(IsSkeletalMesh((char *)(LPCSTR)fname)) { p_robot = (CSkeletalMesh *)escena.m_mesh[nro_mesh]; p_robot->initAnimation(0,true,30); } } scaleToFit(); } }
void CSolidView::ArmarEscena() { if(escena.IsReady()) escena.Release(); escena.Create(m_hWnd); // Cargo un mesh de ejemplo char mesh_path[MAX_PATH]; GetCurrentDirectory(MAX_PATH, mesh_path); //strcat(mesh_path, "\\media\\SkeletalAnimations\\BasicHuman\\WomanJeans-TgcSkeletalMesh.xml"); //strcat(mesh_path, "\\media\\QuakeRoom1\\QuakeMap-TgcScene.xml"); strcat(mesh_path, "\\media\\QuakeRoom1\\QuakeMap-TgcScene.flat"); //por algun motivo no anda usando un path relativo y usando \ en vez de / //reemplazo todas las \\ por / for (char * p = mesh_path; *p; p++) if (*p == '\\') *p = '/'; int nro_obj = -1; //int nro_obj = escena.LoadMesh(mesh_path); //escena.LoadSceneFromXml(mesh_path); // Escenario del quake escena.LoadSceneFromFlat(mesh_path); scaleToFit(); /* if(nro_obj!=-1) { p_robot = (CSkeletalMesh *)escena.m_mesh[nro_obj]; p_robot->initAnimation(0,true,30); } */ // Test de lighting /* p_piso = new CMesh(); p_piso->CreateGrid(&escena,D3DXVECTOR3(0,0,0),1000,1000,10,10,"C:\\TgcViewer\\Examples\\Media\\Texturas\\paredLisa.jpg"); escena.lookAt = D3DXVECTOR3(500,0,500); escena.lookFrom = D3DXVECTOR3(1500,300,1500); */ }
void CSolidView::OnCargarTgcScene() { OPENFILENAME ofn; char szFile[256], szFileTitle[256]; unsigned int i; char szFilter[256]; strcpy(szFilter,"Archivos de Escena(*.xml)|*.xml"); szFile[0] = '\0'; for(i=0;szFilter[i]!='\0';++i) if(szFilter[i]=='|') szFilter[i]='\0'; // Set all structure members to zero. memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hInstance = AfxGetApp()->m_hInstance; ofn.hwndOwner = AfxGetMainWnd()->m_hWnd; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile= szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER; if (GetOpenFileName( &ofn )) { escena.ReleaseTextures(); escena.ReleaseMeshes(); CString fname(ofn.lpstrFile); fname.Replace('\\','/'); p_robot = NULL; escena.LoadSceneFromXml((char *)(LPCSTR)fname); scaleToFit(); } }