Fixes #7; Move sprite/billboard system to graphics.c
This commit is contained in:
parent
dd4290fe4e
commit
8469e7aeb0
171
custom_types.h
171
custom_types.h
@ -16,67 +16,67 @@ struct NODE;
|
|||||||
struct QUAD;
|
struct QUAD;
|
||||||
|
|
||||||
typedef struct BODY {
|
typedef struct BODY {
|
||||||
VECTOR gForce;
|
VECTOR gForce;
|
||||||
VECTOR position;
|
VECTOR position;
|
||||||
SVECTOR velocity;
|
SVECTOR velocity;
|
||||||
int mass;
|
int mass;
|
||||||
int invMass;
|
int invMass;
|
||||||
VECTOR min;
|
VECTOR min;
|
||||||
VECTOR max;
|
VECTOR max;
|
||||||
int restitution;
|
int restitution;
|
||||||
} BODY;
|
} BODY;
|
||||||
|
|
||||||
typedef struct VANIM {
|
typedef struct VANIM {
|
||||||
int nframes; // number of frames e.g 20
|
int nframes; // number of frames e.g 20
|
||||||
int nvert; // number of vertices e.g 21
|
int nvert; // number of vertices e.g 21
|
||||||
int cursor; // anim cursor
|
int cursor; // anim cursor
|
||||||
int lerpCursor; // anim cursor
|
int lerpCursor; // anim cursor
|
||||||
int dir; // playback direction (1 or -1)
|
int dir; // playback direction (1 or -1)
|
||||||
int interpolate; // use lerp to interpolate keyframes
|
int interpolate; // use lerp to interpolate keyframes
|
||||||
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
|
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
|
||||||
} VANIM;
|
} VANIM;
|
||||||
|
|
||||||
typedef struct PRIM {
|
typedef struct PRIM {
|
||||||
VECTOR order;
|
VECTOR order;
|
||||||
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
||||||
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
||||||
} PRIM;
|
} PRIM;
|
||||||
|
|
||||||
typedef struct MESH {
|
typedef struct MESH {
|
||||||
int totalVerts;
|
int totalVerts;
|
||||||
TMESH * tmesh;
|
TMESH * tmesh;
|
||||||
PRIM * index;
|
PRIM * index;
|
||||||
TIM_IMAGE * tim;
|
TIM_IMAGE * tim;
|
||||||
unsigned long * tim_data;
|
unsigned long * tim_data;
|
||||||
MATRIX mat;
|
MATRIX mat;
|
||||||
VECTOR pos;
|
VECTOR pos;
|
||||||
SVECTOR rot;
|
SVECTOR rot;
|
||||||
short isRigidBody;
|
short isRigidBody;
|
||||||
short isStaticBody;
|
short isStaticBody;
|
||||||
short isRound;
|
short isRound;
|
||||||
short isPrism;
|
short isPrism;
|
||||||
short isAnim;
|
short isAnim;
|
||||||
short isActor;
|
short isActor;
|
||||||
short isLevel;
|
short isLevel;
|
||||||
short isBG;
|
short isBG;
|
||||||
short isSprite;
|
short isSprite;
|
||||||
long p;
|
long p;
|
||||||
long OTz;
|
long OTz;
|
||||||
BODY * body;
|
BODY * body;
|
||||||
VANIM * anim;
|
VANIM * anim;
|
||||||
struct NODE * node;
|
struct NODE * node;
|
||||||
VECTOR pos2D;
|
VECTOR pos2D;
|
||||||
} MESH;
|
} MESH;
|
||||||
|
|
||||||
typedef struct QUAD {
|
typedef struct QUAD {
|
||||||
VECTOR v0, v1;
|
VECTOR v0, v1;
|
||||||
VECTOR v2, v3;
|
VECTOR v2, v3;
|
||||||
} QUAD;
|
} QUAD;
|
||||||
|
|
||||||
typedef struct CAMPOS {
|
typedef struct CAMPOS {
|
||||||
VECTOR pos;
|
VECTOR pos;
|
||||||
SVECTOR rot;
|
SVECTOR rot;
|
||||||
} CAMPOS;
|
} CAMPOS;
|
||||||
|
|
||||||
|
|
||||||
// Blender cam ~= PSX cam with these settings :
|
// Blender cam ~= PSX cam with these settings :
|
||||||
@ -86,49 +86,48 @@ typedef struct CAMPOS {
|
|||||||
// Lower values mean wider angle
|
// Lower values mean wider angle
|
||||||
|
|
||||||
typedef struct CAMANGLE {
|
typedef struct CAMANGLE {
|
||||||
CAMPOS * campos;
|
CAMPOS * campos;
|
||||||
TIM_IMAGE * BGtim;
|
TIM_IMAGE * BGtim;
|
||||||
unsigned long * tim_data;
|
unsigned long * tim_data;
|
||||||
QUAD bw, fw;
|
QUAD bw, fw;
|
||||||
int index;
|
int index;
|
||||||
MESH * objects[];
|
MESH * objects[];
|
||||||
} CAMANGLE;
|
} CAMANGLE;
|
||||||
|
|
||||||
typedef struct CAMPATH {
|
typedef struct CAMPATH {
|
||||||
short len, cursor, pos;
|
short len, cursor, pos;
|
||||||
VECTOR points[];
|
VECTOR points[];
|
||||||
} CAMPATH;
|
} CAMPATH;
|
||||||
|
|
||||||
typedef struct SIBLINGS {
|
typedef struct SIBLINGS {
|
||||||
int index;
|
int index;
|
||||||
struct NODE * list[];
|
struct NODE * list[];
|
||||||
} SIBLINGS ;
|
} SIBLINGS ;
|
||||||
|
|
||||||
typedef struct CHILDREN {
|
typedef struct CHILDREN {
|
||||||
int index;
|
int index;
|
||||||
MESH * list[];
|
MESH * list[];
|
||||||
} CHILDREN ;
|
} CHILDREN ;
|
||||||
|
|
||||||
typedef struct NODE {
|
typedef struct NODE {
|
||||||
MESH * plane;
|
MESH * plane;
|
||||||
SIBLINGS * siblings;
|
SIBLINGS * siblings;
|
||||||
CHILDREN * objects;
|
CHILDREN * objects;
|
||||||
CHILDREN * rigidbodies;
|
CHILDREN * rigidbodies;
|
||||||
} NODE;
|
} NODE;
|
||||||
|
|
||||||
typedef struct LEVEL {
|
typedef struct LEVEL {
|
||||||
CVECTOR * BGc;
|
CVECTOR * BGc;
|
||||||
VECTOR * BKc;
|
VECTOR * BKc;
|
||||||
MATRIX * cmat;
|
MATRIX * cmat;
|
||||||
MATRIX * lgtmat;
|
MATRIX * lgtmat;
|
||||||
MESH ** meshes;
|
MESH ** meshes;
|
||||||
int * meshes_length;
|
int * meshes_length;
|
||||||
MESH * actorPtr;
|
MESH * actorPtr;
|
||||||
MESH * levelPtr;
|
MESH * levelPtr;
|
||||||
MESH * propPtr;
|
MESH * propPtr;
|
||||||
CAMANGLE * camPtr;
|
CAMANGLE * camPtr;
|
||||||
CAMPATH * camPath;
|
CAMPATH * camPath;
|
||||||
CAMANGLE ** camAngles;
|
CAMANGLE ** camAngles;
|
||||||
NODE * curNode;
|
NODE * curNode;
|
||||||
MESH * meshPlan; // This one is temporary
|
} LEVEL;
|
||||||
} LEVEL;
|
|
||||||
|
1908
levels/level0.c
1908
levels/level0.c
File diff suppressed because it is too large
Load Diff
@ -72,16 +72,3 @@ extern NODE * level0_curNode;
|
|||||||
|
|
||||||
extern NODE level0_nodePlane;
|
extern NODE level0_nodePlane;
|
||||||
|
|
||||||
extern SVECTOR level0_modelPlan_normal[];
|
|
||||||
|
|
||||||
extern SVECTOR level0_modelPlan_uv[];
|
|
||||||
|
|
||||||
extern CVECTOR level0_modelPlan_color[];
|
|
||||||
|
|
||||||
extern PRIM level0_modelPlan_index[];
|
|
||||||
|
|
||||||
extern BODY level0_modelPlan_body;
|
|
||||||
|
|
||||||
extern TMESH level0_modelPlan;
|
|
||||||
|
|
||||||
extern MESH level0_meshPlan;
|
|
||||||
|
@ -11022,6 +11022,5 @@ LEVEL level1 = {
|
|||||||
&level1_camAngle_camPath_001,
|
&level1_camAngle_camPath_001,
|
||||||
&level1_camPath,
|
&level1_camPath,
|
||||||
(CAMANGLE **)&level1_camAngles,
|
(CAMANGLE **)&level1_camAngles,
|
||||||
&level1_nodegnd_002,
|
&level1_nodegnd_002
|
||||||
&level1_meshPlan
|
|
||||||
};
|
};
|
||||||
|
@ -311,7 +311,14 @@ long drawQuad(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No animation
|
// Mesh is sprite
|
||||||
|
if (mesh->isSprite){
|
||||||
|
// Find inverse rotation matrix so that sprite always faces camera
|
||||||
|
MATRIX rot, invRot;
|
||||||
|
ReadRotMatrix(&rot);
|
||||||
|
TransposeMatrix(&rot, &invRot);
|
||||||
|
SetMulRotMatrix(&invRot);
|
||||||
|
}
|
||||||
// Use regular vertex coords
|
// Use regular vertex coords
|
||||||
nclip = RotAverageNclip4(
|
nclip = RotAverageNclip4(
|
||||||
&mesh->tmesh->v[ mesh->index[t].order.pad ],
|
&mesh->tmesh->v[ mesh->index[t].order.pad ],
|
||||||
@ -334,6 +341,7 @@ long drawQuad(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (mesh->isSprite){
|
if (mesh->isSprite){
|
||||||
|
// Turn off shading on sprite
|
||||||
SetShadeTex( poly4, 1 );
|
SetShadeTex( poly4, 1 );
|
||||||
}
|
}
|
||||||
// Transparency effect
|
// Transparency effect
|
||||||
@ -381,6 +389,13 @@ long drawTri(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No animation
|
// No animation
|
||||||
|
if (mesh->isSprite){
|
||||||
|
// Find inverse rotation matrix so that sprite always faces camera
|
||||||
|
MATRIX rot, invRot;
|
||||||
|
ReadRotMatrix(&rot);
|
||||||
|
TransposeMatrix(&rot, &invRot);
|
||||||
|
SetMulRotMatrix(&invRot);
|
||||||
|
}
|
||||||
// Use model's regular vertex coordinates
|
// Use model's regular vertex coordinates
|
||||||
nclip = RotAverageNclip3(
|
nclip = RotAverageNclip3(
|
||||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||||
|
75
src/main.c
75
src/main.c
@ -87,8 +87,6 @@ int meshes_length = 0;
|
|||||||
NODE curNode = {0};
|
NODE curNode = {0};
|
||||||
CAMPATH camPath = {0};
|
CAMPATH camPath = {0};
|
||||||
CAMANGLE camPtr = {0}, camAngles[] = {0};
|
CAMANGLE camPtr = {0}, camAngles[] = {0};
|
||||||
MESH meshPlan = {0};
|
|
||||||
VECTOR modelPlan_pos = {0};
|
|
||||||
LEVEL curLvl = {
|
LEVEL curLvl = {
|
||||||
&BGc,
|
&BGc,
|
||||||
&BKc,
|
&BKc,
|
||||||
@ -102,8 +100,7 @@ LEVEL curLvl = {
|
|||||||
&camPtr,
|
&camPtr,
|
||||||
&camPath,
|
&camPath,
|
||||||
(CAMANGLE **)&camAngles,
|
(CAMANGLE **)&camAngles,
|
||||||
&curNode,
|
&curNode
|
||||||
&meshPlan
|
|
||||||
};
|
};
|
||||||
LEVEL * loadLvl;
|
LEVEL * loadLvl;
|
||||||
// Pad
|
// Pad
|
||||||
@ -229,22 +226,7 @@ int main() {
|
|||||||
// using atantable (faster)
|
// using atantable (faster)
|
||||||
camAngleToAct.vy = (patan(-posToActor.vx, -posToActor.vz) / 16) - 3076 ;
|
camAngleToAct.vy = (patan(-posToActor.vx, -posToActor.vz) / 16) - 3076 ;
|
||||||
camAngleToAct.vx = patan(dist, posToActor.vy) >> 4;
|
camAngleToAct.vx = patan(dist, posToActor.vy) >> 4;
|
||||||
// Sprite system WIP
|
// Find Actor's forward vector
|
||||||
objAngleToCam.vy = patan( posToCam.vx,posToCam.vz );
|
|
||||||
objAngleToCam.vx = patan( posToCam.vx,posToCam.vy );
|
|
||||||
//~ objAngleToCam.vz = patan( posToCam.vz,posToCam.vy );
|
|
||||||
//~ objAngleToCam.vx = patan( psqrt(posToCam.vx * posToCam.vx + posToCam.vy * posToCam.vy), posToCam.vy );
|
|
||||||
//~ curLvl.meshPlan.rot->vx = -( (objAngleToCam.vx >> 4) - 3076 ) ;
|
|
||||||
//~ curLvl.meshPlan.rot->vx = (( (objAngleToCam.vx >> 4) - 3076 ) * ( (objAngleToCam.vz >> 4) - 3076 ) >> 12) * (nsin(posToCam.vz) >> 10 < 0 ? -1 : 1);
|
|
||||||
//~ curLvl.meshPlan.rot->vx = ( (objAngleToCam.vx >> 4) - 3076 ) * ( (objAngleToCam.vz >> 4) - 3076 ) >> 12 ;
|
|
||||||
curLvl.meshPlan->rot.vy = -( (objAngleToCam.vy >> 4) + 1024 ) ;
|
|
||||||
//~ posToCam = getVectorTo(*curLvl.meshPlan.pos, camera.pos);
|
|
||||||
//~ posToCam = getVectorTo(camera.pos, *curLvl.meshPlan.pos);
|
|
||||||
posToCam.vx = -camera.pos.vx - curLvl.meshPlan->pos.vx ;
|
|
||||||
posToCam.vz = -camera.pos.vz - curLvl.meshPlan->pos.vz ;
|
|
||||||
posToCam.vy = -camera.pos.vy - curLvl.meshPlan->pos.vy ;
|
|
||||||
//~ psqrt(posToCam.vx * posToCam.vx + posToCam.vy * posToCam.vy);
|
|
||||||
// Actor Forward vector for 3d relative orientation
|
|
||||||
fVecActor = curLvl.actorPtr->pos;
|
fVecActor = curLvl.actorPtr->pos;
|
||||||
fVecActor.vx = curLvl.actorPtr->pos.vx + (nsin(curLvl.actorPtr->rot.vy/2));
|
fVecActor.vx = curLvl.actorPtr->pos.vx + (nsin(curLvl.actorPtr->rot.vy/2));
|
||||||
fVecActor.vz = curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2));
|
fVecActor.vz = curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2));
|
||||||
@ -264,20 +246,10 @@ int main() {
|
|||||||
camera.pos.vx = -(camera.x/ONE);
|
camera.pos.vx = -(camera.x/ONE);
|
||||||
camera.pos.vy = -(camera.y/ONE);
|
camera.pos.vy = -(camera.y/ONE);
|
||||||
camera.pos.vz = -(camera.z/ONE);
|
camera.pos.vz = -(camera.z/ONE);
|
||||||
//~ InvCamPos.vx = camera.x/ONE;
|
|
||||||
//~ InvCamPos.vz = camera.z/ONE;
|
|
||||||
//~ applyVector(&InvCamPos, -1,-1,-1, *=);
|
|
||||||
angle.vy = -(curLvl.actorPtr->rot.vy / 2) + angleCam.vy;
|
angle.vy = -(curLvl.actorPtr->rot.vy / 2) + angleCam.vy;
|
||||||
//~ angle.vx += 10;
|
|
||||||
//~ FntPrint("cos %d", (ncos(angle.vy) * ncos(angle.vx)) >> 12);
|
|
||||||
//~ angle = curLvl.actorPtr->rot->vy;
|
|
||||||
// Camera horizontal position
|
// Camera horizontal position
|
||||||
getCameraZY(&camera.z, &camera.y, curLvl.actorPtr->pos.vz, curLvl.actorPtr->pos.vy, angle.vx, dist);
|
getCameraZY(&camera.z, &camera.y, curLvl.actorPtr->pos.vz, curLvl.actorPtr->pos.vy, angle.vx, dist);
|
||||||
getCameraXZ(&camera.x, &camera.z, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vz, angle.vy, dist);
|
getCameraXZ(&camera.x, &camera.z, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vz, angle.vy, dist);
|
||||||
//~ getCameraXZY(&camera.x, &camera.z, &camera.y, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vz, curLvl.actorPtr->pos.vy, angle.vy, angle.vx, dist);
|
|
||||||
//~ void getCameraXZY(int * x, int * z, int * y, int actorX, int actorZ, int actorY, int angle, int angleX, int distance) {
|
|
||||||
// Camera vertical position
|
|
||||||
//~ getCameraXZ(&camera.x, &camera.y, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vy, angle, dist);
|
|
||||||
// FIXME! camera lerping to pos
|
// FIXME! camera lerping to pos
|
||||||
//~ angle += lerp(camera.rot.vy, -curLvl.actorPtr->rot->vy, 128);
|
//~ angle += lerp(camera.rot.vy, -curLvl.actorPtr->rot->vy, 128);
|
||||||
//~ angle = lerpD(camera.rot.vy << 12, curLvl.actorPtr->rot->vy << 12, 1024 << 12) >> 12;
|
//~ angle = lerpD(camera.rot.vy << 12, curLvl.actorPtr->rot->vy << 12, 1024 << 12) >> 12;
|
||||||
@ -289,9 +261,7 @@ int main() {
|
|||||||
//~ camera.pos.vy = -(camera.y/ONE);
|
//~ camera.pos.vy = -(camera.y/ONE);
|
||||||
camera.pos.vy = 100;
|
camera.pos.vy = 100;
|
||||||
camera.pos.vz = -(camera.z/ONE);
|
camera.pos.vz = -(camera.z/ONE);
|
||||||
//~ fVecActor = *curLvl.actorPtr->pos;
|
|
||||||
//~ fVecActor.vx = curLvl.actorPtr->pos->vx + (nsin(curLvl.actorPtr->rot->vy));
|
|
||||||
//~ fVecActor.vz = curLvl.actorPtr->pos->vz - (ncos(curLvl.actorPtr->rot->vy));
|
|
||||||
getCameraXZ(&camera.x, &camera.z, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vz, angle.vy, dist);
|
getCameraXZ(&camera.x, &camera.z, curLvl.actorPtr->pos.vx, curLvl.actorPtr->pos.vz, angle.vy, dist);
|
||||||
angle.vy += 10;
|
angle.vy += 10;
|
||||||
}
|
}
|
||||||
@ -309,10 +279,6 @@ int main() {
|
|||||||
if (curLvl.camPtr->tim_data){
|
if (curLvl.camPtr->tim_data){
|
||||||
checkLineW( &curLvl.camAngles[ curCamAngle ]->fw.v3, &curLvl.camAngles[ curCamAngle ]->fw.v2, curLvl.actorPtr);
|
checkLineW( &curLvl.camAngles[ curCamAngle ]->fw.v3, &curLvl.camAngles[ curCamAngle ]->fw.v2, curLvl.actorPtr);
|
||||||
if ( curLvl.camAngles[ curCamAngle ]->fw.v0.vx ) {
|
if ( curLvl.camAngles[ curCamAngle ]->fw.v0.vx ) {
|
||||||
//~ FntPrint("BL x : %d, y : %d\n", camAngles[ curCamAngle ]->fw.v3.vx, camAngles[ curCamAngle ]->fw.v3.vy);
|
|
||||||
//~ FntPrint("BR x : %d, y : %d\n", camAngles[ curCamAngle ]->fw.v2.vx, camAngles[ curCamAngle ]->fw.v2.vy);
|
|
||||||
//~ FntPrint("Pos : %d\n", checkLineW( &camAngles[ curCamAngle ]->fw.v3, &camAngles[ curCamAngle ]->fw.v2, curLvl.actorPtr) );
|
|
||||||
//~ FntPrint("Pos : %d\n", checkLineW( &camAngles[ curCamAngle ]->bw.v2, &camAngles[ curCamAngle ]->bw.v3, curLvl.actorPtr) );
|
|
||||||
// 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
|
||||||
@ -326,9 +292,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( curLvl.camAngles[ curCamAngle ]->bw.v0.vx ) {
|
if ( curLvl.camAngles[ curCamAngle ]->bw.v0.vx ) {
|
||||||
//~ FntPrint("BL x : %d, y : %d\n", camAngles[ curCamAngle ]->bw.v3.vx, camAngles[ curCamAngle ]->bw.v3.vy);
|
|
||||||
//~ FntPrint("BR x : %d, y : %d\n", camAngles[ curCamAngle ]->bw.v2.vx, camAngles[ curCamAngle ]->bw.v2.vy);
|
|
||||||
//~ // FntPrint("Pos : %d\n", checkLineW( &camAngles[ curCamAngle ]->bw.v2, &camAngles[ curCamAngle ]->bw.v3, curLvl.actorPtr) );
|
|
||||||
// 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
|
||||||
@ -365,10 +328,6 @@ int main() {
|
|||||||
camera.pos.vx = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vx << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vx << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vx = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vx << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vx << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
camera.pos.vy = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vy << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vy << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vy = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vy << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vy << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
camera.pos.vz = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vz << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vz << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vz = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vz << precision, curLvl.camPath->points[curLvl.camPath->cursor+1].vz << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
//~ FntPrint("Cam %d, %d\n", (int32_t)curLvl.camPath->points[curLvl.camPath->cursor].vx, curLvl.camPath->points[curLvl.camPath->cursor+1].vx);
|
|
||||||
//~ FntPrint("Cam %d, %d, %d\n", camera.pos.vx, camera.pos.vy, camera.pos.vz);
|
|
||||||
//~ FntPrint("Theta y: %d x: %d\n", theta.vy, theta.vx);
|
|
||||||
//~ FntPrint("Pos: %d Cur: %d\nTheta y: %d x: %d\n", curLvl.camPath->pos, curLvl.camPath->cursor, theta.vy, theta.vx);
|
|
||||||
// Linearly increment the lerp factor
|
// Linearly increment the lerp factor
|
||||||
curLvl.camPath->pos += 20;
|
curLvl.camPath->pos += 20;
|
||||||
// If camera has reached next key pos, reset pos index, move cursor to next key pos
|
// If camera has reached next key pos, reset pos index, move cursor to next key pos
|
||||||
@ -409,7 +368,6 @@ int main() {
|
|||||||
camera.pos.vx = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vx << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vx << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vx = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vx << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vx << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
camera.pos.vy = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vy << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vy << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vy = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vy << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vy << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
camera.pos.vz = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vz << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vz << precision, curLvl.camPath->pos << precision) >> precision;
|
camera.pos.vz = lerpD(curLvl.camPath->points[curLvl.camPath->cursor].vz << precision, curLvl.camPath->points[curLvl.camPath->cursor + 1].vz << precision, curLvl.camPath->pos << precision) >> precision;
|
||||||
//~ FntPrint("%d %d %d %d\n", camAngleToAct.vy, camera.pos.vx, camera.rot.vy, dist);
|
|
||||||
// Ony move cam if position is between first curLvl.camPath->vx and last curLvl.camPath->vx
|
// Ony move cam if position is between first curLvl.camPath->vx and last curLvl.camPath->vx
|
||||||
if ( camAngleToAct.vy < -50 && camera.pos.vx > curLvl.camPath->points[curLvl.camPath->len - 1].vx ) {
|
if ( camAngleToAct.vy < -50 && camera.pos.vx > curLvl.camPath->points[curLvl.camPath->len - 1].vx ) {
|
||||||
// Clamp curLvl.camPath position to cameraSpeed
|
// Clamp curLvl.camPath position to cameraSpeed
|
||||||
@ -449,14 +407,6 @@ int main() {
|
|||||||
curLvl.levelPtr = curLvl.curNode->plane;
|
curLvl.levelPtr = curLvl.curNode->plane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// DONTNEED ?
|
|
||||||
// Moveable prop
|
|
||||||
//~ if ( !getIntCollision( *propPtr->body , *curLvl.curNode->siblings->list[msh]->plane->body).vx &&
|
|
||||||
//~ !getIntCollision( *propPtr->body , *curLvl.curNode->siblings->list[msh]->plane->body).vz ) {
|
|
||||||
//~ if ( propPtr->node != curLvl.curNode->siblings->list[ msh ]){
|
|
||||||
//~ propPtr->node = curLvl.curNode->siblings->list[ msh ];
|
|
||||||
//~ }
|
|
||||||
//~ }
|
|
||||||
if ( !getIntCollision( *curLvl.propPtr->body , *curLvl.curNode->plane->body).vx &&
|
if ( !getIntCollision( *curLvl.propPtr->body , *curLvl.curNode->plane->body).vx &&
|
||||||
!getIntCollision( *curLvl.propPtr->body , *curLvl.curNode->plane->body).vz ) {
|
!getIntCollision( *curLvl.propPtr->body , *curLvl.curNode->plane->body).vz ) {
|
||||||
curLvl.propPtr->node = curLvl.curNode;
|
curLvl.propPtr->node = curLvl.curNode;
|
||||||
@ -528,7 +478,6 @@ int main() {
|
|||||||
enlightMesh(&curLvl, curLvl.camAngles[curCamAngle]->objects[mesh], &lgtang);
|
enlightMesh(&curLvl, curLvl.camAngles[curCamAngle]->objects[mesh], &lgtang);
|
||||||
transformMesh(&camera, curLvl.camAngles[curCamAngle]->objects[mesh]);
|
transformMesh(&camera, curLvl.camAngles[curCamAngle]->objects[mesh]);
|
||||||
drawPoly(curLvl.camAngles[curCamAngle]->objects[mesh], &Flag, atime, &camMode, &nextpri, ot[db], &db, &draw[db]);
|
drawPoly(curLvl.camAngles[curCamAngle]->objects[mesh], &Flag, atime, &camMode, &nextpri, ot[db], &db, &draw[db]);
|
||||||
// int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -578,14 +527,8 @@ int main() {
|
|||||||
FntPrint("Time : %d dt :%d", timeS, dt);
|
FntPrint("Time : %d dt :%d", timeS, dt);
|
||||||
//~ FntPrint("%d\n", curCamAngle );
|
//~ FntPrint("%d\n", curCamAngle );
|
||||||
//~ FntPrint("%x\n", primbuff[db]);
|
//~ FntPrint("%x\n", primbuff[db]);
|
||||||
//~ FntPrint("Actor : %d %d\n", curLvl.actorPtr->pos->vx, curLvl.actorPtr->pos->vy);
|
|
||||||
//~ FntPrint("%d %d\n", curLvl.actorPtr->pos->vx, curLvl.actorPtr->pos->vz);
|
|
||||||
//~ FntPrint("%d %d\n", curLvl.actorPtr->pos2D.vx + CENTERX, curLvl.actorPtr->pos2D.vy + CENTERY);
|
|
||||||
//~ FntPrint(" %d %d %d\n", wp.vx, wp.vy, wp.vz);
|
|
||||||
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);
|
||||||
//~ display(disp, draw, otdisc[db], primbuff[db], nextpri, db);
|
|
||||||
//~ frame = VSync(-1);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -594,8 +537,6 @@ void callback() {
|
|||||||
read_controller( &theControllers[0], &controllers[0].pad[0], 0 ); // Read controllers
|
read_controller( &theControllers[0], &controllers[0].pad[0], 0 ); // Read controllers
|
||||||
// Pad 2
|
// Pad 2
|
||||||
read_controller( &theControllers[1], &controllers[1].pad[0], 1 );
|
read_controller( &theControllers[1], &controllers[1].pad[0], 1 );
|
||||||
//~ u_short pad = PadRead(0);
|
|
||||||
//~ u_short pad = 0;
|
|
||||||
u_char PADL = ~theControllers[0].button1;
|
u_char PADL = ~theControllers[0].button1;
|
||||||
u_char PADR = ~theControllers[0].button2;
|
u_char PADR = ~theControllers[0].button2;
|
||||||
static u_short lastPad;
|
static u_short lastPad;
|
||||||
@ -604,7 +545,6 @@ void callback() {
|
|||||||
static int lerpValues[4096 >> 7];
|
static int lerpValues[4096 >> 7];
|
||||||
static short cursor = 0;
|
static short cursor = 0;
|
||||||
static short angleCamTimer = 0;
|
static short angleCamTimer = 0;
|
||||||
//~ static short curCamAngle = 0;
|
|
||||||
if( !lerpValues[0] ) {
|
if( !lerpValues[0] ) {
|
||||||
for ( long long i = 0; i < div ; i++ ){
|
for ( long long i = 0; i < div ; i++ ){
|
||||||
lerpValues[(div-1)-i] = lerp(-24, -264, easeIn(i));
|
lerpValues[(div-1)-i] = lerp(-24, -264, easeIn(i));
|
||||||
@ -738,10 +678,10 @@ void callback() {
|
|||||||
}
|
}
|
||||||
if ( PADL & PadSelect && !timer ) {
|
if ( PADL & PadSelect && !timer ) {
|
||||||
//~ if (!levelHasChanged){
|
//~ if (!levelHasChanged){
|
||||||
//~ #ifndef USECD
|
#ifndef USECD
|
||||||
printf("load:%p:%08x:%s", &load_all_overlays_here, &level, overlayFile);
|
printf("load:%p:%08x:%s", &load_all_overlays_here, &level, overlayFile);
|
||||||
//~ PCload( &load_all_overlays_here, &levelHasChanged, overlayFile );
|
//~ PCload( &load_all_overlays_here, &levelHasChanged, overlayFile );
|
||||||
//~ #endif
|
#endif
|
||||||
#ifdef USECD
|
#ifdef USECD
|
||||||
level = !level;
|
level = !level;
|
||||||
//~ levelHasChanged = 1;
|
//~ levelHasChanged = 1;
|
||||||
@ -776,8 +716,7 @@ void callback() {
|
|||||||
angleCam.vy += lerp( angleCam.vy, 0, 64 ) == 0 ? 1 : lerp( angleCam.vy, 0, 64 );
|
angleCam.vy += lerp( angleCam.vy, 0, 64 ) == 0 ? 1 : lerp( angleCam.vy, 0, 64 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//~ FntPrint("level :%d", level);
|
// Print controller infos
|
||||||
//~ FntPrint("angleCam :%d %d\n", angleCam.vy, lerp( angleCam.vy, 0, 64) );
|
|
||||||
//~ FntPrint( "Pad 1 : %02x\nButtons:%02x %02x, Stick:%02d %02d %02d %02d\n",
|
//~ FntPrint( "Pad 1 : %02x\nButtons:%02x %02x, Stick:%02d %02d %02d %02d\n",
|
||||||
//~ theControllers[0].type, // Controller type : 0x00 == none, 0x41 == standard, 0x73 == analog/dualshock, 0x12 == mouse, 0x23 == steering wheel, 0x63 == gun, 0x53 == analog joystick
|
//~ theControllers[0].type, // Controller type : 0x00 == none, 0x41 == standard, 0x73 == analog/dualshock, 0x12 == mouse, 0x23 == steering wheel, 0x63 == gun, 0x53 == analog joystick
|
||||||
//~ theControllers[0].button1, //
|
//~ theControllers[0].button1, //
|
||||||
|
Loading…
Reference in New Issue
Block a user