void EditorUI::uiObjectStateChanged(Vector3 MdlObject::*state, float Vector3::*axis, fltk::Input *o, float scale) { MdlObject *sel = GetSingleSel(); if (sel) { float val=atof(o->value()); (sel->*state).*axis = val * scale; Update(); } }
void EditorUI::uiObjectRotationChanged(int axis, fltk::Input *o) { MdlObject *sel = GetSingleSel(); if (sel) { Vector3 euler = sel->rotation.GetEuler(); euler.v[axis] = atof(o->value()) * DegreesToRadians; sel->rotation.SetEuler(euler); Update(); } }
void EditorUI::menuObjectSave() { MdlObject* sel = GetSingleSel(); if (!sel) return; const char *fn=FileChooser ("Save model file:", FileChooserPattern, sel->name.c_str(),true); if(fn) { Model *submdl = new Model; submdl->root = sel; Model::Save (submdl,fn); submdl->root = 0; delete submdl; } }
void EditorUI::menuObjectLoad() { MdlObject* obj = GetSingleSel(); if (!obj) return; const char *fn=FileChooser("Load model file:",FileChooserPattern, 0,false); if(fn) { Model* submdl = Model::Load(fn); if (submdl) model->InsertModel (obj, submdl); delete submdl; } }
void EditorUI::menuObjectLoad() { MdlObject* obj = GetSingleSel(); if (!obj) return; static std::string fn; if (FileOpenDlg("Load object:", FileChooserPattern, fn)) { Model* submdl = Model::Load(fn); if (submdl) model->InsertModel (obj, submdl); delete submdl; BACKUP_POINT("Load object"); Update(); } }
void EditorUI::menuObjectSave() { MdlObject* sel = GetSingleSel(); if (!sel) return; static std::string fn; char fnl [256]; strncpy (fnl, fn.c_str(),sizeof(fnl)); strncpy (fltk::filename_name (fnl), sel->name.c_str(), sizeof(fnl)); fn = fnl; if (FileSaveDlg("Save object:", FileChooserPattern, fn)) { Model *submdl = new Model; submdl->root = sel; Model::Save (submdl,fn); submdl->root = 0; delete submdl; } }
void EditorUI::menuObjectReplace() { MdlObject* old = GetSingleSel(); if (!old) return; char buf[128]; sprintf (buf, "Select model to replace \'%s\' ", old->name.c_str()); static std::string fn; if (FileOpenDlg(buf, FileChooserPattern, fn)) { Model *submdl = Model::Load(fn); if (submdl) { model->ReplaceObject (old, submdl->root); submdl->root = 0; BACKUP_POINT("Replace object"); Update (); } delete submdl; } }
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(); } }
void EditorUI::menuObjectReplace() { MdlObject* old = GetSingleSel(); if (!old) return; char buf[128]; sprintf (buf, "Select model to replace \'%s\' ", old->name.c_str()); const char *fn=FileChooser (buf, FileChooserPattern, 0,false); if(fn) { Model *submdl = new Model; if (submdl->Load (fn)) { model->ReplaceObject (old, submdl->root); submdl->root = 0; Update (); } delete submdl; } }
void EditorUI::uiAddObject () { const char *r = fltk::input("Add empty object", 0); if (r) { MdlObject *obj=new MdlObject; obj->name = r; if (model->root) { MdlObject *parent=GetSingleSel (); if (!parent) delete obj; else { obj->parent = parent; parent->childs.push_back (obj); parent->isOpen=true; } } else model->root=obj; Update (); } }