source: OGRE/trunk/ogrenew/OgreMain/src/OgreTagPoint.cpp @ 657

Revision 657, 5.2 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://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
36namespace 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        makeTransform(mDerivedPosition, mDerivedScale, mDerivedOrientation, mFullLocalTransform);
109
110        // Include Entity transform
111        if (mParentEntity)
112        {
113            Node* entityParentNode = mParentEntity->getParentNode();
114            if (entityParentNode)
115            {
116                // Combine orientation with that of parent entity
117                Quaternion mParentQ = entityParentNode->_getDerivedOrientation();
118                mDerivedOrientation = mParentQ * mDerivedOrientation;
119
120                Vector3 mParentS = entityParentNode->_getDerivedScale();
121
122                if (mInheritScale)
123                {
124                    // Incorporate parent entity scale
125                    mDerivedScale *= mParentS;
126                }
127
128                // Change position vector based on parent entity's orientation & scale
129                mDerivedPosition = mParentQ * (mParentS * mDerivedPosition);
130
131                // Add altered position vector to parent entity
132                mDerivedPosition += entityParentNode->_getDerivedPosition();
133            }
134        }
135
136
137    }
138    //-----------------------------------------------------------------------------
139    const LightList& TagPoint::getLights(void) const
140    {
141        return mParentEntity->getParentSceneNode()->findLights(mParentEntity->getBoundingRadius());
142    }
143
144}
Note: See TracBrowser for help on using the repository browser.