wobject.cpp
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2013 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #include "wobject.h"
21 #include "world.h"
22 
23 using namespace farsa;
24 
25 WObject::WObject( World* w, QString name, const wMatrix& tm, bool addToWorld ) {
26  this->worldv = w;
27  this->tm = tm;
28  namev = name;
29  texturev = "tile2";
30  colorv = Qt::white;
31  invisible = false;
33  if ( addToWorld ) {
34  worldv->pushObject( this );
35  }
36 }
37 
39  worldv->popObject( this );
40 }
41 
42 const wMatrix& WObject::matrix() const {
43  return tm;
44 }
45 
46 void WObject::setPosition( const wVector& newpos ) {
47  tm.w_pos = newpos;
48  changedMatrix();
49 }
50 
51 void WObject::setPosition( real x, real y, real z ) {
52  tm.w_pos = wVector(x,y,z);
53  changedMatrix();
54 }
55 
57  return worldv;
58 }
59 
60 const World* WObject::world() const {
61  return worldv;
62 }
63 
64 QString WObject::name() const {
65  return namev;
66 }
67 
68 void WObject::setTexture( QString textureName ) {
69  texturev = textureName;
70 }
71 
72 QString WObject::texture() const {
73  return texturev;
74 }
75 
76 void WObject::setColor( QColor c ) {
77  colorv = c;
78 }
79 
80 void WObject::setAlpha( int alpha ) {
81  colorv.setAlpha( alpha );
82 }
83 
84 QColor WObject::color() const {
85  return colorv;
86 }
87 
90 }
91 
94 }
95 
97  /* nothing to do */
98 }
99 
101  /* nothing to do */
102 }
103 
104 void WObject::setMatrix( const wMatrix& newm ) {
105  tm = newm;
106  changedMatrix();
107 }
108 
110  return invisible;
111 }
112 
113 void WObject::setInvisible( bool b ) {
114  invisible = b;
115 }
116 
118  /* nothing to do here */;
119 }