source: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp @ 2702

Revision 2702, 1.1 KB checked in by mattausch, 16 years ago (diff)

implemented dynamic object placement / removal

Line 
1#include "ObjectPlacer.h"
2#include "Matrix4x4.h"
3#include "SceneGraph.h"
4
5
6
7namespace GtpVisibilityPreprocessor
8{
9
10// ---------------------------------------------------------------------------
11//  ObjectPlacer implementation
12// ---------------------------------------------------------------------------
13
14ObjectPlacer::ObjectPlacer()
15: mCurrentObject(0)
16{
17}
18
19
20void ObjectPlacer::AddObject(SceneGraphLeaf *obj)
21{
22        mLibraryObjects.push_back(obj);
23}
24
25
26void ObjectPlacer::NextObject()
27{
28        mCurrentObject = (mCurrentObject + 1) % (int)mLibraryObjects.size();
29}
30
31
32void ObjectPlacer::PreviousObject()
33{
34        mCurrentObject = (mCurrentObject - 1) % (int)mLibraryObjects.size();
35}
36
37
38SceneGraphLeaf *ObjectPlacer::GetCurrentObject()
39{
40        if (mCurrentObject >= mLibraryObjects.size())
41                return NULL;
42
43        return mLibraryObjects[mCurrentObject];
44}
45
46
47void ObjectPlacer::PlaceObject(const Vector3 &pt)
48{
49        Vector3 p = pt;
50
51        SceneGraphLeaf *obj = mLibraryObjects[mCurrentObject];
52
53        // set pivot to ground of object
54        p.y -= obj->GetOriginalBox().Min().y;
55        Matrix4x4 trafo = TranslationMatrix(p);
56
57        obj->LoadTransform(trafo);
58}
59
60}
Note: See TracBrowser for help on using the repository browser.