Skip to content

Commit 6f3aff6

Browse files
committed
AnimationOmni_Z: Match
1 parent d5a229f commit 6f3aff6

File tree

5 files changed

+183
-12
lines changed

5 files changed

+183
-12
lines changed

src/Engine/AnimationOmni_Z.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "AnimationOmni_Z.h"
2+
#include "Program_Z.h"
3+
#include "Omni_Z.h"
4+
5+
void AnimationOmni_Z::UpdateFrame(Float i_Time, Omni_Z* i_Omni) {
6+
// Start
7+
if (m_StartKfr.GetNbKeys()) {
8+
Float l_StartValue;
9+
m_StartKfr.GetValue(i_Time, l_StartValue);
10+
i_Omni->SetStart(l_StartValue);
11+
}
12+
13+
// End
14+
if (m_EndKfr.GetNbKeys()) {
15+
Float l_EndValue;
16+
m_EndKfr.GetValue(i_Time, l_EndValue);
17+
i_Omni->SetEnd(l_EndValue);
18+
}
19+
20+
// Color
21+
if (m_ColorKfr.GetNbKeys()) {
22+
Vec3f l_ColorValue;
23+
m_ColorKfr.GetValue(i_Time, l_ColorValue);
24+
i_Omni->SetColor(l_ColorValue);
25+
}
26+
}
27+
28+
void AnimationOmni_Z::Load(void** i_Data) {
29+
gData.ClassMgr->LoadName(m_ObjectName, i_Data);
30+
LOAD_Z(m_ObjectId);
31+
m_ColorKfr.Load(i_Data);
32+
m_StartKfr.Load(i_Data);
33+
m_EndKfr.Load(i_Data);
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
#ifndef _ANIMATIONOMNI_Z_H_
22
#define _ANIMATIONOMNI_Z_H_
3+
#include "Keyframer_Z.h"
4+
#include "Name_Z.h"
35
#include "Types_Z.h"
6+
7+
class Omni_Z;
8+
9+
class AnimationOmni_Z {
10+
private:
11+
Name_Z m_ObjectName; // Omni Node name
12+
S16 m_ObjectId; // Omni Node index
13+
KeyframerVec3fComp_Z m_ColorKfr;
14+
KeyframerFloatComp_Z m_StartKfr;
15+
KeyframerFloatComp_Z m_EndKfr;
16+
17+
public:
18+
void UpdateFrame(Float i_Time, Omni_Z* i_Omni);
19+
void Load(void** i_Data);
20+
};
21+
422
#endif // _ANIMATIONOMNI_Z_H_

src/Engine/includes/KeyframerBase_Z.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ struct Key_Z {
3333

3434
class Keyframer_Z {
3535
public:
36-
Keyframer_Z()
37-
: m_Flag(FL_KEYFRAMER_SMOOTH) {
36+
U16 GetFlag() const {
37+
return m_Flag;
38+
}
39+
40+
void EnableFlag(U16 i_Flag) {
41+
m_Flag |= i_Flag;
3842
}
3943

4044
public:

src/Engine/includes/Keyframer_Z.h

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#define KEY_QUAT_COMP_FACTOR 2000.0f
1010

1111
struct KeyFlag_Z : public Key_Z {
12+
friend class KeyframerFlag_Z;
13+
1214
public:
1315
KeyFlag_Z() {
1416
}
@@ -309,6 +311,10 @@ struct KeyVec3fComp_Z : public Key_Z {
309311

310312
void Set(Vec3f const& i_Value, Vec3f const& i_TgtIn, Vec3f const& i_TgtOut);
311313

314+
inline Vec3f Get() const {
315+
return Vec3f(m_ValueX * (1.0f / KEY_FLOAT_COMP_FACTOR), m_ValueY * (1.0f / KEY_FLOAT_COMP_FACTOR), m_ValueZ * (1.0f / KEY_FLOAT_COMP_FACTOR));
316+
}
317+
312318
inline void Get(Vec3f& o_Value) const {
313319
GetValue(o_Value);
314320
}
@@ -319,12 +325,20 @@ struct KeyVec3fComp_Z : public Key_Z {
319325
o_Value.z = m_ValueZ * (1.0f / KEY_FLOAT_COMP_FACTOR);
320326
}
321327

328+
inline Vec3f GetTgtIn() const {
329+
return Vec3f(m_TgtInX * (1.0f / KEY_FLOAT_COMP_FACTOR), m_TgtInY * (1.0f / KEY_FLOAT_COMP_FACTOR), m_TgtInZ * (1.0f / KEY_FLOAT_COMP_FACTOR));
330+
}
331+
322332
inline void GetTgtIn(Vec3f& o_TgtIn) const {
323333
o_TgtIn.x = m_TgtInX * (1.0f / KEY_FLOAT_COMP_FACTOR);
324334
o_TgtIn.y = m_TgtInY * (1.0f / KEY_FLOAT_COMP_FACTOR);
325335
o_TgtIn.z = m_TgtInZ * (1.0f / KEY_FLOAT_COMP_FACTOR);
326336
}
327337

338+
inline Vec3f GetTgtOut() const {
339+
return Vec3f(m_TgtOutX * (1.0f / KEY_FLOAT_COMP_FACTOR), m_TgtOutY * (1.0f / KEY_FLOAT_COMP_FACTOR), m_TgtOutZ * (1.0f / KEY_FLOAT_COMP_FACTOR));
340+
}
341+
328342
inline void GetTgtOut(Vec3f& o_TgtOut) const {
329343
o_TgtOut.x = m_TgtOutX * (1.0f / KEY_FLOAT_COMP_FACTOR);
330344
o_TgtOut.y = m_TgtOutY * (1.0f / KEY_FLOAT_COMP_FACTOR);
@@ -452,6 +466,10 @@ struct KeyVec2fLinearComp_Z : public Key_Z {
452466
m_ValueY = i_Value.y * KEY_FLOAT_COMP_FACTOR;
453467
}
454468

469+
inline const Vec2f Get() const {
470+
return Vec2f(m_ValueX * (1.0f / KEY_FLOAT_COMP_FACTOR), m_ValueY * (1.0f / KEY_FLOAT_COMP_FACTOR));
471+
}
472+
455473
inline void Get(Vec2f& o_Value) const {
456474
GetValue(o_Value);
457475
}
@@ -484,6 +502,12 @@ struct KeyVec4fLinear_Z : public Key_Z {
484502
GetValue(o_Value);
485503
}
486504

505+
inline void Get(Vec3f& o_Value) const {
506+
o_Value.x = m_Value.x;
507+
o_Value.y = m_Value.y;
508+
o_Value.z = m_Value.z;
509+
}
510+
487511
inline void GetValue(Vec4f& o_Value) const {
488512
o_Value = m_Value;
489513
}
@@ -610,7 +634,7 @@ class KeyframerHdl_Z {
610634
m_Keys.Flush();
611635
}
612636

613-
S32 GetValue(Float i_Time, BaseObject_ZHdl& o_Value, S32 i_KeyOffset = 1) const;
637+
S32 GetValue(Float i_Time, BaseObject_ZHdl& o_Value, S32 i_KeyOffset = 1);
614638
void Load(void** i_Data);
615639
void MarkHandles();
616640
void UpdateLinks();
@@ -661,8 +685,8 @@ class KeyframerFloat_Z : public Keyframer_Z {
661685
m_Keys.Flush();
662686
}
663687

664-
S32 GetValue(Float i_Time, Float& o_Value, Bool& o_Side, S32 i_KeyOffset = 1) const;
665-
S32 GetValue(Float i_Time, Float& o_Value, S32 i_KeyOffset = 1) const;
688+
S32 GetValue(Float i_Time, Float& o_Value, Bool& o_Side, S32 i_KeyOffset = 1);
689+
S32 GetValue(Float i_Time, Float& o_Value, S32 i_KeyOffset = 1);
666690
S32 GetCctValue(S32 i_StartKey, S32 i_KeyCount, Float i_Time, Float& o_Value, S32 i_KeyOffset = 1) const;
667691
void Load(void** i_Data);
668692

@@ -712,8 +736,8 @@ class KeyframerFloatComp_Z : public Keyframer_Z {
712736
m_Keys.Flush();
713737
}
714738

715-
S32 GetValue(Float i_Time, Float& o_Value, Bool& o_Side, S32 i_KeyOffset = 1) const;
716-
S32 GetValue(Float i_Time, Float& o_Value, S32 i_KeyOffset = 1) const;
739+
S32 GetValue(Float i_Time, Float& o_Value, Bool& o_Side, S32 i_KeyOffset = 1);
740+
S32 GetValue(Float i_Time, Float& o_Value, S32 i_KeyOffset = 1);
717741
S32 GetCctValue(S32 i_StartKey, S32 i_KeyCount, Float i_Time, Float& o_Value, S32 i_KeyOffset = 1) const;
718742
void Load(void** i_Data);
719743

@@ -862,7 +886,7 @@ class KeyframerRot_Z {
862886
m_Keys.Flush();
863887
}
864888

865-
S32 GetValue(Float i_Time, Quat& o_Value, S32 i_KeyOffset = 1) const;
889+
S32 GetValue(Float i_Time, Quat& o_Value, S32 i_KeyOffset = 1);
866890
S32 GetCctValue(S32 i_StartKey, S32 i_KeyCount, Float i_Time, Quat& o_Value, S32 i_KeyOffset = 1) const;
867891
void Load(void** i_Data);
868892

@@ -1000,7 +1024,7 @@ class KeyframerVec3fComp_Z : public Keyframer_Z {
10001024
m_Keys.Flush();
10011025
}
10021026

1003-
S32 GetValue(Float i_Time, Vec3f& o_Value, S32 i_KeyOffset = 1) const;
1027+
S32 GetValue(Float i_Time, Vec3f& o_Value, S32 i_KeyOffset = 1);
10041028
S32 GetCctValue(S32 i_StartKey, S32 i_KeyCount, Float i_Time, Vec3f& o_Value, S32 i_KeyOffset = 1) const;
10051029
void Load(void** i_Data);
10061030

@@ -1061,6 +1085,10 @@ class KeyframerVec3fLinear_Z : public Keyframer_Z {
10611085

10621086
class KeyframerExtVec3f_Z : public Keyframer_Z {
10631087
public:
1088+
KeyframerExtVec3f_Z() {
1089+
m_Flag = FL_KEYFRAMER_SMOOTH;
1090+
}
1091+
10641092
inline S32 GetNbKeys() const {
10651093
return m_Keys.GetSize();
10661094
}
@@ -1097,7 +1125,7 @@ class KeyframerExtVec3f_Z : public Keyframer_Z {
10971125
m_Keys.Flush();
10981126
}
10991127

1100-
S32 GetValue(Float i_Time, Vec3f& o_Value, S32 i_KeyOffset = 1) const;
1128+
S32 GetValue(Float i_Time, Vec3f& o_Value, S32 i_KeyOffset = 1);
11011129
void Load(void** i_Data);
11021130

11031131
private:
@@ -1245,7 +1273,7 @@ class KeyframerVec4fLinear_Z : public Keyframer_Z {
12451273
m_Keys.Flush();
12461274
}
12471275

1248-
S32 GetValue(Float i_Time, Vec4f& o_Value, S32 i_KeyOffset = 1) const;
1276+
S32 GetValue(Float i_Time, Vec4f& o_Value, S32 i_KeyOffset = 1);
12491277
void Load(void** i_Data);
12501278

12511279
KeyframerVec4fLinear_Z& operator=(const KeyframerVec4fLinear_Z& i_Kfr) {

src/Engine/includes/Omni_Z.h

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,91 @@
11
#ifndef _OMNI_Z_H_
22
#define _OMNI_Z_H_
3-
#include "Types_Z.h"
3+
#include "Object_Z.h"
4+
#include "MaterialAnim_ZHdl.h"
5+
#include "Material_ZHdl.h"
6+
7+
class Omni_Z : public Object_Z {
8+
private:
9+
Mat4x4 m_TextureProjMat;
10+
Vec3f m_Color;
11+
Float m_Intensity; // Scales the final color
12+
Vec3f m_ScaledColor; // Color after intensity applied
13+
Float m_SpotInnerHalfAngleRad; // Inner angle for spotlight (unused in MASTER code but math is right) - Originally called InnerHalfRad
14+
Float m_SpotOuterHalfAngleRad; // Cutoff angle in radians for spotlight - Originally called OuterHalfRad
15+
Float m_SpotAtt0; // = -1 / (cos(spotInnerHalfAngleRad) - cos(spotOuterHalfAngleRad)) - Baked from angles
16+
Float m_SpotAtt1; // = 1 + (cos(spotOuterHalfAngleRad) / (cos(spotInnerHalfAngleRad) - cos(spotOuterHalfAngleRad))) - Baked from angles
17+
Float m_Start; // Start of falloff (linear interp on pc at least)
18+
Float m_End; // End of falloff (linear interp on pc at least)
19+
MaterialAnim_ZHdl m_MaterialAnimHdl;
20+
Material_ZHdl m_MaterialHdl;
21+
22+
public:
23+
Omni_Z();
24+
25+
virtual ~Omni_Z() { }
26+
27+
virtual void Load(void** i_Data);
28+
virtual void EndLoad();
29+
virtual void AfterEndLoad();
30+
virtual Bool MarkHandles();
31+
virtual void Draw(DrawInfo_Z& i_DrawInfo, ObjectDatas_Z* i_Data);
32+
virtual void UpdateObject(Node_Z* i_Node, ObjectDatas_Z* i_Data);
33+
34+
void Changed();
35+
// TODO: Define OmniFrust_Z
36+
//static void InFrustrum(DrawInfo_Z& i_DrawInfo, const Sphere_Z& i_UnkSph, Node_Z* i_Node, Omni_Z* i_Omni, OmniFrust_Z& i_OmniFrust, U8 i_Index);
37+
static U32 SetOmnis(const Box_Z& i_UnkBox, DrawInfo_Z& i_DrawInfo, Bool i_LocalValue, Bool i_UnkBool, U32 i_UnkU32_1, U32 i_UnkU32_2);
38+
static U32 SubOmnis(const Sphere_Z& i_UnkSph, const Box_Z& i_UnkBox, DrawInfo_Z& i_DrawInfo, U32 i_UnkU32_1, U32 i_UnkU32_2);
39+
40+
inline void SetColor(const Vec3f& i_Color) {
41+
m_Color = i_Color;
42+
Changed();
43+
}
44+
45+
inline const Vec3f& GetColor() const {
46+
return m_ScaledColor;
47+
}
48+
49+
inline void SetIntensity(Float i_Intensity) {
50+
m_Intensity = i_Intensity;
51+
Changed();
52+
}
53+
54+
inline Float GetIntensity() const {
55+
return m_Intensity;
56+
}
57+
58+
void SetSpot(Float i_InnerHalfAngleDeg, Float i_OuterHalfAngleDeg);
59+
60+
inline Float GetSpotAtt0() const {
61+
return m_SpotAtt0;
62+
}
63+
64+
inline Float GetSpotAtt1() const {
65+
return m_SpotAtt1;
66+
}
67+
68+
inline void SetStart(Float i_Start) { m_Start = i_Start; }
69+
70+
inline Float GetStart() const { return m_Start; }
71+
72+
void SetEnd(Float i_End);
73+
74+
inline Float GetEnd() const { return m_End; }
75+
76+
inline void SetMaterial(const Material_ZHdl& i_Material) {
77+
m_MaterialHdl = i_Material;
78+
}
79+
80+
inline const Material_ZHdl& GetMaterial() const {
81+
return m_MaterialHdl;
82+
}
83+
84+
void SetMaterialAnim(const MaterialAnim_ZHdl& i_MaterialAnim);
85+
86+
inline const MaterialAnim_ZHdl& GetMaterialAnim() const {
87+
return m_MaterialAnimHdl;
88+
}
89+
};
90+
491
#endif // _OMNI_Z_H_

0 commit comments

Comments
 (0)