Add wall flag, collision. Fix precalc BG mode.

This commit is contained in:
ABelliqueux 2021-08-07 16:41:08 +02:00
parent 0a1ab4b51d
commit f03d4e03b7
10 changed files with 10671 additions and 10852 deletions

View File

@ -35,7 +35,7 @@ LDFLAGS += -ltap
LDFLAGS += -lcd LDFLAGS += -lcd
LDFLAGS += -Wl,--end-group LDFLAGS += -Wl,--end-group
include $(THISDIR)/thirdparty/nugget/common.mk include $(THISDIR)thirdparty/nugget/common.mk
# convert TIM file to bin # convert TIM file to bin
%.o: %.tim %.o: %.tim

View File

@ -59,6 +59,7 @@ typedef struct MESH {
short isAnim; short isAnim;
short isActor; short isActor;
short isLevel; short isLevel;
short isWall;
short isBG; short isBG;
short isSprite; short isSprite;
long p; long p;
@ -75,7 +76,7 @@ typedef struct QUAD {
} QUAD; } QUAD;
typedef struct CAMPOS { typedef struct CAMPOS {
VECTOR pos; SVECTOR pos;
SVECTOR rot; SVECTOR rot;
} CAMPOS; } CAMPOS;

View File

@ -29,4 +29,4 @@ void getCameraZY( int * z, int * y, int actorZ, int actorY, int angleX, int dist
void applyCamera(CAMERA * cam); void applyCamera(CAMERA * cam);
void setCameraPos(CAMERA * camera, SVECTOR * pos, SVECTOR * rot); void setCameraPos(CAMERA * camera, SVECTOR * pos, SVECTOR * rot);
void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR * angle, VECTOR * angleCam, short curCamAngle, int camMode, int * lerping); void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR * angle, VECTOR * angleCam, short *curCamAngle, int camMode, int * lerping);

View File

@ -90,8 +90,8 @@ BODY level0_modelCube_body = {
{0, 0, 0, 0}, {0, 0, 0, 0},
0,-236,23, 0, 0,-236,23, 0,
0,-1024,0, 0, 0,-1024,0, 0,
1, 5,
ONE/1, ONE/5,
-33,-32,-33, 0, -33,-32,-33, 0,
33,32,33, 0, 33,32,33, 0,
0, 0,
@ -122,6 +122,7 @@ MESH level0_meshCube = {
0, // isAnim 0, // isAnim
1, // isActor 1, // isActor
0, // isLevel 0, // isLevel
0, // isWall
0, // isBG 0, // isBG
0,// isSprite 0,// isSprite
0, 0,
@ -914,6 +915,7 @@ MESH level0_meshPlane = {
{0}, {0},
{0,0,0, 0}, {0,0,0, 0},
{0,0,0, 0}, {0,0,0, 0},
0, // isWall
0, // isProp 0, // isProp
0, // isRigidBody 0, // isRigidBody
0, // isStaticBody 0, // isStaticBody

View File

@ -1,74 +1,37 @@
#pragma once #pragma once
#include "../custom_types.h" #include "../custom_types.h"
extern LEVEL level0; extern LEVEL level0;
extern CVECTOR level0_BGc; extern CVECTOR level0_BGc;
extern VECTOR level0_BKc; extern VECTOR level0_BKc;
extern CAMPOS level0_camPos_Camera; extern CAMPOS level0_camPos_Camera;
extern CAMPATH level0_camPath; extern CAMPATH level0_camPath;
extern MATRIX level0_lgtmat; extern MATRIX level0_lgtmat;
extern MATRIX level0_cmat; extern MATRIX level0_cmat;
extern SVECTOR modelCube_mesh[]; extern SVECTOR modelCube_mesh[];
extern SVECTOR level0_modelCube_normal[]; extern SVECTOR level0_modelCube_normal[];
extern CVECTOR level0_modelCube_color[]; extern CVECTOR level0_modelCube_color[];
extern PRIM level0_modelCube_index[]; extern PRIM level0_modelCube_index[];
extern BODY level0_modelCube_body; extern BODY level0_modelCube_body;
extern TMESH level0_modelCube; extern TMESH level0_modelCube;
extern MESH level0_meshCube; extern MESH level0_meshCube;
extern SVECTOR modelPlane_mesh[]; extern SVECTOR modelPlane_mesh[];
extern SVECTOR level0_modelPlane_normal[]; extern SVECTOR level0_modelPlane_normal[];
extern CVECTOR level0_modelPlane_color[]; extern CVECTOR level0_modelPlane_color[];
extern PRIM level0_modelPlane_index[]; extern PRIM level0_modelPlane_index[];
extern BODY level0_modelPlane_body; extern BODY level0_modelPlane_body;
extern TMESH level0_modelPlane; extern TMESH level0_modelPlane;
extern MESH level0_meshPlane; extern MESH level0_meshPlane;
extern MESH * level0_meshes[2]; extern MESH * level0_meshes[2];
extern int level0_meshes_length; extern int level0_meshes_length;
extern CAMANGLE level0_camAngle_Camera; extern CAMANGLE level0_camAngle_Camera;
extern CAMANGLE * level0_camAngles[0]; extern CAMANGLE * level0_camAngles[0];
extern SIBLINGS level0_nodePlane_siblings; extern SIBLINGS level0_nodePlane_siblings;
extern CHILDREN level0_nodePlane_objects; extern CHILDREN level0_nodePlane_objects;
extern CHILDREN level0_nodePlane_rigidbodies; extern CHILDREN level0_nodePlane_rigidbodies;
extern NODE level0_nodePlane; extern NODE level0_nodePlane;
extern MESH * level0_actorPtr; extern MESH * level0_actorPtr;
extern MESH * level0_levelPtr; extern MESH * level0_levelPtr;
extern MESH * level0_propPtr; extern MESH * level0_propPtr;
extern CAMANGLE * level0_camPtr; extern CAMANGLE * level0_camPtr;
extern NODE * level0_curNode; extern NODE * level0_curNode;
extern NODE level0_nodePlane; extern NODE level0_nodePlane;

File diff suppressed because it is too large Load Diff

View File

@ -2,350 +2,177 @@
#include "../custom_types.h" #include "../custom_types.h"
extern CVECTOR level1_BGc; // Far color
extern VECTOR level1_BKc;
extern LEVEL level1; extern LEVEL level1;
extern CVECTOR level1_BGc;
extern VECTOR level1_BKc;
extern CAMPOS level1_camPos_camPath; extern CAMPOS level1_camPos_camPath;
extern CAMPOS level1_camPos_camPath_001; extern CAMPOS level1_camPos_camPath_001;
extern CAMPOS level1_camPos_camPath_002; extern CAMPOS level1_camPos_camPath_002;
extern CAMPOS level1_camPos_camPath_003; extern CAMPOS level1_camPos_camPath_003;
extern CAMPOS level1_camPos_camPath_004; extern CAMPOS level1_camPos_camPath_004;
extern CAMPOS level1_camPos_camPath_005; extern CAMPOS level1_camPos_camPath_005;
extern CAMPATH level1_camPath; extern CAMPATH level1_camPath;
extern MATRIX level1_lgtmat; extern MATRIX level1_lgtmat;
extern MATRIX level1_cmat; extern MATRIX level1_cmat;
extern SVECTOR modelCube_mesh[]; extern SVECTOR modelCube_mesh[];
extern SVECTOR level1_modelCube_normal[]; extern SVECTOR level1_modelCube_normal[];
extern SVECTOR level1_modelCube_uv[]; extern SVECTOR level1_modelCube_uv[];
extern CVECTOR level1_modelCube_color[]; extern CVECTOR level1_modelCube_color[];
extern PRIM level1_modelCube_index[]; extern PRIM level1_modelCube_index[];
extern BODY level1_modelCube_body; extern BODY level1_modelCube_body;
extern TMESH level1_modelCube; extern TMESH level1_modelCube;
extern unsigned long _binary_TIM_cat_tim_start[]; extern unsigned long _binary_TIM_cat_tim_start[];
extern unsigned long _binary_TIM_cat_tim_end[]; extern unsigned long _binary_TIM_cat_tim_end[];
extern unsigned long _binary_TIM_cat_tim_length; extern unsigned long _binary_TIM_cat_tim_length;
extern TIM_IMAGE level1_tim_cat; extern TIM_IMAGE level1_tim_cat;
extern MESH level1_meshCube; extern MESH level1_meshCube;
extern SVECTOR modelCylindre_mesh[]; extern SVECTOR modelCylindre_mesh[];
extern SVECTOR level1_modelCylindre_normal[]; extern SVECTOR level1_modelCylindre_normal[];
extern SVECTOR level1_modelCylindre_uv[]; extern SVECTOR level1_modelCylindre_uv[];
extern CVECTOR level1_modelCylindre_color[]; extern CVECTOR level1_modelCylindre_color[];
extern PRIM level1_modelCylindre_index[]; extern PRIM level1_modelCylindre_index[];
extern VANIM level1_modelCylindre_anim; extern VANIM level1_modelCylindre_anim;
extern BODY level1_modelCylindre_body; extern BODY level1_modelCylindre_body;
extern TMESH level1_modelCylindre; extern TMESH level1_modelCylindre;
extern unsigned long _binary_TIM_home_tim_start[]; extern unsigned long _binary_TIM_home_tim_start[];
extern unsigned long _binary_TIM_home_tim_end[]; extern unsigned long _binary_TIM_home_tim_end[];
extern unsigned long _binary_TIM_home_tim_length; extern unsigned long _binary_TIM_home_tim_length;
extern TIM_IMAGE level1_tim_home; extern TIM_IMAGE level1_tim_home;
extern MESH level1_meshCylindre; extern MESH level1_meshCylindre;
extern SVECTOR modelgnd_mesh[]; extern SVECTOR modelgnd_mesh[];
extern SVECTOR level1_modelgnd_normal[]; extern SVECTOR level1_modelgnd_normal[];
extern SVECTOR level1_modelgnd_uv[]; extern SVECTOR level1_modelgnd_uv[];
extern CVECTOR level1_modelgnd_color[]; extern CVECTOR level1_modelgnd_color[];
extern PRIM level1_modelgnd_index[]; extern PRIM level1_modelgnd_index[];
extern BODY level1_modelgnd_body; extern BODY level1_modelgnd_body;
extern TMESH level1_modelgnd; extern TMESH level1_modelgnd;
extern MESH level1_meshgnd; extern MESH level1_meshgnd;
extern SVECTOR modelgnd_001_mesh[]; extern SVECTOR modelgnd_001_mesh[];
extern SVECTOR level1_modelgnd_001_normal[]; extern SVECTOR level1_modelgnd_001_normal[];
extern SVECTOR level1_modelgnd_001_uv[]; extern SVECTOR level1_modelgnd_001_uv[];
extern CVECTOR level1_modelgnd_001_color[]; extern CVECTOR level1_modelgnd_001_color[];
extern PRIM level1_modelgnd_001_index[]; extern PRIM level1_modelgnd_001_index[];
extern BODY level1_modelgnd_001_body; extern BODY level1_modelgnd_001_body;
extern TMESH level1_modelgnd_001; extern TMESH level1_modelgnd_001;
extern MESH level1_meshgnd_001; extern MESH level1_meshgnd_001;
extern SVECTOR modelgnd_003_mesh[]; extern SVECTOR modelgnd_003_mesh[];
extern SVECTOR level1_modelgnd_003_normal[]; extern SVECTOR level1_modelgnd_003_normal[];
extern SVECTOR level1_modelgnd_003_uv[]; extern SVECTOR level1_modelgnd_003_uv[];
extern CVECTOR level1_modelgnd_003_color[]; extern CVECTOR level1_modelgnd_003_color[];
extern PRIM level1_modelgnd_003_index[]; extern PRIM level1_modelgnd_003_index[];
extern BODY level1_modelgnd_003_body; extern BODY level1_modelgnd_003_body;
extern TMESH level1_modelgnd_003; extern TMESH level1_modelgnd_003;
extern MESH level1_meshgnd_003; extern MESH level1_meshgnd_003;
extern SVECTOR modelgnd_002_mesh[]; extern SVECTOR modelgnd_002_mesh[];
extern SVECTOR level1_modelgnd_002_normal[]; extern SVECTOR level1_modelgnd_002_normal[];
extern SVECTOR level1_modelgnd_002_uv[]; extern SVECTOR level1_modelgnd_002_uv[];
extern CVECTOR level1_modelgnd_002_color[]; extern CVECTOR level1_modelgnd_002_color[];
extern PRIM level1_modelgnd_002_index[]; extern PRIM level1_modelgnd_002_index[];
extern BODY level1_modelgnd_002_body; extern BODY level1_modelgnd_002_body;
extern TMESH level1_modelgnd_002; extern TMESH level1_modelgnd_002;
extern MESH level1_meshgnd_002; extern MESH level1_meshgnd_002;
extern SVECTOR modelLara_mesh[]; extern SVECTOR modelLara_mesh[];
extern SVECTOR level1_modelLara_normal[]; extern SVECTOR level1_modelLara_normal[];
extern SVECTOR level1_modelLara_uv[]; extern SVECTOR level1_modelLara_uv[];
extern CVECTOR level1_modelLara_color[]; extern CVECTOR level1_modelLara_color[];
extern PRIM level1_modelLara_index[]; extern PRIM level1_modelLara_index[];
extern BODY level1_modelLara_body; extern BODY level1_modelLara_body;
extern TMESH level1_modelLara; extern TMESH level1_modelLara;
extern unsigned long _binary_TIM_lara_tim_start[]; extern unsigned long _binary_TIM_lara_tim_start[];
extern unsigned long _binary_TIM_lara_tim_end[]; extern unsigned long _binary_TIM_lara_tim_end[];
extern unsigned long _binary_TIM_lara_tim_length; extern unsigned long _binary_TIM_lara_tim_length;
extern TIM_IMAGE level1_tim_lara; extern TIM_IMAGE level1_tim_lara;
extern MESH level1_meshLara; extern MESH level1_meshLara;
extern SVECTOR modelobject_mesh[]; extern SVECTOR modelobject_mesh[];
extern SVECTOR level1_modelobject_normal[]; extern SVECTOR level1_modelobject_normal[];
extern SVECTOR level1_modelobject_uv[]; extern SVECTOR level1_modelobject_uv[];
extern CVECTOR level1_modelobject_color[]; extern CVECTOR level1_modelobject_color[];
extern PRIM level1_modelobject_index[]; extern PRIM level1_modelobject_index[];
extern BODY level1_modelobject_body; extern BODY level1_modelobject_body;
extern TMESH level1_modelobject; extern TMESH level1_modelobject;
extern MESH level1_meshobject; extern MESH level1_meshobject;
extern SVECTOR modelPlan_mesh[]; extern SVECTOR modelPlan_mesh[];
extern SVECTOR level1_modelPlan_normal[]; extern SVECTOR level1_modelPlan_normal[];
extern SVECTOR level1_modelPlan_uv[]; extern SVECTOR level1_modelPlan_uv[];
extern CVECTOR level1_modelPlan_color[]; extern CVECTOR level1_modelPlan_color[];
extern PRIM level1_modelPlan_index[]; extern PRIM level1_modelPlan_index[];
extern BODY level1_modelPlan_body; extern BODY level1_modelPlan_body;
extern TMESH level1_modelPlan; extern TMESH level1_modelPlan;
extern MESH level1_meshPlan; extern MESH level1_meshPlan;
extern SVECTOR modelSphere_mesh[]; extern SVECTOR modelSphere_mesh[];
extern SVECTOR level1_modelSphere_normal[]; extern SVECTOR level1_modelSphere_normal[];
extern SVECTOR level1_modelSphere_uv[]; extern SVECTOR level1_modelSphere_uv[];
extern CVECTOR level1_modelSphere_color[]; extern CVECTOR level1_modelSphere_color[];
extern PRIM level1_modelSphere_index[]; extern PRIM level1_modelSphere_index[];
extern BODY level1_modelSphere_body; extern BODY level1_modelSphere_body;
extern TMESH level1_modelSphere; extern TMESH level1_modelSphere;
extern MESH level1_meshSphere; extern MESH level1_meshSphere;
extern SVECTOR modelSphere_001_mesh[]; extern SVECTOR modelSphere_001_mesh[];
extern SVECTOR level1_modelSphere_001_normal[]; extern SVECTOR level1_modelSphere_001_normal[];
extern SVECTOR level1_modelSphere_001_uv[]; extern SVECTOR level1_modelSphere_001_uv[];
extern CVECTOR level1_modelSphere_001_color[]; extern CVECTOR level1_modelSphere_001_color[];
extern PRIM level1_modelSphere_001_index[]; extern PRIM level1_modelSphere_001_index[];
extern BODY level1_modelSphere_001_body; extern BODY level1_modelSphere_001_body;
extern TMESH level1_modelSphere_001; extern TMESH level1_modelSphere_001;
extern MESH level1_meshSphere_001; extern MESH level1_meshSphere_001;
extern SVECTOR modelwall_mesh[]; extern SVECTOR modelwall_mesh[];
extern SVECTOR level1_modelwall_normal[]; extern SVECTOR level1_modelwall_normal[];
extern SVECTOR level1_modelwall_uv[]; extern SVECTOR level1_modelwall_uv[];
extern CVECTOR level1_modelwall_color[]; extern CVECTOR level1_modelwall_color[];
extern PRIM level1_modelwall_index[]; extern PRIM level1_modelwall_index[];
extern BODY level1_modelwall_body; extern BODY level1_modelwall_body;
extern TMESH level1_modelwall; extern TMESH level1_modelwall;
extern MESH level1_meshwall; extern MESH level1_meshwall;
extern SVECTOR modelwall_001_mesh[]; extern SVECTOR modelwall_001_mesh[];
extern SVECTOR level1_modelwall_001_normal[]; extern SVECTOR level1_modelwall_001_normal[];
extern SVECTOR level1_modelwall_001_uv[]; extern SVECTOR level1_modelwall_001_uv[];
extern CVECTOR level1_modelwall_001_color[]; extern CVECTOR level1_modelwall_001_color[];
extern PRIM level1_modelwall_001_index[]; extern PRIM level1_modelwall_001_index[];
extern BODY level1_modelwall_001_body; extern BODY level1_modelwall_001_body;
extern TMESH level1_modelwall_001; extern TMESH level1_modelwall_001;
extern MESH level1_meshwall_001; extern MESH level1_meshwall_001;
extern SVECTOR modelwall_002_mesh[]; extern SVECTOR modelwall_002_mesh[];
extern SVECTOR level1_modelwall_002_normal[]; extern SVECTOR level1_modelwall_002_normal[];
extern SVECTOR level1_modelwall_002_uv[]; extern SVECTOR level1_modelwall_002_uv[];
extern CVECTOR level1_modelwall_002_color[]; extern CVECTOR level1_modelwall_002_color[];
extern PRIM level1_modelwall_002_index[]; extern PRIM level1_modelwall_002_index[];
extern BODY level1_modelwall_002_body; extern BODY level1_modelwall_002_body;
extern TMESH level1_modelwall_002; extern TMESH level1_modelwall_002;
extern MESH level1_meshwall_002; extern MESH level1_meshwall_002;
extern SVECTOR modelwall_003_mesh[]; extern SVECTOR modelwall_003_mesh[];
extern SVECTOR level1_modelwall_003_normal[]; extern SVECTOR level1_modelwall_003_normal[];
extern SVECTOR level1_modelwall_003_uv[]; extern SVECTOR level1_modelwall_003_uv[];
extern CVECTOR level1_modelwall_003_color[]; extern CVECTOR level1_modelwall_003_color[];
extern PRIM level1_modelwall_003_index[]; extern PRIM level1_modelwall_003_index[];
extern BODY level1_modelwall_003_body; extern BODY level1_modelwall_003_body;
extern TMESH level1_modelwall_003; extern TMESH level1_modelwall_003;
extern MESH level1_meshwall_003; extern MESH level1_meshwall_003;
extern MESH * level1_meshes[15]; extern MESH * level1_meshes[15];
extern int level1_meshes_length; extern int level1_meshes_length;
extern CAMANGLE level1_camAngle_camPath_001; extern CAMANGLE level1_camAngle_camPath_001;
extern CAMANGLE * level1_camAngles[0]; extern CAMANGLE * level1_camAngles[0];
extern SIBLINGS level1_nodegnd_siblings;
extern CHILDREN level1_nodegnd_objects;
extern CHILDREN level1_nodegnd_rigidbodies;
extern NODE level1_nodegnd;
extern SIBLINGS level1_nodegnd_001_siblings; extern SIBLINGS level1_nodegnd_001_siblings;
extern CHILDREN level1_nodegnd_001_objects; extern CHILDREN level1_nodegnd_001_objects;
extern CHILDREN level1_nodegnd_001_rigidbodies; extern CHILDREN level1_nodegnd_001_rigidbodies;
extern NODE level1_nodegnd_001; extern NODE level1_nodegnd_001;
extern SIBLINGS level1_nodegnd_002_siblings;
extern CHILDREN level1_nodegnd_002_objects;
extern CHILDREN level1_nodegnd_002_rigidbodies;
extern NODE level1_nodegnd_002;
extern SIBLINGS level1_nodegnd_003_siblings; extern SIBLINGS level1_nodegnd_003_siblings;
extern CHILDREN level1_nodegnd_003_objects; extern CHILDREN level1_nodegnd_003_objects;
extern CHILDREN level1_nodegnd_003_rigidbodies; extern CHILDREN level1_nodegnd_003_rigidbodies;
extern NODE level1_nodegnd_003; extern NODE level1_nodegnd_003;
extern SIBLINGS level1_nodegnd_002_siblings;
extern MESH * level1_actorPtr; extern CHILDREN level1_nodegnd_002_objects;
extern CHILDREN level1_nodegnd_002_rigidbodies;
extern MESH * level1_levelPtr;
extern MESH * level1_propPtr;
extern CAMANGLE * level1_camPtr;
extern NODE * level1_curNode;
extern NODE level1_nodegnd;
extern NODE level1_nodegnd_001;
extern NODE level1_nodegnd_002; extern NODE level1_nodegnd_002;
extern SIBLINGS level1_nodegnd_siblings;
extern CHILDREN level1_nodegnd_objects;
extern CHILDREN level1_nodegnd_rigidbodies;
extern NODE level1_nodegnd;
extern MESH * level1_actorPtr;
extern MESH * level1_levelPtr;
extern MESH * level1_propPtr;
extern CAMANGLE * level1_camPtr;
extern NODE * level1_curNode;
extern NODE level1_nodegnd_001;
extern NODE level1_nodegnd_003; extern NODE level1_nodegnd_003;
extern NODE level1_nodegnd_002;
extern NODE level1_nodegnd;

View File

@ -34,15 +34,10 @@ void setCameraPos( CAMERA * camera, SVECTOR * pos, SVECTOR * rot ) {
copyVector(dc_camPos, pos); copyVector(dc_camPos, pos);
copyVector(dc_camRot, rot); copyVector(dc_camRot, rot);
}; };
void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR * angle, VECTOR * angleCam, short curCamAngle, int camMode, int * lerping){ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR * angle, VECTOR * angleCam, short *curCamAngle, int camMode, int * lerping){
int dist = 0; int dist = 0;
short cameraSpeed = 40; short cameraSpeed = 40;
//~ if(camMode != 2) {
//~ camera->rot->vy = camAngleToAct->vy;
//~ // using csin/ccos, no need for theta
//~ camera->rot->vx = camAngleToAct->vx;
//~ }
if(camMode < 4 ) { if(camMode < 4 ) {
*lerping = 0; *lerping = 0;
} }
@ -73,32 +68,33 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
case 2 : case 2 :
// If BG images exist // If BG images exist
if (curLvl->camPtr->tim_data){ if (curLvl->camPtr->tim_data){
checkLineW( &curLvl->camAngles[ curCamAngle ]->fw.v3, &curLvl->camAngles[ curCamAngle ]->fw.v2, curLvl->actorPtr); // Check which side of the line the actor is on (World space)
if ( curLvl->camAngles[ curCamAngle ]->fw.v0.vx ) { checkLineW( &curLvl->camAngles[ *curCamAngle ]->fw.v3, &curLvl->camAngles[ *curCamAngle ]->fw.v2, curLvl->actorPtr);
if ( curLvl->camAngles[ *curCamAngle ]->fw.v0.vx ) {
// If actor in camAngle->fw area of screen // If actor in camAngle->fw area of screen
if ( checkLineW( &curLvl->camAngles[ curCamAngle ]->fw.v3, &curLvl->camAngles[ curCamAngle ]->fw.v2, curLvl->actorPtr) == -1 && if ( checkLineW( &curLvl->camAngles[ *curCamAngle ]->fw.v3, &curLvl->camAngles[ *curCamAngle ]->fw.v2, curLvl->actorPtr) == -1 &&
( checkLineW( &curLvl->camAngles[ curCamAngle ]->bw.v2, &curLvl->camAngles[ curCamAngle ]->bw.v3, curLvl->actorPtr) >= 0 ( checkLineW( &curLvl->camAngles[ *curCamAngle ]->bw.v2, &curLvl->camAngles[ *curCamAngle ]->bw.v3, curLvl->actorPtr) >= 0 )
)
) { ) {
if (curCamAngle < 5) { if (*curCamAngle < 5) {
curCamAngle++; (*curCamAngle)++;
curLvl->camPtr = curLvl->camAngles[ curCamAngle ]; curLvl->camPtr = curLvl->camAngles[ *curCamAngle ];
LoadTexture(curLvl->camPtr->tim_data, curLvl->camPtr->BGtim); LoadTexture(curLvl->camPtr->tim_data, curLvl->camPtr->BGtim);
} }
} }
} }
if ( curLvl->camAngles[ curCamAngle ]->bw.v0.vx ) { if ( curLvl->camAngles[ *curCamAngle ]->bw.v0.vx ) {
// If actor in camAngle->bw area of screen // If actor in camAngle->bw area of screen
if ( checkLineW( &curLvl->camAngles[ curCamAngle ]->fw.v3, &curLvl->camAngles[ curCamAngle ]->fw.v2, curLvl->actorPtr) >= 0 && if ( checkLineW( &curLvl->camAngles[ *curCamAngle ]->fw.v3, &curLvl->camAngles[ *curCamAngle ]->fw.v2, curLvl->actorPtr) >= 0 &&
checkLineW( &curLvl->camAngles[ curCamAngle ]->bw.v2, &curLvl->camAngles[ curCamAngle ]->bw.v3, curLvl->actorPtr) == -1 checkLineW( &curLvl->camAngles[ *curCamAngle ]->bw.v2, &curLvl->camAngles[ *curCamAngle ]->bw.v3, curLvl->actorPtr) == -1
) { ) {
if (curCamAngle > 0) { if (*curCamAngle > 0) {
curCamAngle--; (*curCamAngle)--;
curLvl->camPtr = curLvl->camAngles[ curCamAngle ]; curLvl->camPtr = curLvl->camAngles[ *curCamAngle ];
LoadTexture(curLvl->camPtr->tim_data, curLvl->camPtr->BGtim); LoadTexture(curLvl->camPtr->tim_data, curLvl->camPtr->BGtim);
} }
} }
} }
// Find screen space coordinates
worldToScreen( &curLvl->actorPtr->pos, &curLvl->actorPtr->pos2D ); worldToScreen( &curLvl->actorPtr->pos, &curLvl->actorPtr->pos2D );
} }
setCameraPos(camera, &curLvl->camPtr->campos->pos, &curLvl->camPtr->campos->rot); setCameraPos(camera, &curLvl->camPtr->campos->pos, &curLvl->camPtr->campos->rot);

View File

@ -152,8 +152,11 @@ int main() {
LoadTexture(curLvl.meshes[k]->tim_data, curLvl.meshes[k]->tim); LoadTexture(curLvl.meshes[k]->tim_data, curLvl.meshes[k]->tim);
} }
} }
// Load current BG if exists // Load current BG if exists, and set cam mode accordingly
if (curLvl.camPtr->tim_data){ if (curLvl.camPtr->tim_data){
// Switch to proper cam mode and angle
camMode = FIXED;
curCamAngle = 1;
LoadTexture(curLvl.camPtr->tim_data, curLvl.camPtr->BGtim); LoadTexture(curLvl.camPtr->tim_data, curLvl.camPtr->BGtim);
} }
// Polycount // Polycount
@ -170,13 +173,7 @@ int main() {
propStartNode = curLvl.propPtr->node; propStartNode = curLvl.propPtr->node;
// Set camera starting pos // Set camera starting pos
setCameraPos(&camera, &curLvl.camPtr->campos->pos, &curLvl.camPtr->campos->rot); setCameraPos(&camera, &curLvl.camPtr->campos->pos, &curLvl.camPtr->campos->rot);
// Time counter
// Find curCamAngle if using pre-calculated BGs
if (camMode == 2) {
if (curLvl.camPtr->tim_data){
curCamAngle = 1;
}
}
oldTime = GetRCnt(RCntCNT1); oldTime = GetRCnt(RCntCNT1);
// Main loop // Main loop
while ( VSync(VSYNC) ) { while ( VSync(VSYNC) ) {
@ -230,7 +227,8 @@ int main() {
if (time % timediv == 0){ if (time % timediv == 0){
atime ++; atime ++;
} }
// Reset player pos // TODO : put in a function
// Reset player/prop pos
if(curLvl.actorPtr->pos.vy >= 200){ if(curLvl.actorPtr->pos.vy >= 200){
copyVector(&curLvl.actorPtr->body->position, &actorStartPos ); copyVector(&curLvl.actorPtr->body->position, &actorStartPos );
copyVector(&curLvl.actorPtr->rot, &actorStartRot ); copyVector(&curLvl.actorPtr->rot, &actorStartRot );
@ -267,13 +265,24 @@ int main() {
} }
// Physics // Physics
if ( physics ) { if ( physics ) {
// if(time%1 == 0){
for ( int k = 0; k < *curLvl.meshes_length; k ++ ) { for ( int k = 0; k < *curLvl.meshes_length; k ++ ) {
if ( curLvl.meshes[k]->isRigidBody == 1 ) { if ( curLvl.meshes[k]->isRigidBody == 1 ) {
applyAcceleration( curLvl.meshes[k]->body, dt); applyAcceleration( curLvl.meshes[k]->body, dt);
// Get col between actor and level
if ( curLvl.meshes[k]->isActor ){ if ( curLvl.meshes[k]->isActor ){
// Get col between actor and level
checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body ); checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body );
// Get col between actor and current node's walls
// Loop on current node's objects
for (short obj=0; obj < curLvl.curNode->objects->index; obj++){
// If isWall, check collision
if ( curLvl.curNode->objects->list[obj]->isWall ){
if( getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vz &&
getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vx) {
curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
}
}
}
} }
// Get col between props and level // Get col between props and level
if ( curLvl.meshes[k]->isProp ){ if ( curLvl.meshes[k]->isProp ){
@ -306,7 +315,7 @@ int main() {
// Clear Secondary OT // Clear Secondary OT
ClearOTagR(ot[db], OTLEN); ClearOTagR(ot[db], OTLEN);
// Set camera according to mode // Set camera according to mode
setCameraMode(&curLvl, &camera, &posToActor, &angle, &angleCam, curCamAngle, camMode, &lerping); setCameraMode(&curLvl, &camera, &posToActor, &angle, &angleCam, &curCamAngle, camMode, &lerping);
// Render scene // Render scene
renderScene(&curLvl, &camera, &camMode, &nextpri, ot[db], otdisc[db], &db, &draw[db], curCamAngle, atime); renderScene(&curLvl, &camera, &camMode, &nextpri, ot[db], otdisc[db], &db, &draw[db], curCamAngle, atime);
// Set camera // Set camera
@ -320,7 +329,7 @@ int main() {
= =
); );
// Point camera at actor unless camMode == FIXED // Point camera at actor unless camMode == FIXED
if (camMode!=2){ copyVector(dc_camRot, dc_actorRot); } if (camMode != FIXED){ copyVector(dc_camRot, dc_actorRot); }
// //
applyCamera(&camera); applyCamera(&camera);
@ -335,8 +344,9 @@ int main() {
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]); AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
//~ FntPrint("\nTime : %d\n", time); //~ FntPrint("\nTime : %d\n", time);
FntPrint("#Tri : %d\n", triCount); FntPrint("\n#Tri : %d\n", triCount);
FntPrint("#RCnt : %d %d\n", oldTime, dt); FntPrint("#RCnt : %d %d\n", oldTime, dt);
FntPrint("CamAngle : %d\n", curCamAngle);
FntFlush(-1); FntFlush(-1);
display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db); display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db);
} }
@ -375,6 +385,7 @@ void callback() {
angleCam.vy = 0; angleCam.vy = 0;
} }
if ( PAD & PadShldR1 && !timer ) { if ( PAD & PadShldR1 && !timer ) {
// Change camera angle switching mode if using pre-calculated BGs
if (!curLvl.camPtr->tim_data){ if (!curLvl.camPtr->tim_data){
if(camMode < 5){ if(camMode < 5){
camMode ++; camMode ++;
@ -505,7 +516,7 @@ void callback() {
timer = 30; timer = 30;
lastPad = PAD; lastPad = PAD;
} }
if( theControllers[0].type == 0x73 && camMode == 0){ if( theControllers[0].type == 0x73 && camMode == ACTOR){
// Cam control - horizontal // Cam control - horizontal
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) { if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) {
angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 8 ; angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 8 ;

View File

@ -108,9 +108,12 @@ void checkBodyCol(BODY * one, BODY * two){
VECTOR colInt, colExt; VECTOR colInt, colExt;
colInt = getIntCollision( *one , *two ); colInt = getIntCollision( *one , *two );
//~ colExt = getExtCollision( *one , *two ); //~ colExt = getExtCollision( *one , *two );
// If collisiton on Y axis,
if ( colInt.vy ) { if ( colInt.vy ) {
// and above plane
if ( !colInt.vx && !colInt.vz ) { if ( !colInt.vx && !colInt.vz ) {
one->position.vy = one->min.vy; // collide
one->position.vy = two->max.vy - one->max.vy ;
one->velocity.vy = 0; one->velocity.vy = 0;
two->velocity.vy = 0; two->velocity.vy = 0;
} }