#ifndef __TERRAIN_ECSTYPES #define __TERRAIN_ECSTYPES #include "ecs2.h" #include "haloo3d/haloo3d.h" // #include "haloo3d/haloo3dex_easy.h" // Baseline render context. When a pointer to this is attached as a component, // it becomes a render target, and that entity will perform the precalcs // necessary for later object rendering. typedef struct { // struct vec4 precalcs[H3D_OBJ_MAXVERTICES]; // haloo3d_facef outfaces[H3D_FACEF_MAXCLIP]; // haloo3d_perspective(render.perspective, fov, ASPECT, NEARCLIP, FARCLIP); // mfloat_t precalc_perspective[MAT4_SIZE]; mfloat_t precalc_screen[MAT4_SIZE]; mfloat_t precalc_halfwidth; // Optimization for reducing calcs per tri mfloat_t precalc_halfheight; // Optimization for reducing calcs per tri mfloat_t fov; mfloat_t nearclip; mfloat_t farclip; // NOTE: aspect ratio calculated from window haloo3d_fb window; // Baseline render settings. Some of these settings will be applied to // each object associated with this context haloo3d_trirender rendersettings; // If alpha is 0, screen is not cleared uint16_t windowclear; } render_context; // Associate this to some entity along with a placement and it will be the // main "renderer" for a viewpoint typedef render_context *ecs_rendercontext; // Associate lighting with some object. Since this is part of the renderer, // this isn't a component you can assign (it also doesn't mean anything on its // own) typedef struct { struct vec3 dir; mfloat_t minlight; // Whether to automatically move lighting when models have a // lookvec. This also normalizes the light uint8_t autolightfix; } object_lighting; // All values which allow rendering of a 3d object typedef struct { // haloo3d_trirender rendersettings; // baseline settings for THIS object. struct vec3 scale; // how big the thing should be in world object_lighting *lighting; // a pointer to lighting, null for none render_context *context; // What to render into haloo3d_obj *model; haloo3d_fb *texture; uint8_t cullbackface; // Whether to cull backfaces (you probably should) } ecs_object; // Some placement within the world. Doesn't imply anything other than a // position and a facing direction typedef struct { struct vec3 pos; struct vec3 up; struct vec3 lookvec; } ecs_placement; // Movement is applied to placement and may also be used to check for // collisions and whatever typedef struct { struct vec3 pos; struct vec3 up; struct vec3 lookvec; } ecs_movement; // Use rotation to override the lookvec of an ecs_placement typedef struct { mfloat_t yaw; mfloat_t pitch; } ecs_rotation; // typedef haloo3d_camera *ecs_camera; // typedef haloo3d_obj_instance *ecs_object; // // A billboard for OUR system, which does not look up or down at the target. // As // // such, no matter what the lookat is set to, y is always going to be equal // to // // the y of the instance, so it appears to be looking "straight" // typedef struct { // haloo3d_obj_instance *obj; // struct vec3 *lookat; // } ecs_billboard; // // A component which allows an object instance to die // // when the maze is initiailized. // typedef struct { // haloo3d_obj_instance *obj; // haloo3d_easyrender *render; // worldstate *ws; // void (*diefunc)(haloo3d_obj_instance *); // } ecs_dieoninit; // Setup ECS system for our game ECS_START(tecs) float delta_s; // Store delta time in ecs ECS_COMPONENT(ecs_rendercontext); ECS_COMPONENT(ecs_object); ECS_COMPONENT(ecs_placement); ECS_COMPONENT(ecs_rotation); ECS_COMPONENT(ecs_movement); ECS_END(tecs) ECS_FN_INIT(tecs) ECS_FN_NEWENTITY(tecs) // And then a copy of the components here... that sucksssss ECS_CID(ecs_rendercontext, 0); ECS_CID(ecs_object, 1); ECS_CID(ecs_placement, 2); ECS_CID(ecs_rotation, 3); ECS_CID(ecs_movement, 4); #endif