49
49
SG_IObject(clientobj,clientinfo,callbacks),
50
m_localPosition(MT_Point3(0,0,0)),
51
m_localRotation(1,0,0,0,1,0,0,0,1),
50
m_localPosition(MT_Point3(0.0,0.0,0.0)),
51
m_localRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
52
52
m_localScaling(MT_Vector3(1.f,1.f,1.f)),
54
m_worldPosition(MT_Point3(0.0,0.0,0.0)),
55
m_worldRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
56
m_worldScaling(MT_Vector3(1.f,1.f,1.f)),
53
58
m_parent_relation (NULL),
55
m_worldPosition(MT_Point3(0,0,0)),
56
m_worldRotation(0,0,0,0,0,0,0,0,0),
57
m_worldScaling(MT_Vector3(1.f,1.f,1.f))
60
m_bbox(MT_Point3(-1.0, -1.0, -1.0), MT_Point3(1.0, 1.0, 1.0)),
67
70
m_localPosition(other.m_localPosition),
68
71
m_localRotation(other.m_localRotation),
69
72
m_localScaling(other.m_localScaling),
70
m_parent_relation(NULL),
71
74
m_worldPosition(other.m_worldPosition),
72
75
m_worldRotation(other.m_worldRotation),
73
m_worldScaling(other.m_worldScaling)
76
m_worldScaling(other.m_worldScaling),
78
m_parent_relation(NULL),
81
m_radius(other.m_radius)
75
83
// duplicate the parent relation for this object
76
84
m_parent_relation = other.m_parent_relation->NewCopy();
122
131
// our world coordinates.
124
133
if (!bComputesWorldTransform)
126
ComputeWorldTransforms(parent);
134
bComputesWorldTransform = ComputeWorldTransforms(parent);
136
return bComputesWorldTransform;
130
void SG_Spatial::ComputeWorldTransforms(const SG_Spatial *parent)
139
bool SG_Spatial::ComputeWorldTransforms(const SG_Spatial *parent)
132
m_parent_relation->UpdateChildCoordinates(this,parent);
141
return m_parent_relation->UpdateChildCoordinates(this,parent);
137
145
* Position and translation methods
285
293
return m_worldScaling;
296
SG_BBox& SG_Spatial::BBox()
301
void SG_Spatial::SetBBox(SG_BBox& bbox)
306
MT_Transform SG_Spatial::GetWorldTransform() const
308
return MT_Transform(m_worldPosition,
309
m_worldRotation.scaled(
310
m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]));
313
bool SG_Spatial::inside(const MT_Point3 &point) const
315
MT_Scalar radius = m_worldScaling[m_worldScaling.closestAxis()]*m_radius;
316
return (m_worldPosition.distance2(point) <= radius*radius) ?
317
m_bbox.transform(GetWorldTransform()).inside(point) :
321
void SG_Spatial::getBBox(MT_Point3 *box) const
323
m_bbox.get(box, GetWorldTransform());
326
void SG_Spatial::getAABBox(MT_Point3 *box) const
328
m_bbox.getaa(box, GetWorldTransform());