a lot of camera progress

This commit is contained in:
shibbo 2020-07-07 03:23:12 -04:00
parent 80c6107813
commit 2d2fb25679
18 changed files with 395 additions and 199 deletions

View File

@ -0,0 +1,12 @@
#pragma once
#include "Camera/Camera.h"
class CamTranslatorAnim
{
public:
Camera* getCamera() const;
u32 _0;
Camera* mCamera; // _4
};

View File

@ -4,6 +4,12 @@
#include "JGeometry/TMatrix34.h"
#include "Actor/NameObj/NameObj.h"
class CamTranslatorDummy
{
public:
inline CamTranslatorDummy();
};
class Camera : public NameObj
{
public:
@ -11,8 +17,9 @@ public:
void setZoneMtx(s32);
u32 _C;
CameraPoseParam* mParams; // _10
u32 _14;
u32 _18;
JGeometry::TMatrix34<JGeometry::SMatrix34C<f32>> mMtx; // _1C
JGeometry::TMatrix34<JGeometry::SMatrix34C<f32> > mMtx; // _1C
};

View File

@ -1,5 +1,44 @@
#pragma once
#include "Camera/Camera.h"
#include "Camera/CameraParallel.h"
#include "Actor/NameObj/NameObj.h"
#include <revolution.h>
struct CameraEntry
{
const char* mName;
const char* mType;
Camera* (*mCreationFunc)(void);
s32 mUnk;
};
class CameraHolder : public NameObj
{
public:
CameraHolder(const char *);
s8 getIndexOf(const char *) const;
Camera* getDefaultCamera();
s8 getIndexOfDefault() const;
s8 mDefaultCameraIdx; // _C
};
namespace
{
template<typename T>
Camera* createCamera();
template<>
Camera* createCamera<CameraParallel>()
{
return new CameraParallel("平行カメラ");
}
const CameraEntry sCameraTable[0x1] =
{
{ "CAM_TYPE_XZ_PARA", "並行", createCamera<CameraParallel>, 0x1000000 }
};
};

View File

@ -0,0 +1,9 @@
#pragma once
#include "Camera/Camera.h"
class CameraParallel : public Camera
{
public:
CameraParallel(const char *);
};

View File

@ -0,0 +1,93 @@
#pragma once
#include "Camera/CameraHolder.h"
#include "Camera/CameraParamChunkID.h"
#include "Camera/CameraParamString.h"
#include "Camera/DotCamParams.h"
#include "JGeometry/TVec3.h"
namespace
{
const char* sFlagName[0x6] =
{
"flag.noreset",
"flag.nofovy",
"flag.lofserpoff",
"flag.antibluroff",
"flag.collisionoff",
"flag.subjectiveoff"
};
};
class CameraGeneralParam
{
public:
CameraGeneralParam();
CameraGeneralParam* operator=(const CameraGeneralParam &);
f32 _0;
JGeometry::TVec3<f32> _4;
JGeometry::TVec3<f32> _10;
JGeometry::TVec3<f32> _1C;
f32 _28;
f32 _2C;
u32 _30;
u32 _34;
CameraParamString mStringParam; // _38
};
class CameraParamChunk
{
public:
class ExParam
{
public:
ExParam();
void init();
JGeometry::TVec3<f32> mWOffset; // _0
f32 mLOffset; // _C
f32 mLOffsetV; // _10
f32 mRoll; // _14
f32 mFovy; // _18
s32 mCamInt; // _1C
u16 mFlags; // _20
f32 mUpper; // _24
f32 mLower; // _28
u32 mGNDInt; // _2C
f32 mUPlay; // _30
f32 mLPlay; // _34
u32 mPushDelay; // _38
u32 mPushDelayLow; // _3C
u32 mUDown; // _40
u32 mVPanUse; // _44
JGeometry::TVec3<f32> mPanAxis; // _48
};
CameraParamChunk(CameraHolder *, const CameraParamChunkID &);
virtual void copy(const CameraParamChunk *);
virtual void load(DotCamReader *, CameraHolder *);
virtual void initiate();
virtual const char* getClassName() const;
s32 getZoneID() const;
bool isOnNoReset() const;
bool isOnUseFovy() const;
bool isLOfsErpOff() const;
bool isAntiBlurOff() const;
bool isCollisionOff() const;
bool isSubjectiveCameraOff() const;
void getVPanAxis(JGeometry::TVec3<f32> *) const;
void setUseFovy(bool);
void setLOFsErpOff(bool);
void setCollisionOff(bool);
CameraParamChunkID* mChunk; // _4
s8 mDefaultCamera; // _8
CameraParamChunk::ExParam mParams; // _C
CameraGeneralParam mGeneralParams; // _60
};

View File

@ -0,0 +1,14 @@
#pragma once
class CameraParamString
{
public:
CameraParamString();
CameraParamString* operator=(const CameraParamString &);
void setCharPtr(const char *);
const char* getCharPtr() const;
void copy(const char *);
const char* mCharPtr; // _0
};

View File

@ -15,6 +15,7 @@ public:
JGeometry::TVec3<f32> _C;
JGeometry::TVec3<f32> _18;
JGeometry::TVec3<f32> _24;
f32 _30;
JGeometry::TVec3<f32> _34;
JGeometry::TVec3<f32> _40;
f32 _4C;

View File

@ -1,7 +1,7 @@
#pragma once
#include <revolution.h>
#include "JGeometry/TVec3.h"
#include "JMap/JMapInfoIter.h"
class DotCamReader
{
@ -13,20 +13,26 @@ public:
virtual bool getValueInt(const char *, s32 *) = 0;
virtual bool getValueFloat(const char *, f32 *) = 0;
virtual void getValueVec(const char *, JGeometry::TVec3<f32> *) = 0;
virtual bool getValueString(const char *, const char **) = 0;
virtual s32 getValueString(const char *, const char **) = 0;
};
class DotCamReaderInBin : DotCamReader
class DotCamReaderInBin : public DotCamReader
{
public:
DotCamReaderInBin(const void *);
virtual ~DotCamReaderInBin();
virtual s32 getVersion() const;
virtual bool hasMoreChunk() const;
virtual void nextToChunk();
virtual bool getValueInt(const char *, s32 *);
virtual bool getValueFloat(const char *, f32 *);
virtual void getValueVec(const char *, JGeometry::TVec3<f32> *);
virtual bool getValueString(const char *, const char **);
virtual s32 getValueString(const char *, const char **);
void init(const void *);
s32 mVersion; // _4
u32 _8;
JMapInfo mInfo; // _C
JMapInfoIter mIter; // _14
};

View File

@ -41,6 +41,7 @@ class JMapInfo
public:
JMapInfo();
JMapInfo(u32 val);
~JMapInfo() { }
bool attach(const void *);
@ -49,8 +50,8 @@ public:
s32 searchItemInfo(const char *) const;
s32 getValueType(const char *) const;
s32 getValueFast(s32, s32, const char **) const;
s32 getvalueFast(s32, s32, u32 *) const;
s32 getvalueFast(s32, s32, s32 *) const;
s32 getValueFast(s32, s32, u32 *) const;
s32 getValueFast(s32, s32, s32 *) const;
template<typename T>
void getValue(s32, const char *, T *) const;

View File

@ -1,13 +0,0 @@
#pragma once
#include "Actor/NameObj/NameObj.h"
class CameraHolder : public NameObj
{
public:
CameraHolder(const char *);
s32 getIndexOf(const char *) const;
s32 getIndexOfDefault() const;
};

View File

@ -1,41 +0,0 @@
#pragma once
#include <revolution.h>
#include "JGeometry/TVec3.h"
#include "System/Camera/DotCamParams.h"
#include "System/Camera/CameraHolder.h"
class CameraParamChunk
{
public:
s32 getZoneID() const;
bool isOnNoReset() const;
bool isOnUseFovy() const;
bool isLOfsErpOff() const;
bool isAntiBlurOff() const;
bool isCollisionOff() const;
bool isSubjectiveCameraOff() const;
void getVPanAxis(JGeometry::TVec3<f32> *) const;
void load(DotCamReader *, CameraHolder *);
void setUseFovy(bool);
void setLOFsErpOff(bool);
void setCollisionOff(bool);
void arrangeCamTypeName(u32, const char**);
u8 _0[0xC];
JGeometry::TVec3<f32> mWOffset; // _C
f32 mLOffset; // _18
f32 mLOffsetV; // _1C
f32 mRoll; // _20
f32 mFovy; // _24
s32 mCamInt; // _28
u16 mFlags; // _2C
u8 _2E[0x54-0x2E];
f32 mVPanAxisX; // _54
f32 mVPanAxisY; // _58
f32 mVPanAxisZ; // _5C
};

9
source/Camera/Camera.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "Camera/Camera.h"
Camera::Camera(const char *pName) : NameObj(pName)
{
mParams = new CameraPoseParam();
_14 = 0;
_18 = 0;
mMtx.identity();
}

View File

@ -1 +1,6 @@
#include "Camera/CameraHolder.h"
namespace
{
}

View File

@ -0,0 +1,84 @@
#include "Camera/CameraParamChunk.h"
#include "MR/MathUtil.h"
#include "string.h"
bool CameraParamChunk::isOnNoReset() const
{
return mParams.mFlags & 0x1;
}
bool CameraParamChunk::isOnUseFovy() const
{
return (mParams.mFlags >> 1) & 0x1;
}
bool CameraParamChunk::isLOfsErpOff() const
{
return (mParams.mFlags >> 2) & 0x1;
}
bool CameraParamChunk::isAntiBlurOff() const
{
return (mParams.mFlags >> 3) & 0x1;
}
bool CameraParamChunk::isCollisionOff() const
{
return (mParams.mFlags >> 4) & 0x1;
}
bool CameraParamChunk::isSubjectiveCameraOff() const
{
return (mParams.mFlags >> 5) & 0x1;
}
void CameraParamChunk::getVPanAxis(JGeometry::TVec3<f32> *out) const
{
out->x = mParams.mPanAxis.x;
out->y = mParams.mPanAxis.y;
out->z = mParams.mPanAxis.z;
if (MR::isNearZero(*out, 0.001f))
{
out->set<f32>(0.0f, 1.0f, 0.0f);
}
MR::normalize(out);
}
void CameraParamChunk::setUseFovy(bool flag)
{
mParams.mFlags = (mParams.mFlags & 0xFFFFFFFD);
if (flag)
{
mParams.mFlags |= 0x2;
}
}
void CameraParamChunk::setLOFsErpOff(bool flag)
{
mParams.mFlags = (mParams.mFlags & 0xFFFFFFFB);
if (flag)
{
mParams.mFlags |= 0x4;
}
}
void CameraParamChunk::setCollisionOff(bool flag)
{
mParams.mFlags = (mParams.mFlags & 0xFFFFFFEF);
if (flag)
{
mParams.mFlags |= 0x10;
}
}
void CameraParamChunk::initiate()
{
mParams.init();
CameraGeneralParam params;
mGeneralParams = params;
}

View File

@ -0,0 +1,37 @@
#include "Camera/CameraParamString.h"
#include "smg.h"
#include <revolution.h>
CameraParamString::CameraParamString()
{
mCharPtr = nullptr;
}
CameraParamString* CameraParamString::operator=(const CameraParamString &otherParam)
{
copy(otherParam.mCharPtr);
return this;
}
void CameraParamString::setCharPtr(const char *pCharPtr)
{
copy(pCharPtr);
}
const char* CameraParamString::getCharPtr() const
{
return mCharPtr;
}
void CameraParamString::copy(const char *pCharPtr)
{
if (pCharPtr != nullptr && (s32)*pCharPtr != nullptr)
{
mCharPtr = pCharPtr;
}
else
{
mCharPtr = nullptr;
}
}

View File

@ -0,0 +1,50 @@
#include "Camera/DotCamParams.h"
#include "smg.h"
DotCamReaderInBin::DotCamReaderInBin(const void *pData)
: mVersion(0)
{
JMapInfo mInfo();
mIter.mInfo = nullptr;
mIter.mPos = -1;
init(pData);
}
void DotCamReaderInBin::nextToChunk()
{
if (mIter.isValid())
{
mIter.mPos++;
}
}
bool DotCamReaderInBin::getValueInt(const char *pName, s32 *out)
{
return mIter.getValue<s32>(pName, out);
}
bool DotCamReaderInBin::getValueFloat(const char *pName, f32 *out)
{
return mIter.getValue<f32>(pName, out);
}
s32 DotCamReaderInBin::getValueString(const char *pName, const char **pOut)
{
s32 curPos = mIter.mPos;
const JMapInfo* info = mIter.mInfo;
s32 pos = info->searchItemInfo(pName);
if (pos < 0)
{
return 0;
}
else
{
return info->getValueFast(curPos, pos, pOut);
}
}
s32 DotCamReaderInBin::getVersion() const
{
return mVersion;
}

View File

@ -458,15 +458,27 @@ namespace MR
bool isConnectedWithRail(const JMapInfoIter &iter)
{
bool ret;
if (!iter.isValid())
return 0;
s32 out = -1;
bool ret = MR::getJMapInfoArgNoInit(iter, "CommonPath_ID", &out);
if (!ret)
return 0;
{
ret = false;
}
else
return out;
{
s32 path_id = -1;
bool res = MR::getJMapInfoArgNoInit(iter, "CommonPath_ID", &path_id);
if (res)
{
ret = path_id + 1;
}
else
{
ret = false;
}
}
return ret;
}
};

View File

@ -1,129 +0,0 @@
#include "System/Camera/CameraParamChunk.h"
#include "MR/MathUtil.h"
#include "string.h"
bool CameraParamChunk::isOnNoReset() const
{
return mFlags & 0x1;
}
bool CameraParamChunk::isOnUseFovy() const
{
return (mFlags >> 1) & 0x1;
}
bool CameraParamChunk::isLOfsErpOff() const
{
return (mFlags >> 2) & 0x1;
}
bool CameraParamChunk::isAntiBlurOff() const
{
return (mFlags >> 3) & 0x1;
}
bool CameraParamChunk::isCollisionOff() const
{
return (mFlags >> 4) & 0x1;
}
bool CameraParamChunk::isSubjectiveCameraOff() const
{
return (mFlags >> 5) & 0x1;
}
void CameraParamChunk::getVPanAxis(JGeometry::TVec3<f32> *out) const
{
out->x = mVPanAxisX;
out->y = mVPanAxisY;
out->z = mVPanAxisZ;
if (MR::isNearZero(*out, 0.001f))
{
out->set<f32>(0.0f, 1.0f, 0.0f);
}
MR::normalize(out);
}
void CameraParamChunk::setUseFovy(bool flag)
{
mFlags = (mFlags & 0xFFFFFFFD);
if (flag)
{
mFlags |= 0x2;
}
}
void CameraParamChunk::setLOFsErpOff(bool flag)
{
mFlags = (mFlags & 0xFFFFFFFB);
if (flag)
{
mFlags |= 0x4;
}
}
void CameraParamChunk::setCollisionOff(bool flag)
{
mFlags = (mFlags & 0xFFFFFFEF);
if (flag)
{
mFlags |= 0x10;
}
}
/* todo some still invalid logic... */
void CameraParamChunk::arrangeCamTypeName(u32 type, const char **out)
{
if (type < 0x30004)
{
if (type < 0x30006)
{
if (type < 0x30009)
{
if (!strcmp(*out, "CAM_TYPE_ICECUBE_PLANET"))
{
*out = "CAM_TYPE_CUBE_PLANET";
return;
}
}
if (!strcmp(*out, "CAM_TYPE_BEHIND_DEBUG"))
{
*out = "CAM_TYPE_SLIDER";
return;
}
else
{
if (!strcmp(*out, "CAM_TYPE_INWARD_TOWER_TEST"))
{
*out = "CAM_TYPE_INWARD_TOWER";
return;
}
else
{
if (!strcmp(*out, "CAM_TYPE_EYE_FIXED_THERE_TEST"))
{
*out = "CAM_TYPE_EYEPOS_FIX_THERE";
return;
}
return;
}
}
return;
}
if (!strcmp(*out, "CAM_TYPE_DONKETSU_TEST"))
{
return;
}
*out = "CAM_TYPE_BOSS_DONKETSU";
}
}