diff --git a/assets/entities/collision_default.symtres b/assets/entities/collision_default.symtres new file mode 100644 index 0000000..1cfd667 --- /dev/null +++ b/assets/entities/collision_default.symtres @@ -0,0 +1,12 @@ +Entity +{ + type : 1 + scale : 1.000 1.000 1.000 + rotation : 0.000 0.000 0.000 1.000 + position : -5.000 2.000 14.000 + flags : 1 + name : Collision + bounding_box_min : -0.500 -0.500 -0.500 + bounding_box_max : 0.500 0.500 0.500 +} + diff --git a/assets/entities/turret.symtres b/assets/entities/turret.symtres index a8a00aa..3c61a54 100644 --- a/assets/entities/turret.symtres +++ b/assets/entities/turret.symtres @@ -95,16 +95,16 @@ Entity { type : 7 scale : 1.000 1.000 1.000 - volume : 1.0000 + volume : 0.5000 rolloff_factor : 0.9500 rotation : 0.000 0.000 0.000 1.000 loop : true sound_min_distance : 0.0000 position : 0.000 0.000 0.000 flags : 9 - source_filename : sounds/windy_ambience.ogg - sound_type : 2 - sound_max_distance : 30.0000 + source_filename : sounds/turret_hum.wav + sound_type : 1 + sound_max_distance : 40.0000 name : Turret_Ambient_Sound bounding_box_min : -0.500 -0.500 -0.500 sound_attenuation_type : 2 diff --git a/assets/models/default.pamesh b/assets/models/default.symbres old mode 100755 new mode 100644 similarity index 100% rename from assets/models/default.pamesh rename to assets/models/default.symbres diff --git a/assets/scenes/scene_1.symtres b/assets/scenes/scene_1.symtres index 9d93d90..8f1a216 100755 --- a/assets/scenes/scene_1.symtres +++ b/assets/scenes/scene_1.symtres @@ -21,9 +21,9 @@ Player { type : 2 scale : 1.000 1.000 1.000 - rotation : 0.000 -0.488 0.000 0.873 + rotation : 0.000 0.345 0.000 0.939 player_key_mask : 0 - position : -55.691 2.167 -8.502 + position : -10.436 2.167 27.829 flags : 1 player_health : 100 name : Player @@ -32,6 +32,15 @@ Player bounding_box_max : 1.500 1.500 1.000 } +Scene_Entity_Entry +{ + scale : 1.000 4.000 -10.000 + rotation : 0.000 0.000 0.000 1.000 + position : -29.000 3.000 25.000 + filename : collision_default + name : Collision +} + Scene_Entity_Entry { scale : 1.000 1.000 1.000 diff --git a/assets/sounds/turret_hum.wav b/assets/sounds/turret_hum.wav new file mode 100644 index 0000000..3ac8c5b Binary files /dev/null and b/assets/sounds/turret_hum.wav differ diff --git a/src/common/version.h b/src/common/version.h index 3a9c458..ae5e7ac 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,7 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 2 -#define SYMMETRY_VERSION_REVISION 363 +#define SYMMETRY_VERSION_REVISION 364 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/editor.c b/src/game/editor.c index 6fe7a8a..c9b8167 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -174,7 +174,7 @@ void editor_init(struct Editor* editor) void editor_init_entities(struct Editor* editor) { editor->selected_entity = NULL; - editor->cursor_entity = scene_static_mesh_create(game_state_get()->scene, "EDITOR_SELECTED_ENTITY_WIREFRAME", NULL, "sphere.symbres", MAT_UNSHADED); + editor->cursor_entity = scene_static_mesh_create(game_state_get()->scene, "EDITOR_SELECTED_ENTITY_WIREFRAME", NULL, "cube.symbres", MAT_UNSHADED); editor->cursor_entity->base.flags |= EF_TRANSIENT | EF_SKIP_RENDER | EF_HIDE_IN_EDITOR_SCENE_HIERARCHY | EF_IGNORE_RAYCAST; } diff --git a/src/game/entity.c b/src/game/entity.c index 76ef101..74361b7 100755 --- a/src/game/entity.c +++ b/src/game/entity.c @@ -320,6 +320,9 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e struct Entity* new_entity = NULL; switch(type) { + case ET_DEFAULT: + new_entity = scene_entity_create(scene, name, parent_entity); + break; case ET_CAMERA: { bool has_fbo = false; @@ -509,12 +512,13 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e break; default: log_warning("Unhandled Entity type '%d' detected", type); + return new_entity; break; } vec3 position = { 0.f, 0.f, 0.f }; quat rotation = { 0.f, 0.f, 0.f, 1.f }; - vec3 scale = { 1.f, 1.f, 1.f }; + vec3 scale = { 1.f, 1.f, 1.f }; if(hashmap_value_exists(object->data, "position")) position = hashmap_vec3_get(object->data, "position"); if(hashmap_value_exists(object->data, "rotation")) rotation = hashmap_quat_get(object->data, "rotation"); diff --git a/src/game/player.c b/src/game/player.c index 5a14126..38e9018 100755 --- a/src/game/player.c +++ b/src/game/player.c @@ -232,7 +232,7 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix // Get all the entities that intersect then check the distance if it is less than // or equal to min_collision_distance then we are colliding struct Raycast_Result ray_result; - scene_ray_intersect(scene, &forward_ray, &ray_result, ERM_STATIC_MESH); + scene_ray_intersect(scene, &forward_ray, &ray_result, ERM_STATIC_MESH | ERM_DEFAULT); debug_vars_show_int("Colliding Entities", ray_result.num_entities_intersected); if(ray_result.num_entities_intersected > 0) { @@ -270,7 +270,7 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix struct Ray downward_ray; transform_get_absolute_position(player->body_mesh, &downward_ray.origin); vec3_fill(&downward_ray.direction, 0.f, -1.f, 0.f); - scene_ray_intersect(scene, &downward_ray, &down_ray_result, ERM_STATIC_MESH); + scene_ray_intersect(scene, &downward_ray, &down_ray_result, ERM_STATIC_MESH | ERM_DEFAULT); if(down_ray_result.num_entities_intersected > 0) { for(int i = 0; i < down_ray_result.num_entities_intersected; i++) @@ -376,7 +376,7 @@ void player_on_mousebutton_released(const struct Event* event) half_height /= 2; struct Ray bullet_ray = camera_screen_coord_to_ray(player->camera, half_width, half_height); - struct Entity* colliding_entity = scene_ray_intersect_closest(scene, &bullet_ray, ERM_ENEMY); + struct Entity* colliding_entity = scene_ray_intersect_closest(scene, &bullet_ray, ERM_ENEMY | ERM_STATIC_MESH | ERM_DEFAULT); int intensity = player->weapon_light_intensity_min + rand() % player->weapon_light_intensity_max; player->weapon_light->intensity = intensity; @@ -386,15 +386,17 @@ void player_on_mousebutton_released(const struct Event* event) if(!colliding_entity || colliding_entity == player->body_mesh) return; + if(colliding_entity->type != ET_ENEMY) // If we did not hit an enemy, check if we hit it's mesh instead. If the mesh has a parent enemy entity, assume we hit an enemy otherwise stop + { + if(colliding_entity->transform.parent->type == ET_ENEMY) + colliding_entity = colliding_entity->transform.parent; + else + return; + } + float distance = bv_distance_ray_bounding_box(&bullet_ray, &colliding_entity->derived_bounding_box); if(distance > 0.f) { - //vec3 collision_point = bullet_ray.direction; - //vec3_scale(&collision_point, &collision_point, distance); - //vec3_add(&collision_point, &collision_point, &bullet_ray.origin); - //struct Static_Mesh* bullet = scene_static_mesh_create(game_state_get()->scene, "bullet", NULL, "cube.symbres", MAT_UNSHADED); - //struct Light* bullet = entity_load("Spot", DIRT_INSTALL, true); - //if(bullet) transform_set_position(bullet, &collision_point); enemy_apply_damage((struct Enemy*)colliding_entity, player->damage); } } diff --git a/src/game/scene.c b/src/game/scene.c index 7894b7e..c24b677 100755 --- a/src/game/scene.c +++ b/src/game/scene.c @@ -496,7 +496,7 @@ void scene_write_entity_entry(struct Scene* scene, struct Entity* entity, struct // For entities with archetypes, we only write the name of the archetype to load // them from and their transformation info struct Parser_Object* object = parser_object_new(parser, PO_SCENE_ENTITY_ENTRY); - hashmap_str_set(object->data, "filename", &scene->entity_archetypes[entity->archetype_index][0]); + ////hashmap_str_set(object->data, "filename", &scene->entity_archetypes[entity->archetype_index][0]); hashmap_str_set(object->data, "name", entity->name); hashmap_vec3_set(object->data, "position", &entity->transform.position); hashmap_vec3_set(object->data, "scale", &entity->transform.scale); diff --git a/todo.txt b/todo.txt index f68500e..203c9bd 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,8 @@ Todo: - Game End + - Add functionality to editor that enables adding a default empty entity without having to load it from file + - Fix crash when default entity type is loaded from file - Don't save parent entity's transform when saving entity archetype. Only save the transformation values for children - - Enemies getting hit by bullets - - Add weapon flash, muzzle mesh to turrets - - Add collision-only entities that can be used to manually approximate collision mesh for an entity - Save case sensitive file names when scene entity entries - Disbale all player actions when scene cleared dialog or scene restart dialog are active - Memory utils that provide allocation tracking @@ -434,4 +433,6 @@ Done: * Background music track per scene specified in scene properties * Fixed bug where child entities' absolute position does not change when parent rotates * Player weapon mesh and lighting - * Added muzzle mesh to player \ No newline at end of file + * Added muzzle mesh to player + * Add weapon flash, muzzle mesh to turrets + * Enemies getting hit by bullets \ No newline at end of file