Document: Camera related code

This commit is contained in:
Dominik Peters
2024-10-20 04:54:40 +00:00
committed by Banjo Kazooie
parent d1b41e109d
commit da047aa99a
10 changed files with 373 additions and 331 deletions

73
include/core2/camera.h Normal file
View File

@@ -0,0 +1,73 @@
#ifndef _CAMERA_H_
#define _CAMERA_H_
#include <ultratypes.h>
#include <core2/file.h>
typedef struct {
s32 type: 24;
s32 valid: 8;
s32 data_ptr;
} CameraNode;
typedef struct {
f32 position[3];
f32 horizontalSpeed;
f32 verticalSpeed;
f32 rotation;
f32 accelaration;
f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll
s32 unknownFlag; // unknown, some sort of flag value, is &'ed with 1, 2 and 4
} CameraNodeType1;
CameraNodeType1 *cameraNodeType1_init();
void cameraNodeType1_free(CameraNodeType1 *this);
void cameraNodeType1_fromFile(File *file_ptr, CameraNodeType1 *this);
void cameraNodeType1_getPosition(CameraNodeType1 *this, f32 position[3]);
void cameraNodeType1_getHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 *horizontal_speed, f32 *vertical_speed);
void cameraNodeType1_getRotationAndAccelaration(CameraNodeType1 *this, f32 *rotation, f32 *accelaration);
typedef struct {
f32 position[3];
f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll
} CameraNodeType2;
CameraNodeType2 *cameraNodeType2_init();
void cameraNodeType2_free(CameraNodeType2 *this);
void cameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *this);
void cameraNodeType2_getPosition(CameraNodeType2 *this, f32 position[3]);
/*
* Sets 0 to pitch, 1 to yaw and 2 to roll
*/
void cameraNodeType2_getPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]);
typedef struct {
f32 position[3];
f32 horizontalSpeed;
f32 verticalSpeed;
f32 rotation;
f32 accelaration;
f32 closeDistance;
f32 farDistance;
f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll
s32 unknownFlag;
} CameraNodeType3;
CameraNodeType3 *cameraNodeType3_init();
void cameraNodeType3_free(CameraNodeType3 *this);
void cameraNodeType3_fromFile(File *file_ptr, CameraNodeType3 *this);
void cameraNodeType3_getPosition(CameraNodeType3 *this, f32 position[3]);
void cameraNodeType3_getHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 *horizontal_speed, f32 *vertical_speed);
void cameraNodeType3_getRotationAndAccelaration(CameraNodeType3 *this, f32 *rotation, f32 *accelaration);
/*
* Sets 0 to pitch, 1 to yaw and 2 to roll
*/
void cameraNodeType3_getPositionWithPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]);
f32 cameraNodeType3_getCloseDistance(CameraNodeType3 *this);
f32 cameraNodeType3_getFarDistance(CameraNodeType3 *this);
typedef struct {
s32 unknownFlag;
} CameraNodeType4;
CameraNodeType4 *cameraNodeType4_init();
void cameraNodeType4_free(CameraNodeType4 *this);
void cameraNodeType4_fromFile(File *file_ptr, CameraNodeType4 *this);
#endif

View File

@@ -2,32 +2,35 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/camera.h>
#include <core2/file.h> #include <core2/file.h>
void func_802BA23C(s32 *arg0, s32 arg1); static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1);
/* .code */ /* .code */
s32 * func_802BA1E0(void){ CameraNodeType4 *cameraNodeType4_init(){
s32 * sp1C = malloc(4); CameraNodeType4 * this;
func_802BA23C(sp1C, 1);
return sp1C; this = malloc(sizeof(CameraNodeType4));
__code33250_func_802BA23C(this, 1);
return this;
} }
void func_802BA214(s32 *arg0){ void cameraNodeType4_free(CameraNodeType4 *this){
free(arg0); free(this);
} }
s32 func_802BA234(s32 *arg0){ s32 code33250_func_802BA234(CameraNodeType4 *this){
return *arg0; return this->unknownFlag;
} }
void func_802BA23C(s32 *arg0, s32 arg1){ static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1){
*arg0 = arg1; this->unknownFlag = arg1;
} }
void func_802BA244(File *file_ptr, s32 *arg1){ void cameraNodeType4_fromFile(File *file_ptr, CameraNodeType4 *this){
while(!file_isNextByteExpected(file_ptr, 0)){ while(!file_isNextByteExpected(file_ptr, 0)){
file_getWord_ifExpected(file_ptr, 1, arg1); file_getWord_ifExpected(file_ptr, 1, &this->unknownFlag);
} }
} }

View File

@@ -3,154 +3,142 @@
#include "variables.h" #include "variables.h"
#include <core2/file.h> #include <core2/file.h>
#include <core2/camera.h>
typedef struct{ static void __cameraNodeType3_setPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]);
f32 unk0[3]; static void __cameraNodeType3_setFarDistance(CameraNodeType3 *this, f32 far_distance);
f32 unkC; static void __cameraNodeType3_setCloseDistance(CameraNodeType3 *this, f32 close_distnace);
f32 unk10; static void __cameraNodeType3_setPosition(CameraNodeType3 *this, f32 position[3]);
f32 unk14; static void __cameraNodeType3_setHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 horizontal_speed, f32 vertical_speed);
f32 unk18; static void __cameraNodeType3_setRotationAndAccelaration(CameraNodeType3 *this, f32 rotation, f32 accelaration);
f32 unk1C; static void __code33310_func_802BA510(CameraNodeType3 *this, bool arg1);
f32 unk20; static void __code33310_func_802BA530(CameraNodeType3 *this, bool arg1);
f32 unk24[3];
s32 unk30;
}Struct_core2_33310;
void func_802BA3E8(Struct_core2_33310 *arg0, f32 arg1[3]);
void func_802BA414(Struct_core2_33310 *arg0, f32 arg1);
void func_802BA428(Struct_core2_33310 *arg0, f32 arg1);
void func_802BA460(Struct_core2_33310 *arg0, f32 arg1[3]);
void func_802BA494(Struct_core2_33310 *arg0, f32 arg1, f32 arg2);
void func_802BA4BC(Struct_core2_33310 *arg0, f32 arg1, f32 arg2);
void func_802BA510(Struct_core2_33310 *arg0, bool arg1);
void func_802BA530(Struct_core2_33310 *arg0, bool arg1);
/* .code */ /* .code */
void func_802BA2A0(Struct_core2_33310 *arg0, bool arg1, s32 arg2){ static void __code33310_func_802BA2A0(CameraNodeType3 *this, bool arg1, s32 arg2) {
if(arg1) { if(arg1) {
arg0->unk30 |= arg2; this->unknownFlag |= arg2;
} }
else{ else{
arg0->unk30 &= ~arg2; this->unknownFlag &= ~arg2;
} }
} }
bool func_802BA2D0(Struct_core2_33310 *arg0, s32 arg1){ bool __code33310_func_802BA2D0(CameraNodeType3 *this, s32 arg1) {
if(arg0->unk30 & arg1) if(this->unknownFlag & arg1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
Struct_core2_33310 *func_802BA2F4(void){ CameraNodeType3 *cameraNodeType3_init() {
Struct_core2_33310 * this; CameraNodeType3 * this;
f32 sp20[3]; f32 sp20[3];
this = (Struct_core2_33310 *)malloc(sizeof(Struct_core2_33310)); this = (CameraNodeType3 *)malloc(sizeof(CameraNodeType3));
ml_vec3f_clear(sp20); ml_vec3f_clear(sp20);
func_802BA460(this, sp20); __cameraNodeType3_setPosition(this, sp20);
func_802BA3E8(this, sp20); __cameraNodeType3_setPitchYawRoll(this, sp20);
func_802BA494(this, 2.84f, 5.68f); __cameraNodeType3_setHorizontalAndVerticalSpeed(this, 2.84f, 5.68f);
func_802BA4BC(this, 4.0f, 16.0f); __cameraNodeType3_setRotationAndAccelaration(this, 4.0f, 16.0f);
func_802BA428(this, 1000.0f); __cameraNodeType3_setCloseDistance(this, 1000.0f);
func_802BA414(this, 1000.0f); __cameraNodeType3_setFarDistance(this, 1000.0f);
func_802BA530(this, FALSE); __code33310_func_802BA530(this, FALSE);
func_802BA510(this, FALSE); __code33310_func_802BA510(this, FALSE);
return this; return this;
} }
void func_802BA398(Struct_core2_33310 *arg0){ void cameraNodeType3_free(CameraNodeType3 *this) {
free(arg0); free(this);
} }
void func_802BA3B8(Struct_core2_33310 *arg0, f32 arg1[3]){ void cameraNodeType3_getPositionWithPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]) {
ml_vec3f_add(arg1, arg0->unk0, arg0->unk24); ml_vec3f_add(pitch_yaw_roll, this->position, this->pitchYawRoll);
} }
void func_802BA3E8(Struct_core2_33310 *arg0, f32 arg1[3]){ static void __cameraNodeType3_setPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]) {
ml_vec3f_diff_copy(arg0->unk24, arg1, arg0->unk0); ml_vec3f_diff_copy(this->pitchYawRoll, pitch_yaw_roll, this->position);
} }
f32 func_802BA40C(Struct_core2_33310 *arg0){ f32 cameraNodeType3_getFarDistance(CameraNodeType3 *this) {
return arg0->unk20; return this->farDistance;
} }
void func_802BA414(Struct_core2_33310 *arg0, f32 arg1){ static void __cameraNodeType3_setFarDistance(CameraNodeType3 *this, f32 far_distance) {
arg0->unk20 = arg1; this->farDistance = far_distance;
} }
f32 func_802BA420(Struct_core2_33310 *arg0){ f32 cameraNodeType3_getCloseDistance(CameraNodeType3 *this) {
return arg0->unk1C; return this->closeDistance;
} }
void func_802BA428(Struct_core2_33310 *arg0, f32 arg1){ static void __cameraNodeType3_setCloseDistance(CameraNodeType3 *this, f32 close_distance) {
arg0->unk1C = arg1; this->closeDistance = close_distance;
} }
void func_802BA434(Struct_core2_33310 *arg0, f32 arg1[3]){ void cameraNodeType3_getPosition(CameraNodeType3 *this, f32 position[3]) {
ml_vec3f_copy(arg1, arg0->unk0); ml_vec3f_copy(position, this->position);
} }
void func_802BA460(Struct_core2_33310 *arg0, f32 arg1[3]){ static void __cameraNodeType3_setPosition(CameraNodeType3 *this, f32 position[3]) {
ml_vec3f_copy(arg0->unk0, arg1); ml_vec3f_copy(this->position, position);
} }
void func_802BA480(Struct_core2_33310 *arg0, f32 *arg1, f32 *arg2){ void cameraNodeType3_getHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 *horizontal_speed, f32 *vertical_speed) {
*arg1 = arg0->unkC; *horizontal_speed = this->horizontalSpeed;
*arg2 = arg0->unk10; *vertical_speed = this->verticalSpeed;
} }
void func_802BA494(Struct_core2_33310 *arg0, f32 arg1, f32 arg2){ static void __cameraNodeType3_setHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 horizontal_speed, f32 vertical_speed) {
arg0->unkC = arg1; this->horizontalSpeed = horizontal_speed;
arg0->unk10 = arg2; this->verticalSpeed = vertical_speed;
} }
void func_802BA4A8(Struct_core2_33310 *arg0, f32 *arg1, f32 *arg2){ void cameraNodeType3_getRotationAndAccelaration(CameraNodeType3 *this, f32 *rotation, f32 *accelaration) {
*arg1 = arg0->unk14; *rotation = this->rotation;
*arg2 = arg0->unk18; *accelaration = this->accelaration;
} }
void func_802BA4BC(Struct_core2_33310 *arg0, f32 arg1, f32 arg2){ static void __cameraNodeType3_setRotationAndAccelaration(CameraNodeType3 *this, f32 rotation, f32 accelaration) {
arg0->unk14 = arg1; this->rotation = rotation;
arg0->unk18 = arg2; this->accelaration = accelaration;
} }
bool func_802BA4D0(Struct_core2_33310 *arg0){ bool code33310_func_802BA4D0(CameraNodeType3 *this) {
return func_802BA2D0(arg0, 4); return __code33310_func_802BA2D0(this, 4);
} }
bool func_802BA4F0(Struct_core2_33310 *arg0){ bool code33310_func_802BA4F0(CameraNodeType3 *this) {
return func_802BA2D0(arg0, 1); return __code33310_func_802BA2D0(this, 1);
} }
void func_802BA510(Struct_core2_33310 *arg0, bool arg1){ static void __code33310_func_802BA510(CameraNodeType3 *this, bool arg1) {
func_802BA2A0(arg0, arg1, 4); __code33310_func_802BA2A0(this, arg1, 4);
} }
void func_802BA530(Struct_core2_33310 *arg0, bool arg1){ static void __code33310_func_802BA530(CameraNodeType3 *this, bool arg1) {
func_802BA2A0(arg0, arg1, 1); __code33310_func_802BA2A0(this, arg1, 1);
} }
void func_802BA550(File *file_ptr, Struct_core2_33310 *arg1){ void cameraNodeType3_fromFile(File *file_ptr, CameraNodeType3 *this) {
while(!file_isNextByteExpected(file_ptr, 0)) { while(!file_isNextByteExpected(file_ptr, 0)) {
if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->unk0, 3)){ if(!file_getNFloats_ifExpected(file_ptr, 1, this->position, 3)) {
if(file_isNextByteExpected(file_ptr, 2)) { if(file_isNextByteExpected(file_ptr, 2)) {
file_getFloat(file_ptr, &arg1->unkC); file_getFloat(file_ptr, &this->horizontalSpeed);
file_getFloat(file_ptr, &arg1->unk10); file_getFloat(file_ptr, &this->verticalSpeed);
} }
else if(file_isNextByteExpected(file_ptr, 3)) { else if(file_isNextByteExpected(file_ptr, 3)) {
file_getFloat(file_ptr, &arg1->unk14); file_getFloat(file_ptr, &this->rotation);
file_getFloat(file_ptr, &arg1->unk18); file_getFloat(file_ptr, &this->accelaration);
} }
else if(file_isNextByteExpected(file_ptr, 6)) { else if(file_isNextByteExpected(file_ptr, 6)) {
file_getFloat(file_ptr, &arg1->unk1C); file_getFloat(file_ptr, &this->closeDistance);
file_getFloat(file_ptr, &arg1->unk20); file_getFloat(file_ptr, &this->farDistance);
} }
else{ else{
if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk24, 3)){ if(!file_getNFloats_ifExpected(file_ptr, 4, this->pitchYawRoll, 3)) {
file_getWord_ifExpected(file_ptr, 5, &arg1->unk30); file_getWord_ifExpected(file_ptr, 5, &this->unknownFlag);
}
} }
} }
}//L802BA654
} }
} }

View File

@@ -4,132 +4,124 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/camera.h>
typedef struct {
f32 unk0[3];
f32 unkC;
f32 unk10;
f32 unk14;
f32 unk18;
f32 unk1C[3];
s32 unk28;
} Struct_core2_336F0;
void func_802BA7B8(Struct_core2_336F0 *arg0, f32 arg1[3]); static void __cameraNodeType1_setPosition(CameraNodeType1 *this, f32 position[3]);
void func_802BA808(Struct_core2_336F0 *arg0, f32 arg1[3]); static void __cameraNodeType1_func_802BA808(CameraNodeType1 *this, f32 arg1[3]);
void func_802BA840(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2); static void __cameraNodeType1_setHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 horizontal_speed, f32 vertical_speed);
void func_802BA868(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2); static void __cameraNodeType1_setRotationAndAccelaration(CameraNodeType1 *this, f32 rotation, f32 accelaration);
void func_802BA8DC(Struct_core2_336F0 *arg0, s32 arg1); static void __code336F0_func_802BA8DC(CameraNodeType1 *this, s32 arg1);
void func_802BA8FC(Struct_core2_336F0 *arg0, s32 arg1); static void __code336F0_func_802BA8FC(CameraNodeType1 *this, s32 arg1);
void func_802BA91C(Struct_core2_336F0 *arg0, s32 arg1); static void __code336F0_func_802BA91C(CameraNodeType1 *this, s32 arg1);
void func_802BA680(Struct_core2_336F0 *arg0, s32 arg1, s32 arg2){ static void __code336F0_func_802BA680(CameraNodeType1 *this, s32 arg1, s32 arg2) {
if(arg1) { if(arg1) {
arg0->unk28 |= arg2; this->unknownFlag |= arg2;
} else{ } else{
arg0->unk28 &= ~arg2; this->unknownFlag &= ~arg2;
} }
} }
bool func_802BA6B0(Struct_core2_336F0 *arg0, s32 arg1){ static bool __code336F0_func_802BA6B0(CameraNodeType1 *this, s32 arg1) {
if (arg0->unk28 & arg1) if (this->unknownFlag & arg1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
Struct_core2_336F0 *func_802BA6D4(void){ CameraNodeType1 *cameraNodeType1_init() {
Struct_core2_336F0 *this; CameraNodeType1 *this;
f32 sp20[3]; f32 sp20[3];
this = (Struct_core2_336F0 *)malloc(sizeof(Struct_core2_336F0)); this = (CameraNodeType1 *)malloc(sizeof(CameraNodeType1));
ml_vec3f_clear(sp20); ml_vec3f_clear(sp20);
func_802BA7B8(this, sp20); __cameraNodeType1_setPosition(this, sp20);
func_802BA808(this, sp20); __cameraNodeType1_func_802BA808(this, sp20);
func_802BA840(this, 0.7f, 2.33f); __cameraNodeType1_setHorizontalAndVerticalSpeed(this, 0.7f, 2.33f);
func_802BA868(this, 4.0f, 16.0f); __cameraNodeType1_setRotationAndAccelaration(this, 4.0f, 16.0f);
func_802BA8DC(this, 0); __code336F0_func_802BA8DC(this, 0);
func_802BA91C(this, 1); __code336F0_func_802BA91C(this, 1);
func_802BA8FC(this, 0); __code336F0_func_802BA8FC(this, 0);
return this; return this;
} }
void func_802BA76C(Struct_core2_336F0 *arg0){ void cameraNodeType1_free(CameraNodeType1 *this) {
free(arg0); free(this);
} }
void func_802BA78C(Struct_core2_336F0 *arg0, f32 arg1[3]){ void cameraNodeType1_getPosition(CameraNodeType1 *this, f32 position[3]) {
ml_vec3f_copy(arg1, arg0->unk0); ml_vec3f_copy(position, this->position);
} }
void func_802BA7B8(Struct_core2_336F0 *arg0, f32 arg1[3]){ static void __cameraNodeType1_setPosition(CameraNodeType1 *this, f32 position[3]) {
ml_vec3f_copy(arg0->unk0, arg1); ml_vec3f_copy(this->position, position);
} }
void func_802BA7D8(Struct_core2_336F0 *arg0, f32 arg1[3]){ void code336F0_func_802BA7D8(CameraNodeType1 *this, f32 arg1[3]) {
ml_vec3f_add(arg1, arg0->unk0, arg0->unk1C); ml_vec3f_add(arg1, this->position, this->pitchYawRoll);
} }
void func_802BA808(Struct_core2_336F0 *arg0, f32 arg1[3]){ static void __cameraNodeType1_func_802BA808(CameraNodeType1 *this, f32 arg1[3]) {
ml_vec3f_diff_copy(arg0->unk1C, arg1, arg0->unk0); ml_vec3f_diff_copy(this->pitchYawRoll, arg1, this->position);
} }
void func_802BA82C(Struct_core2_336F0 *arg0, f32 *arg1, f32 *arg2){ void cameraNodeType1_getHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 *horizontal_speed, f32 *vertical_speed) {
*arg1 = arg0->unkC; *horizontal_speed = this->horizontalSpeed;
*arg2 = arg0->unk10; *vertical_speed = this->verticalSpeed;
} }
void func_802BA840(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2){ static void __cameraNodeType1_setHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 horizontal_speed, f32 vertical_speed) {
arg0->unkC = arg1; this->horizontalSpeed = horizontal_speed;
arg0->unk10 = arg2; this->verticalSpeed = vertical_speed;
} }
void func_802BA854(Struct_core2_336F0 *arg0, f32 *arg1, f32 *arg2){ void cameraNodeType1_getRotationAndAccelaration(CameraNodeType1 *this, f32 *rotation, f32 *accelaration) {
*arg1 = arg0->unk14; *rotation = this->rotation;
*arg2 = arg0->unk18; *accelaration = this->accelaration;
} }
void func_802BA868(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2){ static void __cameraNodeType1_setRotationAndAccelaration(CameraNodeType1 *this, f32 rotation, f32 accelaration) {
arg0->unk14 = arg1; this->rotation = rotation;
arg0->unk18 = arg2; this->accelaration = accelaration;
} }
bool func_802BA87C(Struct_core2_336F0 *arg0){ bool code336F0_func_802BA87C(CameraNodeType1 *this) {
return func_802BA6B0(arg0, 1); return __code336F0_func_802BA6B0(this, 0x1);
} }
bool func_802BA89C(Struct_core2_336F0 *arg0){ bool code336F0_func_802BA89C(CameraNodeType1 *this) {
return func_802BA6B0(arg0, 4); return __code336F0_func_802BA6B0(this, 0x4);
} }
bool func_802BA8BC(Struct_core2_336F0 *arg0){ bool code336F0_func_802BA8BC(CameraNodeType1 *this) {
return func_802BA6B0(arg0, 2); return __code336F0_func_802BA6B0(this, 0x2);
} }
void func_802BA8DC(Struct_core2_336F0 *arg0, s32 arg1){ static void __code336F0_func_802BA8DC(CameraNodeType1 *this, s32 arg1) {
func_802BA680(arg0, arg1, 1); __code336F0_func_802BA680(this, arg1, 0x1);
} }
void func_802BA8FC(Struct_core2_336F0 *arg0, s32 arg1){ static void __code336F0_func_802BA8FC(CameraNodeType1 *this, s32 arg1) {
func_802BA680(arg0, arg1, 4); __code336F0_func_802BA680(this, arg1, 0x4);
} }
void func_802BA91C(Struct_core2_336F0 *arg0, s32 arg1){ static void __code336F0_func_802BA91C(CameraNodeType1 *this, s32 arg1) {
func_802BA680(arg0, arg1, 2); __code336F0_func_802BA680(this, arg1, 0x2);
} }
void func_802BA93C(File *file_ptr, Struct_core2_336F0 *arg1){ void cameraNodeType1_fromFile(File *file_ptr, CameraNodeType1 *this) {
while(!file_isNextByteExpected(file_ptr, 0)) { while(!file_isNextByteExpected(file_ptr, 0)) {
if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->unk0, 3)){ if(!file_getNFloats_ifExpected(file_ptr, 1, this->position, 3)) {
if(file_isNextByteExpected(file_ptr, 2)) { if(file_isNextByteExpected(file_ptr, 2)) {
file_getFloat(file_ptr, &arg1->unkC); file_getFloat(file_ptr, &this->horizontalSpeed);
file_getFloat(file_ptr, &arg1->unk10); file_getFloat(file_ptr, &this->verticalSpeed);
} }
else if(file_isNextByteExpected(file_ptr, 3)) { else if(file_isNextByteExpected(file_ptr, 3)) {
file_getFloat(file_ptr, &arg1->unk14); file_getFloat(file_ptr, &this->rotation);
file_getFloat(file_ptr, &arg1->unk18); file_getFloat(file_ptr, &this->accelaration);
} }
else if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk1C, 3)){ else if(!file_getNFloats_ifExpected(file_ptr, 4, this->pitchYawRoll, 3)) {
file_getWord_ifExpected(file_ptr, 5, &arg1->unk28); file_getWord_ifExpected(file_ptr, 5, &this->unknownFlag);
} }
}//L802BAA0C }//L802BAA0C
} }

View File

@@ -3,51 +3,47 @@
#include "variables.h" #include "variables.h"
#include <core2/file.h> #include <core2/file.h>
#include <core2/camera.h>
typedef struct { static void __cameraNodeType2_setPosition(CameraNodeType2 *this, f32 position[3]);
f32 position[3]; static void __cameraNodeType2_setPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]);
f32 rotation[3];
} CameraNodeType2;
void ncCameraNodeType2_setPosition(CameraNodeType2 *this, f32 src[3]);
void ncCameraNodeType2_setRotation(CameraNodeType2 *this, f32 src[3]);
/* .code */ /* .code */
CameraNodeType2 *ncCameraNodeType2_new(void){ CameraNodeType2 *cameraNodeType2_init() {
CameraNodeType2 *this; CameraNodeType2 *this;
f32 sp18[3]; f32 sp18[3];
this = (CameraNodeType2 *)malloc(sizeof(CameraNodeType2)); this = (CameraNodeType2 *)malloc(sizeof(CameraNodeType2));
ml_vec3f_clear(sp18); ml_vec3f_clear(sp18);
ncCameraNodeType2_setPosition(this, sp18); __cameraNodeType2_setPosition(this, sp18);
ncCameraNodeType2_setRotation(this, sp18); __cameraNodeType2_setPitchYawRoll(this, sp18);
return this; return this;
} }
void ncCameraNodeType2_free(CameraNodeType2 *this){ void cameraNodeType2_free(CameraNodeType2 *this) {
free(this); free(this);
} }
void ncCameraNodeType2_getPosition(CameraNodeType2 *this, f32 dst[3]){\ void cameraNodeType2_getPosition(CameraNodeType2 *this, f32 position[3]) {
ml_vec3f_copy(dst, this->position); ml_vec3f_copy(position, this->position);
} }
void ncCameraNodeType2_setPosition(CameraNodeType2 *this, f32 src[3]){ void __cameraNodeType2_setPosition(CameraNodeType2 *this, f32 position[3]) {
ml_vec3f_copy(this->position, src); ml_vec3f_copy(this->position, position);
} }
void ncCameraNodeType2_getRotation(CameraNodeType2 *this, f32 dst[3]){\ void cameraNodeType2_getPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]) {\
ml_vec3f_copy(dst, this->rotation); ml_vec3f_copy(pitch_yaw_roll, this->pitchYawRoll);
} }
void ncCameraNodeType2_setRotation(CameraNodeType2 *this, f32 src[3]){ void __cameraNodeType2_setPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]) {
ml_vec3f_copy(this->rotation, src); ml_vec3f_copy(this->pitchYawRoll, pitch_yaw_roll);
} }
void ncCameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *arg1){ void cameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *this) {
while(!file_isNextByteExpected(file_ptr, 0)) { while(!file_isNextByteExpected(file_ptr, 0)) {
if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->position, 3)){ if(!file_getNFloats_ifExpected(file_ptr, 1, &this->position, 3)) {
file_getNFloats_ifExpected(file_ptr, 2, arg1->rotation, 3); file_getNFloats_ifExpected(file_ptr, 2, &this->pitchYawRoll, 3);
}//L802BAA0C }
} }
} }

View File

@@ -75,12 +75,12 @@ int func_80290D48(void){
sp1C = bs_getState(); sp1C = bs_getState();
switch(ncCameraNodeList_getNodeType(camera_node_index)){ switch(ncCameraNodeList_getNodeType(camera_node_index)){
case 4: case 4:
sp28 = func_802B9E34(camera_node_index); sp28 = ncCameraNodeList_getCameraNodeType4(camera_node_index);
sp24 = func_802BA234(sp28); sp24 = code33250_func_802BA234(sp28);
func_80290BC0(sp24); func_80290BC0(sp24);
return FALSE; return FALSE;
case 3: //L80290DD8 case 3: //L80290DD8
if(bsBeeFly_inSet(sp1C) && !func_802BA4D0(func_802B9E48(camera_node_index))){ if(bsBeeFly_inSet(sp1C) && !code33310_func_802BA4D0(ncCameraNodeList_getCameraNodeType3(camera_node_index))){
return FALSE; return FALSE;
} }
ncDynamicCamera_setState(0x11); ncDynamicCamera_setState(0x11);
@@ -88,7 +88,7 @@ int func_80290D48(void){
func_80291488(0x9); func_80291488(0x9);
return TRUE; return TRUE;
case 1://L80290E28 case 1://L80290E28
if(bsBeeFly_inSet(sp1C) && !func_802BA89C(func_802B9E5C(camera_node_index))){ if(bsBeeFly_inSet(sp1C) && !code336F0_func_802BA89C(ncCameraNodeList_getCameraNodeType1(camera_node_index))){
return FALSE; return FALSE;
} }
ncDynamicCamera_setState(0x8); ncDynamicCamera_setState(0x8);

View File

@@ -3,31 +3,26 @@
#include "variables.h" #include "variables.h"
#include <core2/file.h> #include <core2/file.h>
#include <core2/camera.h>
#define NC_CAMERA_NODE_LIST_CAPACITY 0x46 #define NC_CAMERA_NODE_LIST_CAPACITY 0x46
typedef struct { static void __ncCameraNodeList_removeNode(int camera_node_index);
s32 type:24; s32 ncCameraNodeList_nodeIsValid(int camera_node_index);
s32 valid:8; static void __ncCameraNodeList_setCameraNodeType(int camera_node_index, s32 type);
s32 data_ptr;
} Struct_Core2_32DB0_0s;
void __ncCameraNodeList_removeNode(s32 arg0);
s32 ncCameraNodeList_nodeIsValid(s32 arg0);
void func_802B9EBC(s32 arg0, s32 arg1);
/* .bss */ /* .bss */
Struct_Core2_32DB0_0s ncCameraNodeList[NC_CAMERA_NODE_LIST_CAPACITY]; CameraNode sNcCameraNodeList[NC_CAMERA_NODE_LIST_CAPACITY];
/* .code */ /* .code */
void ncCameraNodeList_init(void){ void ncCameraNodeList_init() {
int i; int i;
for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) { for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) {
ncCameraNodeList[i].valid = FALSE; sNcCameraNodeList[i].valid = FALSE;
} }
} }
void ncCameraNodeList_free(void){ void ncCameraNodeList_free() {
int i; int i;
for(i=0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) { for(i=0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) {
@@ -36,144 +31,139 @@ void ncCameraNodeList_free(void){
} }
} }
void __ncCameraNodeList_addNode(s32 camera_node_index){ static void __ncCameraNodeList_addNode(int camera_node_index) {
ncCameraNodeList[camera_node_index].valid = TRUE; sNcCameraNodeList[camera_node_index].valid = TRUE;
ncCameraNodeList[camera_node_index].type = 0; sNcCameraNodeList[camera_node_index].type = 0;
} }
void __ncCameraNodeList_removeNode(s32 camera_node_index){ static void __ncCameraNodeList_removeNode(int camera_node_index) {
func_802B9EBC(camera_node_index, 0); __ncCameraNodeList_setCameraNodeType(camera_node_index, 0);
ncCameraNodeList[camera_node_index].valid = 0; sNcCameraNodeList[camera_node_index].valid = 0;
} }
//ncCameraNodeList_getdata_ptr_type4 CameraNodeType4* ncCameraNodeList_getCameraNodeType4(int camera_node_index) {
s32 func_802B9E34(s32 camera_node_index){ return sNcCameraNodeList[camera_node_index].data_ptr;
return ncCameraNodeList[camera_node_index].data_ptr;
} }
//ncCameraNodeList_getdata_ptr_type3 CameraNodeType3* ncCameraNodeList_getCameraNodeType3(int camera_node_index) {
s32 func_802B9E48(s32 camera_node_index){ return sNcCameraNodeList[camera_node_index].data_ptr;
return ncCameraNodeList[camera_node_index].data_ptr;
} }
//ncCameraNodeList_getdata_ptr_type1 CameraNodeType1* ncCameraNodeList_getCameraNodeType1(int camera_node_index) {
s32 func_802B9E5C(s32 camera_node_index){ return sNcCameraNodeList[camera_node_index].data_ptr;
return ncCameraNodeList[camera_node_index].data_ptr;
} }
//ncCameraNodeList_getdata_ptr_type2 CameraNodeType2* ncCameraNodeList_getCameraNodeType2(int camera_node_index) {
s32 func_802B9E70(s32 camera_node_index){ return sNcCameraNodeList[camera_node_index].data_ptr;
return ncCameraNodeList[camera_node_index].data_ptr;
} }
s32 ncCameraNodeList_capacity(void){ s32 __ncCameraNodeList_capacity() {
return NC_CAMERA_NODE_LIST_CAPACITY; return NC_CAMERA_NODE_LIST_CAPACITY;
} }
s32 ncCameraNodeList_getNodeType(s32 camera_node_index){ s32 ncCameraNodeList_getNodeType(int camera_node_index) {
return ncCameraNodeList[camera_node_index].type; return sNcCameraNodeList[camera_node_index].type;
} }
s32 ncCameraNodeList_nodeIsValid(s32 camera_node_index){ s32 ncCameraNodeList_nodeIsValid(int camera_node_index) {
return ncCameraNodeList[camera_node_index].valid; return sNcCameraNodeList[camera_node_index].valid;
} }
void func_802B9EBC(s32 camera_node_index, s32 arg1){ static void __ncCameraNodeList_setCameraNodeType(int camera_node_index, s32 type) {
if(arg1 == ncCameraNodeList[camera_node_index].type) if(type == sNcCameraNodeList[camera_node_index].type)
return; return;
//remove old cameraNodedata_ptr
switch(ncCameraNodeList[camera_node_index].type){ switch(sNcCameraNodeList[camera_node_index].type) {
case 4:// L802B9F08 case 4:
func_802BA214(ncCameraNodeList[camera_node_index].data_ptr); cameraNodeType4_free(sNcCameraNodeList[camera_node_index].data_ptr);
break; break;
case 3:// L802B9F18 case 3:
func_802BA398(ncCameraNodeList[camera_node_index].data_ptr); cameraNodeType3_free(sNcCameraNodeList[camera_node_index].data_ptr);
break; break;
case 1:// L802B9F28 case 1:
func_802BA76C(ncCameraNodeList[camera_node_index].data_ptr); cameraNodeType1_free(sNcCameraNodeList[camera_node_index].data_ptr);
break; break;
case 2:// L802B9F38 case 2:
ncCameraNodeType2_free(ncCameraNodeList[camera_node_index].data_ptr); cameraNodeType2_free(sNcCameraNodeList[camera_node_index].data_ptr);
break; break;
case 0:// L802B9F40 case 0:
break; break;
} }
ncCameraNodeList[camera_node_index].type = arg1; sNcCameraNodeList[camera_node_index].type = type;
//init new camera node data_ptr switch (type)
switch (arg1)
{ {
case 4:// L802B9F80 case 4:
ncCameraNodeList[camera_node_index].data_ptr = func_802BA1E0(); sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType4_init();
break; break;
case 3:// L802B9F90 case 3:
ncCameraNodeList[camera_node_index].data_ptr = func_802BA2F4(); sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType3_init();
break; break;
case 1:// L802B9FA0 case 1:
ncCameraNodeList[camera_node_index].data_ptr = func_802BA6D4(); sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType1_init();
break; break;
case 2:// L802B9FB0 case 2:
ncCameraNodeList[camera_node_index].data_ptr = ncCameraNodeType2_new(); sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType2_init();
break; break;
case 0:// L802B9FBC case 0:
break; break;
} }
} }
void __ncCameraNodeList_nodeFromFile(File *file_ptr, s32 arg1){ void __ncCameraNodeList_nodeFromFile(File *file_ptr, int camera_node_index) {
u8 sp27; u8 camera_node_type;
__ncCameraNodeList_addNode(arg1); __ncCameraNodeList_addNode(camera_node_index);
file_getByte_ifExpected(file_ptr, 2, &sp27); file_getByte_ifExpected(file_ptr, 2, &camera_node_type);
func_802B9EBC(arg1, sp27); __ncCameraNodeList_setCameraNodeType(camera_node_index, camera_node_type);
switch(ncCameraNodeList_getNodeType(arg1)){ switch(ncCameraNodeList_getNodeType(camera_node_index)) {
case 4:// L802BA030 case 4:
func_802BA244(file_ptr, func_802B9E34(arg1)); cameraNodeType4_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType4(camera_node_index));
break; break;
case 3:// L802BA04C case 3:
func_802BA550(file_ptr, func_802B9E48(arg1)); cameraNodeType3_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType3(camera_node_index));
break; break;
case 1:// L802BA068 case 1:
func_802BA93C(file_ptr, func_802B9E5C(arg1)); cameraNodeType1_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType1(camera_node_index));
break; break;
case 2:// L802BA084 case 2:
ncCameraNodeType2_fromFile(file_ptr, func_802B9E70(arg1)); cameraNodeType2_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType2(camera_node_index));
break; break;
case 0:// L802BA098 case 0:
break; break;
} }
} }
void ncCameraNodeList_fromFile(File *file_ptr) { void ncCameraNodeList_fromFile(File *file_ptr) {
s16 sp26; s16 camera_node_index;
ncCameraNodeList_free(); ncCameraNodeList_free();
ncCameraNodeList_init(); ncCameraNodeList_init();
while(!file_isNextByteExpected(file_ptr, 0)) { while(!file_isNextByteExpected(file_ptr, 0)) {
if(file_getShort_ifExpected(file_ptr, 1, &sp26)) if(file_getShort_ifExpected(file_ptr, 1, &camera_node_index))
__ncCameraNodeList_nodeFromFile(file_ptr, sp26); __ncCameraNodeList_nodeFromFile(file_ptr, camera_node_index);
} }
} }
void ncCameraNodeList_defrag(void){ void ncCameraNodeList_defrag() {
int i; int i;
for(i = 0; i < NC_CAMERA_NODE_LIST_CAPACITY; i++) { for(i = 0; i < NC_CAMERA_NODE_LIST_CAPACITY; i++) {
if(ncCameraNodeList[i].valid){ if(sNcCameraNodeList[i].valid) {
switch(ncCameraNodeList[i].type){ switch(sNcCameraNodeList[i].type) {
case 4:// L802BA17C case 4:
ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr);
break; break;
case 3:// L802BA18C case 3:
ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr);
break; break;
case 1:// L802BA19C case 1:
ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr);
break; break;
case 2:// L802BA1AC case 2:
ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr);
break; break;
case 0:// L802BA1B8 case 0:
break; break;
} }
} }

View File

@@ -2,8 +2,8 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
extern f32 func_802BA40C(void *); extern f32 cameraNodeType3_getFarDistance(void *);
extern f32 func_802BA420(void *); extern f32 cameraNodeType3_getCloseDistance(void *);
/* .bss */ /* .bss */
f32 D_8037DAC0[3]; f32 D_8037DAC0[3];
@@ -74,17 +74,17 @@ void func_802BF798(void) {
f32 sp28; f32 sp28;
s32 temp_v0; s32 temp_v0;
temp_v0 = func_802B9E48(); temp_v0 = ncCameraNodeList_getCameraNodeType3();
D_8037DAE4 = func_802BA4F0(temp_v0); D_8037DAE4 = code33310_func_802BA4F0(temp_v0);
func_802BA3B8(temp_v0, &D_8037DAD0); cameraNodeType3_getPositionWithPitchYawRoll(temp_v0, &D_8037DAD0);
func_802BA434(temp_v0, &D_8037DAC0); cameraNodeType3_getPosition(temp_v0, &D_8037DAC0);
func_802BA480(temp_v0, &sp2C, &sp28); cameraNodeType3_getHorizontalAndVerticalSpeed(temp_v0, &sp2C, &sp28);
func_802BE230(sp2C, sp28); func_802BE230(sp2C, sp28);
func_802BA4A8(temp_v0, &sp2C, &sp28); cameraNodeType3_getRotationAndAccelaration(temp_v0, &sp2C, &sp28);
func_802BE244(sp2C, sp28); func_802BE244(sp2C, sp28);
D_8037DAE8 = sp2C; D_8037DAE8 = sp2C;
D_8037DAEC = sp28; D_8037DAEC = sp28;
D_8037DAE0 = func_802BA420(temp_v0); D_8037DAE0 = cameraNodeType3_getCloseDistance(temp_v0);
D_8037DADC = func_802BA40C(temp_v0); D_8037DADC = cameraNodeType3_getFarDistance(temp_v0);
D_8037DAE5 = 0; D_8037DAE5 = 0;
} }

View File

@@ -63,14 +63,14 @@ void ncDynamicCam8_func_802BF9B8(s32 arg0) {
f32 sp28; f32 sp28;
s32 temp_s0; s32 temp_s0;
temp_s0 = func_802B9E5C(arg0); temp_s0 = ncCameraNodeList_getCameraNodeType1(arg0);
D_8037DB0C = func_802BA8BC(temp_s0); D_8037DB0C = code336F0_func_802BA8BC (temp_s0);
D_8037DB0D = func_802BA87C(temp_s0); D_8037DB0D = code336F0_func_802BA87C(temp_s0);
func_802BA7D8(temp_s0, &D_8037DB00); code336F0_func_802BA7D8(temp_s0, &D_8037DB00);
func_802BA78C(temp_s0, &D_8037DAF0); cameraNodeType1_getPosition(temp_s0, &D_8037DAF0);
func_802BA82C(temp_s0, &sp2C, &sp28); cameraNodeType1_getHorizontalAndVerticalSpeed(temp_s0, &sp2C, &sp28);
func_802BE230(sp2C, sp28); func_802BE230(sp2C, sp28);
func_802BA854(temp_s0, &sp2C, &sp28); cameraNodeType1_getRotationAndAccelaration(temp_s0, &sp2C, &sp28);
func_802BE244(sp2C, sp28); func_802BE244(sp2C, sp28);
D_8037DB0E = 0; D_8037DB0E = 0;
} }

View File

@@ -41,9 +41,9 @@ void ncStaticCamera_update(void){
void __ncStaticCamera_setToNode(s32 camera_node_index){ void __ncStaticCamera_setToNode(s32 camera_node_index){
UNK_TYPE(s32) sp1C; UNK_TYPE(s32) sp1C;
sp1C = func_802B9E70(camera_node_index); sp1C = ncCameraNodeList_getCameraNodeType2(camera_node_index);
ncCameraNodeType2_getPosition(sp1C, ncStaticCameraPosition); cameraNodeType2_getPosition(sp1C, ncStaticCameraPosition);
ncCameraNodeType2_getRotation(sp1C, ncStaticCameraRotation); cameraNodeType2_getPitchYawRoll(sp1C, ncStaticCameraRotation);
} }
void ncStaticCamera_setToNode(s32 camera_node_index){ void ncStaticCamera_setToNode(s32 camera_node_index){