Ejemplo n.º 1
0
void Convexer::makeConvex(HACD::HACD * myHACD, std::vector<PQP_Model *> &ret_val, const ConvParam &p) {
  
  
  // Set the approximation parameters
  myHACD->SetCompacityWeight(0.001);
  myHACD->SetVolumeWeight(0.0);
  myHACD->SetConnectDist(p.ccConnectDist);               // if two connected components are seperated by distance < ccConnectDist
						      // then create a virtual edge between them so the can be merged during 
						      // the simplification process
	    
  myHACD->SetNClusters(p.nClusters);                     // minimum number of clusters
  myHACD->SetNVerticesPerCH(100);                      // max of 100 vertices per convex-hull
  myHACD->SetConcavity(p.concavity);                     // maximum concavity
  myHACD->SetSmallClusterThreshold(0.25);				 // threshold to detect small clusters
  myHACD->SetNTargetTrianglesDecimatedMesh(p.targetNTrianglesDecimatedMesh); // # triangles in the decimated mesh
//     myHACD->SetCallBack(&CallBack);
  myHACD->SetAddExtraDistPoints(p.addExtraDistPoints);   
  myHACD->SetAddFacesPoints(p.addFacesPoints); 
  
  myHACD->Compute(); // Make it Convex!!
  
  addModels(myHACD, ret_val);
  
  // Debug
//   cout << "Convex process ended successfully. Number of models: " << ret_val.size() << endl;
//   cout << "Model 0. Num triangles:  " << ret_val.at(0)->num_tris << endl;;
//   for (unsigned int i = 0; i < ret_val.at(0)->num_tris ;i++) {
//     cout << "Triangle " << i << " (";
//     cout << ret_val.at(0)->tris[i].p1[0] << ", " << ret_val.at(0)->tris[i].p1[1] << ", " << ret_val.at(0)->tris[i].p1[2] << ") (";
//     cout << ret_val.at(0)->tris[i].p2[0] << ", " << ret_val.at(0)->tris[i].p2[1] << ", " << ret_val.at(0)->tris[i].p2[2] << ") (";
//     cout << ret_val.at(0)->tris[i].p3[0] << ", " << ret_val.at(0)->tris[i].p3[1] << ", " << ret_val.at(0)->tris[i].p3[2] << ").  ";
    
//   }
}
Ejemplo n.º 2
0
void
Coordinator::init(const vpz::Model& mdls, Time current, Time duration)
{
    m_currentTime = current;
    m_durationTime = duration;
    buildViews();
    addModels(mdls);
    m_isStarted = true;

    m_eventTable.init(current);
}
Ejemplo n.º 3
0
int Game::run()
{
	addModels();
	// Holds where the mouse clicked
	position2di click;
	stringw start = L"Back";

	// Used to switch classes
	next = 0;

	while(device->run() && !next)
	{
		if(device->isWindowActive())
		{
			// Keep an update on the size of the window
			ResX = driver->getScreenSize().Width;
			ResY = driver->getScreenSize().Height;

			// Start the scene
			driver->beginScene(true, true, SColor(0,0,0,0));

			// Handler for the back button thing
			if(reciever->mouseOver(rect<s32>(50,150,150,170)))
			{
				device->getCursorControl()->setActiveIcon(ECI_HAND);
				start = L">Back";
				if(reciever->isButtonDown(reciever->LeftButton, click))
					if(click.X > 50 && click.Y > 150 && click.X < 150 && click.Y < 170)
						next = 1;
			}else{
				device->getCursorControl()->setActiveIcon(ECI_NORMAL);
				start = L"Back";
			}
			arial->draw(start, rect<s32>(50,150,150,170), SColor(255,255,255,255));
			
			// Draw changes and close scene
			smgr->drawAll();
			guienv->drawAll();
			driver->endScene();
		}
	}
	removeModels();
	return next;
}
Ejemplo n.º 4
0
/*
 =======================================================================================================================
 =======================================================================================================================
 */
void CDialogTextures::OnRefresh() {
    quickTree.Clear();

    addModels( true );

    if (mode == TEXTURES) {
        idStrList textures(1024);
        int count = declManager->GetNumDecls( DECL_MATERIAL );
        int i;
        const idMaterial *mat;

        for (i = 0; i < count; i++) {
            mat = declManager->MaterialByIndex(i, false);
            if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && !idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
                textures.Append(mat->GetName());
            }
        }

        declManager->Reload( false );

        BuildTree();
        count = textures.Num();
        for (i = 0; i < count; i++) {
            mat = declManager->FindMaterial(textures[i].c_str());
            if ( mat ) {
                mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
            }
        }
        SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::TEXTURES);
    } else if (mode == MATERIALS) {
        idStrList textures(1024);
        int count = declManager->GetNumDecls( DECL_MATERIAL );
        int i;
        const idMaterial *mat;

        for (i = 0; i < count; i++) {
            mat = declManager->MaterialByIndex(i, false);
            if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
                textures.Append(mat->GetName());
            }
        }

        declManager->Reload( false );

        BuildTree();
        count = textures.Num();
        for (i = 0; i < count; i++) {
            mat = declManager->FindMaterial(textures[i].c_str());
            if ( mat ) {
                mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
            }
        }
        SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
    } else if (mode == SOUNDS || mode == SOUNDPARENT) {
        HTREEITEM root = m_treeTextures.GetRootItem();
        HTREEITEM sib = m_treeTextures.GetNextItem(root, TVGN_ROOT);
        while (sib) {
            idStr str = m_treeTextures.GetItemText(sib);
            if (str.Icmp(TypeNames[SOUNDS]) == 0) {
                CWaitCursor cursor;
                m_treeTextures.DeleteItem(sib);

                declManager->Reload( false );
                bool rootItems = m_chkHideRoot.GetCheck() == 0;
                addSounds(rootItems);
                return;
            }
            sib = m_treeTextures.GetNextSiblingItem(sib);
        }
    }
}