From 05c476c22a6669a7e7ec96e9aa97b5fe8f053765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Fri, 13 Sep 2013 07:16:56 +0000 Subject: [PATCH] Added nacl_phystest to test physic compatibility with nacl. --- build/vs2010/Lol.sln | 23 ++++++ test/Makefile.am | 9 ++- test/nacl_phystest.cpp | 121 +++++++++++++++++++++++++++++ test/nacl_phystest.h | 61 +++++++++++++++ test/nacl_phystest.vcxproj | 87 +++++++++++++++++++++ test/nacl_phystest.vcxproj.filters | 20 +++++ 6 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 test/nacl_phystest.cpp create mode 100644 test/nacl_phystest.h create mode 100644 test/nacl_phystest.vcxproj create mode 100644 test/nacl_phystest.vcxproj.filters diff --git a/build/vs2010/Lol.sln b/build/vs2010/Lol.sln index f202f254..b5216316 100644 --- a/build/vs2010/Lol.sln +++ b/build/vs2010/Lol.sln @@ -158,6 +158,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06_sprite", "..\..\demos\tu EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "voxel", "..\..\people\benlitz\private\voxel\voxel.vcxproj", "{52493826-AC00-470B-A745-4F602529B3B0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nacl_phystest", "..\..\test\nacl_phystest.vcxproj", "{EE203B88-44CF-4859-9D42-7A1F43FECB53}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1007,6 +1009,26 @@ Global {52493826-AC00-470B-A745-4F602529B3B0}.Release|x64.ActiveCfg = Release|x64 {52493826-AC00-470B-A745-4F602529B3B0}.Release|x64.Build.0 = Release|x64 {52493826-AC00-470B-A745-4F602529B3B0}.Release|Xbox 360.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Any CPU.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|ORBIS.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|PS3.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Win32.Build.0 = Debug|Win32 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|x64.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|x64.Build.0 = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Debug|Xbox 360.ActiveCfg = Debug|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Any CPU.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Mixed Platforms.Build.0 = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|ORBIS.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|PS3.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Win32.ActiveCfg = Release|Win32 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Win32.Build.0 = Release|Win32 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|x64.ActiveCfg = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|x64.Build.0 = Release|x64 + {EE203B88-44CF-4859-9D42-7A1F43FECB53}.Release|Xbox 360.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1031,6 +1053,7 @@ Global {80F81C11-8DA2-4990-91CB-9807783BA46E} = {E0491194-35E3-4513-9D31-608EA3165ECF} {EE203B88-44CF-4859-9D42-7A1F43FECB52} = {E0491194-35E3-4513-9D31-608EA3165ECF} {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E} = {E0491194-35E3-4513-9D31-608EA3165ECF} + {EE203B88-44CF-4859-9D42-7A1F43FECB53} = {E0491194-35E3-4513-9D31-608EA3165ECF} {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} = {E5C5E320-C077-4362-9A3F-3920C6447601} {F7D4A671-612F-4FF4-883F-2097697694B7} = {E5C5E320-C077-4362-9A3F-3920C6447601} {7B083DA2-FE08-4F6D-BFDD-195D5C2783EB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} diff --git a/test/Makefile.am b/test/Makefile.am index 04f8f7aa..fbc804bc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = math sandbox xolotl bench: benchsuite$(EXEEXT) ./benchsuite$(EXEEXT) -noinst_PROGRAMS = benchsuite $(testsuite) btphystest meshviewer +noinst_PROGRAMS = benchsuite $(testsuite) btphystest nacl_phystest meshviewer TESTS = $(testsuite) @@ -50,6 +50,13 @@ btphystest_LDFLAGS += \ -s TOTAL_MEMORY=$(shell expr 32 '*' 1024 '*' 1024) endif +nacl_phystest_SOURCES = \ + nacl_phystest.cpp nacl_phystest.h +nacl_phystest_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/bullet \ + -DHAVE_PHYS_USE_BULLET +nacl_phystest_DEPENDENCIES = @LOL_DEPS@ +nacl_phystest_LDFLAGS = $(AM_LDFLAGS) + meshviewer_SOURCES = meshviewer.cpp \ shinymvtexture.lolfx shinyfur.lolfx meshviewer_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/test/nacl_phystest.cpp b/test/nacl_phystest.cpp new file mode 100644 index 00000000..dd6d55b2 --- /dev/null +++ b/test/nacl_phystest.cpp @@ -0,0 +1,121 @@ +// +// BtPhysTest +// +// Copyright: (c) 2009-2013 Benjamin "Touky" Huet +// (c) 2012-2013 Sam Hocevar +// + +#if defined HAVE_CONFIG_H +# include "config.h" +#endif + +#include "core.h" +#include "loldebug.h" + +using namespace lol; + +#ifndef HAVE_PHYS_USE_BULLET +#define HAVE_PHYS_USE_BULLET +#endif /* HAVE_PHYS_USE_BULLET */ + +//#include "physics/lolphysics.h" +//#include "physics/easyphysics.h" + +#include "nacl_phystest.h" + +//using namespace lol::phys; + +int gNumObjects = 64; + +Nacl_PhysTest::Nacl_PhysTest(bool editor) +{ + /* Register an input controller for the keyboard */ + m_controller = new Controller(KEY_MAX, 0); + m_controller->GetKey(KEY_MOVE_FORWARD).Bind("Keyboard", "Up"); + m_controller->GetKey(KEY_MOVE_BACK).Bind("Keyboard", "Down"); + m_controller->GetKey(KEY_MOVE_LEFT).Bind("Keyboard", "Left"); + m_controller->GetKey(KEY_MOVE_RIGHT).Bind("Keyboard", "Right"); + m_controller->GetKey(KEY_MOVE_JUMP).Bind("Keyboard", "Space"); + m_controller->GetKey(KEY_MOVE_UP).Bind("Keyboard", "PageUp"); + m_controller->GetKey(KEY_MOVE_DOWN).Bind("Keyboard", "PageDown"); + m_controller->GetKey(KEY_QUIT).Bind("Keyboard", "Escape"); + + /* Create a camera that matches the settings of XNA BtPhysTest */ + m_camera = new Camera(); + m_camera->SetView(vec3(50.f, 50.f, 0.f), + vec3(0.f, 0.f, 0.f), + vec3(0, 1, 0)); + m_camera->SetProjection(45.f, .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x); + g_scene->PushCamera(m_camera); + + m_ready = false; + + /* + m_simulation = new Simulation(); + m_simulation->SetWorldLimit(vec3(-1000.0f, -1000.0f, -1000.0f), vec3(1000.0f, 1000.0f, 1000.0f)); + m_simulation->Init(); + vec3 NewGravity = vec3(.0f, -10.0f, .0f); + m_simulation->SetGravity(NewGravity); + m_simulation->SetContinuousDetection(true); + m_simulation->SetTimestep(1.f / 120.f); + Ticker::Ref(m_simulation); + */ + + /* Add a white directional light */ + m_light1 = new Light(); + m_light1->SetPosition(vec4(0.2f, 0.2f, 0.f, 0.f)); + m_light1->SetColor(vec4(0.5f, 0.5f, 0.5f, 1.f)); + Ticker::Ref(m_light1); + + /* Add an orangeish point light */ + m_light2 = new Light(); + m_light2->SetPosition(vec4(-15.f, 15.f, 15.f, 1.f)); + m_light2->SetColor(vec4(0.4f, 0.3f, 0.2f, 1.f)); + Ticker::Ref(m_light2); +} + +void Nacl_PhysTest::TickGame(float seconds) +{ + WorldEntity::TickGame(seconds); + + if (m_controller->GetKey(KEY_QUIT).IsReleased()) + Ticker::Shutdown(); +} + +void Nacl_PhysTest::TickDraw(float seconds) +{ + WorldEntity::TickDraw(seconds); + + if (!m_ready) + { + /* FIXME: this object never cleans up */ + m_ready = true; + } + else + { + } +} + +Nacl_PhysTest::~Nacl_PhysTest() +{ + g_scene->PopCamera(m_camera); + Ticker::Unref(m_light1); + Ticker::Unref(m_light2); + + //Ticker::Unref(m_simulation); +} + +int main(int argc, char **argv) +{ + System::Init(argc, argv); + + Application app("Nacl_PhysTest", ivec2(1280, 960), 60.0f); + + new Nacl_PhysTest(argc > 1); + app.ShowPointer(false); + + app.Run(); + + return EXIT_SUCCESS; +} + diff --git a/test/nacl_phystest.h b/test/nacl_phystest.h new file mode 100644 index 00000000..d46581e1 --- /dev/null +++ b/test/nacl_phystest.h @@ -0,0 +1,61 @@ +// +// BtPhysTest +// +// Copyright: (c) 2009-2013 Benjamin "Touky" Huet +// (c) 2012 Sam Hocevar +// + +#if !defined __BTPHYSTEST_H__ +#define __BTPHYSTEST_H__ + +class Nacl_PhysTest : public WorldEntity +{ +public: + Nacl_PhysTest(bool editor = false); + virtual ~Nacl_PhysTest(); + + char const *GetName() { return ""; } + +protected: + virtual void TickGame(float seconds); + virtual void TickDraw(float seconds); + +private: + enum + { + KEY_MOVE_FORWARD, + KEY_MOVE_BACK, + KEY_MOVE_LEFT, + KEY_MOVE_RIGHT, + KEY_MOVE_UP, + KEY_MOVE_DOWN, + KEY_MOVE_JUMP, + KEY_QUIT, + KEY_MAX, + }; + + TileSet* m_cat_texture; + Shader* m_cat_shader; + Camera* m_camera; + Controller * m_controller; + Light * m_light1; + Light * m_light2; + bool m_ready; + + //lol::phys::Simulation* m_simulation; + //Array m_constraint_list; + //Array m_physobj_list; + //Array m_ground_list; + //Array m_platform_list; + //Array m_character_list; + //Array m_stairs_list; + + float m_loop_value; + float m_target_timer; + int m_cam_target; + float m_fov_dp; + float m_loc_dp; +}; + +#endif // __BTPHYSTEST_H__ + diff --git a/test/nacl_phystest.vcxproj b/test/nacl_phystest.vcxproj new file mode 100644 index 00000000..5b9ba51b --- /dev/null +++ b/test/nacl_phystest.vcxproj @@ -0,0 +1,87 @@ + + + + + Debug + ORBIS + + + Debug + PS3 + + + Debug + Win32 + + + Debug + x64 + + + Debug + Xbox 360 + + + Release + ORBIS + + + Release + PS3 + + + Release + Win32 + + + Release + x64 + + + Release + Xbox 360 + + + + + + + + + + + {9e62f2fe-3408-4eae-8238-fd84238ceeda} + + + {83d3b207-c601-4025-8f41-01dedc354661} + + + {d84021ca-b233-4e0f-8a52-071b83bbccc4} + + + + + true + + + + {ee203b88-44cf-4859-9d42-7a1f43fecb53} + Application + Win32Proj + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/nacl_phystest.vcxproj.filters b/test/nacl_phystest.vcxproj.filters new file mode 100644 index 00000000..ccd5e2f8 --- /dev/null +++ b/test/nacl_phystest.vcxproj.filters @@ -0,0 +1,20 @@ + + + + + + + + + + + {4fc7662b-b17a-49b9-acd1-0cf767183b07} + + + {ccecd634-9321-4c49-9471-e9da50dda6d4} + + + + + + \ No newline at end of file