Attempt eggCamera

This commit is contained in:
robojumper
2025-03-19 23:16:03 +01:00
parent 5c67aac0f2
commit 217851300a
7 changed files with 183 additions and 11 deletions
+1 -1
View File
@@ -2166,7 +2166,7 @@ egg/prim/eggAssert.cpp:
.bss start:0x80674C60 end:0x80674D68
egg/gfx/eggCamera.cpp:
.text start:0x8049C5C0 end:0x8049CAC0
.text start:0x8049C5C0 end:0x8049CAC8
egg/gfx/eggPalette.cpp:
.text start:0x8049CAD0 end:0x8049CB44
+7 -7
View File
@@ -37352,8 +37352,8 @@ __vt__Q23EGG14CoreController = .data:0x8056EC50; // type:object size:0x38
@3874 = .data:0x8056ECD0; // type:object size:0xA scope:local data:string
@3878 = .data:0x8056ECDC; // type:object size:0xD scope:local data:string
@3881 = .data:0x8056ECF0; // type:object size:0x10 scope:local data:string
EGG____OrthoCamera__vtable = .data:0x8056ED00; // type:object size:0x30
EGG__LookAtCamera__vtable = .data:0x8056ED30; // type:object size:0x30
__vt__Q23EGG11OrthoCamera = .data:0x8056ED00; // type:object size:0x30
__vt__Q23EGG12LookAtCamera = .data:0x8056ED30; // type:object size:0x30
lbl_8056ED60 = .data:0x8056ED60; // type:object size:0x10
__vt__Q23EGG10CapTexture = .data:0x8056ED70; // type:object size:0x10
__vt__Q23EGG10CpuTexture = .data:0x8056ED80; // type:object size:0x20
@@ -37365,7 +37365,7 @@ lbl_8056EEB0 = .data:0x8056EEB0; // type:object size:0x78
__vt__Q23EGG11DrawPathDOF = .data:0x8056EF28; // type:object size:0x78
lbl_8056EFA0 = .data:0x8056EFA0; // type:object size:0x50
__vt__Q23EGG3Fog = .data:0x8056EFF0; // type:object size:0x20
__vt__Q23EGG10FogManager = .data:0x8056F010; // type:object size:0x20
__vt__Q23EGG10FogManager = .data:0x8056F010; // type:object size:0x1C
EGG__Frustum__vtable = .data:0x8056F030; // type:object size:0x18
EGG__GfxEnginer__Configuration__vtable = .data:0x8056F048; // type:object size:0x10
__vt__Q23EGG8IScnProc = .data:0x8056F058; // type:object size:0x10
@@ -37373,7 +37373,7 @@ EGG__LightManager__vtable = .data:0x8056F068; // type:object size:0x30
EGG__LightObject__vtable = .data:0x8056F098; // type:object size:0x20
__vt__Q23EGG12LightTexture = .data:0x8056F0B8; // type:object size:0x38
__vt__Q23EGG19LightTextureManager = .data:0x8056F0F0; // type:object size:0x1C
lbl_8056F110 = .data:0x8056F110; // type:object size:0x10
lbl_8056F110 = .data:0x8056F110; // type:object size:0x9 data:string
jumptable_8056F120 = .data:0x8056F120; // type:object size:0x30 scope:local
__vt__Q23EGG14PostEffectBase = .data:0x8056F150; // type:object size:0x1C
lbl_8056F170 = .data:0x8056F170; // type:object size:0x20
@@ -39832,9 +39832,9 @@ lbl_80574F30 = .sdata:0x80574F30; // type:object size:0x8
sTextureSize__Q23EGG12LightTexture = .sdata:0x80574F38; // type:object size:0x2 data:2byte
lbl_80574F3A = .sdata:0x80574F3A; // type:object size:0x1 data:byte
lbl_80574F3C = .sdata:0x80574F3C; // type:object size:0xC
sByteCodeCalcStr__Q23EGG7ModelEx = .sdata:0x80574F48; // type:object size:0x8 data:4byte
sByteCodeCalcStr__Q23EGG7ModelEx = .sdata:0x80574F48; // type:object size:0x4 data:4byte
lbl_80574F50 = .sdata:0x80574F50; // type:object size:0x8 data:string
sByteCodeMixStr__Q23EGG7ModelEx = .sdata:0x80574F58; // type:object size:0x8 data:4byte
sByteCodeMixStr__Q23EGG7ModelEx = .sdata:0x80574F58; // type:object size:0x4 data:4byte
lbl_80574F60 = .sdata:0x80574F60; // type:object size:0x4 data:4byte
lbl_80574F64 = .sdata:0x80574F64; // type:object size:0x4 data:4byte
sAudioRmtSpeakerWpadVolume__Q23EGG18AudioRmtSpeakerMgr = .sdata:0x80574F68; // type:object size:0x1 data:byte
@@ -48445,7 +48445,7 @@ lbl_8057FFA0 = .sbss2:0x8057FFA0; // type:object size:0x8 data:4byte
lbl_8057FFA8 = .sbss2:0x8057FFA8; // type:object size:0x8
lbl_8057FFB0 = .sbss2:0x8057FFB0; // type:object size:0x8
DefaultBlackColor = .sbss2:0x8057FFB8; // type:object size:0x8 scope:local data:2byte
sBlack__3EGG = .sbss2:0x8057FFC0; // type:object size:0x8 data:byte
sBlack__3EGG = .sbss2:0x8057FFC0; // type:object size:0x4 data:byte
lbl_8057FFC8 = .sbss2:0x8057FFC8; // type:object size:0x4
lbl_80580000 = .bss:0x80580000; // type:object size:0x14 data:4byte
lbl_80580014 = .bss:0x80580014; // type:object size:0xC
+67 -1
View File
@@ -1,6 +1,72 @@
#ifndef EGG_CAMERA_H
#define EGG_CAMERA_H
namespace EGG {} // namespace EGG
#include "egg/math/eggMatrix.h"
#include "egg/math/eggVector.h"
#include "nw4r/g3d/g3d_camera.h"
namespace EGG {
class BaseCamera {
public:
BaseCamera() {}
// Which way around?
virtual Matrix34f &getViewMatrix() = 0;
virtual const Matrix34f &getViewMatrix() const = 0;
virtual void updateMatrix();
virtual void doUpdateMatrix() = 0;
virtual void loadMatrix() = 0;
virtual void loadOldMatrix() = 0;
virtual EGG::Vector3f getPosition() = 0;
virtual void draw(EGG::BaseCamera *cam);
virtual void doDraw() = 0;
virtual Matrix34f &getViewMatrixOld() = 0;
void setG3DCamera(nw4r::g3d::Camera &);
};
class LookAtCamera : public BaseCamera {
public:
LookAtCamera() : mPosition(0.0f, 10.0f, 0.0f), mRight(0.0f, 0.0f, 0.0f), mUp(0.0f, 1.0f, 0.0f) {}
// Which way around?
virtual Matrix34f &getViewMatrix() override {
return mViewMtx;
}
virtual const Matrix34f &getViewMatrix() const override {
return mViewMtx;
}
virtual void doUpdateMatrix() override;
virtual void loadMatrix() override;
virtual void loadOldMatrix() override;
virtual EGG::Vector3f getPosition() override {
return mPosition;
}
virtual void doDraw() override;
virtual Matrix34f &getViewMatrixOld() override;
protected:
/* 0x04 */ Matrix34f mViewMtx;
/* 0x34 */ Matrix34f mOtherMtx;
/* 0x64 */ Vector3f mPosition;
/* 0x70 */ Vector3f mRight;
/* 0x7C */ Vector3f mUp;
};
class OrthoCamera : public LookAtCamera {
public:
OrthoCamera();
virtual void doUpdateMatrix() override;
private:
void update_parms();
/* 0x88 */ f32 field_0x88;
/* 0x8C */ f32 field_0x8C;
};
} // namespace EGG
#endif
+7
View File
@@ -1,6 +1,8 @@
#ifndef EGG_G3D_UTILITY_H
#define EGG_G3D_UTILITY_H
#include "nw4r/g3d/g3d_scnmdl.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "rvl/MEM/mem_allocator.h"
namespace EGG {
@@ -11,6 +13,11 @@ public:
return sAllocator;
}
static u16 SetTexture(
nw4r::g3d::ResMat resMat, nw4r::g3d::ScnMdl::CopiedMatAccess param_2, char *name, GXTexObj *texObj, bool copy,
void *param_6, int param_7, int param_8
);
private:
static MEMAllocator *sAllocator;
};
+2 -1
View File
@@ -27,7 +27,8 @@ public:
bool setBinaryToTexture(const void *data);
bool deleteTexture(int idx);
void replaceModelTextures(nw4r::g3d::ResMdl) const;
int replaceModelTextures(nw4r::g3d::ResMdl) const;
int replaceModelTexture(u16, nw4r::g3d::ResMdl) const;
void drawAndCaptureTexture(f32, f32, f32, f32);
// Inofficial
+74 -1
View File
@@ -1,3 +1,76 @@
#include "egg/gfx/eggCamera.h"
namespace EGG {} // namespace EGG
#include "common.h"
#include "egg/math/eggMatrix.h"
#include "egg/math/eggVector.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX/GXTransform.h"
namespace EGG {
void BaseCamera::updateMatrix() {
doUpdateMatrix();
}
void EGG::BaseCamera::draw(EGG::BaseCamera *cam) {
cam->loadMatrix();
doDraw();
}
void BaseCamera::setG3DCamera(nw4r::g3d::Camera &cam) {
cam.SetCameraMtxDirectly(*reinterpret_cast<const nw4r::math::MTX34 *>(&getViewMatrix()));
}
Matrix34f &LookAtCamera::getViewMatrixOld() {
return mOtherMtx;
}
void LookAtCamera::doUpdateMatrix() {
mOtherMtx.copyFrom(mViewMtx);
EGG::Vector3f posRight = mPosition;
posRight -= mRight;
posRight.normalise();
EGG::Vector3f forward = posRight.cross(mUp);
forward.normalise();
EGG::Vector3f up = posRight.cross(forward);
up.normalise();
mViewMtx.setTranslation(Vector3f((forward.dot(mPosition)), (up.dot(mPosition)), (posRight.dot(mPosition))));
mViewMtx.setBase(0, forward);
mViewMtx.setBase(1, up);
mViewMtx.setBase(2, posRight);
}
void LookAtCamera::doDraw() {}
void LookAtCamera::loadMatrix() {
Matrix34f mtx;
GXLoadPosMtxImm(mViewMtx.m, 0);
mViewMtx.inverseTransposeTo(mtx);
GXLoadNrmMtxImm(mtx.m, 0);
}
void LookAtCamera::loadOldMatrix() {}
OrthoCamera::OrthoCamera() {
field_0x8C = 0.5f;
field_0x88 = 0.0f;
update_parms();
}
void OrthoCamera::update_parms() {
f32 z = field_0x8C;
f32 sin = Math<f32>::sin(field_0x88);
f32 cos = Math<f32>::cos(field_0x88);
mPosition.set(mRight.x, mRight.y, z);
mUp.set(sin, cos, 0.0f);
}
void OrthoCamera::doUpdateMatrix() {
update_parms();
LookAtCamera::doUpdateMatrix();
}
} // namespace EGG
+25
View File
@@ -1,8 +1,11 @@
#include "egg/gfx/eggLightTextureMgr.h"
#include "common.h"
#include "egg/gfx/eggG3DUtility.h"
#include "egg/gfx/eggLightTexture.h"
#include "egg/gfx/eggStateGX.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "rvl/GX/GXTexture.h"
#include <cstring>
@@ -95,6 +98,28 @@ bool LightTextureManager::deleteTexture(int idx) {
return false;
}
int LightTextureManager::replaceModelTextures(nw4r::g3d::ResMdl mdl) const {
int count = 0;
for (u16 i = 0; i < mTextureCount; i++) {
count += replaceModelTexture(i, mdl);
}
return count;
}
int LightTextureManager::replaceModelTexture(u16 tex, nw4r::g3d::ResMdl mdl) const {
if (mpTextures[tex] == nullptr) {
return 0;
}
GXTexObj obj;
mpTextures[tex]->getTexObj(&obj);
int count = 0;
for (u32 i = 0; i < mdl.GetResMatNumEntries(); i++) {
nw4r::g3d::ResMat mat = mdl.GetResMat(i);
// TODO
// count += G3DUtility::SetTexture(mat, nullptr, mpLightMgr[tex]->getName(), obj, false, void *param_6, int param_7, int param_8)
}
}
bool LightTextureManager::setBinaryToTexture(const void *data) {
const LightTexture::Bin *bin = reinterpret_cast<const LightTexture::Bin *>(data);
for (int i = 0; i < getNumLightTextures(); i++) {