Пример #1
0
void plExportDlgImp::IInitDlg(HWND hDlg)
{
    // Set the client path
    const char* path = plMaxConfig::GetClientPath(false, true);
    SetDlgItemText(hDlg, IDC_CLIENT_PATH, path);

    // Set the preshade button
    CheckDlgButton(hDlg, IDC_PRESHADE_CHECK, fPreshade ? BST_CHECKED : BST_UNCHECKED);
    CheckDlgButton(hDlg, IDC_PHYSICAL_CHECK, fPhysicalsOnly ? BST_CHECKED : BST_UNCHECKED);
    CheckDlgButton(hDlg, IDC_LIGHTMAP_CHECK, fLightMap ? BST_CHECKED : BST_UNCHECKED);

    char buf[256];
    sprintf(buf, "Last export took %d:%02d", fLastExportTime/60, fLastExportTime%60);
    SetDlgItemText(hDlg, IDC_LAST_EXPORT, buf);

    SetWindowPos(hDlg, NULL, fXPos, fYPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

    //
    // Get the names of all the pages in this scene and put them in the combo
    //
    HWND hPages = GetDlgItem(hDlg, IDC_PAGE_COMBO);
    ComboBox_AddString(hPages, kAllPages);

    bool foundPage = false;

    CompSet comps;
    GetPagesRecur((plMaxNode*)GetCOREInterface()->GetRootNode(), comps);
    for (CompSet::iterator it = comps.begin(); it != comps.end(); it++)
    {
        const char* page = LocCompGetPage(*it);
        if (page)
        {
            int idx = ComboBox_AddString(hPages, page);
            if (!strcmp(page, fExportPage))
            {
                foundPage = true;
                ComboBox_SetCurSel(hPages, idx);
            }
        }
    }

    if (!foundPage)
    {
        fExportPage[0] = '\0';
        ComboBox_SetCurSel(hPages, 0);
    }

    CheckRadioButton(hDlg, IDC_RADIO_FILE, IDC_RADIO_DIR, IDC_RADIO_FILE);
    IGetRadio(hDlg);

    SetDlgItemText(hDlg, IDC_EXPORT_PATH, fExportSourceDir);
}
Пример #2
0
static void GetPagesRecur(plMaxNode* node, CompSet& comps)
{
    if (!node)
        return;

    plComponentBase* comp = node->ConvertToComponent();
    if (comp && (comp->ClassID() == ROOM_CID || comp->ClassID() == PAGEINFO_CID))
    {
        comps.insert(comp);
    }

    for (int i = 0; i < node->NumberOfChildren(); i++)
        GetPagesRecur((plMaxNode*)node->GetChildNode(i), comps);
}
Пример #3
0
void Eye3D::unweighted_graphic_model(BinaryTree *tree, ComponentsInfo *compInfo)
{
    assert(tree);
    _viz->clear();
    /// find meaningful components
    refine_segmentation(tree, compInfo);
    m_graph::DottyOutput<BinaryTree> dot0(tree);
//    dot0.write("tree.dot");
//    std::cout<<"write to "<< "tree.dot"<<std::endl;
    m_graph::DottyOutput<BinaryTree> dot1(&ClusterNode::hierarchyTree);
//    dot1.write("htree.dot");
//    std::cout<<"write to "<< "htree.dot"<<std::endl;

    /// 
    auto nodesRange = tree->get_all_nodes();
    BinaryTree::NodeId rootId = 0;
    /// connect adjacent components (leafs)
    typedef std::set<BinaryTree::NodeId> CompSet;
    std::map<PointF3D, CompSet> points;
    std::array<PointF3D,3> p3;
    auto nodeRange = tree->get_all_nodes();
    std::vector<BinaryTree::NodeId> tab;
    bool onlyLeaf = true;
    // connect adjacent leaf nodes 
    while(nodeRange.first != nodeRange.second){
        auto id = *nodeRange.first;
        TrNode node = tree->get_node(id);
        if (!onlyLeaf || node.is_leaf()) {
            CompSet components;
            components.insert(id);
            TrianglePtrS triangles;
            triangles_of_component(node.friendId, &triangles);
            PointF3D center;
            for(Triangle *t : triangles){
                auto v1 = t->v1(); 
                auto v2 = t->v2(); 
                auto v3 = t->v3(); 
                p3[0] = PointF3D(v1->x, v1->y, v1->z);
                p3[1] = PointF3D(v2->x, v2->y, v2->z);
                p3[2] = PointF3D(v3->x, v3->y, v3->z);
                PointF3D t;
                for(auto &p : p3){
                    if (node.is_leaf()) {
                        /// if vertex of an triangles is shared by some components,
                        /// then they are adjacent components
                        // add current component to the containers(owners)
                        auto rst = points.insert(make_pair(p, components));
                        if (!rst.second) {
                            // there is some other adjacent components contain the point
                            auto &neighborhood = rst.first->second;
                            for(auto nbId : neighborhood){
                                // add edge between adjacent components
                                if (nbId != id) 
                                    tree->add_edge(id, nbId);
                                
                            }
                            // add current component to the containers
                            neighborhood.insert(id);
                        }
                    }
                    t += p;
                }
                // t/3 == the center of one triangles mesh
                node.center += (t/3);
            }
            node.center /= triangles.size();
            node.proportion = node.size / float(hTree.get_node(hTree.rootId).size);
            //        node.weight = weight_type(node) + 1 / node.proportion * SIZEBIAS;
            node.degree = tree->get_degree(id);
            node.dist = sqrt(pow(node.center.x - _center.x, 2) + pow(node.center.y - _center.y, 2) +
                    pow(node.center.z - _center.z, 2));
            tree->modify_node(id, node);
        }
        nodeRange.first++;
    }
    /// angle, only for leafs
    int maxSize = -1;
    PointF3D maxCenter; 
    for(auto id : compInfo->_leafs){
        TrNode node = tree->get_node(id);
        if (node.size > maxSize) {
            maxCenter = node.center;
        }
    }
    // the base line
    float x0 = _center.x - maxCenter.x;
    float y0 = _center.y - maxCenter.y;
    float z0 = _center.z - maxCenter.z;
    for(auto id : compInfo->_leafs){
        TrNode node = tree->get_node(id);
        float x = _center.x - node.center.x;
        float y = _center.y - node.center.y;
        float z = _center.z - node.center.z;
        node.angle = (x*x0 + y*y0 + z*z0) / (sqrt(pow(x0, 2) + pow(y0,2) + pow(z0,2))*
                                             sqrt(pow(x, 2)+ pow(y, 2) + pow(z, 2)));
        tree->modify_node(id, node);

    }




}