void EditorUI::SelectionUpdated() { vector<MdlObject*> sel =model->GetSelectedObjects (); char label[128]; if (sel.size () == 1) { MdlObject *f = sel.front(); PolyMesh *pm = f->GetPolyMesh(); sprintf (label, "MdlObject %s selected: position=(%4.1f,%4.1f,%4.1f) scale=(%3.2f,%3.2f,%3.2f) polycount=%d vertexcount=%d", f->name.c_str(), f->position.x, f->position.y, f->position.z, f->scale.x, f->scale.y, f->scale.z, pm? int(pm->poly.size()):0, pm?int(pm->verts.size()):0); } else if(sel.size() > 1) { int plcount = 0, vcount = 0; for (unsigned int a=0;a<sel.size();a++) { PolyMesh *pm = sel[a]->GetPolyMesh(); if (pm) { plcount += pm->poly.size(); vcount += pm->verts.size(); } } sprintf (label, "Multiple objects selected. Total polycount: %d, Total vertexcount: %d", plcount, vcount); } else label[0]=0; status->value (label); status->redraw (); Update (); }
bool Model::ImportUVCoords (Model* other, IProgressCtl &progctl) { vector <MdlObject*> objects=GetObjectList (); MdlObject *srcobj = other->root; vector <Vector3> pverts; int numPl = 0, curPl=0; for (int a=0;a<objects.size();a++) numPl += objects[a]->poly.size(); for (int a=0;a<objects.size();a++) { MdlObject *obj = objects[a]; Matrix objTransform; obj->GetFullTransform(objTransform); // give each polygon an independent set of vertices, this will be optimized back to normal later vector <Vertex> nverts; for (int b=0;b<obj->poly.size();b++) { Poly *pl = obj->poly[b]; for (int v=0;v<pl->verts.size();v++) { nverts.push_back (obj->verts[pl->verts[v]]); pl->verts[v]=nverts.size()-1; } } obj->verts=nverts; // match our polygons with the ones of the other model for (int b=0;b<obj->poly.size();b++) { Poly *pl = obj->poly[b]; pverts.clear(); for (int pv=0;pv<pl->verts.size();pv++) { Vector3 tpos; objTransform.apply (&obj->verts [pl->verts[pv]].pos, &tpos); pverts.push_back (tpos); } int startVertex; int bestpl = MatchPolygon (srcobj,pverts,startVertex); if (bestpl >= 0) { // copy texture coordinates from rt->poly[bestpl] to pl Poly *src = srcobj->poly [bestpl]; for (int v=0;v<src->verts.size();v++) { Vertex &dstvrt = obj->verts[pl->verts[(v + startVertex)%pl->verts.size()]]; dstvrt.tc[0] = srcobj->verts[src->verts[v]].tc[0]; } } progctl.Update ((float)(curPl++) / numPl); } obj->Optimize (); obj->InvalidateRenderData(); } return true; }
void EditorUI::menuObjectMerge() { vector <MdlObject*> sel = model->GetSelectedObjects (); for (int a=0; a<sel.size(); a++) { MdlObject *parent = sel [a]->parent; if (parent) parent->MergeChild (sel[a]); } Update (); }
void EditorUI::menuObjectMerge() { vector <MdlObject*> sel = model->GetSelectedObjects (); for (unsigned int a=0;a<sel.size();a++) { MdlObject *parent = sel [a]->parent; if (parent) parent->MergeChild (sel[a]); } BACKUP_POINT("Selected objects merged"); Update (); }
void Model::CalculateRadius () { vector<MdlObject*> objs = GetObjectList(); radius=0.0f; for (int o=0;o<objs.size();o++) { MdlObject *obj = objs[o]; Matrix objTransform; obj->GetFullTransform(objTransform); for(int v=0;v<obj->verts.size();v++){ Vector3 tpos; objTransform.apply(&obj->verts[v].pos,&tpos); float r= (tpos-mid).length(); if (radius < r) radius=r; } } }
void EditorUI::uiObjectPositionChanged(int axis, fltk::Input *o) { MdlObject *sel = GetSingleSel(); if (sel) { float val=atof(o->value()); if (chkOnlyMoveOrigin->value()) { Vector3 newPos = sel->position; newPos[axis] = val; sel->MoveOrigin(newPos - sel->position); } else sel->position[axis] = val; BACKUP_POINT("Object position change"); Update(); } }