Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
pivot.cpp
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
4
**
5
** This program is free software: you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation, either version 3 of the License, or
8
** (at your option) any later version.
9
**
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
14
**
15
** You should have received a copy of the GNU General Public License
16
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
/* $Header: /Commando/Code/ww3d2/pivot.cpp 1 1/22/01 3:36p Greg_h $ */
20
/***********************************************************************************************
21
*** Confidential - Westwood Studios ***
22
***********************************************************************************************
23
* *
24
* Project Name : Commando / G 3D Library *
25
* *
26
* $Archive:: /Commando/Code/ww3d2/pivot.cpp $*
27
* *
28
* Author:: Greg_h *
29
* *
30
* $Modtime:: 1/08/01 10:04a $*
31
* *
32
* $Revision:: 1 $*
33
* *
34
*---------------------------------------------------------------------------------------------*
35
* Functions: *
36
* PivotClass::PivotClass -- Constructor for PivotClass *
37
* PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
38
* PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
39
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
40
41
#include "
pivot.h
"
42
#include "wwmath.h"
43
#include <
string.h
>
44
45
46
/***********************************************************************************************
47
* PivotClass::PivotClass -- Constructor for PivotClass *
48
* *
49
* INPUT: *
50
* *
51
* OUTPUT: *
52
* *
53
* WARNINGS: *
54
* *
55
* HISTORY: *
56
* 07/24/1997 GH : Created. *
57
*=============================================================================================*/
58
PivotClass::PivotClass
(
void
) :
59
Parent
(
NULL
),
60
BaseTransform
(1),
61
Transform
(1),
62
#ifdef LAZY_CAP_MTX_ALLOC
63
CapTransformPtr(
NULL
),
64
Index
(0),
65
IsVisible
(
true
),
66
WorldSpaceTranslation
(
false
)
67
#else
68
CapTransform
(1),
69
Index
(0),
70
IsVisible
(
true
),
71
WorldSpaceTranslation
(
false
),
72
IsCaptured
(
false
),
73
Unused
(
false
)
74
#endif
75
{
76
Name
[0] = 0;
77
}
78
79
PivotClass::PivotClass
(
const
PivotClass
& that) :
80
Parent
(that.
Parent
),
81
BaseTransform
(that.
BaseTransform
),
82
Transform
(that.
Transform
),
83
#ifdef LAZY_CAP_MTX_ALLOC
84
CapTransformPtr(
NULL
),
85
Index
(that.
Index
),
86
IsVisible
(that.
IsVisible
),
87
WorldSpaceTranslation
(that.
WorldSpaceTranslation
)
88
#else
89
CapTransform
(that.
CapTransform
),
90
Index
(that.
Index
),
91
IsVisible
(that.
IsVisible
),
92
WorldSpaceTranslation
(that.
WorldSpaceTranslation
),
93
IsCaptured
(that.
IsCaptured
),
94
Unused
(that.
Unused
)
95
#endif
96
{
97
memcpy(
Name
, that.
Name
,
sizeof
(
Name
));
98
#ifdef LAZY_CAP_MTX_ALLOC
99
if
(that.CapTransformPtr !=
NULL
)
100
{
101
CapTransformPtr =
MSGW3DNEW
(
"PivotClassCaptureBoneMtx"
)
DynamicMatrix3D
;
102
CapTransformPtr->
Mat
= that.CapTransformPtr->Mat;
103
}
104
#endif
105
}
106
107
PivotClass
&
PivotClass::operator=
(
const
PivotClass
& that)
108
{
109
if
(
this
!= &that)
110
{
111
memcpy(
Name
, that.
Name
,
sizeof
(
Name
));
112
Parent
= that.
Parent
;
113
BaseTransform
= that.
BaseTransform
;
114
Transform
= that.
Transform
;
115
#ifdef LAZY_CAP_MTX_ALLOC
116
CapTransformPtr =
NULL
;
117
Index
= that.
Index
;
118
IsVisible
= that.
IsVisible
;
119
WorldSpaceTranslation
= that.
WorldSpaceTranslation
;
120
if
(that.CapTransformPtr !=
NULL
)
121
{
122
CapTransformPtr =
MSGW3DNEW
(
"PivotClassCaptureBoneMtx"
)
DynamicMatrix3D
;
123
CapTransformPtr->
Mat
= that.CapTransformPtr->Mat;
124
}
125
#else
126
CapTransform
= that.
CapTransform
;
127
Index
= that.
Index
;
128
IsVisible
= that.
IsVisible
;
129
WorldSpaceTranslation
= that.
WorldSpaceTranslation
;
130
IsCaptured
= that.
IsCaptured
;
131
Unused
= that.
Unused
;
132
#endif
133
}
134
return
*
this
;
135
}
136
137
void
PivotClass::Capture_Update
(
void
)
138
{
139
#ifdef LAZY_CAP_MTX_ALLOC
140
if
(!CapTransformPtr)
141
return
;
142
143
const
Matrix3D
* ct = &CapTransformPtr->Mat;
144
#else
145
const
Matrix3D
* ct = &
CapTransform
;
146
#endif
147
148
if
(
WorldSpaceTranslation
)
149
{
150
// The Translation of CapTransform is meant to be in world space,
151
// so remove before applying orientation
152
Matrix3D
CapOrientation = *ct;
153
CapOrientation.
Set_Translation
(
Vector3
( 0,0,0 ) );
154
#ifdef ALLOW_TEMPORARIES
155
Matrix3D::Multiply
(
Transform
,CapOrientation,&(
Transform
));
156
#else
157
Transform
.postMul(CapOrientation);
158
#endif
159
// Now apply translation in world space
160
Transform
.Adjust_Translation( ct->
Get_Translation
() );
161
}
162
else
163
{
164
#ifdef ALLOW_TEMPORARIES
165
Matrix3D::Multiply
(
Transform
, *ct, &(
Transform
));
166
#else
167
Transform
.postMul(*ct);
168
#endif
169
}
170
}
171
NULL
#define NULL
Definition
BaseType.h:92
MSGW3DNEW
#define MSGW3DNEW(MSG)
Definition
always.h:107
true
@ true
Definition
bool.h:59
false
@ false
Definition
bool.h:59
DynamicMatrix3D
Definition
matrix3d.h:1813
DynamicMatrix3D::Mat
Matrix3D Mat
Definition
matrix3d.h:1816
Matrix3D
Definition
matrix3d.h:133
Matrix3D::Multiply
static void Multiply(const Matrix3D &A, const Matrix3D &B, Matrix3D *set_result)
Definition
matrix3d.cpp:640
Matrix3D::Set_Translation
WWINLINE void Set_Translation(const Vector3 &t)
Definition
matrix3d.h:219
Matrix3D::Get_Translation
WWINLINE Vector3 Get_Translation(void) const
Definition
matrix3d.h:217
Vector3
Definition
vector3.h:85
pivot.h
string.h
PivotClass::CapTransform
Matrix3D CapTransform
Definition
pivot.h:102
PivotClass::BaseTransform
Matrix3D BaseTransform
Definition
pivot.h:92
PivotClass::Parent
PivotClass * Parent
Definition
pivot.h:91
PivotClass::Transform
Matrix3D Transform
Definition
pivot.h:93
PivotClass::PivotClass
PivotClass(void)
Definition
pivot.cpp:58
PivotClass::IsCaptured
bool IsCaptured
Definition
pivot.h:106
PivotClass::operator=
PivotClass & operator=(const PivotClass &that)
Definition
pivot.cpp:107
PivotClass::Unused
bool Unused
Definition
pivot.h:107
PivotClass::Name
char Name[W3D_NAME_LEN]
Definition
pivot.h:90
PivotClass::IsVisible
bool IsVisible
Definition
pivot.h:104
PivotClass::WorldSpaceTranslation
bool WorldSpaceTranslation
Definition
pivot.h:105
PivotClass::Capture_Update
void Capture_Update(void)
Definition
pivot.cpp:137
PivotClass::Index
int Index
Definition
pivot.h:103
Code
Libraries
Source
WWVegas
WW3D2
pivot.cpp
Generated by
1.13.2