Newton Dynamics  4.00
ndCharacterRootNode.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_CHARACTER_ROOT_NODE_H__
23 #define __ND_CHARACTER_ROOT_NODE_H__
24 
25 #include "ndNewtonStdafx.h"
26 #include "ndCharacterNode.h"
27 
29 {
30  public:
31  D_CLASS_REFLECTION(ndCharacterRootNode);
32  D_NEWTON_API ndCharacterRootNode(const ndCharacterLoadDescriptor& desc);
33  D_NEWTON_API ndCharacterRootNode(ndCharacter* const owner, ndBodyDynamic* const body);
34  D_NEWTON_API virtual ~ndCharacterRootNode ();
35 
36  ndCharacter* GetOwner() const;
37  virtual ndBodyDynamic* GetBody() const;
38 
39  const ndMatrix& GetCoronalFrame() const;
40  D_NEWTON_API void SetCoronalFrame(const ndMatrix& sagittalFrameInGlobalSpace);
41 
42  protected:
43  //void UpdateGlobalPose(ndWorld* const world, dFloat32 timestep);
44  void Save(const ndCharacterSaveDescriptor& desc) const;
45 
46  ndMatrix m_coronalFrame;
47  ndCharacter* m_owner;
48  ndBodyDynamic* m_body;
49  friend class ndCharacter;
50 };
51 
52 inline ndCharacter* ndCharacterRootNode::GetOwner() const
53 {
54  return m_owner;
55 }
56 
57 inline ndBodyDynamic* ndCharacterRootNode::GetBody() const
58 {
59  return m_body;
60 }
61 
62 inline const ndMatrix& ndCharacterRootNode::GetCoronalFrame() const
63 {
64  return m_coronalFrame;
65 }
66 
67 inline void ndCharacterRootNode::SetCoronalFrame(const ndMatrix& frameInGlobalSpace)
68 {
69  m_coronalFrame = frameInGlobalSpace * m_body->GetMatrix().Inverse();
70  m_coronalFrame.m_posit = ndVector::m_wOne;
71 }
72 
73 
74 #endif
ndCharacterLoadDescriptor
Definition: ndCharacterNode.h:38
ndCharacterNode
Definition: ndCharacterNode.h:95
ndCharacterRootNode
Definition: ndCharacterRootNode.h:29
ndCharacter
Definition: ndCharacter.h:45
ndBodyDynamic
Definition: ndBodyDynamic.h:43
ndMatrix
Definition: ndMatrix.h:42
ndCharacterSaveDescriptor
Definition: ndCharacterNode.h:71