-
Notifications
You must be signed in to change notification settings - Fork 3
File structure
Schnappy edited this page Jun 22, 2021
·
1 revision
The export process creates 3 files :
- custom_types.h
- levels/level0.h
- levels/level0.c
This file contains structures typedef specific to 3dcam engine.
#pragma once
#include <sys/types.h>
#include <libgte.h>
#include <libgpu.h>
struct BODY;
struct VANIM;
struct PRIM;
struct MESH;
struct CAMPOS;
struct CAMPATH;
struct CAMANGLE;
struct SIBLINGS;
struct CHILDREN;
struct NODE;
struct QUAD;
typedef struct BODY {
VECTOR gForce;
VECTOR position;
SVECTOR velocity;
int mass;
int invMass;
VECTOR min;
VECTOR max;
int restitution;
} BODY;
typedef struct VANIM {
int nframes; // number of frames e.g 20
int nvert; // number of vertices e.g 21
int cursor; // anim cursor
int lerpCursor; // anim cursor
int dir; // playback direction (1 or -1)
int interpolate; // use lerp to interpolate keyframes
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
} VANIM;
typedef struct PRIM {
VECTOR order;
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)
} PRIM;
typedef struct MESH {
TMESH * tmesh;
PRIM * index;
TIM_IMAGE * tim;
unsigned long * tim_data;
MATRIX mat;
VECTOR pos;
SVECTOR rot;
short isRigidBody;
short isStaticBody;
short isPrism;
short isAnim;
short isActor;
short isLevel;
short isBG;
short isSprite;
long p;
long OTz;
BODY * body;
VANIM * anim;
struct NODE * node;
VECTOR pos2D;
} MESH;
typedef struct QUAD {
VECTOR v0, v1;
VECTOR v2, v3;
} QUAD;
typedef struct CAMPOS {
VECTOR pos;
SVECTOR rot;
} CAMPOS;
// Blender cam ~= PSX cam with these settings :
// NTSC - 320x240, PAL 320x256, pixel ratio 1:1,
// cam focal length : perspective 90° ( 16 mm ))
// With a FOV of 1/2, camera focal length is ~= 16 mm / 90°
// Lower values mean wider angle
typedef struct CAMANGLE {
CAMPOS * campos;
TIM_IMAGE * BGtim;
unsigned long * tim_data;
QUAD bw, fw;
int index;
MESH * objects[];
} CAMANGLE;
typedef struct CAMPATH {
short len, cursor, pos;
VECTOR points[];
} CAMPATH;
typedef struct SIBLINGS {
int index;
struct NODE * list[];
} SIBLINGS ;
typedef struct CHILDREN {
int index;
MESH * list[];
} CHILDREN ;
typedef struct NODE {
MESH * plane;
SIBLINGS * siblings;
CHILDREN * objects;
CHILDREN * rigidbodies;
} NODE;
typedef struct LEVEL {
MATRIX * cmat;
MATRIX * lgtmat;
MESH ** meshes;
int * meshes_length;
MESH * actorPtr;
MESH * levelPtr;
MESH * propPtr;
CAMANGLE * camPtr;
CAMPATH * camPath;
CAMANGLE ** camAngles;
NODE * curNode;
MESH * meshPlan; // This one is temporary
} LEVEL;
This file contains the declarations of all the objects in the scene :
#pragma once
#include "../custom_types.h"
extern LEVEL level0;
extern CAMPOS level0_camPos_Camera;
extern CAMPATH level0_camPath;
extern MATRIX level0_lgtmat;
extern MATRIX level0_cmat;
extern SVECTOR modelCube_mesh[];
extern SVECTOR level0_modelCube_normal[];
extern CVECTOR level0_modelCube_color[];
extern PRIM level0_modelCube_index[];
extern BODY level0_modelCube_body;
extern TMESH level0_modelCube;
extern MESH level0_meshCube;
extern SVECTOR modelPlan_mesh[];
extern SVECTOR level0_modelPlan_normal[];
extern CVECTOR level0_modelPlan_color[];
extern PRIM level0_modelPlan_index[];
extern BODY level0_modelPlan_body;
extern TMESH level0_modelPlan;
extern MESH level0_meshPlan;
extern MESH * level0_meshes[2];
extern int level0_meshes_length;
extern CAMANGLE level0_camAngle_Camera;
extern CAMANGLE * level0_camAngles[0];
extern SIBLINGS level0_nodePlan_siblings;
extern CHILDREN level0_nodePlan_objects;
extern CHILDREN level0_nodePlan_rigidbodies;
extern NODE level0_nodePlan;
extern MESH * level0_actorPtr;
extern MESH * level0_levelPtr;
extern MESH * level0_propPtr;
extern CAMANGLE * level0_camPtr;
extern NODE * level0_curNode;
extern NODE level0_nodePlan;
This file contains the data of all the objects in the scene :
#include "level0.h"
CAMPOS level0_camPos_Camera = {
{ -486,347,423 },
{ 301,531,0 }
};
CAMPATH level0_camPath = {
0,
0,
0
};
MATRIX level0_lgtmat = {
-2319, 3254, -894,
0,0,0,
0,0,0,
};
MATRIX level0_cmat = {
4096,0,0,
4096,0,0,
4096,0,0
};
SVECTOR level0_modelCube_mesh[] = {
{ 65,65,65 },
{ 65,65,-65 },
{ -65,65,-65 },
{ -65,65,65 },
{ 65,-65,65 },
{ 65,-65,-65 },
{ -65,-65,-65 },
{ -65,-65,65 }
};
SVECTOR level0_modelCube_normal[] = {
-2365,-2365,-2365, 0,
-2365,-2365,2365, 0,
2365,-2365,2365, 0,
2365,-2365,-2365, 0,
-2365,2365,-2365, 0,
-2365,2365,2365, 0,
2365,2365,2365, 0,
2365,2365,-2365, 0
};
CVECTOR level0_modelCube_color[] = {
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0,
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0,
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0,
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0,
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0,
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0
};
PRIM level0_modelCube_index[] = {
0,1,2,3,8,
4,7,6,5,8,
0,4,5,1,8,
1,5,6,2,8,
2,6,7,3,8,
4,0,3,7,8
};
BODY level0_modelCube_body = {
{0, 0, 0, 0},
0,-130,0, 0,
0,0,0, 0,
1,
ONE/1,
-65,-65,-65, 0,
65,65,65, 0,
0,
};
TMESH level0_modelCube = {
level0_modelCube_mesh,
level0_modelCube_normal,
0,
level0_modelCube_color,
6
};
MESH level0_meshCube = {
&level0_modelCube,
level0_modelCube_index,
0,
0,
{0},
{0,-130,0, 0},
{0,0,0},
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
&level0_modelCube_body,
0,
0,
0
};
SVECTOR level0_modelPlan_mesh[] = {
{ -195,0,-195 },
{ 195,0,-195 },
{ -195,0,195 },
{ 195,0,195 }
};
SVECTOR level0_modelPlan_normal[] = {
0,4096,0, 0,
0,4096,0, 0,
0,4096,0, 0,
0,4096,0, 0
};
CVECTOR level0_modelPlan_color[] = {
80, 80, 80, 0,
128, 128, 128, 0,
128, 128, 128, 0
};
PRIM level0_modelPlan_index[] = {
0,1,3,2,8
};
BODY level0_modelPlan_body = {
{0, 0, 0, 0},
0,0,0, 0,
0,0,0, 0,
1,
ONE/1,
-195,0,-195, 0,
195,0,195, 0,
0,
};
TMESH level0_modelPlan = {
level0_modelPlan_mesh,
level0_modelPlan_normal,
0,
level0_modelPlan_color,
1
};
MESH level0_meshPlan = {
&level0_modelPlan,
level0_modelPlan_index,
0,
0,
{0},
{0,0,0, 0},
{0,0,0},
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
&level0_modelPlan_body,
0,
0,
0
};
MESH * level0_meshes[2] = {
&level0_meshCube,
&level0_meshPlan
};
int level0_meshes_length = 2;
CAMANGLE level0_camAngle_Camera = {
&level0_camPos_Camera,
0,
0,
{ 0 },
{ 0 },
0,
0
};
CAMANGLE * level0_camAngles[0] = {
};
SIBLINGS level0_nodePlan_siblings = {
0,
{
0
}
};
CHILDREN level0_nodePlan_objects = {
0,
{
0
}
};
CHILDREN level0_nodePlan_rigidbodies = {
1,
{
&level0_meshCube
}
};
NODE level0_nodePlan = {
&level0_meshPlan,
&level0_nodePlan_siblings,
&level0_nodePlan_objects,
&level0_nodePlan_rigidbodies
};
MESH * level0_actorPtr = &level0_meshCube;
MESH * level0_levelPtr = &level0_meshPlan;
MESH * level0_propPtr = &level0_meshCube;
CAMANGLE * level0_camPtr = &level0_camAngle_Camera;
NODE * level0_curNode = &level0_nodePlan;
LEVEL level0 = {
&level0_cmat,
&level0_lgtmat,
(MESH **)&level0_meshes,
&level0_meshes_length,
&level0_meshCube,
&level0_meshPlan,
&level0_meshCube,
&level0_camAngle_Camera,
&level0_camPath,
(CAMANGLE **)&level0_camAngles,
&level0_nodePlan,
&level0_meshPlan
};
The level.c/.h files showed here correspond to the minimum blender setup.