Began Newton Dynamics Physics integration and modified build script

dev
Shariq Shah 8 years ago
parent 5ecb721dac
commit ac12a48b8a
  1. 1
      README.md
  2. 206
      build/genie.lua
  3. 1316
      include/common/newton/Newton.h
  4. BIN
      lib/windows/newton/newton.dll
  5. BIN
      lib/windows/newton/newton.exp
  6. BIN
      lib/windows/newton/newton.lib
  7. BIN
      lib/windows/newton/newton_d.dll
  8. BIN
      lib/windows/newton/newton_d.exp
  9. BIN
      lib/windows/newton/newton_d.lib
  10. BIN
      lib/windows/newton/newton_d.pdb
  11. 4
      src/common/array_str.h
  12. 17
      src/common/common.h
  13. 11
      src/game/main.c
  14. 27
      src/game/physics.c
  15. 7
      src/game/physics.h
  16. 256
      src/libsymmetry/game.c
  17. 4
      src/libsymmetry/scene.c

@ -155,6 +155,7 @@
- ## TODO - ## TODO
- Complete Newton integration
- Add fallback shader - Add fallback shader
- Implement Game States - Implement Game States
- Store Materials in new format supported by parser - Store Materials in new format supported by parser

@ -8,10 +8,16 @@ solution "Symmetry"
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"}
buildoptions {"-Wall", "-std=c99", "`pkg-config --cflags-only-I sdl2`"} buildoptions {"-Wall", "-std=c99", "`pkg-config --cflags-only-I sdl2`"}
configuration {"windows", "vs2017"} configuration {"windows", "vs2017"}
defines {"_CRT_SECURE_NO_WARNINGS"} defines {"_CRT_SECURE_NO_WARNINGS"}
flags {"NoIncrementalLink", "NoEditAndContinue"} flags {"NoIncrementalLink", "NoEditAndContinue"}
local windowsPlatform = string.gsub(os.getenv("WindowsSDKVersion") or "10.0.16299.0", "\\", "")
local action = premake.action.current()
if(action ~= nil) then
action.vstudio.windowsTargetPlatformVersion = windowsPlatform
action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform
end
configuration "Debug" configuration "Debug"
if (_ACTION ~= nil and _ACTION ~= "postbuild_copy") then if (_ACTION ~= nil and _ACTION ~= "postbuild_copy") then
os.mkdir(_ACTION .. "/debug") os.mkdir(_ACTION .. "/debug")
@ -27,112 +33,100 @@ solution "Symmetry"
end end
defines { "NDEBUG", "ExtraWarnings" } defines { "NDEBUG", "ExtraWarnings" }
flags { "OptimizeSpeed"} flags { "OptimizeSpeed"}
newaction {
trigger = "postbuild_copy",
description = "Action to copy relevant dlls to executable directory after build",
execute = function ()
-- local copy_dest_dir = ""
-- local symlink_dest_dir = ""
-- if(_ARGS[1] == "vs2017") then
-- copy_dest_dir = "vs2017"
-- symlink_dest_dir = "..\\..\\..\\assets"
-- printf("Copying DLLs to visual studio build directory...\n")
-- end
------------------------- -- -- Create sym links
-- Game -- local output = os.outputof("mklink /D vs2017\\debug\\assets ..\\..\\..\\assets" .. path.translate(copy_dest_dir, "\\") .. "\\debug\\assets " .. symlink_dest_dir)
------------------------- -- printf("MKlink debug output : %s", output)
project "Game" -- output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\release\\assets " ..symlink_dest_dir)
kind "ConsoleApp" -- printf("MKlink release output : %s", output)
targetname "Symmetry" end
language "C" }
files { "../src/common/**.c", "../src/common/**.h", "../src/game/**.c", "../src/game/**.h"}
defines {"GAME"}
configuration "linux"
includedirs {"../include/linux/sdl2/", "../include/common/soloud/"}
libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/"}
links {"SDL2", "m"}
configuration {"windows", "vs2017"}
includedirs {"../include/windows/sdl2/", "../include/common/soloud/"}
libdirs {"../lib/windows/sdl2/", "../lib/windows/soloud/"}
links {"SDL2"}
configuration "Debug"
links {"soloud_x64_d"}
configuration "Release"
links {"soloud_x64"}
configuration {"windows", "Release", "vs2017"}
postbuildcommands {
"xcopy ..\\..\\assets ..\\..\\bin\\assets /s /e /h /i /y /d",
"copy release\\Symmetry.exe ..\\..\\bin\\ /Y",
"copy release\\libSymmetry.dll ..\\..\\bin\\ /Y",
"copy release\\SDL2.dll ..\\..\\bin\\ /Y",
"copy release\\soloud_x64.dll ..\\..\\bin\\ /Y",
}
newaction {
trigger = "postbuild_copy",
description = "Action to copy relevant dlls to executable directory after build",
execute = function ()
local copy_dest_dir = ""
local symlink_dest_dir = ""
if(_ARGS[1] == "vs2017") then
copy_dest_dir = "vs2017"
symlink_dest_dir = "..\\..\\..\\assets"
printf("Copying DLLs to visual studio build directory...\n")
else
copy_dest_dir = "projects/qbs"
symlink_dest_dir = "..\\..\\..\\..\\assets"
printf("Copying DLLs to qbs build directory...\n")
end
local success = false -------------------------
success = os.copyfile("../libs/windows/sdl2/SDL2.dll", copy_dest_dir .. "/debug/SDL2.dll") -- Game
success = os.copyfile("../libs/windows/sdl2/SDL2.dll", copy_dest_dir .. "/release/SDL2.dll") -------------------------
success = os.copyfile("../libs/windows/soloud_x64_d.dll", copy_dest_dir .. "/debug/soloud_x64_d.dll") project "Game"
success = os.copyfile("../libs/windows/soloud_x64.dll", copy_dest_dir .. "/release/soloud_x64.dll") kind "ConsoleApp"
targetname "Symmetry"
language "C"
files { "../src/common/**.c", "../src/common/**.h", "../src/game/**.c", "../src/game/**.h"}
defines {"GAME"}
if success ~= true then configuration "linux"
printf("Copying one or more dlls failed.") includedirs {"../include/linux/sdl2/", "../include/common/soloud/"}
else libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/"}
printf("Copying dlls successful.") links {"SDL2", "m"}
end
-- Create sym links configuration {"windows", "vs2017"}
local output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\debug\\assets " .. symlink_dest_dir) includedirs {"../include/windows/sdl2/", "../include/common/soloud/", "../include/common/newton/"}
printf("MKlink debug output : %s", output) libdirs {"../lib/windows/sdl2/", "../lib/windows/soloud/", "../lib/windows/newton/"}
output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\release\\assets " ..symlink_dest_dir) links {"SDL2"}
printf("MKlink release output : %s", output)
end configuration "Debug"
} links {"soloud_x64_d", "newton_d"}
if(_ACTION == "vs2017") then configuration "Release"
postbuildcommands links {"soloud_x64", "newton"}
{
_PREMAKE_COMMAND .. " postbuild_copy vs2017" configuration {"windows", "Release", "vs2017"}
} postbuildcommands
else {
postbuildcommands "copy ..\\..\\lib\\windows\\sdl2\\SDL2.dll release\\ /Y",
{ "copy ..\\..\\lib\\windows\\soloud\\soloud_x64.dll release\\ /Y",
_PREMAKE_COMMAND .. " postbuild_copy qbs" "copy ..\\..\\lib\\windows\\newton\\newton.dll release\\ /Y",
} "xcopy ..\\..\\assets ..\\..\\bin\\assets /s /e /h /i /y /d",
end "copy release\\Symmetry.exe ..\\..\\bin\\ /Y",
------------------------- "copy release\\libSymmetry.dll ..\\..\\bin\\ /Y",
-- libSymmetry "copy release\\SDL2.dll ..\\..\\bin\\ /Y",
------------------------- "copy release\\soloud_x64.dll ..\\..\\bin\\ /Y",
project "Library" "copy release\\newton.dll ..\\..\\bin\\ /Y",
kind "SharedLib" "rmdir release\\assets",
language "C" "mklink /D release\\assets ..\\..\\..\\assets"
targetname "Symmetry" }
defines {"GAME_LIB", "USE_GLAD"}
includedirs {"../include/common"} configuration {"windows", "Debug", "vs2017"}
files { "../src/common/**.c", "../src/common/**.h", "../src/libsymmetry/**.h", "../src/libsymmetry/**.c" } postbuildcommands
{
"copy ..\\..\\lib\\windows\\sdl2\\SDL2.dll debug\\ /Y",
"copy ..\\..\\lib\\windows\\soloud\\soloud_x64_d.dll debug\\ /Y",
"copy ..\\..\\lib\\windows\\newton\\newton_d.dll debug\\ /Y",
"rmdir debug\\assets",
"mklink /D debug\\assets ..\\..\\..\\assets"
}
-------------------------
-- libSymmetry
-------------------------
project "Library"
kind "SharedLib"
language "C"
targetname "Symmetry"
defines {"GAME_LIB", "USE_GLAD"}
includedirs {"../include/common"}
files { "../src/common/**.c", "../src/common/**.h", "../src/libsymmetry/**.h", "../src/libsymmetry/**.c" }
configuration "windows" configuration "windows"
targetname "libSymmetry" targetname "libSymmetry"
configuration {"windows", "vs2017"} configuration {"windows", "vs2017"}
includedirs {"../include/windows/sdl2/"} includedirs {"../include/windows/sdl2/"}
flags "NoImportLib" flags "NoImportLib"
configuration {"linux"} configuration {"linux"}
includedirs {"../include/linux/sdl2/"} includedirs {"../include/linux/sdl2/"}
configuration "Debug" configuration "Debug"
defines {"GL_DEBUG_CONTEXT"} defines {"GL_DEBUG_CONTEXT"}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -4,7 +4,7 @@
// String type based on array that is conveniently resizable and // String type based on array that is conveniently resizable and
// converatble to/from other types. // converatble to/from other types.
char* str_new(const char* str); //char* str_new(const char* str);
size_t str_len(const char* str); //size_t str_len(const char* str);
#endif #endif

@ -47,6 +47,12 @@ enum Sound_Attenuation_Type
SA_EXPONENTIAL // Exponential distance attenuation model SA_EXPONENTIAL // Exponential distance attenuation model
}; };
struct Physics_Api
{
void(*init)(void);
void(*cleanup)(void);
};
struct Sound_Api struct Sound_Api
{ {
void (*update_3d)(void); void (*update_3d)(void);
@ -142,11 +148,12 @@ struct Platform_Api
void* (*load_function_gl)(const char* name); void* (*load_function_gl)(const char* name);
void (*reload_game_lib)(void); void (*reload_game_lib)(void);
struct Window_Api window; struct Window_Api window;
struct Sound_Api sound; struct Sound_Api sound;
struct File_Api file; struct File_Api file;
struct Config_Api config; struct Config_Api config;
struct Log_Api log; struct Log_Api log;
struct Physics_Api physics;
}; };
struct Game_Api struct Game_Api

@ -4,6 +4,7 @@
#include "../common/log.h" #include "../common/log.h"
#include "sound.h" #include "sound.h"
#include "platform.h" #include "platform.h"
#include "physics.h"
#include "file_io.h" #include "file_io.h"
#include "config_vars.h" #include "config_vars.h"
#include "../common/hashmap.h" #include "../common/hashmap.h"
@ -118,8 +119,14 @@ int main(int argc, char** args)
.log = .log =
{ {
.file_handle_get = &log_file_handle_get .file_handle_get = &log_file_handle_get
} },
.physics =
{
.init = &physics_init,
.cleanup = &physics_cleanup
}
}; };
if(!game_lib_load()) if(!game_lib_load())
log_error("main", "Failed to load game library"); log_error("main", "Failed to load game library");
else else
@ -221,7 +228,7 @@ bool init(void)
return true; return true;
} }
void cleanup() void cleanup(void)
{ {
if(game.cleanup) game.cleanup(); if(game.cleanup) game.cleanup();
if(game_lib_handle) platform_unload_library(game_lib_handle); if(game_lib_handle) platform_unload_library(game_lib_handle);

@ -0,0 +1,27 @@
#include "physics.h"
#include "../common/log.h"
#include <Newton.h>
static NewtonWorld* newton_world = 0;
void physics_init(void)
{
newton_world = NewtonCreate();
if(!newton_world)
{
log_error("physics:init", "Physics world created!");
}
else
{
log_message("Physics world created");
}
}
void physics_cleanup(void)
{
if(newton_world)
{
NewtonDestroy(newton_world);
}
}

@ -0,0 +1,7 @@
#ifndef PHYSICS_H
#define PHYSICS_H
void physics_init(void);
void physics_cleanup(void);
#endif

@ -25,6 +25,7 @@
#include "gui.h" #include "gui.h"
#include "editor.h" #include "editor.h"
#include "sprite.h" #include "sprite.h"
#include "../common/string_utils.h"
#include "../common/parser.h" #include "../common/parser.h"
#include "../common/hashmap.h" #include "../common/hashmap.h"
#include "../common/variant.h" #include "../common/variant.h"
@ -96,6 +97,7 @@ bool game_init(struct Window* window, struct Platform_Api* platform_api)
light_init(); light_init();
material_init(); material_init();
entity_init(); entity_init();
platform->physics.init();
scene_init(); scene_init();
/* Debug scene setup */ /* Debug scene setup */
@ -106,132 +108,128 @@ bool game_init(struct Window* window, struct Platform_Api* platform_api)
void scene_setup(void) void scene_setup(void)
{ {
// struct Entity* player = scene_add_new("player", ET_CAMERA); // struct Entity* player = scene_add_new("player", ET_CAMERA);
// game_state->player_node = player->id; // game_state->player_node = player->id;
// vec3 viewer_pos = {10, 5, 100}; // vec3 viewer_pos = {10, 5, 100};
// transform_set_position(player, &viewer_pos); // transform_set_position(player, &viewer_pos);
// int render_width, render_height; // int render_width, render_height;
// render_width = 1024; // render_width = 1024;
// render_height = 768; // render_height = 768;
// camera_create(player, render_width, render_height); // camera_create(player, render_width, render_height);
// camera_attach_fbo(player, render_width, render_height, 1, 1, 1); // camera_attach_fbo(player, render_width, render_height, 1, 1, 1);
// vec4_fill(&player->camera.clear_color, 0.3f, 0.6f, 0.9f, 1.0f); // vec4_fill(&player->camera.clear_color, 0.3f, 0.6f, 0.9f, 1.0f);
// vec4 color = {1.f, 1.f, 1.f, 1.f }; // vec4 color = {1.f, 1.f, 1.f, 1.f };
// struct Entity* new_ent = scene_add_new("Model_Entity", ET_STATIC_MESH); // struct Entity* new_ent = scene_add_new("Model_Entity", ET_STATIC_MESH);
// vec3 position = {0, 0, -5}; // vec3 position = {0, 0, -5};
// transform_translate(new_ent, &position, TS_WORLD); // transform_translate(new_ent, &position, TS_WORLD);
// new_ent->renderable = true; // new_ent->renderable = true;
// model_create(new_ent, "default.pamesh", "Blinn_Phong"); // model_create(new_ent, "default.pamesh", "Blinn_Phong");
// model_set_material_param(new_ent, "diffuse_color", &color); // model_set_material_param(new_ent, "diffuse_color", &color);
// int tex = texture_create_from_file("white.tga", TU_DIFFUSE); // int tex = texture_create_from_file("white.tga", TU_DIFFUSE);
// model_set_material_param(new_ent, "diffuse_texture", &tex); // model_set_material_param(new_ent, "diffuse_texture", &tex);
// vec3 scale = {1, 1, 1}; // vec3 scale = {1, 1, 1};
// transform_scale(new_ent, &scale); // transform_scale(new_ent, &scale);
// /* struct Entity* sound_ent = scene_add_as_child("Sound_ENT", ET_SOUND_SOURCE, new_ent->id); */ // /* struct Entity* sound_ent = scene_add_as_child("Sound_ENT", ET_SOUND_SOURCE, new_ent->id); */
// /* struct Sound_Source* sound_source = &sound_ent->sound_source; */ // /* struct Sound_Source* sound_source = &sound_ent->sound_source; */
// /* platform->sound.source_create(true, 1, &sound_source->source_handle, &sound_source->buffer_handles[0]); */ // /* platform->sound.source_create(true, 1, &sound_source->source_handle, &sound_source->buffer_handles[0]); */
// /* platform->sound.source_load_wav(sound_source->source_handle, */ // /* platform->sound.source_load_wav(sound_source->source_handle, */
// /* sound_source->buffer_handles[0], */ // /* sound_source->buffer_handles[0], */
// /* "BigExplosion.wav"); */ // /* "BigExplosion.wav"); */
// /* //sound_source_relative_set(source, true); */ // /* //sound_source_relative_set(source, true); */
// /* platform->sound.source_volume_set(sound_source->source_handle, 1.f); */ // /* platform->sound.source_volume_set(sound_source->source_handle, 1.f); */
// /* platform->sound.source_loop_set(sound_source->source_handle, true); */ // /* platform->sound.source_loop_set(sound_source->source_handle, true); */
// /* platform->sound.source_play(sound_source->source_handle); */ // /* platform->sound.source_play(sound_source->source_handle); */
// int parent_node = new_ent->id; // int parent_node = new_ent->id;
// int num_suz = 10; // int num_suz = 10;
// srand(time(NULL)); // srand(time(NULL));
// for(int i = 0; i < num_suz; i++) // for(int i = 0; i < num_suz; i++)
// { // {
// int x = rand() % num_suz; // int x = rand() % num_suz;
// int y = rand() % num_suz; // int y = rand() % num_suz;
// int z = rand() % num_suz; // int z = rand() % num_suz;
// x++; y++; z++; // x++; y++; z++;
// struct Entity* suz = scene_add_as_child("Suzanne", ET_STATIC_MESH, parent_node); // struct Entity* suz = scene_add_as_child("Suzanne", ET_STATIC_MESH, parent_node);
// //struct Entity* suz = scene_add_new("Suzanne", ET_STATIC_MESH); // //struct Entity* suz = scene_add_new("Suzanne", ET_STATIC_MESH);
// suz->renderable = true; // suz->renderable = true;
// model_create(suz, "default.pamesh", "Blinn_Phong"); // model_create(suz, "default.pamesh", "Blinn_Phong");
// model_set_material_param(suz, "diffuse_color", &color); // model_set_material_param(suz, "diffuse_color", &color);
// float spec_str = 80.f; // float spec_str = 80.f;
// model_set_material_param(suz, "specular_strength", &spec_str); // model_set_material_param(suz, "specular_strength", &spec_str);
// vec3 s_pos = {x, 0, z}; // vec3 s_pos = {x, 0, z};
// transform_translate(suz, &s_pos, TS_WORLD); // transform_translate(suz, &s_pos, TS_WORLD);
// } // }
// struct Entity* ground = scene_add_new("Ground", ET_STATIC_MESH); // struct Entity* ground = scene_add_new("Ground", ET_STATIC_MESH);
// ground->renderable = true; // ground->renderable = true;
// model_create(ground, "default.pamesh", "Blinn_Phong"); // model_create(ground, "default.pamesh", "Blinn_Phong");
// model_set_material_param(ground, "diffuse_color", &color); // model_set_material_param(ground, "diffuse_color", &color);
// int white_tex = texture_create_from_file("white.tga", TU_DIFFUSE); // int white_tex = texture_create_from_file("white.tga", TU_DIFFUSE);
// model_set_material_param(ground, "diffuse_texture", &white_tex); // model_set_material_param(ground, "diffuse_texture", &white_tex);
// float spec_str = 80.f; // float spec_str = 80.f;
// model_set_material_param(ground, "specular_strength", &spec_str); // model_set_material_param(ground, "specular_strength", &spec_str);
// vec3 pos = {0, -5, 0}; // vec3 pos = {0, -5, 0};
// vec3 scale_ground = {400.f, 2.f, 400.f}; // vec3 scale_ground = {400.f, 2.f, 400.f};
// transform_set_position(ground, &pos); // transform_set_position(ground, &pos);
// transform_scale(ground, &scale_ground); // transform_scale(ground, &scale_ground);
// /* struct Entity* screen = scene_add_new("Screen", NULL); */ // /* struct Entity* screen = scene_add_new("Screen", NULL); */
// /* struct Model* screen_model = entity_component_add(screen, C_MODEL, NULL, NULL); */ // /* struct Model* screen_model = entity_component_add(screen, C_MODEL, NULL, NULL); */
// /* screen_model->geometry_index = geom_find("Quad"); */ // /* screen_model->geometry_index = geom_find("Quad"); */
// /* struct Entity* screen_camera = scene_add_as_child("Screen_Camera", NULL, screen->node); */ // /* struct Entity* screen_camera = scene_add_as_child("Screen_Camera", NULL, screen->node); */
// /* struct Transform* screen_camera_tran = entity_component_get(screen_camera, C_TRANSFORM); */ // /* struct Transform* screen_camera_tran = entity_component_get(screen_camera, C_TRANSFORM); */
// /* transform_rotate(screen_camera_tran, &UNIT_Y, 180.f, TS_WORLD); */ // /* transform_rotate(screen_camera_tran, &UNIT_Y, 180.f, TS_WORLD); */
// /* struct Camera* cam = entity_component_add(screen_camera, C_CAMERA, 50, 50); */ // /* struct Camera* cam = entity_component_add(screen_camera, C_CAMERA, 50, 50); */
// /* cam->nearz = 0.1f; */ // /* cam->nearz = 0.1f; */
// /* cam->farz = 50.f; */ // /* cam->farz = 50.f; */
// /* camera_update_proj(cam); */ // /* camera_update_proj(cam); */
// /* camera_attach_fbo(cam, 128, 128, 1, 1, 0); */ // /* camera_attach_fbo(cam, 128, 128, 1, 1, 0); */
// /* model_set_material_param(screen_model, "diffuse_color", &color); */ // /* model_set_material_param(screen_model, "diffuse_color", &color); */
// /* model_set_material_param(screen_model, "diffuse_texture", &cam->render_tex); */ // /* model_set_material_param(screen_model, "diffuse_texture", &cam->render_tex); */
// const int MAX_LIGHTS = 3; // const int MAX_LIGHTS = 3;
// for(int i = 0; i < MAX_LIGHTS; i++) // for(int i = 0; i < MAX_LIGHTS; i++)
// { // {
// int x = rand() % MAX_LIGHTS; // int x = rand() % MAX_LIGHTS;
// int z = rand() % MAX_LIGHTS; // int z = rand() % MAX_LIGHTS;
// x++; z++; // x++; z++;
// struct Entity* light_ent = scene_add_new("Light_Ent", ET_LIGHT); // struct Entity* light_ent = scene_add_new("Light_Ent", ET_LIGHT);
// vec3 lt_pos = {x * 20, 0, z * 20}; // vec3 lt_pos = {x * 20, 0, z * 20};
// transform_set_position(light_ent, &lt_pos); // transform_set_position(light_ent, &lt_pos);
// light_create(light_ent, LT_POINT); // light_create(light_ent, LT_POINT);
// vec3_fill(&light_ent->light.color, 1.f / (float)x, 1.f / ((rand() % 10) + 1.f), 1.f / (float)z); // vec3_fill(&light_ent->light.color, 1.f / (float)x, 1.f / ((rand() % 10) + 1.f), 1.f / (float)z);
// light_ent->light.intensity = 1.f; // light_ent->light.intensity = 1.f;
// } // }
// ///* log_message("Sizeof Entity : %d", sizeof(struct Entity)); */ /////* log_message("Sizeof Entity : %d", sizeof(struct Entity)); */
// ///* struct Entity* light_ent = entity_find("Ground"); */ /////* struct Entity* light_ent = entity_find("Ground"); */
// ///* entity_save(light_ent, "ground.ent", DT_INSTALL); */ /////* entity_save(light_ent, "ground.ent", DT_INSTALL); */
// //scene_save("test.symtres", DIRT_INSTALL); // struct Entity* suz = entity_find("Suzanne");
// struct Entity* sound_ent = scene_add_as_child("Sound_Ent", ET_SOUND_SOURCE, suz->id);
// //struct Entity* light = entity_load("light.ent", DT_INSTALL); // struct Sound_Source* sound_source = &sound_ent->sound_source;
//sound_source->source_filename = str_new("sounds/teh_beatz.wav");
// struct Entity* suz = entity_find("Suzanne"); // sound_source->type = ST_WAV;
// struct Entity* sound_ent = scene_add_as_child("Sound_Ent", ET_SOUND_SOURCE, suz->id); // sound_source->attenuation_type = SA_LINEAR;
// struct Sound_Source* sound_source = &sound_ent->sound_source; // sound_source->rolloff_factor = 0.95f;
// sound_source->source_filename = str_new("sounds/teh_beatz.wav"); // sound_source->loop = true;
// sound_source->type = ST_WAV; // sound_source->volume = 1.f;
// sound_source->attenuation_type = SA_LINEAR; // sound_source->min_distance = 1.f;
// sound_source->rolloff_factor = 0.95f; // sound_source->max_distance = 50.f;
// sound_source->loop = true; // sound_source->playing = true;
// sound_source->volume = 1.f;
// sound_source->min_distance = 1.f; // sound_source->source_instance = 0;
// sound_source->max_distance = 50.f; // sound_source->source = NULL;
// sound_source->playing = true;
// entity_apply_sound_params(sound_ent);
// sound_source->source_instance = 0;
// sound_source->source = NULL; // scene_save("test_scene.symtres", DIRT_INSTALL);
// entity_apply_sound_params(sound_ent); if(scene_load("test_scene.symtres", DIRT_INSTALL))
// scene_save("parser_write.symtres", DIRT_INSTALL);
if(scene_load("parser_write.symtres", DIRT_INSTALL))
{ {
log_message("Scene loaded!"); log_message("Scene loaded!");
struct Entity* player = entity_find("player"); struct Entity* player = entity_find("player");
@ -1678,7 +1676,11 @@ void game_cleanup(void)
game_state = NULL; game_state = NULL;
} }
if(platform) free(platform); if(platform)
{
platform->physics.cleanup();
free(platform);
}
} }
struct Game_State* game_state_get(void) struct Game_State* game_state_get(void)

@ -14,8 +14,8 @@ static int root_node = -1;
void scene_init(void) void scene_init(void)
{ {
/* Add root node to scene */ /* Add root node to scene */
/* struct Entity* root = entity_create("ROOT", ET_ROOT, -1); */ /*struct Entity* root = entity_create("ROOT", ET_ROOT, -1);
/* root_node = root->id; */ root_node = root->id; */
} }
struct Entity* scene_add_new(const char* name, const int type) struct Entity* scene_add_new(const char* name, const int type)

Loading…
Cancel
Save