graphicalwobject.cpp
1 /********************************************************************************
2  * FARSA Experiments Library *
3  * Copyright (C) 2007-2012 *
4  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
5  * Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it> *
6  * Gianluca Massera <emmegian@yahoo.it> *
7  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
22  ********************************************************************************/
23 
24 #include "graphicalwobject.h"
25 
26 namespace farsa {
27 
28 GraphicalWObject::GraphicalWObject(World* world, QString name, const wMatrix& tm) :
29  WObject(world, name, tm, false),
30  m_attachedObject(NULL)
31 {
32  // Adding here to the world, even if not at the end of the hierarchy (all classes inheriting
33  // from this have the same renderer anyway)
34  world->pushObject(this);
35 }
36 
38 {
39  // Nothing do to here
40 }
41 
42 void GraphicalWObject::attachToObject(WObject* object, bool makeOwner)
43 {
44  m_attachedObject = object;
45 
46  if (makeOwner) {
48  } else {
49  setOwner(NULL);
50  }
51 }
52 
53 void GraphicalWObject::updateAndRender(RenderWObject* renderer, QGLContext* gw)
54 {
56 
57  render(renderer, gw);
58 }
59 
61 {
63 
64  renderAABB(renderer, gw);
65 }
66 
68 {
70 
71  calculateAABB(minPoint, maxPoint, tm);
72 }
73 
74 void GraphicalWObject::updateAndCalculateOBB(wVector& dimension, wVector& minPoint, wVector& maxPoint)
75 {
77 
78  calculateOBB(dimension, minPoint, maxPoint);
79 }
80 
82 {
83  // The default implementation does nothing
84 }
85 
86 void GraphicalWObject::calculateAABB(wVector& minPoint, wVector& maxPoint, const wMatrix)
87 {
88  // The default implementation does nothing
89  minPoint = wVector(0, 0, 0);
90  maxPoint = wVector(0, 0, 0);
91 }
92 
93 void GraphicalWObject::calculateOBB(wVector& dimension, wVector& minPoint, wVector& maxPoint)
94 {
95  // The default implementation does nothing
96  dimension = wVector(0, 0, 0);
97  minPoint = wVector(0, 0, 0);
98  maxPoint = wVector(0, 0, 0);
99 }
100 
102 {
103  if (m_attachedObject == NULL) {
104  return;
105  }
106 
108 }
109 
110 }