~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to source/gameengine/SceneGraph/SG_Spatial.h

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: SG_Spatial.h 15444 2008-07-05 17:05:05Z lukep $
 
2
 * $Id: SG_Spatial.h 20239 2009-05-17 12:51:51Z ben2610 $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
35
35
#include <MT_Matrix3x3.h> // or Quaternion later ?
36
36
#include "SG_IObject.h"
37
37
#include "SG_BBox.h"
 
38
#include "SG_ParentRelation.h"
38
39
 
39
40
 
40
41
class SG_Node;
61
62
        
62
63
        SG_BBox                 m_bbox;
63
64
        MT_Scalar               m_radius;
64
 
        
 
65
        bool                    m_modified;
 
66
        bool                    m_ogldirty;             // true if the openGL matrix for this object must be recomputed
65
67
 
66
68
public:
67
69
 
 
70
        inline void ClearModified() 
 
71
        { 
 
72
                m_modified = false; 
 
73
                m_ogldirty = true;
 
74
        }
 
75
        inline void SetModified()
 
76
        {
 
77
                m_modified = true;
 
78
                ActivateScheduleUpdateCallback();
 
79
        }
 
80
        inline void ClearDirty()
 
81
        {
 
82
                m_ogldirty = false;
 
83
        }
68
84
        /** 
69
85
         * Define the realtionship this node has with it's parent
70
86
         * node. You should pass an unshared instance of an SG_ParentRelation
84
100
                SG_ParentRelation *relation
85
101
        );
86
102
        
87
 
                SG_ParentRelation *
88
 
        GetParentRelation(
89
 
        );
 
103
        SG_ParentRelation * GetParentRelation()
 
104
        {
 
105
                return m_parent_relation;
 
106
        }
 
107
 
 
108
 
90
109
 
91
110
 
92
111
        /**
105
124
                bool local
106
125
        );
107
126
 
108
 
                void                            
109
 
        SetLocalPosition(
110
 
                const MT_Point3& trans
111
 
        );
112
 
 
113
 
                void                            
114
 
        SetWorldPosition(
115
 
                const MT_Point3& trans
116
 
        );
 
127
        void SetLocalPosition(const MT_Point3& trans)
 
128
        {
 
129
                m_localPosition = trans;
 
130
                SetModified();
 
131
        }
 
132
 
 
133
        void SetWorldPosition(const MT_Point3& trans)
 
134
        {
 
135
                m_worldPosition = trans;
 
136
        }
 
137
 
117
138
        
118
139
                void                            
119
140
        RelativeRotate(
121
142
                bool local
122
143
        );
123
144
 
124
 
                void                            
125
 
        SetLocalOrientation(
126
 
                const MT_Matrix3x3& rot
127
 
        );
128
 
 
129
 
                void                            
130
 
        SetWorldOrientation(
131
 
                const MT_Matrix3x3& rot
132
 
        );
133
 
 
134
 
                void                            
135
 
        RelativeScale(
136
 
                const MT_Vector3& scale
137
 
        );
138
 
 
139
 
                void                            
140
 
        SetLocalScale(
141
 
                const MT_Vector3& scale
142
 
        );
143
 
 
144
 
                void                            
145
 
        SetWorldScale(
146
 
                const MT_Vector3& scale
147
 
        );
148
 
 
149
 
        const 
150
 
                MT_Point3&
151
 
        GetLocalPosition(
152
 
        ) const ;
153
 
 
154
 
        const 
155
 
                MT_Matrix3x3&
156
 
        GetLocalOrientation(
157
 
        ) const ;
158
 
 
159
 
        const 
160
 
                MT_Vector3&     
161
 
        GetLocalScale(
162
 
        ) const;
163
 
 
164
 
        const 
165
 
                MT_Point3&
166
 
        GetWorldPosition(
167
 
        ) const ;
168
 
 
169
 
        const 
170
 
                MT_Matrix3x3&   
171
 
        GetWorldOrientation(
172
 
        ) const ;
173
 
 
174
 
        const 
175
 
                MT_Vector3&     
176
 
        GetWorldScaling(
177
 
        ) const ;
 
145
        void SetLocalOrientation(const MT_Matrix3x3& rot)
 
146
        {
 
147
                m_localRotation = rot;
 
148
                SetModified();
 
149
        }
 
150
 
 
151
        // rot is arrange like openGL matrix
 
152
        void SetLocalOrientation(const float* rot)
 
153
        {
 
154
                m_localRotation.setValue(rot);
 
155
                SetModified();
 
156
        }
 
157
 
 
158
        void SetWorldOrientation(const MT_Matrix3x3& rot) 
 
159
        {
 
160
                m_worldRotation = rot;
 
161
        }
 
162
 
 
163
        void RelativeScale(const MT_Vector3& scale)
 
164
        {
 
165
                m_localScaling = m_localScaling * scale;
 
166
                SetModified();
 
167
        }
 
168
 
 
169
        void SetLocalScale(const MT_Vector3& scale)
 
170
        {
 
171
                m_localScaling = scale;
 
172
                SetModified();
 
173
        }
 
174
 
 
175
        void SetWorldScale(const MT_Vector3& scale)
 
176
        { 
 
177
                m_worldScaling = scale;
 
178
        }
 
179
 
 
180
        const MT_Point3& GetLocalPosition() const       
 
181
        {
 
182
                return m_localPosition;
 
183
        }
 
184
 
 
185
        const MT_Matrix3x3& GetLocalOrientation() const 
 
186
        {
 
187
                return m_localRotation;
 
188
        }
 
189
 
 
190
        const MT_Vector3& GetLocalScale() const
 
191
        {
 
192
                return m_localScaling;
 
193
        }
 
194
 
 
195
        const MT_Point3& GetWorldPosition() const       
 
196
        {
 
197
                return m_worldPosition;
 
198
        }
 
199
 
 
200
        const MT_Matrix3x3&     GetWorldOrientation() const     
 
201
        {
 
202
                return m_worldRotation;
 
203
        }
 
204
 
 
205
        const MT_Vector3& GetWorldScaling() const       
 
206
        {
 
207
                return m_worldScaling;
 
208
        }
 
209
 
 
210
        void SetWorldFromLocalTransform()
 
211
        {
 
212
                m_worldPosition= m_localPosition;
 
213
                m_worldScaling= m_localScaling;
 
214
                m_worldRotation= m_localRotation;
 
215
        }
 
216
 
 
217
 
178
218
 
179
219
        MT_Transform GetWorldTransform() const;
180
220
 
181
 
        bool    ComputeWorldTransforms(         const SG_Spatial *parent);
 
221
        bool    ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated)
 
222
        {
 
223
                return m_parent_relation->UpdateChildCoordinates(this,parent,parentUpdated);
 
224
        }
 
225
 
182
226
 
183
227
        /**
184
228
         * Bounding box functions.
185
229
         */
186
 
        SG_BBox& BBox();
187
 
        void SetBBox(SG_BBox & bbox);
 
230
        SG_BBox& BBox()
 
231
        {
 
232
                return m_bbox;
 
233
        }
 
234
 
 
235
        void SetBBox(SG_BBox& bbox)
 
236
        {
 
237
                m_bbox = bbox;
 
238
        }
 
239
 
 
240
 
188
241
        bool inside(const MT_Point3 &point) const;
189
242
        void getBBox(MT_Point3 *box) const;
190
243
        void getAABBox(MT_Point3 *box) const;
191
244
        
192
245
        MT_Scalar Radius() const { return m_radius; }
193
246
        void SetRadius(MT_Scalar radius) { m_radius = radius; }
 
247
        bool IsModified() { return m_modified; }
 
248
        bool IsDirty() { return m_ogldirty; }
194
249
        
195
250
protected:
196
251
        friend class SG_Controller;
 
252
        friend class KX_BoneParentRelation;
 
253
        friend class KX_VertexParentRelation;
 
254
        friend class KX_SlowParentRelation;
 
255
        friend class KX_NormalParentRelation;
197
256
        
198
257
        /** 
199
258
         * Protected constructor this class is not
203
262
        SG_Spatial(
204
263
                void* clientobj,
205
264
                void* clientinfo,
206
 
                SG_Callbacks callbacks
 
265
                SG_Callbacks& callbacks
207
266
        );
208
267
 
209
268
        SG_Spatial(
221
280
                bool 
222
281
        UpdateSpatialData(
223
282
                const SG_Spatial *parent,
224
 
                double time
 
283
                double time,
 
284
                bool& parentUpdated
225
285
        );
226
286
 
227
287
};