/* * ---------------- www.spacesimulator.net -------------- * ---- Space simulators and 3d engine tutorials ---- * * Author: Damiano Vitulli * * ALL RIGHTS RESERVED * * * Tutorial 1: 3d engine object definition * * * You cannot see anything as output because we need the drawing libraries * */ #include #define MAX_VERTICES 2000 // Max number of vertices (for each object) #define MAX_POLYGONS 2000 // Max number of polygons (for each object) /********************************************************** * * TYPES DECLARATION * *********************************************************/ // Our vertex type typedef struct{ float x,y,z; }vertex_type; // The polygon (triangle), 3 numbers that aim 3 vertices typedef struct{ int a,b,c; }polygon_type; // The object type typedef struct { vertex_type vertex[MAX_VERTICES]; polygon_type polygon[MAX_POLYGONS]; } obj_type, *obj_type_ptr; /********************************************************** * * VARIABLES DECLARATION * *********************************************************/ // And, finally our first object! obj_type cube = { { -10, -10, 10, // vertex v0 10, -10, 10, // vertex v1 10, -10, -10, // vertex v2 -10, -10, -10, // vertex v3 -10, 10, 10, // vertex v4 10, 10, 10, // vertex v5 10, 10, -10, // vertex v6 -10, 10, -10 // vertex v7 }, { 0, 1, 4, // polygon v0,v1,v4 1, 5, 4, // polygon v1,v5,v4 1, 2, 5, // polygon v1,v2,v5 2, 6, 5, // polygon v2,v6,v5 2, 3, 6, // polygon v2,v3,v6 3, 7, 6, // polygon v3,v7,v6 3, 0, 7, // polygon v3,v0,v7 0, 4, 7, // polygon v0,v4,v7 4, 5, 7, // polygon v4,v5,v7 5, 6, 7, // polygon v5,v6,v7 3, 2, 0, // polygon v3,v2,v0 2, 1, 0, // polygon v2,v1,v0 } }; /********************************************************** * * The main routine * *********************************************************/ int main(int argc, char **argv) { return(1); }