1 // 2 // Copyright (c) 2008-2017 the Urho3D project. 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a copy 5 // of this software and associated documentation files (the "Software"), to deal 6 // in the Software without restriction, including without limitation the rights 7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 // copies of the Software, and to permit persons to whom the Software is 9 // furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 // THE SOFTWARE. 21 // 22 23 #pragma once 24 25 #include "Sample.h" 26 27 namespace Urho3D 28 { 29 30 class Node; 31 class Scene; 32 33 } 34 35 /// Ragdoll example. 36 /// This sample demonstrates: 37 /// - Detecting physics collisions 38 /// - Moving an AnimatedModel's bones with physics and connecting them with constraints 39 /// - Using rolling friction to stop rolling objects from moving infinitely 40 class Ragdolls : public Sample 41 { 42 URHO3D_OBJECT(Ragdolls, Sample); 43 44 public: 45 /// Construct. 46 Ragdolls(Context* context); 47 48 /// Setup after engine initialization and before running the main loop. 49 virtual void Start(); 50 51 protected: 52 /// Return XML patch instructions for screen joystick layout for a specific sample app, if any. GetScreenJoystickPatchString()53 virtual String GetScreenJoystickPatchString() const { return 54 "<patch>" 55 " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" 56 " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Spawn</replace>" 57 " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" 58 " <element type=\"Text\">" 59 " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" 60 " <attribute name=\"Text\" value=\"LEFT\" />" 61 " </element>" 62 " </add>" 63 " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" 64 " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" 65 " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" 66 " <element type=\"Text\">" 67 " <attribute name=\"Name\" value=\"KeyBinding\" />" 68 " <attribute name=\"Text\" value=\"SPACE\" />" 69 " </element>" 70 " </add>" 71 "</patch>"; 72 } 73 74 private: 75 /// Construct the scene content. 76 void CreateScene(); 77 /// Construct an instruction text to the UI. 78 void CreateInstructions(); 79 /// Set up a viewport for displaying the scene. 80 void SetupViewport(); 81 /// Subscribe to application-wide logic update and post-render update events. 82 void SubscribeToEvents(); 83 /// Read input and moves the camera. 84 void MoveCamera(float timeStep); 85 /// Spawn a physics object from the camera position. 86 void SpawnObject(); 87 /// Handle the logic update event. 88 void HandleUpdate(StringHash eventType, VariantMap& eventData); 89 /// Handle the post-render update event. 90 void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData); 91 92 /// Flag for drawing debug geometry. 93 bool drawDebug_; 94 }; 95