Added utility sound_source entity functions

dev
Shariq Shah 6 years ago
parent 708a9f9853
commit 5ffa594200
  1. 17
      assets/scenes/Level_1.symtres
  2. BIN
      assets/sounds/bullet_1.wav
  3. 2
      src/common/version.h
  4. 16
      src/game/entity.c
  5. 23
      src/game/entity.h
  6. 77
      src/game/player.c
  7. 17
      src/game/scene.c
  8. 45
      src/game/sound_source.c
  9. 12
      src/game/sound_source.h
  10. 53
      src/system/sound.c
  11. 17
      src/system/sound.h
  12. 34
      todo.txt

@ -3,7 +3,7 @@ Scene_Config
debug_draw_color : 0.800 0.400 0.100 1.000 debug_draw_color : 0.800 0.400 0.100 1.000
fog_type : 1 fog_type : 1
fog_density : 0.1000 fog_density : 0.1000
fog_color : 0.170 0.490 0.630 fog_color : 0.310 0.412 0.529
debug_draw_physics : false debug_draw_physics : false
fog_start_distance : 10.0000 fog_start_distance : 10.0000
fog_max_distance : 450.0000 fog_max_distance : 450.0000
@ -16,13 +16,22 @@ Player
{ {
type : 2 type : 2
scale : 1.000 1.000 1.000 scale : 1.000 1.000 1.000
rotation : 0.000 -0.654 0.000 0.758 rotation : 0.000 -0.351 0.000 -0.938
active : true active : true
position : -38.848 2.992 -29.629 position : 1.750 2.869 22.751
bouding_box_min : -0.500 -0.500 -0.500 bouding_box_min : -0.500 -0.500 -0.500
name : Player name : Player
bouding_box_max : 0.500 0.500 0.500 bouding_box_max : 0.500 0.500 0.500
camera_clear_color : 0.298 0.600 0.898 1.000 camera_clear_color : 0.310 0.412 0.529 1.000
}
Scene_Entity_Entry
{
scale : 1.000 1.000 1.000
rotation : 0.000 0.000 0.000 1.000
position : 8.000 5.000 -20.000
filename : Spot
name : Test_Light
} }
Scene_Entity_Entry Scene_Entity_Entry

Binary file not shown.

@ -4,7 +4,7 @@
/* Auto generated version file. DO NOT MODIFY */ /* Auto generated version file. DO NOT MODIFY */
#define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MAJOR 0
#define SYMMETRY_VERSION_MINOR 1 #define SYMMETRY_VERSION_MINOR 1
#define SYMMETRY_VERSION_REVISION 312 #define SYMMETRY_VERSION_REVISION 313
#define SYMMETRY_VERSION_BRANCH "dev" #define SYMMETRY_VERSION_BRANCH "dev"
#endif #endif

@ -389,6 +389,8 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e
case ET_LIGHT: case ET_LIGHT:
{ {
struct Light* light = scene_light_create(scene, name, parent_entity, LT_POINT); struct Light* light = scene_light_create(scene, name, parent_entity, LT_POINT);
if(!light)
return new_entity;
if(hashmap_value_exists(object->data, "light_type")) light->type = hashmap_int_get(object->data, "light_type"); if(hashmap_value_exists(object->data, "light_type")) light->type = hashmap_int_get(object->data, "light_type");
if(hashmap_value_exists(object->data, "outer_angle")) light->outer_angle = hashmap_float_get(object->data, "outer_angle"); if(hashmap_value_exists(object->data, "outer_angle")) light->outer_angle = hashmap_float_get(object->data, "outer_angle");
if(hashmap_value_exists(object->data, "inner_angle")) light->inner_angle = hashmap_float_get(object->data, "inner_angle"); if(hashmap_value_exists(object->data, "inner_angle")) light->inner_angle = hashmap_float_get(object->data, "inner_angle");
@ -405,6 +407,8 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e
case ET_SOUND_SOURCE: case ET_SOUND_SOURCE:
{ {
struct Sound_Source* sound_source = scene_sound_source_create(scene, name, parent_entity, "sounds/teh_beatz.wav", ST_WAV, true, true); struct Sound_Source* sound_source = scene_sound_source_create(scene, name, parent_entity, "sounds/teh_beatz.wav", ST_WAV, true, true);
if(!sound_source)
return new_entity;
struct Sound_Source_Buffer* default_source_buffer = sound_source->source_buffer; struct Sound_Source_Buffer* default_source_buffer = sound_source->source_buffer;
uint default_source_instance = sound_source->source_instance; uint default_source_instance = sound_source->source_instance;
@ -451,11 +455,6 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e
log_error("entity:read", "No filename provided for sound source for entity '%s'", name); log_error("entity:read", "No filename provided for sound source for entity '%s'", name);
} }
new_entity = &sound_source->base; new_entity = &sound_source->base;
}
break;
case ET_PLAYER:
{
} }
break; break;
case ET_STATIC_MESH: case ET_STATIC_MESH:
@ -465,6 +464,8 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e
if(hashmap_value_exists(object->data, "geometry")) geometry_name = hashmap_str_get(object->data, "geometry"); if(hashmap_value_exists(object->data, "geometry")) geometry_name = hashmap_str_get(object->data, "geometry");
if(hashmap_value_exists(object->data, "material")) material_type = hashmap_int_get(object->data, "material"); if(hashmap_value_exists(object->data, "material")) material_type = hashmap_int_get(object->data, "material");
struct Static_Mesh* mesh = scene_static_mesh_create(scene, name, parent_entity, geometry_name, material_type); struct Static_Mesh* mesh = scene_static_mesh_create(scene, name, parent_entity, geometry_name, material_type);
if(!mesh)
return new_entity;
new_entity = &mesh->base; new_entity = &mesh->base;
//Set material model params for this particular mesh //Set material model params for this particular mesh
@ -495,11 +496,6 @@ struct Entity* entity_read(struct Parser_Object* object, struct Entity* parent_e
}; };
} }
break; break;
case ET_ROOT:
{
//scene_root_set(entity);
}
break;
default: default:
log_warning("Unhandled Entity type '%d' detected", type); log_warning("Unhandled Entity type '%d' detected", type);
break; break;

@ -169,17 +169,18 @@ struct Static_Mesh
struct Player struct Player
{ {
struct Entity base; struct Entity base;
struct Static_Mesh* mesh; struct Static_Mesh* mesh;
struct Camera* camera_node; struct Camera* camera;
float move_speed; struct Sound_Source* weapon_sound;
float move_speed_multiplier; float move_speed;
float turn_speed; float move_speed_multiplier;
float jump_speed; float turn_speed;
float gravity; float jump_speed;
float min_downward_distance; float gravity;
float min_forward_distance; float min_downward_distance;
bool grounded; float min_forward_distance;
bool grounded;
}; };
void entity_init(struct Entity* entity, const char* name, struct Entity* parent); void entity_init(struct Entity* entity, const char* name, struct Entity* parent);

@ -14,9 +14,13 @@
#include "debug_vars.h" #include "debug_vars.h"
#include "geometry.h" #include "geometry.h"
#include "im_render.h" #include "im_render.h"
#include "event.h"
#include "sound_source.h"
#include <float.h> #include <float.h>
static void player_on_mousebutton_released(const struct Event* event);
void player_init(struct Player* player, struct Scene* scene) void player_init(struct Player* player, struct Scene* scene)
{ {
struct Game_State* game_state = game_state_get(); struct Game_State* game_state = game_state_get();
@ -44,11 +48,19 @@ void player_init(struct Player* player, struct Scene* scene)
player_camera->clear_color.y = 0.6f; player_camera->clear_color.y = 0.6f;
player_camera->clear_color.z = 0.9f; player_camera->clear_color.z = 0.9f;
player_camera->clear_color.w = 1.f; player_camera->clear_color.w = 1.f;
player->camera_node = player_camera; player->camera = player_camera;
struct Sound_Source* weapon_sound = scene_sound_source_create(scene, "Player_Weapon_Sound_Source", player, "sounds/bullet_1.wav", ST_WAV, false, false);
if(weapon_sound)
player->weapon_sound = weapon_sound;
else
log_error("player:init", "Could not add weapon entity to player");
// Mark player camera and mesh as transient for now. We don't need to save them to file since we recreate them here anyway // Mark player camera and mesh as transient for now. We don't need to save them to file since we recreate them here anyway
player->camera_node->base.flags |= EF_TRANSIENT; player->camera->base.flags |= EF_TRANSIENT;
player->mesh->base.flags |= EF_TRANSIENT; player->mesh->base.flags |= EF_TRANSIENT;
player->weapon_sound->base.flags |= EF_TRANSIENT;
transform_parent_set(player_camera, player, true); transform_parent_set(player_camera, player, true);
@ -57,10 +69,13 @@ void player_init(struct Player* player, struct Scene* scene)
sound_listener_set(game_state->sound, player_camera); sound_listener_set(game_state->sound, player_camera);
sound_listener_update(game_state->sound); sound_listener_update(game_state->sound);
event_manager_subscribe(game_state->event_manager, EVT_MOUSEBUTTON_RELEASED, &player_on_mousebutton_released);
} }
void player_destroy(struct Player* player) void player_destroy(struct Player* player)
{ {
event_manager_unsubscribe(game_state_get()->event_manager, EVT_MOUSEBUTTON_RELEASED, &player_on_mousebutton_released);
entity_reset(player, player->base.id); entity_reset(player, player->base.id);
scene_entity_base_remove(game_state_get()->scene, &player->base); scene_entity_base_remove(game_state_get()->scene, &player->base);
player->base.flags = EF_NONE; player->base.flags = EF_NONE;
@ -108,7 +123,7 @@ void player_update(struct Player* player, struct Scene* scene, float dt)
transform_rotate(player, &rot_axis_yaw, -yaw, TS_WORLD); transform_rotate(player, &rot_axis_yaw, -yaw, TS_WORLD);
if(pitch != 0.f) if(pitch != 0.f)
transform_rotate(player->camera_node, &rot_axis_pitch, pitch, TS_LOCAL); transform_rotate(player->camera, &rot_axis_pitch, pitch, TS_LOCAL);
/* Movement */ /* Movement */
float move_speed = player->move_speed; float move_speed = player->move_speed;
@ -218,33 +233,45 @@ void player_update(struct Player* player, struct Scene* scene, float dt)
debug_vars_show_vec3("Translation", &translation); debug_vars_show_vec3("Translation", &translation);
debug_vars_show_bool("Grounded", player->grounded); debug_vars_show_bool("Grounded", player->grounded);
}
void player_on_mousebutton_released(const struct Event* event)
{
int button = event->mousebutton.button;
int state = event->mousebutton.state;
struct Game_State* game_state = game_state_get();
struct Scene* scene = game_state->scene;
struct Player* player = &scene->player;
if(game_state->game_mode != GAME_MODE_GAME)
return;
/* Aiming and Projectiles*/ /* Aiming and Projectiles*/
if(input_mousebutton_state_get(MSB_RIGHT, KS_PRESSED)) if(button == MSB_LEFT)
{ {
log_message("Right Click"); log_message("Right Click");
int mouse_x = 0, mouse_y = 0; int half_width = 0, half_height = 0;
platform_mouse_position_get(&mouse_x, &mouse_y); window_get_drawable_size(game_state->window, &half_width, &half_height);
struct Ray bullet_ray = camera_screen_coord_to_ray(player->camera_node, mouse_x, mouse_y); half_width /= 2;
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_STATIC_MESH);
if(!colliding_entity || colliding_entity == player->mesh)
return;
struct Raycast_Result bullet_ray_result; float distance = bv_distance_ray_bounding_box(&bullet_ray, &colliding_entity->derived_bounding_box);
scene_ray_intersect(scene, &bullet_ray, &bullet_ray_result, ERM_STATIC_MESH); if(distance > 0.f)
if(bullet_ray_result.num_entities_intersected > 0)
{ {
for(int i = 0; i < bullet_ray_result.num_entities_intersected; i++) vec3 collision_point = bullet_ray.direction;
{ vec3_scale(&collision_point, &collision_point, distance);
struct Entity* colliding_entity = bullet_ray_result.entities_intersected[i]; vec3_add(&collision_point, &collision_point, &bullet_ray.origin);
if(colliding_entity == player->mesh) //struct Static_Mesh* bullet = scene_static_mesh_create(game_state_get()->scene, "bullet", NULL, "cube.symbres", MAT_UNSHADED);
continue; struct Light* bullet = entity_load("Spot", DIRT_INSTALL);
float distance = bv_distance_ray_bounding_box(&bullet_ray, &colliding_entity->derived_bounding_box); if(bullet) transform_set_position(bullet, &collision_point);
if(distance > 0.f) sound_source_play(game_state->sound, player->weapon_sound);
{
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);
if(bullet) transform_set_position(bullet, &collision_point);
}
}
} }
} }
} }

@ -17,6 +17,7 @@
#include "../system/platform.h" #include "../system/platform.h"
#include "../common/hashmap.h" #include "../common/hashmap.h"
#include "renderer.h" #include "renderer.h"
#include "sound_source.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -186,7 +187,7 @@ bool scene_load(struct Scene* scene, const char* filename, int directory_type)
quat_assign(&player->base.transform.rotation, &rotation); quat_assign(&player->base.transform.rotation, &rotation);
transform_update_transmat(player); transform_update_transmat(player);
if(hashmap_value_exists(player_data, "camera_clear_color")) player->camera_node->clear_color = hashmap_vec4_get(player_data, "camera_clear_color"); if(hashmap_value_exists(player_data, "camera_clear_color")) player->camera->clear_color = hashmap_vec4_get(player_data, "camera_clear_color");
num_objects_loaded++; num_objects_loaded++;
} }
break; break;
@ -233,7 +234,7 @@ bool scene_save(struct Scene* scene, const char* filename, int directory_type)
// Player // Player
struct Parser_Object* player_object = parser_object_new(parser, PO_PLAYER); struct Parser_Object* player_object = parser_object_new(parser, PO_PLAYER);
entity_write(&scene->player, player_object, true); entity_write(&scene->player, player_object, true);
hashmap_vec4_set(player_object->data, "camera_clear_color", &scene->player.camera_node->clear_color); hashmap_vec4_set(player_object->data, "camera_clear_color", &scene->player.camera->clear_color);
scene_write_entity_list(scene, ET_DEFAULT, parser); scene_write_entity_list(scene, ET_DEFAULT, parser);
scene_write_entity_list(scene, ET_LIGHT, parser); scene_write_entity_list(scene, ET_LIGHT, parser);
@ -390,9 +391,7 @@ void scene_post_update(struct Scene* scene)
if(sound_source->base.transform.is_modified) if(sound_source->base.transform.is_modified)
{ {
vec3 abs_pos = { 0.f, 0.f, 0.f }; sound_source_update(sound, sound_source);
transform_get_absolute_position(&sound_source->base, &abs_pos);
sound_source_instance_update_position(sound, sound_source->source_instance, abs_pos);
sound_source->base.transform.is_modified = false; sound_source->base.transform.is_modified = false;
} }
} }
@ -1019,7 +1018,7 @@ struct Entity* scene_entity_duplicate(struct Scene* scene, struct Entity* entity
if(entity->archetype_index != -1) if(entity->archetype_index != -1)
{ {
new_entity = entity_load(scene->entity_archetypes[entity->archetype_index], DIRT_INSTALL); new_entity = entity_load(scene->entity_archetypes[entity->archetype_index], DIRT_INSTALL);
scene_entity_parent_set(scene, new_entity, entity->transform.parent); if(new_entity) scene_entity_parent_set(scene, new_entity, entity->transform.parent);
return new_entity; return new_entity;
} }
@ -1034,6 +1033,8 @@ struct Entity* scene_entity_duplicate(struct Scene* scene, struct Entity* entity
{ {
struct Light* light = (struct Light*)entity; struct Light* light = (struct Light*)entity;
struct Light* new_light = scene_light_create(scene, entity->name, entity->transform.parent, light->type); struct Light* new_light = scene_light_create(scene, entity->name, entity->transform.parent, light->type);
if(!new_light)
return new_entity;
new_light->inner_angle = light->inner_angle; new_light->inner_angle = light->inner_angle;
new_light->outer_angle = light->outer_angle; new_light->outer_angle = light->outer_angle;
new_light->falloff = light->falloff; new_light->falloff = light->falloff;
@ -1053,6 +1054,8 @@ struct Entity* scene_entity_duplicate(struct Scene* scene, struct Entity* entity
{ {
struct Static_Mesh* mesh = (struct Static_Mesh*)entity; struct Static_Mesh* mesh = (struct Static_Mesh*)entity;
struct Static_Mesh* new_mesh = scene_static_mesh_create(scene, entity->name, entity->transform.parent, geom_get(mesh->model.geometry_index)->filename, mesh->model.material->type); struct Static_Mesh* new_mesh = scene_static_mesh_create(scene, entity->name, entity->transform.parent, geom_get(mesh->model.geometry_index)->filename, mesh->model.material->type);
if(!new_mesh)
return new_entity;
memcpy(new_mesh->model.material_params, mesh->model.material_params, sizeof(struct Variant) * MMP_MAX); memcpy(new_mesh->model.material_params, mesh->model.material_params, sizeof(struct Variant) * MMP_MAX);
new_entity = &new_mesh->base; new_entity = &new_mesh->base;
//Handle collision related information here! //Handle collision related information here!
@ -1062,6 +1065,8 @@ struct Entity* scene_entity_duplicate(struct Scene* scene, struct Entity* entity
{ {
struct Sound_Source* sound_source = (struct Sound_Source*)entity; struct Sound_Source* sound_source = (struct Sound_Source*)entity;
struct Sound_Source* new_sound_source = scene_sound_source_create(scene, entity->name, entity->transform.parent, sound_source->source_buffer->filename, sound_source->type, sound_source->loop, sound_source->playing); struct Sound_Source* new_sound_source = scene_sound_source_create(scene, entity->name, entity->transform.parent, sound_source->source_buffer->filename, sound_source->type, sound_source->loop, sound_source->playing);
if(!new_sound_source)
return new_entity;
new_sound_source->min_distance = sound_source->min_distance; new_sound_source->min_distance = sound_source->min_distance;
new_sound_source->max_distance = sound_source->max_distance; new_sound_source->max_distance = sound_source->max_distance;
new_sound_source->rolloff_factor = sound_source->rolloff_factor; new_sound_source->rolloff_factor = sound_source->rolloff_factor;

@ -0,0 +1,45 @@
#include "sound_source.h"
#include "entity.h"
#include "../system/sound.h"
#include "transform.h"
#include "../common/log.h"
static void sound_source_validate_instance(struct Sound* sound, struct Sound_Source* entity)
{
if(!sound_source_instance_is_valid(sound, entity->source_instance))
{
entity->source_instance = sound_source_instance_create(sound, entity->source_buffer, true);
vec3 abs_position = { 0.f };
transform_get_absolute_position(entity, &abs_position);
sound_source_instance_update_position(sound, entity->source_instance, abs_position);
}
}
void sound_source_play(struct Sound* sound, struct Sound_Source* entity)
{
sound_source_validate_instance(sound, entity);
sound_source_instance_rewind(sound, entity->source_instance);
sound_source_instance_play(sound, entity->source_instance);
}
void sound_source_pause(struct Sound* sound, struct Sound_Source* entity)
{
sound_source_validate_instance(sound, entity);
sound_source_instance_pause(sound, entity->source_instance);
}
void sound_source_stop(struct Sound* sound, struct Sound_Source* entity)
{
sound_source_validate_instance(sound, entity);
sound_source_instance_stop(sound, entity->source_instance);
}
void sound_source_update(struct Sound* sound, struct Sound_Source* entity)
{
if(sound_source_instance_is_valid(sound, entity->source_instance))
{
vec3 abs_position = { 0.f };
transform_get_absolute_position(entity, &abs_position);
sound_source_instance_update_position(sound, entity->source_instance, abs_position);
}
}

@ -0,0 +1,12 @@
#ifndef SOUND_SOURCE_H
#define SOUND_SOURCE_H
struct Sound_Source;
struct Sound;
void sound_source_play(struct Sound* sound, struct Sound_Source* entity);
void sound_source_pause(struct Sound* sound, struct Sound_Source* entity);
void sound_source_stop(struct Sound* sound, struct Sound_Source* entity);
void sound_source_update(struct Sound* sound, struct Sound_Source* entity);
#endif

@ -87,7 +87,7 @@ void sound_cleanup(struct Sound* sound)
{ {
struct Sound_Source_Buffer* source = &sound->sound_buffers[i]; struct Sound_Source_Buffer* source = &sound->sound_buffers[i];
if(source->type != ST_NONE) if(source->type != ST_NONE)
sound_source_destroy(sound, source); sound_source_buffer_destroy(sound, source);
} }
@ -108,6 +108,11 @@ void sound_source_instance_update_position(struct Sound* sound, uint source_inst
Soloud_set3dSourceParameters(sound->soloud_context, source_instance, abs_pos.x, abs_pos.y, abs_pos.z); Soloud_set3dSourceParameters(sound->soloud_context, source_instance, abs_pos.x, abs_pos.y, abs_pos.z);
} }
bool sound_source_instance_is_valid(struct Sound* sound, uint source_instance)
{
return Soloud_isValidVoiceHandle(sound->soloud_context, source_instance);
}
uint sound_source_instance_create(struct Sound* sound, struct Sound_Source_Buffer* source, bool is3d) uint sound_source_instance_create(struct Sound* sound, struct Sound_Source_Buffer* source, bool is3d)
{ {
assert(source); assert(source);
@ -185,12 +190,12 @@ bool sound_source_instance_is_paused(struct Sound* sound, uint source_instance)
return Soloud_getPause(sound->soloud_context, source_instance); return Soloud_getPause(sound->soloud_context, source_instance);
} }
struct Sound_Source_Buffer* sound_source_create(struct Sound* sound, const char* filename, int type) struct Sound_Source_Buffer* sound_source_buffer_create(struct Sound* sound, const char* filename, int type)
{ {
if(!filename) if(!filename)
return NULL; return NULL;
struct Sound_Source_Buffer* source = sound_source_get(sound, filename); struct Sound_Source_Buffer* source = sound_source_buffer(sound, filename);
// See if we've already loaded this file otherwise, get the next empty slot. // See if we've already loaded this file otherwise, get the next empty slot.
// If we can't find an empty slot, print error and return NULL // If we can't find an empty slot, print error and return NULL
@ -264,7 +269,7 @@ struct Sound_Source_Buffer* sound_source_create(struct Sound* sound, const char*
return source; return source;
} }
struct Sound_Source_Buffer* sound_source_get(struct Sound* sound, const char* name) struct Sound_Source_Buffer* sound_source_buffer(struct Sound* sound, const char* name)
{ {
struct Sound_Source_Buffer* source = NULL; struct Sound_Source_Buffer* source = NULL;
for(int i = 0; i < MAX_SOUND_BUFFERS; i++) for(int i = 0; i < MAX_SOUND_BUFFERS; i++)
@ -281,11 +286,11 @@ struct Sound_Source_Buffer* sound_source_get(struct Sound* sound, const char* na
return source; return source;
} }
void sound_source_destroy(struct Sound* sound, struct Sound_Source_Buffer* source) void sound_source_buffer_destroy(struct Sound* sound, struct Sound_Source_Buffer* source)
{ {
if(source) if(source)
{ {
sound_source_stop_all(sound, source); sound_source_buffer_stop_all(sound, source);
switch(source->type) switch(source->type)
{ {
case ST_WAV: Wav_destroy(source->wav); source->wav = NULL; break; case ST_WAV: Wav_destroy(source->wav); source->wav = NULL; break;
@ -296,7 +301,7 @@ void sound_source_destroy(struct Sound* sound, struct Sound_Source_Buffer* sourc
} }
} }
void sound_source_volume_set(struct Sound* sound, struct Sound_Source_Buffer* source, float volume) void sound_source_buffer_volume_set(struct Sound* sound, struct Sound_Source_Buffer* source, float volume)
{ {
assert(source); assert(source);
switch(source->type) switch(source->type)
@ -306,7 +311,7 @@ void sound_source_volume_set(struct Sound* sound, struct Sound_Source_Buffer* so
} }
} }
void sound_source_loop_set(struct Sound* sound, struct Sound_Source_Buffer* source, bool loop) void sound_source_buffer_loop_set(struct Sound* sound, struct Sound_Source_Buffer* source, bool loop)
{ {
assert(source); assert(source);
switch(source->type) switch(source->type)
@ -316,7 +321,7 @@ void sound_source_loop_set(struct Sound* sound, struct Sound_Source_Buffer* sour
} }
} }
void sound_source_stop_all(struct Sound* sound, struct Sound_Source_Buffer* source) void sound_source_buffer_stop_all(struct Sound* sound, struct Sound_Source_Buffer* source)
{ {
assert(source); assert(source);
switch(source->type) switch(source->type)
@ -326,7 +331,7 @@ void sound_source_stop_all(struct Sound* sound, struct Sound_Source_Buffer* sour
} }
} }
void sound_source_min_max_distance_set(struct Sound* sound, struct Sound_Source_Buffer* source, float min_distance, float max_distance) void sound_source_buffer_min_max_distance_set(struct Sound* sound, struct Sound_Source_Buffer* source, float min_distance, float max_distance)
{ {
assert(source); assert(source);
switch(source->type) switch(source->type)
@ -335,3 +340,31 @@ void sound_source_min_max_distance_set(struct Sound* sound, struct Sound_Source_
case ST_WAV_STREAM: WavStream_set3dMinMaxDistance(source->wavstream, min_distance, max_distance); break; case ST_WAV_STREAM: WavStream_set3dMinMaxDistance(source->wavstream, min_distance, max_distance); break;
} }
} }
uint sound_source_buffer_play_3d(struct Sound* sound, struct Sound_Source_Buffer* source, vec3 position)
{
assert(source);
uint handle = -1;
switch(source->type)
{
case ST_WAV: handle = Soloud_play3d(sound->soloud_context, source->wav, position.x, position.y, position.z); break;
case ST_WAV_STREAM: handle = Soloud_play3d(sound->soloud_context, source->wavstream, position.x, position.y, position.z); break;
}
return handle;
}
uint sound_source_buffer_play_clocked_3d(struct Sound* sound, struct Sound_Source_Buffer* source, float delay, vec3 position)
{
assert(source);
uint handle = -1;
switch(source->type)
{
case ST_WAV: handle = Soloud_play3dClocked(sound->soloud_context, (double)delay, source->wav, position.x, position.y, position.z); break;
case ST_WAV_STREAM: handle = Soloud_play3dClocked(sound->soloud_context, (double)delay, source->wavstream, position.x, position.y, position.z); break;
}
return handle;
}

@ -63,17 +63,20 @@ void sound_source_instance_rewind(struct Sound* sound, uint source_instance);
void sound_source_instance_stop(struct Sound* sound, uint source_instance); void sound_source_instance_stop(struct Sound* sound, uint source_instance);
void sound_source_instance_min_max_distance_set(struct Sound* sound, uint source_instance, float min_distance, float max_distance); void sound_source_instance_min_max_distance_set(struct Sound* sound, uint source_instance, float min_distance, float max_distance);
void sound_source_instance_attenuation_set(struct Sound* sound, uint source_instance, int attenuation_type, float rolloff_factor); void sound_source_instance_attenuation_set(struct Sound* sound, uint source_instance, int attenuation_type, float rolloff_factor);
bool sound_source_instance_is_valid(struct Sound* sound, uint source_instance);
float sound_source_instance_volume_get(struct Sound* sound, uint source_instance); float sound_source_instance_volume_get(struct Sound* sound, uint source_instance);
bool sound_source_instance_loop_get(struct Sound* sound, uint source_instance); bool sound_source_instance_loop_get(struct Sound* sound, uint source_instance);
bool sound_source_instance_is_paused(struct Sound* sound, uint source_instance); bool sound_source_instance_is_paused(struct Sound* sound, uint source_instance);
struct Sound_Source_Buffer* sound_source_create(struct Sound* sound, const char* filename, int type); struct Sound_Source_Buffer* sound_source_buffer_create(struct Sound* sound, const char* filename, int type);
struct Sound_Source_Buffer* sound_source_get(struct Sound* sound, const char* name); struct Sound_Source_Buffer* sound_source_buffer(struct Sound* sound, const char* name);
void sound_source_destroy(struct Sound* sound, struct Sound_Source_Buffer* source); int sound_source_buffer_play_3d(struct Sound* sound, struct Sound_Source_Buffer* source, vec3 position);
void sound_source_volume_set(struct Sound* sound, struct Sound_Source_Buffer* source, float volume); int sound_source_buffer_play_clocked_3d(struct Sound* sound, struct Sound_Source_Buffer* source, float delay, vec3 position);
void sound_source_loop_set(struct Sound* sound, struct Sound_Source_Buffer* source, bool loop); void sound_source_buffer_destroy(struct Sound* sound, struct Sound_Source_Buffer* source);
void sound_source_stop_all(struct Sound* sound, struct Sound_Source_Buffer* source); void sound_source_buffer_volume_set(struct Sound* sound, struct Sound_Source_Buffer* source, float volume);
void sound_source_min_max_distance_set(struct Sound* sound, struct Sound_Source_Buffer* source, float min_distance, float max_distance); void sound_source_buffer_loop_set(struct Sound* sound, struct Sound_Source_Buffer* source, bool loop);
void sound_source_buffer_stop_all(struct Sound* sound, struct Sound_Source_Buffer* source);
void sound_source_buffer_min_max_distance_set(struct Sound* sound, struct Sound_Source_Buffer* source, float min_distance, float max_distance);
#endif #endif

@ -1,11 +1,17 @@
Todo: Todo:
- Fix quaternion resetting/flipping - Sound source entity functions that automatically track if handles are valid and create/update as necessary
- Fix aggressive frustum culling when camera looks up and the object right infront of the viewer gets culled - Player jump cooldown, don't allow jump until a certian time interval has passed, even if we're grounded
- Sky Cube maps
- Gameplay level features:
- Each scene should always have a directional light that serves as the main source of light when there are no other lights
- Each scene should always have a texture cube that serves as the sky
- Triggers
- Basic Enemy
- Main Menu Scene
? Split this todo into gameplay/engine todos
- Check if running in a lower frame rate affects movement - Check if running in a lower frame rate affects movement
? Write entity flags to scene file or when saving entity to file? ? Write entity flags to scene file or when saving entity to file?
? Add scene init/de-init function hashmap that maps a function that should be called when scene is loaded and unloaded. Save this to file for every scene or map functions based on the name of the scene? ? Add scene init/de-init function hashmap that maps a function that should be called when scene is loaded and unloaded. Save this to file for every scene or map functions based on the name of the scene?
- Command to create a placeholder entity of a particular type in a file
- Reduce the opacity of wireframe around selected entity in editor
- Release mouse when window loses focus and limit fps - Release mouse when window loses focus and limit fps
? When saving a scene entity entry, save the changed properties as well, that way when the scene is loaded, we load the base properties from archetype and the ones we changed per entry are saved when we saved the entity ? When saving a scene entity entry, save the changed properties as well, that way when the scene is loaded, we load the base properties from archetype and the ones we changed per entry are saved when we saved the entity
this will prevent us from having needless amount of entities with only minor changes from one another this will prevent us from having needless amount of entities with only minor changes from one another
@ -18,32 +24,17 @@ Todo:
- Decide how to handle scale when checking sphere-ray intersection - Decide how to handle scale when checking sphere-ray intersection
- Add material export for blender exporter? - Add material export for blender exporter?
- Show current filename of the scene we are working on and whether we have made any changes to it since the last time we saved - Show current filename of the scene we are working on and whether we have made any changes to it since the last time we saved
- Fix crash when exiting from fullscreen mode
- Check if we still need to rotate by 90 degrees when exporting from blender - Check if we still need to rotate by 90 degrees when exporting from blender
- Fire an event when the game mode is changed so that editor camera state and other game related systems know when to update - Fire an event when the game mode is changed so that editor camera state and other game related systems know when to update
- Add config file reloading and fire event that notifies potential listeners to update values from the new config file - Add config file reloading and fire event that notifies potential listeners to update values from the new config file
- Command to reload entities only - Command to reload entities only
- Serialize player, camera properties to file - Serialize player, camera properties to file
- Gameplay level features:
- Each scene should always have a directional light that serves as the main source of light when there are no other lights
- Each scene should always have a texture cube that serves as the sky
- Player/World collision and movement using ray casts only
- Triggers
- Basic Enemy
- Main Menu Scene
? Split this todo into gameplay/engine todos
- Change mouse behaviour to lock cursor when looking around so as not to interfere with gui elements when in editor mode - Change mouse behaviour to lock cursor when looking around so as not to interfere with gui elements when in editor mode
- Folder management api to create/delete folders when none exist. Dirent would suffice for our simple needs? - Folder management api to create/delete folders when none exist. Dirent would suffice for our simple needs?
? Entity creator window to create new types of entities and write them ? Entity creator window to create new types of entities and write them
to disk to disk
- Entity browser window which lists all existing entity types from
where new entities can be creating by dragging and dropping on to
the current scene
- Editor related messages/notifications in the bottom status bar
? Maybe remove physics engine and ode all together if we're not using it or investigate the memory leaks that it causes if we're going to keep it? ? Maybe remove physics engine and ode all together if we're not using it or investigate the memory leaks that it causes if we're going to keep it?
- Disable editor event recievers on game mode change - Disable editor event recievers on game mode change
- Color picker
- Color palette, picker and dropper
- Key binding and function to snap editor camera to selected entity - Key binding and function to snap editor camera to selected entity
location location
- Key binding and function to orient entity to camera orientation - Key binding and function to orient entity to camera orientation
@ -55,7 +46,6 @@ Todo:
? Improve bounding sphere calculation ? Improve bounding sphere calculation
- Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute - Change the way lights are set as uniforms to remove snprintf calls per frame for every light attribute
- Command interface that allows applying commands to selected entity like r x 30 would rotate the selected entity or entities on x axis by 30 degrees - Command interface that allows applying commands to selected entity like r x 30 would rotate the selected entity or entities on x axis by 30 degrees
- Screen mouse coordinates to world-coordinates for aiming
- Player projectiles and sounds - Player projectiles and sounds
- Space partitioning and scene handling - Space partitioning and scene handling
- Move Gui_State and Editor_State into game_state and modify usage as needed - Move Gui_State and Editor_State into game_state and modify usage as needed
@ -129,6 +119,9 @@ Bugs:
- Fix camera not rotating if the cursor overlaps any ui element - Fix camera not rotating if the cursor overlaps any ui element
- Fix hierarchichal transformations in the editor when the entity being transformed is a child entity of another entity - Fix hierarchichal transformations in the editor when the entity being transformed is a child entity of another entity
- Fix camera frustum creation/update - Fix camera frustum creation/update
- Fix quaternion resetting/flipping
- Fix aggressive frustum culling when camera looks up and the object right infront of the viewer gets culled
- Fix crash when exiting from fullscreen mode
Done: Done:
* Input * Input
@ -402,3 +395,4 @@ Done:
* Improve player collision by impelenting sliding along collision plane in case of collision * Improve player collision by impelenting sliding along collision plane in case of collision
* Brought back sprinting by fixing a bug where player movement related variables were written to file as floats but read back as ints * Brought back sprinting by fixing a bug where player movement related variables were written to file as floats but read back as ints
* Move player movement related variables from function to player struct and load them from config file * Move player movement related variables from function to player struct and load them from config file
* Screen mouse coordinates to world-coordinates for aiming
Loading…
Cancel
Save