- Timestamp:
- 05/23/08 17:47:22 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp
r2694 r2702 20 20 void ObjectPlacer::AddObject(SceneGraphLeaf *obj) 21 21 { 22 m DynamicObjects.push_back(obj);22 mLibraryObjects.push_back(obj); 23 23 } 24 24 … … 26 26 void ObjectPlacer::NextObject() 27 27 { 28 mCurrentObject = (mCurrentObject + 1) % (int)m DynamicObjects.size();28 mCurrentObject = (mCurrentObject + 1) % (int)mLibraryObjects.size(); 29 29 } 30 30 … … 32 32 void ObjectPlacer::PreviousObject() 33 33 { 34 mCurrentObject = (mCurrentObject - 1) % (int)m DynamicObjects.size();34 mCurrentObject = (mCurrentObject - 1) % (int)mLibraryObjects.size(); 35 35 } 36 36 … … 38 38 SceneGraphLeaf *ObjectPlacer::GetCurrentObject() 39 39 { 40 if (mCurrentObject >= m DynamicObjects.size())40 if (mCurrentObject >= mLibraryObjects.size()) 41 41 return NULL; 42 42 43 return m DynamicObjects[mCurrentObject];43 return mLibraryObjects[mCurrentObject]; 44 44 } 45 45 … … 49 49 Vector3 p = pt; 50 50 51 SceneGraphLeaf *obj = m DynamicObjects[mCurrentObject];51 SceneGraphLeaf *obj = mLibraryObjects[mCurrentObject]; 52 52 53 53 // set pivot to ground of object … … 58 58 } 59 59 60 61 /*void TestApp::Placer(const String &parm)62 {63 if (parm.Empty())64 {65 OUT1("Object placement: place/load <libaryfile>/removelast/next/previous/save <objectfile>");66 return;67 }68 69 ASM_RET(viewer->GetRoot(), "No scene");70 71 if (!placer)72 placer = new ObjectPlacer;73 74 //-- make sure the placer visualization (which shows the already placed objects) is in the viewer75 SearchNodeByNameVisitor search("placervis");76 search.Apply(viewer->GetRoot(), SearchNodeByNameVisitor::FIRST);77 BranchGroup *placervis = search.GetNode();78 if (!placervis)79 {80 placervis = placer->GetPlacedNodeVisualization();81 viewer->GetRoot()->addChild(placervis);82 placervis->setName("placervis");83 }84 85 if (parm == "place")86 {87 int x, y;88 input_module->GetMousePos(x, y);89 90 Point3f pos = viewer->UnProject(x, y);91 if (viewer && viewer->GetRoot() && viewer->GetRoot()->getBoundingBox()->intersects(pos))92 {93 placer->AddObject(pos);94 OUT1(x << " " << y << " " << pos);95 }96 else97 {98 OUT1("Point out of bounds");99 }100 } else if (parm == "removelast") {101 placer->RemoveLastObject();102 } else if (parm == "next") {103 placer->NextObject();104 } else if (parm == "previous") {105 placer->PreviousObject();106 } else if (parm.Left(5) == "save ") {107 String filename = parm.Right(parm.size()-5);108 if (!filename.Empty())109 placer->SaveObjects(filename);110 } else if (parm.Left(5) == "clear") {111 placer->Clear();112 } else if (parm.Left(5) == "load ") {113 String fn = sysutils::FindFile(parm.Right(parm.size()-5), settings->get_ObjectPath());114 115 ASM_ELSE(!fn.empty(), "Couldn't find file " << fn)116 {117 OUT1("Loading library " << fn << "...");118 SceneBasePtr<BranchGroup> root = ReadSceneGraph(fn, 0, 0, 1);119 120 BranchGroup *library = new BranchGroup;121 ASM_ELSE((root != NULL), "No scene found in file...")122 {123 SearchNodeByNameVisitor search("start");124 search.Apply(root, SearchNodeByNameVisitor::FIRST);125 BranchGroup *local_root = search.GetNode();126 127 if (local_root == NULL)128 {129 OUT1("Note: BranchGroup named \"start\" not found - using root node");130 local_root = root;131 }132 133 placer->SetLibrary(local_root);134 BranchGroup *viz = placer->GetLibraryVisualization();135 mRenderArea->SetSceneRoot(viz);136 mRenderArea->SetCamera(new Camera);137 mRenderArea->GetCamera()->ViewAll(viz->getBoundingSphere());138 }139 }140 } else141 OUT1("Unknown placer command");142 60 } 143 */144 145 }
Note: See TracChangeset
for help on using the changeset viewer.