| @@ -17,7 +17,7 @@ using namespace lol; | |||||
| #include "physics/lolphysics.h" | #include "physics/lolphysics.h" | ||||
| #include "physics/easyphysics.h" | #include "physics/easyphysics.h" | ||||
| #define CAT_MODE 1 | |||||
| #define CAT_MODE 0 | |||||
| #define OBJ_SIZE 2.f | #define OBJ_SIZE 2.f | ||||
| #define NB_SPRITE 4 | #define NB_SPRITE 4 | ||||
| #define PARTICLE_SIZE 4 | #define PARTICLE_SIZE 4 | ||||
| @@ -36,17 +36,17 @@ using namespace lol::phys; | |||||
| #define JUMP_STRAFE .5f | #define JUMP_STRAFE .5f | ||||
| #define TARGET_TIMER 10.f + (rand(4.f) - 2.f) | #define TARGET_TIMER 10.f + (rand(4.f) - 2.f) | ||||
| int gNumObjects = 64; | |||||
| int gNumObjects = 16; | |||||
| #if CAT_MODE | #if CAT_MODE | ||||
| #define USE_WALL 1 | #define USE_WALL 1 | ||||
| #define USE_BODIES 1 | #define USE_BODIES 1 | ||||
| #else | #else | ||||
| #define USE_WALL 1 | #define USE_WALL 1 | ||||
| #define USE_PLATFORM 1 | |||||
| #define USE_PLATFORM 0 | |||||
| #define USE_ROPE 0 | #define USE_ROPE 0 | ||||
| #define USE_BODIES 1 | #define USE_BODIES 1 | ||||
| #define USE_ROTATION 0 | |||||
| #define USE_ROTATION 1 | |||||
| #define USE_CHARACTER 0 | #define USE_CHARACTER 0 | ||||
| #define USE_STAIRS 0 | #define USE_STAIRS 0 | ||||
| #endif | #endif | ||||
| @@ -71,6 +71,14 @@ void BtPhysTest::InitApp() | |||||
| m_loc_dp = .0f; | m_loc_dp = .0f; | ||||
| #endif //CAT_MODE | #endif //CAT_MODE | ||||
| #if 1 //HAS_INPUT | |||||
| InputProfile& ip = m_profile; | |||||
| ip.AddBindings<BtPhysTestKeyInput, BtPhysTestKeyInput::KEY_START, BtPhysTestKeyInput::KEY_MAX>(InputProfileType::Keyboard); | |||||
| m_controller = new Controller("Default"); | |||||
| m_controller->Init(m_profile); | |||||
| Ticker::Ref(m_controller); | |||||
| #else | |||||
| /* Register an input controller for the keyboard */ | /* Register an input controller for the keyboard */ | ||||
| m_controller = new Controller("Default"); | m_controller = new Controller("Default"); | ||||
| m_controller->SetInputCount(KEY_MAX, 0); | m_controller->SetInputCount(KEY_MAX, 0); | ||||
| @@ -82,6 +90,7 @@ void BtPhysTest::InitApp() | |||||
| m_controller->GetKey(KEY_MOVE_UP).Bind("Keyboard", "PageUp"); | m_controller->GetKey(KEY_MOVE_UP).Bind("Keyboard", "PageUp"); | ||||
| m_controller->GetKey(KEY_MOVE_DOWN).Bind("Keyboard", "PageDown"); | m_controller->GetKey(KEY_MOVE_DOWN).Bind("Keyboard", "PageDown"); | ||||
| m_controller->GetKey(KEY_QUIT).Bind("Keyboard", "Escape"); | m_controller->GetKey(KEY_QUIT).Bind("Keyboard", "Escape"); | ||||
| #endif | |||||
| /* Create a camera that matches the settings of XNA BtPhysTest */ | /* Create a camera that matches the settings of XNA BtPhysTest */ | ||||
| m_camera = new Camera(); | m_camera = new Camera(); | ||||
| @@ -301,6 +310,88 @@ void BtPhysTest::InitApp() | |||||
| #endif //USE_ROPE | #endif //USE_ROPE | ||||
| } | } | ||||
| BtPhysTest::~BtPhysTest() | |||||
| { | |||||
| Scene& scene = Scene::GetScene(); | |||||
| scene.PopCamera(m_camera); | |||||
| Ticker::Unref(m_controller); | |||||
| Ticker::Unref(m_light1); | |||||
| Ticker::Unref(m_light2); | |||||
| #if CAT_MODE | |||||
| /* cat datas setup */ | |||||
| Shader::Destroy(m_cat_shader); | |||||
| Tiler::Deregister(m_cat_texture); | |||||
| #endif //CAT_MODE | |||||
| while (m_constraint_list.count()) | |||||
| { | |||||
| EasyConstraint* CurPop = m_constraint_list.last(); | |||||
| m_constraint_list.pop(); | |||||
| CurPop->RemoveFromSimulation(m_simulation); | |||||
| delete CurPop; | |||||
| } | |||||
| array<PhysicsObject*> objects | |||||
| = m_ground_list | |||||
| + m_stairs_list | |||||
| + m_character_list | |||||
| + m_platform_list; | |||||
| while (m_physobj_list.count()) | |||||
| { | |||||
| objects << m_physobj_list.last().m1; | |||||
| m_physobj_list.pop(); | |||||
| } | |||||
| m_ground_list.empty(); | |||||
| m_stairs_list.empty(); | |||||
| m_character_list.empty(); | |||||
| m_platform_list.empty(); | |||||
| while (objects.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = objects.pop(); | |||||
| CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| //while (m_ground_list.count()) | |||||
| //{ | |||||
| // PhysicsObject* CurPop = m_ground_list.last(); | |||||
| // m_ground_list.pop(); | |||||
| // CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| // Ticker::Unref(CurPop); | |||||
| //} | |||||
| //while (m_stairs_list.count()) | |||||
| //{ | |||||
| // PhysicsObject* CurPop = m_stairs_list.last(); | |||||
| // m_stairs_list.pop(); | |||||
| // CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| // Ticker::Unref(CurPop); | |||||
| //} | |||||
| //while (m_character_list.count()) | |||||
| //{ | |||||
| // PhysicsObject* CurPop = m_character_list.last(); | |||||
| // m_character_list.pop(); | |||||
| // CurPop->GetCharacter()->RemoveFromSimulation(m_simulation); | |||||
| // Ticker::Unref(CurPop); | |||||
| //} | |||||
| //while (m_platform_list.count()) | |||||
| //{ | |||||
| // PhysicsObject* CurPop = m_platform_list.last(); | |||||
| // m_platform_list.pop(); | |||||
| // CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| // Ticker::Unref(CurPop); | |||||
| //} | |||||
| //while (m_physobj_list.count()) | |||||
| //{ | |||||
| // PhysicsObject* CurPop = m_physobj_list.last().m1; | |||||
| // m_physobj_list.pop(); | |||||
| // CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| // Ticker::Unref(CurPop); | |||||
| //} | |||||
| Ticker::Unref(m_simulation); | |||||
| } | |||||
| void BtPhysTest::TickGame(float seconds) | void BtPhysTest::TickGame(float seconds) | ||||
| { | { | ||||
| WorldEntity::TickGame(seconds); | WorldEntity::TickGame(seconds); | ||||
| @@ -317,8 +408,10 @@ void BtPhysTest::TickGame(float seconds) | |||||
| return; | return; | ||||
| } | } | ||||
| Debug::DrawSetupSegment(1.f); | |||||
| Debug::DrawGrid(vec3::zero, vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.f); | |||||
| if (m_controller->WasKeyReleasedThisFrame(KEY_QUIT)) | |||||
| if (m_controller->WasKeyReleasedThisFrame(BtPhysTestKeyInput::KEY_QUIT)) | |||||
| Ticker::Shutdown(); | Ticker::Shutdown(); | ||||
| m_loop_value += seconds; | m_loop_value += seconds; | ||||
| @@ -619,65 +712,6 @@ void BtPhysTest::TickDraw(float seconds, Scene &scene) | |||||
| } | } | ||||
| BtPhysTest::~BtPhysTest() | |||||
| { | |||||
| Scene& scene = Scene::GetScene(); | |||||
| scene.PopCamera(m_camera); | |||||
| Ticker::Unref(m_light1); | |||||
| Ticker::Unref(m_light2); | |||||
| #if CAT_MODE | |||||
| /* cat datas setup */ | |||||
| Shader::Destroy(m_cat_shader); | |||||
| Tiler::Deregister(m_cat_texture); | |||||
| #endif //CAT_MODE | |||||
| while (m_constraint_list.count()) | |||||
| { | |||||
| EasyConstraint* CurPop = m_constraint_list.last(); | |||||
| m_constraint_list.pop(); | |||||
| CurPop->RemoveFromSimulation(m_simulation); | |||||
| delete CurPop; | |||||
| } | |||||
| while (m_ground_list.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = m_ground_list.last(); | |||||
| m_ground_list.pop(); | |||||
| CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| while (m_stairs_list.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = m_stairs_list.last(); | |||||
| m_stairs_list.pop(); | |||||
| CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| while (m_character_list.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = m_character_list.last(); | |||||
| m_character_list.pop(); | |||||
| CurPop->GetCharacter()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| while (m_platform_list.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = m_platform_list.last(); | |||||
| m_platform_list.pop(); | |||||
| CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| while (m_physobj_list.count()) | |||||
| { | |||||
| PhysicsObject* CurPop = m_physobj_list.last().m1; | |||||
| m_physobj_list.pop(); | |||||
| CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | |||||
| Ticker::Unref(CurPop); | |||||
| } | |||||
| Ticker::Unref(m_simulation); | |||||
| } | |||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| // CShaderData | // CShaderData | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| @@ -43,26 +43,50 @@ protected: | |||||
| void InitApp(); | void InitApp(); | ||||
| private: | private: | ||||
| enum | |||||
| //MeshViewerInput --------------------------------------------------------- | |||||
| struct BtPhysTestKeyInputBase : public StructSafeEnum | |||||
| { | { | ||||
| 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, | |||||
| enum Type | |||||
| { | |||||
| KEY_START = 0, | |||||
| KEY_MOVE_FORWARD = KEY_START, | |||||
| KEY_MOVE_BACK, | |||||
| KEY_MOVE_LEFT, | |||||
| KEY_MOVE_RIGHT, | |||||
| KEY_MOVE_UP, | |||||
| KEY_MOVE_DOWN, | |||||
| KEY_MOVE_JUMP, | |||||
| KEY_QUIT, | |||||
| KEY_MAX | |||||
| }; | |||||
| protected: | |||||
| virtual bool BuildEnumMap(map<int64_t, String>& enum_map) | |||||
| { | |||||
| enum_map[KEY_MOVE_FORWARD] = g_name_key_Up; | |||||
| enum_map[KEY_MOVE_BACK] = g_name_key_Down; | |||||
| enum_map[KEY_MOVE_LEFT] = g_name_key_Left; | |||||
| enum_map[KEY_MOVE_RIGHT] = g_name_key_Right; | |||||
| enum_map[KEY_MOVE_UP] = g_name_key_PageUp; | |||||
| enum_map[KEY_MOVE_DOWN] = g_name_key_PageDown; | |||||
| enum_map[KEY_MOVE_JUMP] = g_name_key_Space; | |||||
| enum_map[KEY_QUIT] = g_name_key_Escape; | |||||
| return true; | |||||
| } | |||||
| }; | }; | ||||
| typedef SafeEnum<BtPhysTestKeyInputBase> BtPhysTestKeyInput; | |||||
| TileSet* m_cat_texture; | TileSet* m_cat_texture; | ||||
| Shader* m_cat_shader; | Shader* m_cat_shader; | ||||
| CatShaderData* m_cat_sdata; | CatShaderData* m_cat_sdata; | ||||
| Camera* m_camera; | Camera* m_camera; | ||||
| Controller * m_controller; | |||||
| Light * m_light1; | |||||
| Light * m_light2; | |||||
| Controller* m_controller; | |||||
| InputProfile m_profile; | |||||
| Light* m_light1; | |||||
| Light* m_light2; | |||||
| int m_init_status; | int m_init_status; | ||||
| bool m_ready; | bool m_ready; | ||||
| @@ -42,7 +42,10 @@ public: | |||||
| { | { | ||||
| m_physics = new EasyPhysic(this); | m_physics = new EasyPhysic(this); | ||||
| m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]"); | |||||
| //m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]"); | |||||
| m_mesh.SetCurColor(Color::white); | |||||
| m_mesh.AppendFlatChamfBox(vec3(60.f, 1.f, 60.f), -.1f); | |||||
| vec3 BoxSize = vec3(60.f, 1.f, 60.f); | vec3 BoxSize = vec3(60.f, 1.f, 60.f); | ||||
| m_physics->SetCollisionChannel(0, 0xFF); | m_physics->SetCollisionChannel(0, 0xFF); | ||||
| m_physics->SetShapeToBox(BoxSize); | m_physics->SetShapeToBox(BoxSize); | ||||
| @@ -130,88 +133,168 @@ public: | |||||
| m_is_character(false), | m_is_character(false), | ||||
| m_is_phys(false) | m_is_phys(false) | ||||
| { | { | ||||
| array<char const *> MeshRand; | |||||
| array<int> MeshLimit; | |||||
| array<int> MeshType; | |||||
| static array<EasyMesh> MeshRand; | |||||
| static array<int> MeshLimit; | |||||
| static array<int> MeshType; | |||||
| if (!MeshRand.count()) | |||||
| { | |||||
| array<String> colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" }; | |||||
| MeshLimit << 0; | |||||
| MeshLimit << 0; | |||||
| #if USE_BOX | #if USE_BOX | ||||
| MeshRand << "[sc#add afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshRand << "[sc#dad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshRand << "[sc#dda afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshRand << "[sc#daa afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshRand << "[sc#ada afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshRand << "[sc#aad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 0; | |||||
| { | |||||
| array<String> colors = colors_base; | |||||
| while (colors.count()) | |||||
| { | |||||
| EasyMesh m; | |||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| m.SetCurColor(color); | |||||
| m.AppendFlatChamfBox(vec3(1.7f), .4f); | |||||
| m.OpenBrace(); | |||||
| { | |||||
| m.SetCurColor(Color::black); | |||||
| m.ToggleScaleWinding(); | |||||
| m.AppendFlatChamfBox(vec3(1.9f), .4f); | |||||
| m.ScaleX(-1.f); | |||||
| m.ScaleY(-1.f); | |||||
| m.ScaleZ(-1.f); | |||||
| } | |||||
| m.CloseBrace(); | |||||
| MeshRand << m; | |||||
| } | |||||
| } | |||||
| //MeshRand << "[sc#add afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| //MeshRand << "[sc#dad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| //MeshRand << "[sc#dda afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| //MeshRand << "[sc#daa afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| //MeshRand << "[sc#ada afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| //MeshRand << "[sc#aad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 0; | |||||
| #endif //USE_BOX | #endif //USE_BOX | ||||
| #if USE_SPHERE | #if USE_SPHERE | ||||
| #if CAT_MODE | #if CAT_MODE | ||||
| int nb_sprite = NB_SPRITE; | |||||
| //SPRITE | |||||
| vec2 start_point = vec2((float)rand(nb_sprite), (float)rand(nb_sprite)) / vec2((float)nb_sprite); | |||||
| //vec2(0.f, .0f) / vec2((float)nb_sprite); | |||||
| vec2 size = vec2(1.f) / vec2((float)nb_sprite); | |||||
| m_mesh.BD()->SetTexCoordCustomBuild(MeshType::Quad, MeshFaceType::QuadDefault, | |||||
| start_point, start_point + size); | |||||
| m_mesh.BD()->SetTexCoordCustomBuild2(MeshType::Quad, MeshFaceType::QuadDefault, | |||||
| vec2(-PARTICLE_SIZE), vec2(PARTICLE_SIZE)); | |||||
| MeshRand << "[tpbn tvnc sc#ffff aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#faaf aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#afaf aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#aaff aq 0 0]"; | |||||
| int nb_sprite = NB_SPRITE; | |||||
| //SPRITE | |||||
| vec2 start_point = vec2((float)rand(nb_sprite), (float)rand(nb_sprite)) / vec2((float)nb_sprite); | |||||
| //vec2(0.f, .0f) / vec2((float)nb_sprite); | |||||
| vec2 size = vec2(1.f) / vec2((float)nb_sprite); | |||||
| m_mesh.BD()->SetTexCoordCustomBuild(MeshType::Quad, MeshFaceType::QuadDefault, | |||||
| start_point, start_point + size); | |||||
| m_mesh.BD()->SetTexCoordCustomBuild2(MeshType::Quad, MeshFaceType::QuadDefault, | |||||
| vec2(-PARTICLE_SIZE), vec2(PARTICLE_SIZE)); | |||||
| MeshRand << "[tpbn tvnc sc#ffff aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#faaf aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#afaf aq 0 0]"; | |||||
| MeshRand << "[tpbn tvnc sc#aaff aq 0 0]"; | |||||
| #else | #else | ||||
| MeshRand << "[sc#add asph1 2]"; | |||||
| MeshRand << "[sc#dad asph1 2]"; | |||||
| MeshRand << "[sc#dda asph1 2]"; | |||||
| MeshRand << "[sc#daa asph1 2]"; | |||||
| MeshRand << "[sc#ada asph1 2]"; | |||||
| MeshRand << "[sc#aad asph1 2]"; | |||||
| { | |||||
| array<String> colors = colors_base; | |||||
| while (colors.count()) | |||||
| { | |||||
| EasyMesh m; | |||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| m.SetCurColor(color); | |||||
| m.AppendSphere(1, 2.f); | |||||
| MeshRand << m; | |||||
| } | |||||
| } | |||||
| //MeshRand << "[sc#add asph1 2]"; | |||||
| //MeshRand << "[sc#dad asph1 2]"; | |||||
| //MeshRand << "[sc#dda asph1 2]"; | |||||
| //MeshRand << "[sc#daa asph1 2]"; | |||||
| //MeshRand << "[sc#ada asph1 2]"; | |||||
| //MeshRand << "[sc#aad asph1 2]"; | |||||
| #endif | #endif | ||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 1; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 1; | |||||
| #endif //USE_SPHERE | #endif //USE_SPHERE | ||||
| #if USE_CONE | #if USE_CONE | ||||
| MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 2; | |||||
| { | |||||
| array<String> colors = colors_base; | |||||
| while (colors.count()) | |||||
| { | |||||
| EasyMesh m; | |||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| m.SetCurColor(color); | |||||
| m.SetCurColorB(color); | |||||
| m.AppendDisc(8, 2.f); | |||||
| m.RotateX(180.f); | |||||
| m.TranslateY(-1.f); | |||||
| m.AppendCylinder(8, 2.f, 2.f, 0.f); | |||||
| MeshRand << m; | |||||
| } | |||||
| } | |||||
| //MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| //MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| //MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| //MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| //MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| //MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 2; | |||||
| #endif //USE_CONE | #endif //USE_CONE | ||||
| #if USE_CYLINDER | #if USE_CYLINDER | ||||
| MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 3; | |||||
| { | |||||
| array<String> colors = colors_base; | |||||
| while (colors.count()) | |||||
| { | |||||
| EasyMesh m; | |||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| m.SetCurColor(color); | |||||
| m.SetCurColorB(color); | |||||
| m.AppendDisc(8, 2.f); | |||||
| m.RotateX(180.f); | |||||
| m.TranslateY(-1.f); | |||||
| m.MirrorY(); | |||||
| m.AppendCylinder(8.f, 2.f, 2.f, 2.f); | |||||
| MeshRand << m; | |||||
| } | |||||
| } | |||||
| //MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| //MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| //MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| //MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| //MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| //MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 3; | |||||
| #endif //USE_CYLINDER | #endif //USE_CYLINDER | ||||
| #if USE_CAPSULE | #if USE_CAPSULE | ||||
| MeshRand << "[sc#add scb#add acap1 2 1]"; | |||||
| MeshRand << "[sc#dad scb#dad acap1 2 1]"; | |||||
| MeshRand << "[sc#dda scb#dda acap1 2 1]"; | |||||
| MeshRand << "[sc#daa scb#daa acap1 2 1]"; | |||||
| MeshRand << "[sc#ada scb#ada acap1 2 1]"; | |||||
| MeshRand << "[sc#aad scb#aad acap1 2 1]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 4; | |||||
| { | |||||
| array<String> colors = colors_base; | |||||
| while (colors.count()) | |||||
| { | |||||
| EasyMesh m; | |||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| m.SetCurColor(color); | |||||
| m.SetCurColorB(color); | |||||
| m.AppendCapsule(1, 2.f, 1.f); | |||||
| MeshRand << m; | |||||
| } | |||||
| } | |||||
| //MeshRand << "[sc#add scb#add acap1 2 1]"; | |||||
| //MeshRand << "[sc#dad scb#dad acap1 2 1]"; | |||||
| //MeshRand << "[sc#dda scb#dda acap1 2 1]"; | |||||
| //MeshRand << "[sc#daa scb#daa acap1 2 1]"; | |||||
| //MeshRand << "[sc#ada scb#ada acap1 2 1]"; | |||||
| //MeshRand << "[sc#aad scb#aad acap1 2 1]"; | |||||
| MeshLimit << MeshRand.count(); | |||||
| MeshType << 4; | |||||
| #endif //USE_CAPSULE | #endif //USE_CAPSULE | ||||
| } | |||||
| int RandLimit = RandValue; | int RandLimit = RandValue; | ||||
| if (MeshLimit.count() <= RandValue || RandValue < 0) | if (MeshLimit.count() <= RandValue || RandValue < 0) | ||||
| @@ -220,7 +303,8 @@ public: | |||||
| m_physics = new EasyPhysic(this); | m_physics = new EasyPhysic(this); | ||||
| m_mesh.Compile(MeshRand[RandValue]); | |||||
| //m_mesh.Compile(MeshRand[RandValue]); | |||||
| m_mesh = MeshRand[RandValue]; | |||||
| m_mesh.Scale(vec3(OBJ_SIZE)); | m_mesh.Scale(vec3(OBJ_SIZE)); | ||||
| vec3 BoxSize = vec3(2.0f) * OBJ_SIZE; | vec3 BoxSize = vec3(2.0f) * OBJ_SIZE; | ||||
| int ColGroup = 1; | int ColGroup = 1; | ||||
| @@ -191,16 +191,16 @@ public: | |||||
| */ | */ | ||||
| void Translate(vec3 const &v); | void Translate(vec3 const &v); | ||||
| /* See Rotate */ | /* See Rotate */ | ||||
| void RotateX(float angle); | |||||
| void RotateX(float degrees); | |||||
| /* See Rotate */ | /* See Rotate */ | ||||
| void RotateY(float angle); | |||||
| void RotateY(float degrees); | |||||
| /* See Rotate */ | /* See Rotate */ | ||||
| void RotateZ(float angle); | |||||
| void RotateZ(float degrees); | |||||
| /* [cmd:r/rx/ry/rz] Rotate vertices | /* [cmd:r/rx/ry/rz] Rotate vertices | ||||
| - angle : rotation quantity. | |||||
| - degrees : rotation quantity. | |||||
| - axis : rotation axis. | - axis : rotation axis. | ||||
| */ | */ | ||||
| void Rotate(float angle, vec3 const &axis); | |||||
| void Rotate(float degrees, vec3 const &axis); | |||||
| /* [cmd:rj] Randomly move vertices along Origin-to-vertex as f(vtx) = vtx + o2v * (1.0 + rand(r)) | /* [cmd:rj] Randomly move vertices along Origin-to-vertex as f(vtx) = vtx + o2v * (1.0 + rand(r)) | ||||
| - r : jitter maximum value. | - r : jitter maximum value. | ||||
| */ | */ | ||||
| @@ -35,21 +35,21 @@ void EasyMesh::Translate(vec3 const &v) | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::RotateX(float angle) { Rotate(angle, vec3(1, 0, 0)); } | |||||
| void EasyMesh::RotateY(float angle) { Rotate(angle, vec3(0, 1, 0)); } | |||||
| void EasyMesh::RotateZ(float angle) { Rotate(angle, vec3(0, 0, 1)); } | |||||
| void EasyMesh::RotateX(float degrees) { Rotate(degrees, vec3(1, 0, 0)); } | |||||
| void EasyMesh::RotateY(float degrees) { Rotate(degrees, vec3(0, 1, 0)); } | |||||
| void EasyMesh::RotateZ(float degrees) { Rotate(degrees, vec3(0, 0, 1)); } | |||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::Rotate(float angle, vec3 const &axis) | |||||
| void EasyMesh::Rotate(float degrees, vec3 const &axis) | |||||
| { | { | ||||
| if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | ||||
| { | { | ||||
| BD()->CmdStack().AddCmd(EasyMeshCmdType::Rotate); | BD()->CmdStack().AddCmd(EasyMeshCmdType::Rotate); | ||||
| BD()->CmdStack() << angle << axis; | |||||
| BD()->CmdStack() << degrees << axis; | |||||
| return; | return; | ||||
| } | } | ||||
| mat3 m = mat3::rotate(angle, axis); | |||||
| mat3 m = mat3::rotate(degrees, axis); | |||||
| for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | ||||
| { | { | ||||
| m_vert[i].m_coord = m * m_vert[i].m_coord; | m_vert[i].m_coord = m * m_vert[i].m_coord; | ||||
| @@ -932,7 +932,7 @@ String ShaderData::Patch(String const &code, ShaderType type) | |||||
| } | } | ||||
| } | } | ||||
| patched_code.resize(strlen(patched_code.C())); | |||||
| patched_code.resize((int)strlen(patched_code.C())); | |||||
| return patched_code; | return patched_code; | ||||
| } | } | ||||
| @@ -45,7 +45,7 @@ public: | |||||
| { | { | ||||
| using namespace std; | using namespace std; | ||||
| ASSERT(str); | ASSERT(str); | ||||
| resize(strlen(str)); | |||||
| resize((int)strlen(str)); | |||||
| memcpy(&(*this)[0], str, count() + 1); | memcpy(&(*this)[0], str, count() + 1); | ||||
| } | } | ||||
| @@ -162,7 +162,7 @@ public: | |||||
| { | { | ||||
| using namespace std; | using namespace std; | ||||
| int token_len = strlen(token); | |||||
| int token_len = (int)strlen(token); | |||||
| for (int i = count() - token_len; i >= 0; --i) | for (int i = count() - token_len; i >= 0; --i) | ||||
| if (strstr(C() + i, token)) | if (strstr(C() + i, token)) | ||||
| return i; | return i; | ||||
| @@ -281,7 +281,7 @@ public: | |||||
| /* We parse the C string twice because of strlen + memcmp | /* We parse the C string twice because of strlen + memcmp | ||||
| * but it's probably still faster than doing it by hand. */ | * but it's probably still faster than doing it by hand. */ | ||||
| using namespace std; | using namespace std; | ||||
| int sz_len = strlen(sz); | |||||
| int sz_len = (int)strlen(sz); | |||||
| return count() == sz_len | return count() == sz_len | ||||
| && memcmp(C(), sz, sz_len) == 0; | && memcmp(C(), sz, sz_len) == 0; | ||||
| } | } | ||||
| @@ -231,7 +231,7 @@ public: | |||||
| public: | public: | ||||
| void SetLineTime(float new_time = -1.f); | void SetLineTime(float new_time = -1.f); | ||||
| void SetLineMask(int new_mask = 0xFFFFFFFF); | void SetLineMask(int new_mask = 0xFFFFFFFF); | ||||
| void SetLineSegmentSize(float new_segment_size = 100000.f); | |||||
| void SetLineSegmentSize(float new_segment_size = 1.f); | |||||
| void SetLineColor(vec4 new_color = vec4(1.f)); | void SetLineColor(vec4 new_color = vec4(1.f)); | ||||
| float GetLineSegmentSize(); | float GetLineSegmentSize(); | ||||