Skip to content

Commit

Permalink
camanim nearly matched
Browse files Browse the repository at this point in the history
  • Loading branch information
rjkiv committed Jul 3, 2024
1 parent c1aa892 commit 2016be0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/system/math/Rot.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ void Invert(const Transform&, Transform&);
void Interp(const Vector3&, const Vector3&, float, Vector3&);
void Interp(const Hmx::Quat&, const Hmx::Quat&, float, Hmx::Quat&);
void Interp(const Hmx::Color&, const Hmx::Color&, float, Hmx::Color&);
void Interp(float, float, float, float&);

inline void Interp(float f1, float f2, float f3, float& fres){
fres = f3 * (f2 - f1) + f1;
}

TextStream& operator<<(TextStream& ts, const Hmx::Quat& v);
TextStream& operator<<(TextStream& ts, const Vector3& v);
Expand Down
6 changes: 3 additions & 3 deletions src/system/rndobj/Anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RndAnimatable : public virtual Hmx::Object {
virtual bool Loop(){ return 0; }
virtual void StartAnim(){}
virtual void EndAnim(){}
virtual void SetFrame(float frame, float blend); // weak
virtual void SetFrame(float frame, float blend){ mFrame = frame; }
virtual float StartFrame(){ return 0.0f; }
virtual float EndFrame(){ return 0.0f; }
virtual Hmx::Object* AnimTarget(){ return this; }
Expand All @@ -55,8 +55,8 @@ class RndAnimatable : public virtual Hmx::Object {
float FramesPerUnit();
bool ConvertFrames(float&);

float mFrame;
Rate mRate;
float mFrame; // 0x8
Rate mRate; // 0xc
};

class AnimTask : public Task {
Expand Down
4 changes: 4 additions & 0 deletions src/system/rndobj/Cam.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class RndCam : public RndTransformable {
DataNode OnSetZRange(const DataArray*);
DataNode OnSetScreenRect(const DataArray*);
DataNode OnFarPlane(const DataArray*);

float NearPlane() const { return mNearPlane; }
float FarPlane() const { return mFarPlane; }
float YFov() const { return mYFov; }

static RndCam* sCurrent;
NEW_OBJ(RndCam)
Expand Down
27 changes: 24 additions & 3 deletions src/system/rndobj/CamAnim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,31 @@ void RndCamAnim::Replace(Hmx::Object* from, Hmx::Object* to){
}
}

// fn_805CE7DC
void RndCamAnim::SetFrame(float frame, float blend){
RndAnimatable::SetFrame(frame, blend);
if(mCam){
if(!FovKeys().empty()){
float ref = mCam->YFov();
FovKeys().AtFrame(frame, ref);
if(blend != 1.0f){
Interp(mCam->YFov(), ref, blend, ref);
}
mCam->SetFrustum(mCam->NearPlane(), mCam->FarPlane(), ref, 1.0f);
}
}
}

float RndCamAnim::EndFrame(){
Keys<float, float>& theKeys = mKeysOwner->mFovKeys;
if(!theKeys.empty()) return theKeys.back().frame;
else return 0.0f;
return FovKeys().LastFrame();
}

// fn_805CE930
void RndCamAnim::SetKey(float frame){
if(mCam){
const float& val = mCam->YFov();
FovKeys().Add(val, frame, true);
}
}

RndCamAnim::~RndCamAnim(){
Expand Down
8 changes: 5 additions & 3 deletions src/system/rndobj/CamAnim.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class RndCamAnim : public RndAnimatable {
virtual void Replace(Hmx::Object*, Hmx::Object*);
virtual void Print();

Keys<float, float>& FovKeys() { return mKeysOwner->mFovKeys; }

DECLARE_REVS;
NEW_OVERLOAD;
DELETE_OVERLOAD;
Expand All @@ -31,9 +33,9 @@ class RndCamAnim : public RndAnimatable {
REGISTER_OBJ_FACTORY(RndCamAnim)
}

ObjPtr<RndCam, ObjectDir> mCam;
Keys<float, float> mFovKeys;
ObjOwnerPtr<RndCamAnim, ObjectDir> mKeysOwner;
ObjPtr<RndCam, ObjectDir> mCam; // 0x10
Keys<float, float> mFovKeys; // 0x1c
ObjOwnerPtr<RndCamAnim, ObjectDir> mKeysOwner; // 0x24
};

#endif

0 comments on commit 2016be0

Please sign in to comment.