Newton Dynamics
4.00
ndCharacterNode.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_LIMB_NODE_H__
23
#define __ND_CHARACTER_LIMB_NODE_H__
24
25
#include "ndNewtonStdafx.h"
26
#include "ndModel.h"
27
28
class
ndWorld
;
29
class
ndCharacter
;
30
class
ndLimbJoint;
31
class
ndCharacterRootNode
;
32
class
ndCharacterSkeleton;
33
class
ndJointBilateralConstraint
;
34
class
ndCharacterForwardDynamicNode
;
35
class
ndCharacterInverseDynamicNode
;
36
37
class
ndCharacterLoadDescriptor
:
public
ndLoadSaveBase::ndLoadDescriptor
38
{
39
public
:
40
ndCharacterLoadDescriptor
()
41
:
ndLoadSaveBase::ndLoadDescriptor
()
42
,m_limbMap(
nullptr
)
43
{
44
}
45
46
ndCharacterLoadDescriptor
(
const
ndLoadSaveBase::ndLoadDescriptor
& desc)
47
:ndLoadDescriptor(desc)
48
,m_limbMap(
nullptr
)
49
{
50
ndCharacterLoadDescriptor
*
const
modelDesc = (
ndCharacterLoadDescriptor
*)&desc;
51
m_rootNode = desc.m_rootNode;
52
m_limbMap = modelDesc->m_limbMap;
53
}
54
55
ndCharacterLoadDescriptor
(
const
ndLoadSaveBase::ndLoadDescriptor
& desc,
ndTree<const ndCharacterNode*, ndUnsigned32>
*
const
limbMap)
56
:ndLoadDescriptor(desc)
57
,m_limbMap(limbMap)
58
{
59
}
60
61
ndCharacterLoadDescriptor
(
const
ndCharacterLoadDescriptor
& desc)
62
:ndLoadDescriptor(desc)
63
,m_limbMap(desc.m_limbMap)
64
{
65
}
66
67
ndTree<const ndCharacterNode*, ndUnsigned32>
* m_limbMap;
68
};
69
70
class
ndCharacterSaveDescriptor
:
public
ndLoadSaveBase::ndSaveDescriptor
71
{
72
public
:
73
ndCharacterSaveDescriptor
()
74
:
ndLoadSaveBase::ndSaveDescriptor
()
75
,m_limbMap(
nullptr
)
76
{
77
}
78
79
ndCharacterSaveDescriptor
(
const
ndLoadSaveBase::ndSaveDescriptor
& desc)
80
:
ndLoadSaveBase::ndSaveDescriptor
(desc)
81
,m_limbMap(
nullptr
)
82
{
83
}
84
85
ndCharacterSaveDescriptor
(
const
ndCharacterSaveDescriptor
& desc,
nd::TiXmlNode
*
const
rootNode)
86
:
ndLoadSaveBase::ndSaveDescriptor
(desc, rootNode)
87
,m_limbMap(desc.m_limbMap)
88
{
89
}
90
91
ndTree<ndInt32, const ndCharacterNode*>
* m_limbMap;
92
};
93
94
class
ndCharacterNode
:
public
ndNodeHierarchy
<ndCharacterNode>
95
{
96
public
:
97
D_CLASS_REFLECTION(
ndCharacterNode
);
98
D_NEWTON_API
ndCharacterNode
(
const
ndCharacterLoadDescriptor
& desc);
99
D_NEWTON_API
ndCharacterNode
(
ndCharacterNode
*
const
parent);
100
D_NEWTON_API
virtual
~
ndCharacterNode
();
101
102
virtual
ndBodyDynamic
* GetBody()
const
;
103
virtual
ndJointBilateralConstraint
* GetJoint()
const
;
104
105
virtual
ndCharacterNode
* GetAsNode();
106
virtual
ndCharacterRootNode
* GetAsRootNode();
107
virtual
ndCharacterForwardDynamicNode
* GetAsForwardDynamicNode();
108
virtual
ndCharacterInverseDynamicNode
* GetAsInverseDynamicNode();
109
110
const
ndMatrix
& GetLocalPose()
const
;
111
void
SetLocalPose(
const
ndMatrix
& matrix);
112
113
//virtual void UpdateGlobalPose(ndWorld* const world, dFloat32 timestep);
114
//virtual void CalculateLocalPose(ndWorld* const world, dFloat32 timestep);
115
virtual
void
Debug(
ndConstraintDebugCallback
& context)
const
;
116
117
//D_NEWTON_API virtual ndMatrix GetBoneMatrix() const;
118
119
protected
:
120
D_NEWTON_API
ndCharacterNode
* CreateClone()
const
;
121
D_NEWTON_API
virtual
void
Save(
const
ndCharacterSaveDescriptor
& desc)
const
;
122
123
ndMatrix
m_localPose;
124
};
125
126
inline
ndBodyDynamic
* ndCharacterNode::GetBody()
const
127
{
128
return
nullptr
;
129
}
130
131
inline
ndJointBilateralConstraint
* ndCharacterNode::GetJoint()
const
132
{
133
return
nullptr
;
134
}
135
136
//inline void ndCharacterNode::UpdateGlobalPose(ndWorld* const, dFloat32)
137
//{
138
//}
139
//
140
//inline void ndCharacterNode::CalculateLocalPose(ndWorld* const, dFloat32)
141
//{
142
//}
143
144
inline
ndCharacterNode
* ndCharacterNode::GetAsNode()
145
{
146
return
this
;
147
}
148
149
inline
ndCharacterRootNode
* ndCharacterNode::GetAsRootNode()
150
{
151
ndAssert(0);
152
return
nullptr
;
153
}
154
155
inline
ndCharacterInverseDynamicNode
* ndCharacterNode::GetAsInverseDynamicNode()
156
{
157
ndAssert(0);
158
return
nullptr
;
159
}
160
161
inline
ndCharacterForwardDynamicNode
* ndCharacterNode::GetAsForwardDynamicNode()
162
{
163
ndAssert(0);
164
return
nullptr
;
165
}
166
167
inline
const
ndMatrix
& ndCharacterNode::GetLocalPose()
const
168
{
169
return
m_localPose;
170
}
171
172
inline
void
ndCharacterNode::SetLocalPose(
const
ndMatrix
& matrix)
173
{
174
m_localPose = matrix;
175
}
176
177
#endif
nd::TiXmlNode
The parent class for everything in the Document Object Model.
Definition:
tinyxml.h:437
ndCharacterLoadDescriptor
Definition:
ndCharacterNode.h:38
ndCharacterNode
Definition:
ndCharacterNode.h:95
ndTree< const ndCharacterNode *, ndUnsigned32 >
ndCharacterRootNode
Definition:
ndCharacterRootNode.h:29
ndCharacter
Definition:
ndCharacter.h:45
ndBodyDynamic
Definition:
ndBodyDynamic.h:43
ndJointBilateralConstraint
Definition:
ndJointBilateralConstraint.h:53
ndConstraintDebugCallback
Definition:
ndConstraint.h:42
ndCharacterInverseDynamicNode
Definition:
ndCharacterInverseDynamicNode.h:29
ndMatrix
Definition:
ndMatrix.h:42
ndNodeHierarchy
Definition:
ndNodeHierarchy.h:20
ndCharacterSaveDescriptor
Definition:
ndCharacterNode.h:71
ndCharacterForwardDynamicNode
Definition:
ndCharacterForwardDynamicNode.h:31
ndLoadSaveBase::ndLoadDescriptor
Definition:
ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition:
ndSaveLoadSytem.h:93
ndWorld
Definition:
ndWorld.h:47
newton-dynamics
newton-4.00
sdk
dNewton
dModels
dCharacter
ndCharacterNode.h
Generated by
1.8.20