1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #include "OgreStableHeaders.h"
|
---|
26 |
|
---|
27 | #include "OgreTagPoint.h"
|
---|
28 | #include "OgreMatrix4.h"
|
---|
29 | #include "OgreMatrix3.h"
|
---|
30 | #include "OgreEntity.h"
|
---|
31 | #include "OgreSceneNode.h"
|
---|
32 | #include "OgreSkeleton.h"
|
---|
33 | #include "OgreQuaternion.h"
|
---|
34 |
|
---|
35 |
|
---|
36 | namespace Ogre {
|
---|
37 |
|
---|
38 | //-----------------------------------------------------------------------------
|
---|
39 | TagPoint::TagPoint(unsigned short handle, Skeleton* creator): Bone(handle, creator)
|
---|
40 | {
|
---|
41 | mParentEntity = 0;
|
---|
42 | mChildObject = 0;
|
---|
43 | }
|
---|
44 | //-----------------------------------------------------------------------------
|
---|
45 | TagPoint::~TagPoint()
|
---|
46 | {
|
---|
47 | }
|
---|
48 | //-----------------------------------------------------------------------------
|
---|
49 | Entity *TagPoint::getParentEntity(void)
|
---|
50 | {
|
---|
51 | return mParentEntity;
|
---|
52 | }
|
---|
53 | //-----------------------------------------------------------------------------
|
---|
54 | void TagPoint::setParentEntity(Entity *pEntity)
|
---|
55 | {
|
---|
56 | mParentEntity = pEntity;
|
---|
57 | }
|
---|
58 | //-----------------------------------------------------------------------------
|
---|
59 | void TagPoint::setChildObject(MovableObject *pObject)
|
---|
60 | {
|
---|
61 | mChildObject = pObject;
|
---|
62 | }
|
---|
63 | //-----------------------------------------------------------------------------
|
---|
64 | Matrix4 TagPoint::_getFullTransform(void)
|
---|
65 | {
|
---|
66 | //return getParentEntityTransform() * Node::_getFullTransform();
|
---|
67 | // Now that we're overriding updateFromParent(), this doesn't need to be different
|
---|
68 | return Node::_getFullTransform();
|
---|
69 | }
|
---|
70 | //-----------------------------------------------------------------------------
|
---|
71 | Matrix4 TagPoint::_getFullLocalTransform(void)
|
---|
72 | {
|
---|
73 | return mFullLocalTransform;
|
---|
74 | }
|
---|
75 | //-----------------------------------------------------------------------------
|
---|
76 | Matrix4 TagPoint::getParentEntityTransform()
|
---|
77 | {
|
---|
78 |
|
---|
79 | return mParentEntity->_getParentNodeFullTransform();
|
---|
80 | }
|
---|
81 | //-----------------------------------------------------------------------------
|
---|
82 | void TagPoint::_update(bool updateChildren, bool parentHasChanged)
|
---|
83 | {
|
---|
84 | Node::_update(updateChildren, parentHasChanged);
|
---|
85 | }
|
---|
86 | //-----------------------------------------------------------------------------
|
---|
87 | void TagPoint::needUpdate()
|
---|
88 | {
|
---|
89 | // We need to tell parent entities node
|
---|
90 | if (mParentEntity)
|
---|
91 | {
|
---|
92 | Node* n = mParentEntity->getParentNode();
|
---|
93 | if (n)
|
---|
94 | {
|
---|
95 | n->needUpdate();
|
---|
96 | }
|
---|
97 |
|
---|
98 | }
|
---|
99 |
|
---|
100 | }
|
---|
101 | //-----------------------------------------------------------------------------
|
---|
102 | void TagPoint::_updateFromParent(void) const
|
---|
103 | {
|
---|
104 | // Call superclass
|
---|
105 | Bone::_updateFromParent();
|
---|
106 |
|
---|
107 | // Save transform for local skeleton
|
---|
108 | mFullLocalTransform.makeTransform(
|
---|
109 | mDerivedPosition,
|
---|
110 | mDerivedScale,
|
---|
111 | mDerivedOrientation);
|
---|
112 |
|
---|
113 | // Include Entity transform
|
---|
114 | if (mParentEntity)
|
---|
115 | {
|
---|
116 | Node* entityParentNode = mParentEntity->getParentNode();
|
---|
117 | if (entityParentNode)
|
---|
118 | {
|
---|
119 | // Note: orientation/scale inheritance already take care with
|
---|
120 | // _updateFromParent, don't do that with parent entity transform.
|
---|
121 |
|
---|
122 | // Combine orientation with that of parent entity
|
---|
123 | const Quaternion& parentOrientation = entityParentNode->_getDerivedOrientation();
|
---|
124 | mDerivedOrientation = parentOrientation * mDerivedOrientation;
|
---|
125 |
|
---|
126 | // Incorporate parent entity scale
|
---|
127 | const Vector3& parentScale = entityParentNode->_getDerivedScale();
|
---|
128 | mDerivedScale *= parentScale;
|
---|
129 |
|
---|
130 | // Change position vector based on parent entity's orientation & scale
|
---|
131 | mDerivedPosition = parentOrientation * (parentScale * mDerivedPosition);
|
---|
132 |
|
---|
133 | // Add altered position vector to parent entity
|
---|
134 | mDerivedPosition += entityParentNode->_getDerivedPosition();
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | }
|
---|
140 | //-----------------------------------------------------------------------------
|
---|
141 | const LightList& TagPoint::getLights(void) const
|
---|
142 | {
|
---|
143 | return mParentEntity->getParentSceneNode()->findLights(mParentEntity->getBoundingRadius());
|
---|
144 | }
|
---|
145 |
|
---|
146 | }
|
---|