Browse Source

Reorganize includes for Samples and Extras.
Since the URHO3D_PCH build option is made available to support non-PCH build, our build system does not rely on precompiled header to include the Urho3D.h export header anymore. The export header is auto-included by one of Urho3D headers when it is required using the right format with the help of URHO3D_IS_BUILDING compiler define. As such, there is no need to explicitly include Urho3D.h in external project too. Sorry for the flip-flop.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
c2471a240a
58 changed files with 829 additions and 1002 deletions
  1. 0 2
      Docs/Reference.dox
  2. 7 9
      Source/Extras/OgreBatchConverter/OgreBatchConverter.cpp
  3. 0 3
      Source/Samples/01_HelloWorld/HelloWorld.cpp
  4. 2 6
      Source/Samples/02_HelloGUI/HelloGUI.cpp
  5. 2 5
      Source/Samples/03_Sprites/Sprites.cpp
  6. 0 2
      Source/Samples/04_StaticScene/StaticScene.cpp
  7. 18 20
      Source/Samples/05_AnimatingScene/AnimatingScene.cpp
  8. 0 3
      Source/Samples/05_AnimatingScene/Rotator.cpp
  9. 2 5
      Source/Samples/06_SkeletalAnimation/Mover.cpp
  10. 0 3
      Source/Samples/06_SkeletalAnimation/SkeletalAnimation.cpp
  11. 39 41
      Source/Samples/07_Billboards/Billboards.cpp
  12. 0 4
      Source/Samples/08_Decals/Decals.cpp
  13. 26 30
      Source/Samples/09_MultipleViewports/MultipleViewports.cpp
  14. 30 32
      Source/Samples/10_RenderToTexture/RenderToTexture.cpp
  15. 0 2
      Source/Samples/10_RenderToTexture/Rotator.cpp
  16. 30 33
      Source/Samples/11_Physics/Physics.cpp
  17. 28 30
      Source/Samples/12_PhysicsStressTest/PhysicsStressTest.cpp
  18. 6 9
      Source/Samples/13_Ragdolls/CreateRagdoll.cpp
  19. 29 32
      Source/Samples/13_Ragdolls/Ragdolls.cpp
  20. 19 21
      Source/Samples/14_SoundEffects/SoundEffects.cpp
  21. 35 41
      Source/Samples/15_Navigation/Navigation.cpp
  22. 24 26
      Source/Samples/16_Chat/Chat.cpp
  23. 50 54
      Source/Samples/17_SceneReplication/SceneReplication.cpp
  24. 13 15
      Source/Samples/18_CharacterDemo/Character.cpp
  25. 0 4
      Source/Samples/18_CharacterDemo/CharacterDemo.cpp
  26. 0 2
      Source/Samples/18_CharacterDemo/Touch.cpp
  27. 9 11
      Source/Samples/19_VehicleDemo/Vehicle.cpp
  28. 0 2
      Source/Samples/19_VehicleDemo/VehicleDemo.cpp
  29. 19 21
      Source/Samples/20_HugeObjectCount/HugeObjectCount.cpp
  30. 18 20
      Source/Samples/21_AngelScriptIntegration/AngelScriptIntegration.cpp
  31. 14 16
      Source/Samples/22_LuaIntegration/LuaIntegration.cpp
  32. 0 3
      Source/Samples/23_Water/Water.cpp
  33. 0 2
      Source/Samples/24_Urho2DSprite/Urho2DSprite.cpp
  34. 0 3
      Source/Samples/25_Urho2DParticle/Urho2DParticle.cpp
  35. 0 3
      Source/Samples/26_ConsoleInput/ConsoleInput.cpp
  36. 0 2
      Source/Samples/27_Urho2DPhysics/Urho2DPhysics.cpp
  37. 0 2
      Source/Samples/28_Urho2DPhysicsRope/Urho2DPhysicsRope.cpp
  38. 13 15
      Source/Samples/29_SoundSynthesis/SoundSynthesis.cpp
  39. 18 21
      Source/Samples/30_LightAnimation/LightAnimation.cpp
  40. 0 2
      Source/Samples/31_MaterialAnimation/MaterialAnimation.cpp
  41. 2 3
      Source/Samples/32_Urho2DConstraints/Urho2DConstraints.cpp
  42. 1 4
      Source/Samples/33_Urho2DSpriterAnimation/Urho2DSpriterAnimation.cpp
  43. 36 38
      Source/Samples/34_DynamicGeometry/DynamicGeometry.cpp
  44. 1 3
      Source/Samples/35_SignedDistanceFieldText/SignedDistanceFieldText.cpp
  45. 0 2
      Source/Samples/36_Urho2DTileMap/Urho2DTileMap.cpp
  46. 0 2
      Source/Samples/37_UIDrag/UIDrag.cpp
  47. 11 15
      Source/Samples/38_SceneAndUILoad/SceneAndUILoad.cpp
  48. 0 8
      Source/Samples/39_CrowdNavigation/CrowdNavigation.cpp
  49. 6 8
      Source/Samples/40_Localization/L10n.cpp
  50. 0 2
      Source/Samples/41_DatabaseDemo/DatabaseDemo.cpp
  51. 143 152
      Source/Tools/AssetImporter/AssetImporter.cpp
  52. 148 155
      Source/Tools/OgreImporter/OgreImporter.cpp
  53. 1 5
      Source/Tools/PackageTool/PackageTool.cpp
  54. 17 21
      Source/Tools/RampGenerator/RampGenerator.cpp
  55. 3 5
      Source/Tools/ScriptCompiler/ScriptCompiler.cpp
  56. 7 15
      Source/Tools/SpritePacker/SpritePacker.cpp
  57. 2 5
      Source/Tools/Urho3DPlayer/Urho3DPlayer.cpp
  58. 0 2
      Source/Urho3D/Precompiled.h

+ 0 - 2
Docs/Reference.dox

@@ -209,8 +209,6 @@ The Application class provides a minimal framework for a Urho3D C++ application
 will instantiate the Context object and then the user-specified application class. A minimal example, which would just display a blank rendering window and exit by pressing ESC:
 
 \code
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Engine/Application.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Input/InputEvents.h>

+ 7 - 9
Source/Extras/OgreBatchConverter/OgreBatchConverter.cpp

@@ -1,8 +1,6 @@
 // OgreBatchConverter.cpp : Defines the entry point for the console application.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
 #include <Urho3D/IO/FileSystem.h>
 #include <Urho3D/Core/ProcessUtils.h>
@@ -20,10 +18,10 @@ int main(int argc, char** argv)
     const Vector<String>& args = ParseArguments(argc, argv);
     Vector<String> files;
     String currentDir = fileSystem->GetCurrentDir();
-    
+
     // Try to execute OgreImporter from same directory as this executable
     String ogreImporterName = fileSystem->GetProgramDir() + "OgreImporter";
-    
+
     printf("\n\nOgreBatchConverter requires OgreImporter.exe on same directory");
     printf("\nSearching Ogre file in Xml format in %s\n" ,currentDir.CString());
     fileSystem->ScanDir(files, currentDir, "*.xml", SCAN_FILES, true);
@@ -31,27 +29,27 @@ int main(int argc, char** argv)
     #ifdef WIN32
     if (files.Size()) fileSystem->SystemCommand("pause");
     #endif
-    
+
     for (unsigned i = 0 ; i < files.Size(); i++)
     {
         Vector<String> cmdArgs;
         cmdArgs.Push(files[i]);
         cmdArgs.Push(ReplaceExtension(files[i], ".mdl"));
         cmdArgs.Push(args);
-        
+
         String cmdPreview = ogreImporterName;
         for (unsigned j = 0; j < cmdArgs.Size(); j++)
             cmdPreview += " " + cmdArgs[j];
-        
+
         printf("\n%s", cmdPreview.CString());
         fileSystem->SystemRun(ogreImporterName, cmdArgs);
     }
-    
+
     printf("\nExit\n");
     #ifdef WIN32
     fileSystem->SystemCommand("pause");
     #endif
-    
+
     return 0;
 }
 

+ 0 - 3
Source/Samples/01_HelloWorld/HelloWorld.cpp

@@ -20,11 +20,8 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/ProcessUtils.h>
-#include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>

+ 2 - 6
Source/Samples/02_HelloGUI/HelloGUI.cpp

@@ -20,22 +20,18 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Texture2D.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/UI/BorderImage.h>
 #include <Urho3D/UI/Button.h>
 #include <Urho3D/UI/CheckBox.h>
 #include <Urho3D/UI/LineEdit.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/ToolTip.h>
 #include <Urho3D/UI/UI.h>
-#include <Urho3D/UI/UIElement.h>
 #include <Urho3D/UI/UIEvents.h>
 #include <Urho3D/UI/Window.h>
 
@@ -69,7 +65,7 @@ void HelloGUI::Start()
 
     // Initialize Window
     InitWindow();
-    
+
     // Create and add some controls to the Window
     InitControls();
 
@@ -145,7 +141,7 @@ void HelloGUI::InitWindow()
 
     // Subscribe to buttonClose release (following a 'press') events
     SubscribeToEvent(buttonClose, E_RELEASED, HANDLER(HelloGUI, HandleClosePressed));
-    
+
     // Subscribe also to all UI mouse clicks just to see where we have clicked
     SubscribeToEvent(E_UIMOUSECLICK, HANDLER(HelloGUI, HandleControlClicked));
 }

+ 2 - 5
Source/Samples/03_Sprites/Sprites.cpp

@@ -20,13 +20,10 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Texture2D.h>
-#include <Urho3D/Resource/ResourceCache.h>
 #include <Urho3D/UI/Sprite.h>
 #include <Urho3D/UI/UI.h>
 
@@ -118,7 +115,7 @@ void Sprites::MoveSprites(float timeStep)
         // Rotate
         float newRot = sprite->GetRotation() + timeStep * 30.0f;
         sprite->SetRotation(newRot);
-        
+
         // Move, wrap around rendering window edges
         Vector2 newPos = sprite->GetPosition() + sprite->GetVar(VAR_VELOCITY).GetVector2() * timeStep;
         if (newPos.x_ < 0.0f)
@@ -145,7 +142,7 @@ void Sprites::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move sprites, scale movement with time step
     MoveSprites(timeStep);
 }

+ 0 - 2
Source/Samples/04_StaticScene/StaticScene.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>

+ 18 - 20
Source/Samples/05_AnimatingScene/AnimatingScene.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -60,10 +58,10 @@ void AnimatingScene::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -74,13 +72,13 @@ void AnimatingScene::Start()
 void AnimatingScene::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
     // (-1000, -1000, -1000) to (1000, 1000, 1000)
     scene_->CreateComponent<Octree>();
-    
+
     // Create a Zone component into a child scene node. The Zone controls ambient lighting and fog settings. Like the Octree,
     // it also defines its volume with a bounding box, but can be rotated (so it does not need to be aligned to the world X, Y
     // and Z axes.) Drawable objects "pick up" the zone they belong to and use it when rendering; several zones can exist
@@ -92,7 +90,7 @@ void AnimatingScene::CreateScene()
     zone->SetFogColor(Color(0.1f, 0.2f, 0.3f));
     zone->SetFogStart(10.0f);
     zone->SetFogEnd(100.0f);
-    
+
     // Create randomly positioned and oriented box StaticModels in the scene
     const unsigned NUM_OBJECTS = 2000;
     for (unsigned i = 0; i < NUM_OBJECTS; ++i)
@@ -104,7 +102,7 @@ void AnimatingScene::CreateScene()
         StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
         boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-        
+
         // Add our custom Rotator component which will rotate the scene node each frame, when the scene sends its update event.
         // The Rotator component derives from the base class LogicComponent, which has convenience functionality to subscribe
         // to the various update events, and forward them to virtual functions that can be implemented by subclasses. This way
@@ -113,13 +111,13 @@ void AnimatingScene::CreateScene()
         Rotator* rotator = boxNode->CreateComponent<Rotator>();
         rotator->SetRotationSpeed(Vector3(10.0f, 20.0f, 30.0f));
     }
-    
+
     // Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance, we can
     // bring the far clip plane closer for more effective culling of distant objects
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(100.0f);
-    
+
     // Create a point light to the camera scene node
     Light* light = cameraNode_->CreateComponent<Light>();
     light->SetLightType(LIGHT_POINT);
@@ -130,12 +128,12 @@ void AnimatingScene::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText("Use WASD keys and mouse/touch to move");
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -145,7 +143,7 @@ void AnimatingScene::CreateInstructions()
 void AnimatingScene::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -162,23 +160,23 @@ void AnimatingScene::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -196,7 +194,7 @@ void AnimatingScene::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 0 - 3
Source/Samples/05_AnimatingScene/Rotator.cpp

@@ -20,10 +20,7 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/Scene/SceneEvents.h>
 
 #include "Rotator.h"
 

+ 2 - 5
Source/Samples/06_SkeletalAnimation/Mover.cpp

@@ -20,12 +20,9 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Graphics/AnimatedModel.h>
 #include <Urho3D/Graphics/AnimationState.h>
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/Scene/SceneEvents.h>
 
 #include "Mover.h"
 
@@ -50,12 +47,12 @@ void Mover::SetParameters(float moveSpeed, float rotationSpeed, const BoundingBo
 void Mover::Update(float timeStep)
 {
     node_->Translate(Vector3::FORWARD * moveSpeed_ * timeStep);
-    
+
     // If in risk of going outside the plane, rotate the model right
     Vector3 pos = node_->GetPosition();
     if (pos.x_ < bounds_.min_.x_ || pos.x_ > bounds_.max_.x_ || pos.z_ < bounds_.min_.z_ || pos.z_ > bounds_.max_.z_)
         node_->Yaw(rotationSpeed_ * timeStep);
-    
+
     // Get the model's first (only) animation state and advance its time. Note the convenience accessor to other components
     // in the same scene node
     AnimatedModel* model = GetComponent<AnimatedModel>();

+ 0 - 3
Source/Samples/06_SkeletalAnimation/SkeletalAnimation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/AnimatedModel.h>
@@ -32,7 +30,6 @@
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Light.h>
 #include <Urho3D/Graphics/Material.h>
-#include <Urho3D/Graphics/Model.h>
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Graphics/Zone.h>

+ 39 - 41
Source/Samples/07_Billboards/Billboards.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/BillboardSet.h>
@@ -61,10 +59,10 @@ void Billboards::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -75,14 +73,14 @@ void Billboards::Start()
 void Billboards::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Also create a DebugRenderer component so that we can draw debug geometry
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -90,7 +88,7 @@ void Billboards::CreateScene()
     zone->SetAmbientColor(Color(0.1f, 0.1f, 0.1f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light without shadows
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.5f, -1.0f, 0.5f));
@@ -98,7 +96,7 @@ void Billboards::CreateScene()
     light->SetLightType(LIGHT_DIRECTIONAL);
     light->SetColor(Color(0.2f, 0.2f, 0.2f));
     light->SetSpecularIntensity(1.0f);
-    
+
     // Create a "floor" consisting of several tiles
     for (int y = -5; y <= 5; ++y)
     {
@@ -112,17 +110,17 @@ void Billboards::CreateScene()
             floorObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
         }
     }
-    
+
     // Create groups of mushrooms, which act as shadow casters
     const unsigned NUM_MUSHROOMGROUPS = 25;
     const unsigned NUM_MUSHROOMS = 25;
-    
+
     for (unsigned i = 0; i < NUM_MUSHROOMGROUPS; ++i)
     {
         // First create a scene node for the group. The individual mushrooms nodes will be created as children
         Node* groupNode = scene_->CreateChild("MushroomGroup");
         groupNode->SetPosition(Vector3(Random(190.0f) - 95.0f, 0.0f, Random(190.0f) - 95.0f));
-        
+
         for (unsigned j = 0; j < NUM_MUSHROOMS; ++j)
         {
             Node* mushroomNode = groupNode->CreateChild("Mushroom");
@@ -135,7 +133,7 @@ void Billboards::CreateScene()
             mushroomObject->SetCastShadows(true);
         }
     }
-    
+
     // Create billboard sets (floating smoke)
     const unsigned NUM_BILLBOARDNODES = 25;
     const unsigned NUM_BILLBOARDS = 10;
@@ -144,12 +142,12 @@ void Billboards::CreateScene()
     {
         Node* smokeNode = scene_->CreateChild("Smoke");
         smokeNode->SetPosition(Vector3(Random(200.0f) - 100.0f, Random(20.0f) + 10.0f, Random(200.0f) - 100.0f));
-        
+
         BillboardSet* billboardObject = smokeNode->CreateComponent<BillboardSet>();
         billboardObject->SetNumBillboards(NUM_BILLBOARDS);
         billboardObject->SetMaterial(cache->GetResource<Material>("Materials/LitSmoke.xml"));
         billboardObject->SetSorted(true);
-        
+
         for (unsigned j = 0; j < NUM_BILLBOARDS; ++j)
         {
             Billboard* bb = billboardObject->GetBillboard(j);
@@ -158,27 +156,27 @@ void Billboards::CreateScene()
             bb->rotation_ = Random() * 360.0f;
             bb->enabled_ = true;
         }
-        
+
         // After modifying the billboards, they need to be "commited" so that the BillboardSet updates its internals
         billboardObject->Commit();
     }
-    
+
     // Create shadow casting spotlights
     const unsigned NUM_LIGHTS = 9;
-    
+
     for (unsigned i = 0; i < NUM_LIGHTS; ++i)
     {
         Node* lightNode = scene_->CreateChild("SpotLight");
         Light* light = lightNode->CreateComponent<Light>();
-        
+
         float angle = 0.0f;
-        
+
         Vector3 position((i % 3) * 60.0f - 60.0f, 45.0f, (i / 3) * 60.0f - 60.0f);
         Color color(((i + 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 2) & 1) * 0.5f + 0.5f);
-        
+
         lightNode->SetPosition(position);
         lightNode->SetDirection(Vector3(Sin(angle), -1.5f, Cos(angle)));
-        
+
         light->SetLightType(LIGHT_SPOT);
         light->SetRange(90.0f);
         light->SetRampTexture(cache->GetResource<Texture2D>("Textures/RampExtreme.png"));
@@ -187,7 +185,7 @@ void Billboards::CreateScene()
         light->SetSpecularIntensity(1.0f);
         light->SetCastShadows(true);
         light->SetShadowBias(BiasParameters(0.00002f, 0.0f));
-        
+
         // Configure shadow fading for the lights. When they are far away enough, the lights eventually become unshadowed for
         // better GPU performance. Note that we could also set the maximum distance for each object to cast shadows
         light->SetShadowFadeDistance(100.0f); // Fade start distance
@@ -198,12 +196,12 @@ void Billboards::CreateScene()
         // for better shadow depth resolution
         light->SetShadowNearFarRatio(0.01f);
     }
-    
+
     // Create the camera. Limit far clip distance to match the fog
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Set an initial position for the camera scene node above the plane
     cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
 }
@@ -212,7 +210,7 @@ void Billboards::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -222,7 +220,7 @@ void Billboards::CreateInstructions()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -232,7 +230,7 @@ void Billboards::CreateInstructions()
 void Billboards::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -242,7 +240,7 @@ void Billboards::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Billboards, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Billboards, HandlePostRenderUpdate));
@@ -253,23 +251,23 @@ void Billboards::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -279,7 +277,7 @@ void Billboards::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // Toggle debug geometry with space
     if (input->GetKeyPress(KEY_SPACE))
         drawDebug_ = !drawDebug_;
@@ -292,25 +290,25 @@ void Billboards::AnimateScene(float timeStep)
     PODVector<Node*> billboardNodes;
     scene_->GetChildrenWithComponent<Light>(lightNodes);
     scene_->GetChildrenWithComponent<BillboardSet>(billboardNodes);
-    
+
     const float LIGHT_ROTATION_SPEED = 20.0f;
     const float BILLBOARD_ROTATION_SPEED = 50.0f;
-    
+
     // Rotate the lights around the world Y-axis
     for (unsigned i = 0; i < lightNodes.Size(); ++i)
         lightNodes[i]->Rotate(Quaternion(0.0f, LIGHT_ROTATION_SPEED * timeStep, 0.0f), TS_WORLD);
-    
+
     // Rotate the individual billboards within the billboard sets, then recommit to make the changes visible
     for (unsigned i = 0; i < billboardNodes.Size(); ++i)
     {
         BillboardSet* billboardObject = billboardNodes[i]->GetComponent<BillboardSet>();
-        
+
         for (unsigned j = 0; j < billboardObject->GetNumBillboards(); ++j)
         {
             Billboard* bb = billboardObject->GetBillboard(j);
             bb->rotation_ += BILLBOARD_ROTATION_SPEED * timeStep;
         }
-        
+
         billboardObject->Commit();
     }
 }
@@ -321,7 +319,7 @@ void Billboards::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera and animate the scene, scale movement with time step
     MoveCamera(timeStep);
     AnimateScene(timeStep);

+ 0 - 4
Source/Samples/08_Decals/Decals.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -37,9 +35,7 @@
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/UI.h>

+ 26 - 30
Source/Samples/09_MultipleViewports/MultipleViewports.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -37,9 +35,7 @@
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/UI.h>
@@ -63,10 +59,10 @@ void MultipleViewports::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewports for displaying the scene
     SetupViewports();
 
@@ -77,21 +73,21 @@ void MultipleViewports::Start()
 void MultipleViewports::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Also create a DebugRenderer component so that we can draw debug geometry
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create scene node & StaticModel component for showing a static plane
     Node* planeNode = scene_->CreateChild("Plane");
     planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
     StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
     planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
     planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -100,7 +96,7 @@ void MultipleViewports::CreateScene()
     zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light to the world. Enable cascaded shadows on it
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
@@ -124,7 +120,7 @@ void MultipleViewports::CreateScene()
         mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
         mushroomObject->SetCastShadows(true);
     }
-    
+
     // Create randomly sized boxes. If boxes are big enough, make them occluders
     const unsigned NUM_BOXES = 20;
     for (unsigned i = 0; i < NUM_BOXES; ++i)
@@ -140,12 +136,12 @@ void MultipleViewports::CreateScene()
         if (size >= 3.0f)
             boxObject->SetOccluder(true);
     }
-    
+
     // Create the cameras. Limit far clip distance to match the fog
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Parent the rear camera node to the front camera node and turn it 180 degrees to face backward
     // Here, we use the angle-axis constructor for Quaternion instead of the usual Euler angles
     rearCameraNode_ = cameraNode_->CreateChild("RearCamera");
@@ -156,7 +152,7 @@ void MultipleViewports::CreateScene()
     // "view override flags" for this. We could also disable eg. shadows or force low material quality
     // if we wanted
     rearCamera->SetViewOverrideFlags(VO_DISABLE_OCCLUSION);
-    
+
     // Set an initial position for the front camera scene node above the plane
     cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
 }
@@ -165,7 +161,7 @@ void MultipleViewports::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -176,7 +172,7 @@ void MultipleViewports::CreateInstructions()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -187,13 +183,13 @@ void MultipleViewports::SetupViewports()
 {
     Graphics* graphics = GetSubsystem<Graphics>();
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     renderer->SetNumViewports(2);
-    
+
     // Set up the front camera viewport
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
-    
+
     // Clone the default render path so that we do not interfere with the other viewport, then add
     // bloom and FXAA post process effects to the front viewport. Render path commands can be tagged
     // for example with the effect name to allow easy toggling on and off. We start with the effects
@@ -207,7 +203,7 @@ void MultipleViewports::SetupViewports()
     effectRenderPath->SetEnabled("Bloom", false);
     effectRenderPath->SetEnabled("FXAA2", false);
     viewport->SetRenderPath(effectRenderPath);
-    
+
     // Set up the rear camera viewport on top of the front view ("rear view mirror")
     // The viewport index must be greater in that case, otherwise the view would be left behind
     SharedPtr<Viewport> rearViewport(new Viewport(context_, scene_, rearCameraNode_->GetComponent<Camera>(),
@@ -219,7 +215,7 @@ void MultipleViewports::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() method for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(MultipleViewports, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() method for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(MultipleViewports, HandlePostRenderUpdate));
@@ -230,23 +226,23 @@ void MultipleViewports::MoveCamera(float timeStep)
      // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -256,14 +252,14 @@ void MultipleViewports::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // Toggle post processing effects on the front viewport. Note that the rear viewport is unaffected
     RenderPath* effectRenderPath = GetSubsystem<Renderer>()->GetViewport(0)->GetRenderPath();
     if (input->GetKeyPress('B'))
         effectRenderPath->ToggleEnabled("Bloom");
     if (input->GetKeyPress('F'))
         effectRenderPath->ToggleEnabled("FXAA2");
-    
+
     // Toggle debug geometry with space
     if (input->GetKeyPress(KEY_SPACE))
         drawDebug_ = !drawDebug_;
@@ -275,7 +271,7 @@ void MultipleViewports::HandleUpdate(StringHash eventType, VariantMap& eventData
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 30 - 32
Source/Samples/10_RenderToTexture/RenderToTexture.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -63,10 +61,10 @@ void RenderToTexture::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -77,14 +75,14 @@ void RenderToTexture::Start()
 void RenderToTexture::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     {
         // Create the scene which will be rendered to a texture
         rttScene_ = new Scene(context_);
-        
+
         // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
         rttScene_->CreateComponent<Octree>();
-        
+
         // Create a Zone for ambient light & fog control
         Node* zoneNode = rttScene_->CreateChild("Zone");
         Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -94,7 +92,7 @@ void RenderToTexture::CreateScene()
         zone->SetFogColor(Color(0.1f, 0.2f, 0.3f));
         zone->SetFogStart(10.0f);
         zone->SetFogEnd(100.0f);
-        
+
         // Create randomly positioned and oriented box StaticModels in the scene
         const unsigned NUM_OBJECTS = 2000;
         for (unsigned i = 0; i < NUM_OBJECTS; ++i)
@@ -106,31 +104,31 @@ void RenderToTexture::CreateScene()
             StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
             boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
             boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-            
+
             // Add our custom Rotator component which will rotate the scene node each frame, when the scene sends its update event.
             // Simply set same rotation speed for all objects
             Rotator* rotator = boxNode->CreateComponent<Rotator>();
             rotator->SetRotationSpeed(Vector3(10.0f, 20.0f, 30.0f));
         }
-        
+
         // Create a camera for the render-to-texture scene. Simply leave it at the world origin and let it observe the scene
         rttCameraNode_ = rttScene_->CreateChild("Camera");
         Camera* camera = rttCameraNode_->CreateComponent<Camera>();
         camera->SetFarClip(100.0f);
-        
+
         // Create a point light to the camera scene node
         Light* light = rttCameraNode_->CreateComponent<Light>();
         light->SetLightType(LIGHT_POINT);
         light->SetRange(30.0f);
     }
-    
+
     {
         // Create the scene in which we move around
         scene_ = new Scene(context_);
-        
+
         // Create octree, use also default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
         scene_->CreateComponent<Octree>();
-        
+
         // Create a Zone component for ambient lighting & fog control
         Node* zoneNode = scene_->CreateChild("Zone");
         Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -138,7 +136,7 @@ void RenderToTexture::CreateScene()
         zone->SetAmbientColor(Color(0.1f, 0.1f, 0.1f));
         zone->SetFogStart(100.0f);
         zone->SetFogEnd(300.0f);
-        
+
         // Create a directional light without shadows
         Node* lightNode = scene_->CreateChild("DirectionalLight");
         lightNode->SetDirection(Vector3(0.5f, -1.0f, 0.5f));
@@ -146,7 +144,7 @@ void RenderToTexture::CreateScene()
         light->SetLightType(LIGHT_DIRECTIONAL);
         light->SetColor(Color(0.2f, 0.2f, 0.2f));
         light->SetSpecularIntensity(1.0f);
-        
+
         // Create a "floor" consisting of several tiles
         for (int y = -5; y <= 5; ++y)
         {
@@ -160,7 +158,7 @@ void RenderToTexture::CreateScene()
                 floorObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
             }
         }
-        
+
         // Create a "screen" like object for viewing the second scene. Construct it from two StaticModels, a box for the frame
         // and a plane for the actual view
         {
@@ -170,26 +168,26 @@ void RenderToTexture::CreateScene()
             StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
             boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
             boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-            
+
             Node* screenNode = scene_->CreateChild("Screen");
             screenNode->SetPosition(Vector3(0.0f, 10.0f, -0.27f));
             screenNode->SetRotation(Quaternion(-90.0f, 0.0f, 0.0f));
             screenNode->SetScale(Vector3(20.0f, 0.0f, 15.0f));
             StaticModel* screenObject = screenNode->CreateComponent<StaticModel>();
             screenObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
-            
+
             // Create a renderable texture (1024x768, RGB format), enable bilinear filtering on it
             SharedPtr<Texture2D> renderTexture(new Texture2D(context_));
             renderTexture->SetSize(1024, 768, Graphics::GetRGBFormat(), TEXTURE_RENDERTARGET);
             renderTexture->SetFilterMode(FILTER_BILINEAR);
-            
+
             // Create a new material from scratch, use the diffuse unlit technique, assign the render texture
             // as its diffuse texture, then assign the material to the screen plane object
             SharedPtr<Material> renderMaterial(new Material(context_));
             renderMaterial->SetTechnique(0, cache->GetResource<Technique>("Techniques/DiffUnlit.xml"));
             renderMaterial->SetTexture(TU_DIFFUSE, renderTexture);
             screenObject->SetMaterial(renderMaterial);
-            
+
             // Get the texture's RenderSurface object (exists when the texture has been created in rendertarget mode)
             // and define the viewport for rendering the second scene, similarly as how backbuffer viewports are defined
             // to the Renderer subsystem. By default the texture viewport will be updated when the texture is visible
@@ -198,12 +196,12 @@ void RenderToTexture::CreateScene()
             SharedPtr<Viewport> rttViewport(new Viewport(context_, rttScene_, rttCameraNode_->GetComponent<Camera>()));
             surface->SetViewport(0, rttViewport);
         }
-        
+
         // Create the camera which we will move around. Limit far clip distance to match the fog
         cameraNode_ = scene_->CreateChild("Camera");
         Camera* camera = cameraNode_->CreateComponent<Camera>();
         camera->SetFarClip(300.0f);
-        
+
         // Set an initial position for the camera scene node above the plane
         cameraNode_->SetPosition(Vector3(0.0f, 7.0f, -30.0f));
     }
@@ -213,12 +211,12 @@ void RenderToTexture::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText("Use WASD keys and mouse/touch to move");
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -228,7 +226,7 @@ void RenderToTexture::CreateInstructions()
 void RenderToTexture::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -239,23 +237,23 @@ void RenderToTexture::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -279,7 +277,7 @@ void RenderToTexture::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 0 - 2
Source/Samples/10_RenderToTexture/Rotator.cpp

@@ -20,10 +20,8 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
 
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/Scene/SceneEvents.h>
 
 #include "Rotator.h"
 

+ 30 - 33
Source/Samples/11_Physics/Physics.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -33,7 +31,6 @@
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Graphics/Skybox.h>
-#include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/IO/File.h>
@@ -66,10 +63,10 @@ void Physics::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -80,9 +77,9 @@ void Physics::Start()
 void Physics::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Create a physics simulation world with default parameters, which will update at 60fps. Like the Octree must
     // exist before creating drawable components, the PhysicsWorld must exist before creating physics components.
@@ -90,7 +87,7 @@ void Physics::CreateScene()
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<PhysicsWorld>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -99,7 +96,7 @@ void Physics::CreateScene()
     zone->SetFogColor(Color(1.0f, 1.0f, 1.0f));
     zone->SetFogStart(300.0f);
     zone->SetFogEnd(500.0f);
-    
+
     // Create a directional light to the world. Enable cascaded shadows on it
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
@@ -109,7 +106,7 @@ void Physics::CreateScene()
     light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
     // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
     light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
-    
+
     // Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
     // illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
     // generate the necessary 3D texture coordinates for cube mapping
@@ -118,7 +115,7 @@ void Physics::CreateScene()
     Skybox* skybox = skyNode->CreateComponent<Skybox>();
     skybox->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
     skybox->SetMaterial(cache->GetResource<Material>("Materials/Skybox.xml"));
-    
+
     {
         // Create a floor object, 1000 x 1000 world units. Adjust position so that the ground is at zero Y
         Node* floorNode = scene_->CreateChild("Floor");
@@ -127,7 +124,7 @@ void Physics::CreateScene()
         StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
         floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         floorObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-        
+
         // Make the floor physical by adding RigidBody and CollisionShape components. The RigidBody's default
         // parameters make the object static (zero mass.) Note that a CollisionShape by itself will not participate
         // in the physics simulation
@@ -137,7 +134,7 @@ void Physics::CreateScene()
         // rendering and physics representation sizes should match (the box model is also 1 x 1 x 1.)
         shape->SetBox(Vector3::ONE);
     }
-    
+
     {
         // Create a pyramid of movable physics objects
         for (int y = 0; y < 8; ++y)
@@ -150,9 +147,9 @@ void Physics::CreateScene()
                 boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
                 boxObject->SetMaterial(cache->GetResource<Material>("Materials/StoneEnvMapSmall.xml"));
                 boxObject->SetCastShadows(true);
-                
+
                 // Create RigidBody and CollisionShape components like above. Give the RigidBody mass to make it movable
-                // and also adjust friction. The actual mass is not important; only the mass ratios between colliding 
+                // and also adjust friction. The actual mass is not important; only the mass ratios between colliding
                 // objects are significant
                 RigidBody* body = boxNode->CreateComponent<RigidBody>();
                 body->SetMass(1.0f);
@@ -162,13 +159,13 @@ void Physics::CreateScene()
             }
         }
     }
-    
+
     // Create the camera. Set far clip to match the fog. Note: now we actually create the camera node outside the scene, because
     // we want it to be unaffected by scene load / save
     cameraNode_ = new Node(context_);
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(500.0f);
-    
+
     // Set an initial position for the camera scene node above the floor
     cameraNode_->SetPosition(Vector3(0.0f, 5.0f, -20.0f));
 }
@@ -177,7 +174,7 @@ void Physics::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -189,7 +186,7 @@ void Physics::CreateInstructions()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -199,7 +196,7 @@ void Physics::CreateInstructions()
 void Physics::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -209,7 +206,7 @@ void Physics::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Physics, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Physics, HandlePostRenderUpdate));
@@ -220,23 +217,23 @@ void Physics::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -246,11 +243,11 @@ void Physics::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // "Shoot" a physics object with left mousebutton
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
         SpawnObject();
-    
+
     // Check for loading/saving the scene. Save the scene to the file Data/Scenes/Physics.xml relative to the executable
     // directory
     if (input->GetKeyPress(KEY_F5))
@@ -272,7 +269,7 @@ void Physics::MoveCamera(float timeStep)
 void Physics::SpawnObject()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     // Create a smaller box at camera position
     Node* boxNode = scene_->CreateChild("SmallBox");
     boxNode->SetPosition(cameraNode_->GetPosition());
@@ -282,16 +279,16 @@ void Physics::SpawnObject()
     boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
     boxObject->SetMaterial(cache->GetResource<Material>("Materials/StoneEnvMapSmall.xml"));
     boxObject->SetCastShadows(true);
-    
+
     // Create physics components, use a smaller mass also
     RigidBody* body = boxNode->CreateComponent<RigidBody>();
     body->SetMass(0.25f);
     body->SetFriction(0.75f);
     CollisionShape* shape = boxNode->CreateComponent<CollisionShape>();
     shape->SetBox(Vector3::ONE);
-    
+
     const float OBJECT_VELOCITY = 10.0f;
-    
+
     // Set initial velocity for the RigidBody based on camera forward vector. Add also a slight up component
     // to overcome gravity better
     body->SetLinearVelocity(cameraNode_->GetRotation() * Vector3(0.0f, 0.25f, 1.0f) * OBJECT_VELOCITY);
@@ -303,7 +300,7 @@ void Physics::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 28 - 30
Source/Samples/12_PhysicsStressTest/PhysicsStressTest.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -65,10 +63,10 @@ void PhysicsStressTest::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -79,9 +77,9 @@ void PhysicsStressTest::Start()
 void PhysicsStressTest::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Create a physics simulation world with default parameters, which will update at 60fps. Like the Octree must
     // exist before creating drawable components, the PhysicsWorld must exist before creating physics components.
@@ -89,7 +87,7 @@ void PhysicsStressTest::CreateScene()
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<PhysicsWorld>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -98,7 +96,7 @@ void PhysicsStressTest::CreateScene()
     zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light to the world. Enable cascaded shadows on it
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
@@ -108,7 +106,7 @@ void PhysicsStressTest::CreateScene()
     light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
     // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
     light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
-    
+
     {
         // Create a floor object, 500 x 500 world units. Adjust position so that the ground is at zero Y
         Node* floorNode = scene_->CreateChild("Floor");
@@ -117,13 +115,13 @@ void PhysicsStressTest::CreateScene()
         StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
         floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         floorObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-        
+
         // Make the floor physical by adding RigidBody and CollisionShape components
         /*RigidBody* body = */floorNode->CreateComponent<RigidBody>();
         CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
         shape->SetBox(Vector3::ONE);
     }
-    
+
     {
         // Create static mushrooms with triangle mesh collision
         const unsigned NUM_MUSHROOMS = 50;
@@ -144,7 +142,7 @@ void PhysicsStressTest::CreateScene()
             shape->SetTriangleMesh(mushroomObject->GetModel());
         }
     }
-    
+
     {
         // Create a large amount of falling physics objects
         const unsigned NUM_OBJECTS = 1000;
@@ -156,7 +154,7 @@ void PhysicsStressTest::CreateScene()
             boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
             boxObject->SetMaterial(cache->GetResource<Material>("Materials/StoneSmall.xml"));
             boxObject->SetCastShadows(true);
-            
+
             // Give the RigidBody mass to make it movable and also adjust friction
             RigidBody* body = boxNode->CreateComponent<RigidBody>();
             body->SetMass(1.0f);
@@ -167,13 +165,13 @@ void PhysicsStressTest::CreateScene()
             shape->SetBox(Vector3::ONE);
         }
     }
-    
+
     // Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
     // the scene, because we want it to be unaffected by scene load / save
     cameraNode_ = new Node(context_);
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Set an initial position for the camera scene node above the floor
     cameraNode_->SetPosition(Vector3(0.0f, 3.0f, -20.0f));
 }
@@ -182,7 +180,7 @@ void PhysicsStressTest::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -194,7 +192,7 @@ void PhysicsStressTest::CreateInstructions()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -204,7 +202,7 @@ void PhysicsStressTest::CreateInstructions()
 void PhysicsStressTest::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -214,7 +212,7 @@ void PhysicsStressTest::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(PhysicsStressTest, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(PhysicsStressTest, HandlePostRenderUpdate));
@@ -225,23 +223,23 @@ void PhysicsStressTest::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -251,7 +249,7 @@ void PhysicsStressTest::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // "Shoot" a physics object with left mousebutton
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
         SpawnObject();
@@ -276,7 +274,7 @@ void PhysicsStressTest::MoveCamera(float timeStep)
 void PhysicsStressTest::SpawnObject()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     // Create a smaller box at camera position
     Node* boxNode = scene_->CreateChild("SmallBox");
     boxNode->SetPosition(cameraNode_->GetPosition());
@@ -286,16 +284,16 @@ void PhysicsStressTest::SpawnObject()
     boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
     boxObject->SetMaterial(cache->GetResource<Material>("Materials/StoneSmall.xml"));
     boxObject->SetCastShadows(true);
-    
+
     // Create physics components, use a smaller mass also
     RigidBody* body = boxNode->CreateComponent<RigidBody>();
     body->SetMass(0.25f);
     body->SetFriction(0.75f);
     CollisionShape* shape = boxNode->CreateComponent<CollisionShape>();
     shape->SetBox(Vector3::ONE);
-    
+
     const float OBJECT_VELOCITY = 10.0f;
-    
+
     // Set initial velocity for the RigidBody based on camera forward vector. Add also a slight up component
     // to overcome gravity better
     body->SetLinearVelocity(cameraNode_->GetRotation() * Vector3(0.0f, 0.25f, 1.0f) * OBJECT_VELOCITY);
@@ -307,7 +305,7 @@ void PhysicsStressTest::HandleUpdate(StringHash eventType, VariantMap& eventData
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 6 - 9
Source/Samples/13_Ragdolls/CreateRagdoll.cpp

@@ -20,13 +20,10 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Graphics/AnimatedModel.h>
 #include <Urho3D/IO/Log.h>
 #include <Urho3D/Physics/PhysicsEvents.h>
 #include <Urho3D/Physics/RigidBody.h>
-#include <Urho3D/Scene/Node.h>
 
 #include "CreateRagdoll.h"
 
@@ -57,7 +54,7 @@ void CreateRagdoll::HandleNodeCollision(StringHash eventType, VariantMap& eventD
         // We do not need the physics components in the AnimatedModel's root scene node anymore
         node_->RemoveComponent<RigidBody>();
         node_->RemoveComponent<CollisionShape>();
-        
+
         // Create RigidBody & CollisionShape components to bones
         CreateRagdollBone("Bip01_Pelvis", SHAPE_BOX, Vector3(0.3f, 0.2f, 0.25f), Vector3(0.0f, 0.0f, 0.0f),
             Quaternion(0.0f, 0.0f, 0.0f));
@@ -81,7 +78,7 @@ void CreateRagdoll::HandleNodeCollision(StringHash eventType, VariantMap& eventD
             Quaternion(0.0f, 0.0f, 90.0f));
         CreateRagdollBone("Bip01_R_Forearm", SHAPE_CAPSULE, Vector3(0.125f, 0.4f, 0.125f), Vector3(0.2f, 0.0f, 0.0f),
             Quaternion(0.0f, 0.0f, 90.0f));
-        
+
         // Create Constraints between bones
         CreateRagdollConstraint("Bip01_L_Thigh", "Bip01_Pelvis", CONSTRAINT_CONETWIST, Vector3::BACK, Vector3::FORWARD,
             Vector2(45.0f, 45.0f), Vector2::ZERO);
@@ -103,13 +100,13 @@ void CreateRagdoll::HandleNodeCollision(StringHash eventType, VariantMap& eventD
             Vector2(90.0f, 0.0f), Vector2::ZERO);
         CreateRagdollConstraint("Bip01_R_Forearm", "Bip01_R_UpperArm", CONSTRAINT_HINGE, Vector3::BACK, Vector3::BACK,
             Vector2(90.0f, 0.0f), Vector2::ZERO);
-        
+
         // Disable keyframe animation from all bones so that they will not interfere with the ragdoll
         AnimatedModel* model = GetComponent<AnimatedModel>();
         Skeleton& skeleton = model->GetSkeleton();
         for (unsigned i = 0; i < skeleton.GetNumBones(); ++i)
             skeleton.GetBone(i)->animated_ = false;
-        
+
         // Finally remove self from the scene node. Note that this must be the last operation performed in the function
         Remove();
     }
@@ -125,7 +122,7 @@ void CreateRagdoll::CreateRagdollBone(const String& boneName, ShapeType type, co
         LOGWARNING("Could not find bone " + boneName + " for creating ragdoll physics components");
         return;
     }
-    
+
     RigidBody* body = boneNode->CreateComponent<RigidBody>();
     // Set mass to make movable
     body->SetMass(1.0f);
@@ -160,7 +157,7 @@ void CreateRagdoll::CreateRagdollConstraint(const String& boneName, const String
         LOGWARNING("Could not find bone " + parentName + " for creating ragdoll constraint");
         return;
     }
-    
+
     Constraint* constraint = boneNode->CreateComponent<Constraint>();
     constraint->SetConstraintType(type);
     // Most of the constraints in the ragdoll will work better when the connected bodies don't collide against each other

+ 29 - 32
Source/Samples/13_Ragdolls/Ragdolls.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/AnimatedModel.h>
@@ -30,7 +28,6 @@
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Light.h>
 #include <Urho3D/Graphics/Material.h>
-#include <Urho3D/Graphics/Model.h>
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Graphics/Zone.h>
@@ -68,10 +65,10 @@ void Ragdolls::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -82,9 +79,9 @@ void Ragdolls::Start()
 void Ragdolls::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Create a physics simulation world with default parameters, which will update at 60fps. Like the Octree must
     // exist before creating drawable components, the PhysicsWorld must exist before creating physics components.
@@ -92,7 +89,7 @@ void Ragdolls::CreateScene()
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<PhysicsWorld>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -101,7 +98,7 @@ void Ragdolls::CreateScene()
     zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light to the world. Enable cascaded shadows on it
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
@@ -111,7 +108,7 @@ void Ragdolls::CreateScene()
     light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
     // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
     light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
-    
+
     {
         // Create a floor object, 500 x 500 world units. Adjust position so that the ground is at zero Y
         Node* floorNode = scene_->CreateChild("Floor");
@@ -120,7 +117,7 @@ void Ragdolls::CreateScene()
         StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
         floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         floorObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-        
+
         // Make the floor physical by adding RigidBody and CollisionShape components
         RigidBody* body = floorNode->CreateComponent<RigidBody>();
         // We will be spawning spherical objects in this sample. The ground also needs non-zero rolling friction so that
@@ -131,7 +128,7 @@ void Ragdolls::CreateScene()
         // rendering and physics representation sizes should match (the box model is also 1 x 1 x 1.)
         shape->SetBox(Vector3::ONE);
     }
-    
+
     // Create animated models
     for (int z = -1; z <= 1; ++z)
     {
@@ -147,7 +144,7 @@ void Ragdolls::CreateScene()
             // Set the model to also update when invisible to avoid staying invisible when the model should come into
             // view, but does not as the bounding box is not updated
             modelObject->SetUpdateInvisible(true);
-            
+
             // Create a rigid body and a collision shape. These will act as a trigger for transforming the
             // model into a ragdoll when hit by a moving object
             RigidBody* body = modelNode->CreateComponent<RigidBody>();
@@ -158,18 +155,18 @@ void Ragdolls::CreateScene()
             // Create the capsule shape with an offset so that it is correctly aligned with the model, which
             // has its origin at the feet
             shape->SetCapsule(0.7f, 2.0f, Vector3(0.0f, 1.0f, 0.0f));
-            
+
             // Create a custom component that reacts to collisions and creates the ragdoll
             modelNode->CreateComponent<CreateRagdoll>();
         }
     }
-    
+
     // Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
     // the scene, because we want it to be unaffected by scene load / save
     cameraNode_ = new Node(context_);
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Set an initial position for the camera scene node above the floor
     cameraNode_->SetPosition(Vector3(0.0f, 3.0f, -20.0f));
 }
@@ -178,7 +175,7 @@ void Ragdolls::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -190,7 +187,7 @@ void Ragdolls::CreateInstructions()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -200,7 +197,7 @@ void Ragdolls::CreateInstructions()
 void Ragdolls::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -211,23 +208,23 @@ void Ragdolls::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -237,11 +234,11 @@ void Ragdolls::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // "Shoot" a physics object with left mousebutton
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
         SpawnObject();
-    
+
     // Check for loading / saving the scene
     if (input->GetKeyPress(KEY_F5))
     {
@@ -262,7 +259,7 @@ void Ragdolls::MoveCamera(float timeStep)
 void Ragdolls::SpawnObject()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     Node* boxNode = scene_->CreateChild("Sphere");
     boxNode->SetPosition(cameraNode_->GetPosition());
     boxNode->SetRotation(cameraNode_->GetRotation());
@@ -271,15 +268,15 @@ void Ragdolls::SpawnObject()
     boxObject->SetModel(cache->GetResource<Model>("Models/Sphere.mdl"));
     boxObject->SetMaterial(cache->GetResource<Material>("Materials/StoneSmall.xml"));
     boxObject->SetCastShadows(true);
-    
+
     RigidBody* body = boxNode->CreateComponent<RigidBody>();
     body->SetMass(1.0f);
     body->SetRollingFriction(0.15f);
     CollisionShape* shape = boxNode->CreateComponent<CollisionShape>();
     shape->SetSphere(1.0f);
-    
+
     const float OBJECT_VELOCITY = 10.0f;
-    
+
     // Set initial velocity for the RigidBody based on camera forward vector. Add also a slight up component
     // to overcome gravity better
     body->SetLinearVelocity(cameraNode_->GetRotation() * Vector3(0.0f, 0.25f, 1.0f) * OBJECT_VELOCITY);
@@ -289,7 +286,7 @@ void Ragdolls::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Ragdolls, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Ragdolls, HandlePostRenderUpdate));
@@ -301,7 +298,7 @@ void Ragdolls::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 19 - 21
Source/Samples/14_SoundEffects/SoundEffects.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Audio/Audio.h>
 #include <Urho3D/Audio/Sound.h>
 #include <Urho3D/Audio/SoundSource.h>
@@ -80,13 +78,13 @@ void SoundEffects::CreateUI()
 {
     // Create a scene which will not be actually rendered, but is used to hold SoundSource components while they play sounds
     scene_ = new Scene(context_);
-    
+
     UIElement* root = GetSubsystem<UI>()->GetRoot();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     XMLFile* uiStyle = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
     // Set style to the UI root so that elements will inherit it
     root->SetDefaultStyle(uiStyle);
-    
+
     // Create buttons for playing back sounds
     for (unsigned i = 0; i < NUM_SOUNDS; ++i)
     {
@@ -95,21 +93,21 @@ void SoundEffects::CreateUI()
         button->SetVar(VAR_SOUNDRESOURCE, soundResourceNames[i]);
         SubscribeToEvent(button, E_PRESSED, HANDLER(SoundEffects, HandlePlaySound));
     }
-    
+
     // Create buttons for playing/stopping music
     Button* button = CreateButton(20, 80, 120, 40, "Play Music");
     SubscribeToEvent(button, E_RELEASED, HANDLER(SoundEffects, HandlePlayMusic));
-    
+
     button = CreateButton(160, 80, 120, 40, "Stop Music");
     SubscribeToEvent(button, E_RELEASED, HANDLER(SoundEffects, HandleStopMusic));
-    
+
     Audio* audio = GetSubsystem<Audio>();
-    
+
     // Create sliders for controlling sound and music master volume
     Slider* slider = CreateSlider(20, 140, 200, 20, "Sound Volume");
     slider->SetValue(audio->GetMasterGain(SOUND_EFFECT));
     SubscribeToEvent(slider, E_SLIDERCHANGED, HANDLER(SoundEffects, HandleSoundVolume));
-    
+
     slider = CreateSlider(20, 200, 200, 20, "Music Volume");
     slider->SetValue(audio->GetMasterGain(SOUND_MUSIC));
     SubscribeToEvent(slider, E_SLIDERCHANGED, HANDLER(SoundEffects, HandleMusicVolume));
@@ -120,18 +118,18 @@ Button* SoundEffects::CreateButton(int x, int y, int xSize, int ySize, const Str
     UIElement* root = GetSubsystem<UI>()->GetRoot();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
-    
+
     // Create the button and center the text onto it
     Button* button = root->CreateChild<Button>();
     button->SetStyleAuto();
     button->SetPosition(x, y);
     button->SetSize(xSize, ySize);
-    
+
     Text* buttonText = button->CreateChild<Text>();
     buttonText->SetAlignment(HA_CENTER, VA_CENTER);
     buttonText->SetFont(font, 12);
     buttonText->SetText(text);
-    
+
     return button;
 }
 
@@ -140,20 +138,20 @@ Slider* SoundEffects::CreateSlider(int x, int y, int xSize, int ySize, const Str
     UIElement* root = GetSubsystem<UI>()->GetRoot();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
-    
+
     // Create text and slider below it
     Text* sliderText = root->CreateChild<Text>();
     sliderText->SetPosition(x, y);
     sliderText->SetFont(font, 12);
     sliderText->SetText(text);
-    
+
     Slider* slider = root->CreateChild<Slider>();
     slider->SetStyleAuto();
     slider->SetPosition(x, y + 20);
     slider->SetSize(xSize, ySize);
     // Use 0-1 range for controlling sound/music master volume
     slider->SetRange(1.0f);
-    
+
     return slider;
 }
 
@@ -161,11 +159,11 @@ void SoundEffects::HandlePlaySound(StringHash eventType, VariantMap& eventData)
 {
     Button* button = static_cast<Button*>(GetEventSender());
     const String& soundResourceName = button->GetVar(VAR_SOUNDRESOURCE).GetString();
-    
+
     // Get the sound resource
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Sound* sound = cache->GetResource<Sound>(soundResourceName);
-    
+
     if (sound)
     {
         // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays
@@ -186,12 +184,12 @@ void SoundEffects::HandlePlayMusic(StringHash eventType, VariantMap& eventData)
     // Check if the music player node/component already exist
     if (scene_->GetChild("Music"))
         return;
-    
+
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Sound* music = cache->GetResource<Sound>("Music/Ninja Gods.ogg");
     // Set the song to loop
     music->SetLooped(true);
-    
+
     // Create a scene node and a sound source for the music
     Node* musicNode = scene_->CreateChild("Music");
     SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
@@ -209,7 +207,7 @@ void SoundEffects::HandleStopMusic(StringHash eventType, VariantMap& eventData)
 void SoundEffects::HandleSoundVolume(StringHash eventType, VariantMap& eventData)
 {
     using namespace SliderChanged;
-    
+
     float newVolume = eventData[P_VALUE].GetFloat();
     GetSubsystem<Audio>()->SetMasterGain(SOUND_EFFECT, newVolume);
 }
@@ -217,7 +215,7 @@ void SoundEffects::HandleSoundVolume(StringHash eventType, VariantMap& eventData
 void SoundEffects::HandleMusicVolume(StringHash eventType, VariantMap& eventData)
 {
     using namespace SliderChanged;
-    
+
     float newVolume = eventData[P_VALUE].GetFloat();
     GetSubsystem<Audio>()->SetMasterGain(SOUND_MUSIC, newVolume);
 }

+ 35 - 41
Source/Samples/15_Navigation/Navigation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/AnimatedModel.h>
@@ -30,18 +28,14 @@
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Light.h>
 #include <Urho3D/Graphics/Material.h>
-#include <Urho3D/Graphics/Model.h>
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
-#include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Navigation/Navigable.h>
 #include <Urho3D/Navigation/NavigationMesh.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/UI.h>
@@ -65,10 +59,10 @@ void Navigation::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateUI();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -79,21 +73,21 @@ void Navigation::Start()
 void Navigation::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
     // Also create a DebugRenderer component so that we can draw debug geometry
     scene_->CreateComponent<Octree>();
     scene_->CreateComponent<DebugRenderer>();
-    
+
     // Create scene node & StaticModel component for showing a static plane
     Node* planeNode = scene_->CreateChild("Plane");
     planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
     StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
     planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
     planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-    
+
     // Create a Zone component for ambient lighting & fog control
     Node* zoneNode = scene_->CreateChild("Zone");
     Zone* zone = zoneNode->CreateComponent<Zone>();
@@ -102,7 +96,7 @@ void Navigation::CreateScene()
     zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light to the world. Enable cascaded shadows on it
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
@@ -112,12 +106,12 @@ void Navigation::CreateScene()
     light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
     // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
     light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
-    
+
     // Create some mushrooms
     const unsigned NUM_MUSHROOMS = 100;
     for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
         CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
-    
+
     // Create randomly sized boxes. If boxes are big enough, make them occluders
     const unsigned NUM_BOXES = 20;
     for (unsigned i = 0; i < NUM_BOXES; ++i)
@@ -154,12 +148,12 @@ void Navigation::CreateScene()
     // physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
     // it will use renderable geometry instead
     navMesh->Build();
-    
+
     // Create the camera. Limit far clip distance to match the fog
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Set an initial position for the camera scene node above the plane and looking down
     cameraNode_->SetPosition(Vector3(0.0f, 50.0f, 0.0f));
     pitch_ = 80.0f;
@@ -170,7 +164,7 @@ void Navigation::CreateUI()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
     // control the camera, and when visible, it will point the raycast target
     XMLFile* style = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
@@ -181,7 +175,7 @@ void Navigation::CreateUI()
     // Set starting position of the cursor at the rendering window center
     Graphics* graphics = GetSubsystem<Graphics>();
     cursor->SetPosition(graphics->GetWidth() / 2, graphics->GetHeight() / 2);
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -193,7 +187,7 @@ void Navigation::CreateUI()
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
     // The text has multiple rows. Center them in relation to each other
     instructionText->SetTextAlignment(HA_CENTER);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -203,7 +197,7 @@ void Navigation::CreateUI()
 void Navigation::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -213,7 +207,7 @@ void Navigation::SubscribeToEvents()
 {
     // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Navigation, HandleUpdate));
-    
+
     // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Navigation, HandlePostRenderUpdate));
@@ -225,16 +219,16 @@ void Navigation::MoveCamera(float timeStep)
     UI* ui = GetSubsystem<UI>();
     Input* input = GetSubsystem<Input>();
     ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
-    
+
     // Do not move if the UI has a focused element (the console)
     if (ui->GetFocusElement())
         return;
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     // Only move the camera when the cursor is hidden
     if (!ui->GetCursor()->IsVisible())
@@ -243,11 +237,11 @@ void Navigation::MoveCamera(float timeStep)
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-        
+
         // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
         cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
     }
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -257,14 +251,14 @@ void Navigation::MoveCamera(float timeStep)
         cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
     if (input->GetKeyDown('D'))
         cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
-    
+
     // Set destination or teleport with left mouse button
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
         SetPathPoint();
     // Add or remove objects with middle mouse button, then rebuild navigation mesh partially
     if (input->GetMouseButtonPress(MOUSEB_MIDDLE))
         AddOrRemoveObject();
-        
+
     // Toggle debug geometry with space
     if (input->GetKeyPress(KEY_SPACE))
         drawDebug_ = !drawDebug_;
@@ -275,7 +269,7 @@ void Navigation::SetPathPoint()
     Vector3 hitPos;
     Drawable* hitDrawable;
     NavigationMesh* navMesh = scene_->GetComponent<NavigationMesh>();
-    
+
     if (Raycast(250.0f, hitPos, hitDrawable))
     {
         Vector3 pathPos = navMesh->FindNearestPoint(hitPos, Vector3(1.0f, 1.0f, 1.0f));
@@ -301,13 +295,13 @@ void Navigation::AddOrRemoveObject()
     // Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
     Vector3 hitPos;
     Drawable* hitDrawable;
-    
+
     if (Raycast(250.0f, hitPos, hitDrawable))
     {
         // The part of the navigation mesh we must update, which is the world bounding box of the associated
         // drawable component
         BoundingBox updateBox;
-        
+
         Node* hitNode = hitDrawable->GetNode();
         if (hitNode->GetName() == "Mushroom")
         {
@@ -319,7 +313,7 @@ void Navigation::AddOrRemoveObject()
             Node* newNode = CreateMushroom(hitPos);
             updateBox = newNode->GetComponent<StaticModel>()->GetWorldBoundingBox();
         }
-        
+
         // Rebuild part of the navigation mesh, then recalculate path if applicable
         NavigationMesh* navMesh = scene_->GetComponent<NavigationMesh>();
         navMesh->Build(updateBox);
@@ -331,7 +325,7 @@ void Navigation::AddOrRemoveObject()
 Node* Navigation::CreateMushroom(const Vector3& pos)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     Node* mushroomNode = scene_->CreateChild("Mushroom");
     mushroomNode->SetPosition(pos);
     mushroomNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
@@ -340,20 +334,20 @@ Node* Navigation::CreateMushroom(const Vector3& pos)
     mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
     mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
     mushroomObject->SetCastShadows(true);
-    
+
     return mushroomNode;
 }
 
 bool Navigation::Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawable)
 {
     hitDrawable = 0;
-    
+
     UI* ui = GetSubsystem<UI>();
     IntVector2 pos = ui->GetCursorPosition();
     // Check the cursor is visible and there is no UI element in front of the cursor
     if (!ui->GetCursor()->IsVisible() || ui->GetElementAt(pos, true))
         return false;
-    
+
     Graphics* graphics = GetSubsystem<Graphics>();
     Camera* camera = cameraNode_->GetComponent<Camera>();
     Ray cameraRay = camera->GetScreenRay((float)pos.x_ / graphics->GetWidth(), (float)pos.y_ / graphics->GetHeight());
@@ -368,7 +362,7 @@ bool Navigation::Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawa
         hitDrawable = result.drawable_;
         return true;
     }
-    
+
     return false;
 }
 
@@ -383,7 +377,7 @@ void Navigation::FollowPath(float timeStep)
         float distance = (jackNode_->GetPosition() - nextWaypoint).Length();
         if (move > distance)
             move = distance;
-        
+
         jackNode_->LookAt(nextWaypoint, Vector3::UP);
         jackNode_->Translate(Vector3::FORWARD * move);
 
@@ -399,7 +393,7 @@ void Navigation::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 
@@ -412,7 +406,7 @@ void Navigation::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventD
     // If draw debug mode is enabled, draw navigation mesh debug geometry
     if (drawDebug_)
         scene_->GetComponent<NavigationMesh>()->DrawDebugGeometry(true);
-    
+
     if (currentPath_.Size())
     {
         // Visualize the current calculated path

+ 24 - 26
Source/Samples/16_Chat/Chat.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Audio/Audio.h>
 #include <Urho3D/Audio/Sound.h>
 #include <Urho3D/Engine/Engine.h>
@@ -74,7 +72,7 @@ void Chat::Start()
 
     // Create the user interface
     CreateUI();
-    
+
     // Subscribe to UI and network events
     SubscribeToEvents();
 }
@@ -89,19 +87,19 @@ void Chat::CreateUI()
     XMLFile* uiStyle = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
     // Set style to the UI root so that elements will inherit it
     root->SetDefaultStyle(uiStyle);
-    
+
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
     chatHistoryText_ = root->CreateChild<Text>();
     chatHistoryText_->SetFont(font, 12);
-    
+
     buttonContainer_ = root->CreateChild<UIElement>();
     buttonContainer_->SetFixedSize(graphics->GetWidth(), 20);
     buttonContainer_->SetPosition(0, graphics->GetHeight() - 20);
     buttonContainer_->SetLayoutMode(LM_HORIZONTAL);
-    
+
     textEdit_ = buttonContainer_->CreateChild<LineEdit>();
     textEdit_->SetStyleAuto();
-    
+
     sendButton_ = CreateButton("Send", 70);
     connectButton_ = CreateButton("Connect", 90);
     disconnectButton_ = CreateButton("Disconnect", 100);
@@ -129,7 +127,7 @@ void Chat::SubscribeToEvents()
 
     // Subscribe to log messages so that we can pipe them to the chat window
     SubscribeToEvent(E_LOGMESSAGE, HANDLER(Chat, HandleLogMessage));
-    
+
     // Subscribe to network events
     SubscribeToEvent(E_NETWORKMESSAGE, HANDLER(Chat, HandleNetworkMessage));
     SubscribeToEvent(E_SERVERCONNECTED, HANDLER(Chat, HandleConnectionStatus));
@@ -141,16 +139,16 @@ Button* Chat::CreateButton(const String& text, int width)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
-    
+
     Button* button = buttonContainer_->CreateChild<Button>();
     button->SetStyleAuto();
     button->SetFixedWidth(width);
-    
+
     Text* buttonText = button->CreateChild<Text>();
     buttonText->SetFont(font, 12);
     buttonText->SetAlignment(HA_CENTER, VA_CENTER);
     buttonText->SetText(text);
-    
+
     return button;
 }
 
@@ -163,7 +161,7 @@ void Chat::ShowChatText(const String& row)
     String allRows;
     for (unsigned i = 0; i < chatHistory_.Size(); ++i)
         allRows += chatHistory_[i] + "\n";
-    
+
     chatHistoryText_->SetText(allRows);
 }
 
@@ -172,7 +170,7 @@ void Chat::UpdateButtons()
     Network* network = GetSubsystem<Network>();
     Connection* serverConnection = network->GetServerConnection();
     bool serverRunning = network->IsServerRunning();
-    
+
     // Show and hide buttons so that eg. Connect and Disconnect are never shown at the same time
     sendButton_->SetVisible(serverConnection != 0);
     connectButton_->SetVisible(!serverConnection && !serverRunning);
@@ -183,7 +181,7 @@ void Chat::UpdateButtons()
 void Chat::HandleLogMessage(StringHash eventType, VariantMap& eventData)
 {
     using namespace LogMessage;
-    
+
     ShowChatText(eventData[P_MESSAGE].GetString());
 }
 
@@ -192,10 +190,10 @@ void Chat::HandleSend(StringHash eventType, VariantMap& eventData)
     String text = textEdit_->GetText();
     if (text.Empty())
         return; // Do not send an empty message
-    
+
     Network* network = GetSubsystem<Network>();
     Connection* serverConnection = network->GetServerConnection();
-    
+
     if (serverConnection)
     {
         // A VectorBuffer object is convenient for constructing a message to send
@@ -216,12 +214,12 @@ void Chat::HandleConnect(StringHash eventType, VariantMap& eventData)
         address = "localhost"; // Use localhost to connect if nothing else specified
     // Empty the text edit after reading the address to connect to
     textEdit_->SetText(String::EMPTY);
-    
+
     // Connect to server, do not specify a client scene as we are not using scene replication, just messages.
     // At connect time we could also send identity parameters (such as username) in a VariantMap, but in this
     // case we skip it for simplicity
     network->Connect(address, CHAT_SERVER_PORT, 0);
-    
+
     UpdateButtons();
 }
 
@@ -235,7 +233,7 @@ void Chat::HandleDisconnect(StringHash eventType, VariantMap& eventData)
     // Or if we were running a server, stop it
     else if (network->IsServerRunning())
         network->StopServer();
-    
+
     UpdateButtons();
 }
 
@@ -243,16 +241,16 @@ void Chat::HandleStartServer(StringHash eventType, VariantMap& eventData)
 {
     Network* network = GetSubsystem<Network>();
     network->StartServer(CHAT_SERVER_PORT);
-    
+
     UpdateButtons();
 }
 
 void Chat::HandleNetworkMessage(StringHash eventType, VariantMap& eventData)
 {
     Network* network = GetSubsystem<Network>();
-    
+
     using namespace NetworkMessage;
-    
+
     int msgID = eventData[P_MESSAGEID].GetInt();
     if (msgID == MSG_CHAT)
     {
@@ -260,21 +258,21 @@ void Chat::HandleNetworkMessage(StringHash eventType, VariantMap& eventData)
         // Use a MemoryBuffer to read the message data so that there is no unnecessary copying
         MemoryBuffer msg(data);
         String text = msg.ReadString();
-        
+
         // If we are the server, prepend the sender's IP address and port and echo to everyone
         // If we are a client, just display the message
         if (network->IsServerRunning())
         {
             Connection* sender = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
-            
+
             text = sender->ToString() + " " + text;
-            
+
             VectorBuffer sendMsg;
             sendMsg.WriteString(text);
             // Broadcast as in-order and reliable
             network->BroadcastMessage(MSG_CHAT, true, true, sendMsg);
         }
-        
+
         ShowChatText(text);
     }
 }

+ 50 - 54
Source/Samples/17_SceneReplication/SceneReplication.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -44,10 +42,8 @@
 #include <Urho3D/Physics/PhysicsWorld.h>
 #include <Urho3D/Physics/RigidBody.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
 #include <Urho3D/UI/Button.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/LineEdit.h>
 #include <Urho3D/UI/Text.h>
@@ -85,10 +81,10 @@ void SceneReplication::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateUI();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -99,15 +95,15 @@ void SceneReplication::Start()
 void SceneReplication::CreateScene()
 {
     scene_ = new Scene(context_);
-    
+
     // Create scene content on the server only
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     // Create octree and physics world with default settings. Create them as local so that they are not needlessly replicated
     // when a client connects
     scene_->CreateComponent<Octree>(LOCAL);
     scene_->CreateComponent<PhysicsWorld>(LOCAL);
-    
+
     // All static scene content and the camera are also created as local, so that they are unaffected by scene replication and are
     // not removed from the client upon connection. Create a Zone component first for ambient lighting & fog control.
     Node* zoneNode = scene_->CreateChild("Zone", LOCAL);
@@ -116,7 +112,7 @@ void SceneReplication::CreateScene()
     zone->SetAmbientColor(Color(0.1f, 0.1f, 0.1f));
     zone->SetFogStart(100.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light without shadows
     Node* lightNode = scene_->CreateChild("DirectionalLight", LOCAL);
     lightNode->SetDirection(Vector3(0.5f, -1.0f, 0.5f));
@@ -124,7 +120,7 @@ void SceneReplication::CreateScene()
     light->SetLightType(LIGHT_DIRECTIONAL);
     light->SetColor(Color(0.2f, 0.2f, 0.2f));
     light->SetSpecularIntensity(1.0f);
-    
+
     // Create a "floor" consisting of several tiles. Make the tiles physical but leave small cracks between them
     for (int y = -20; y <= 20; ++y)
     {
@@ -136,14 +132,14 @@ void SceneReplication::CreateScene()
             StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
             floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
             floorObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-            
+
             RigidBody* body = floorNode->CreateComponent<RigidBody>();
             body->SetFriction(1.0f);
             CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
             shape->SetBox(Vector3::ONE);
         }
     }
-    
+
     // Create the camera. Limit far clip distance to match the fog
     // The camera needs to be created into a local node so that each client can retain its own camera, that is unaffected by
     // network messages. Furthermore, because the client removes all replicated scene nodes when connecting to a server scene,
@@ -152,7 +148,7 @@ void SceneReplication::CreateScene()
     cameraNode_ = scene_->CreateChild("Camera", LOCAL);
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(300.0f);
-    
+
     // Set an initial position for the camera scene node above the plane
     cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
 }
@@ -174,7 +170,7 @@ void SceneReplication::CreateUI()
     // Set starting position of the cursor at the rendering window center
     Graphics* graphics = GetSubsystem<Graphics>();
     cursor->SetPosition(graphics->GetWidth() / 2, graphics->GetHeight() / 2);
-    
+
     // Construct the instructions text element
     instructionsText_ = ui->GetRoot()->CreateChild<Text>();
     instructionsText_->SetText(
@@ -187,26 +183,26 @@ void SceneReplication::CreateUI()
     instructionsText_->SetPosition(0, graphics->GetHeight() / 4);
     // Hide until connected
     instructionsText_->SetVisible(false);
-    
+
     buttonContainer_ = root->CreateChild<UIElement>();
     buttonContainer_->SetFixedSize(500, 20);
     buttonContainer_->SetPosition(20, 20);
     buttonContainer_->SetLayoutMode(LM_HORIZONTAL);
-    
+
     textEdit_ = buttonContainer_->CreateChild<LineEdit>();
     textEdit_->SetStyleAuto();
-    
+
     connectButton_ = CreateButton("Connect", 90);
     disconnectButton_ = CreateButton("Disconnect", 100);
     startServerButton_ = CreateButton("Start Server", 110);
-    
+
     UpdateButtons();
 }
 
 void SceneReplication::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -216,12 +212,12 @@ void SceneReplication::SubscribeToEvents()
 {
     // Subscribe to fixed timestep physics updates for setting or applying controls
     SubscribeToEvent(E_PHYSICSPRESTEP, HANDLER(SceneReplication, HandlePhysicsPreStep));
-    
+
     // Subscribe HandlePostUpdate() method for processing update events. Subscribe to PostUpdate instead
     // of the usual Update so that physics simulation has already proceeded for the frame, and can
     // accurately follow the object with the camera
     SubscribeToEvent(E_POSTUPDATE, HANDLER(SceneReplication, HandlePostUpdate));
-    
+
     // Subscribe to button actions
     SubscribeToEvent(connectButton_, E_RELEASED, HANDLER(SceneReplication, HandleConnect));
     SubscribeToEvent(disconnectButton_, E_RELEASED, HANDLER(SceneReplication, HandleDisconnect));
@@ -243,16 +239,16 @@ Button* SceneReplication::CreateButton(const String& text, int width)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
-    
+
     Button* button = buttonContainer_->CreateChild<Button>();
     button->SetStyleAuto();
     button->SetFixedWidth(width);
-    
+
     Text* buttonText = button->CreateChild<Text>();
     buttonText->SetFont(font, 12);
     buttonText->SetAlignment(HA_CENTER, VA_CENTER);
     buttonText->SetText(text);
-    
+
     return button;
 }
 
@@ -261,7 +257,7 @@ void SceneReplication::UpdateButtons()
     Network* network = GetSubsystem<Network>();
     Connection* serverConnection = network->GetServerConnection();
     bool serverRunning = network->IsServerRunning();
-    
+
     // Show and hide buttons so that eg. Connect and Disconnect are never shown at the same time
     connectButton_->SetVisible(!serverConnection && !serverRunning);
     disconnectButton_->SetVisible(serverConnection || serverRunning);
@@ -272,7 +268,7 @@ void SceneReplication::UpdateButtons()
 Node* SceneReplication::CreateControllableObject()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     // Create the scene node & visual representation. This will be a replicated object
     Node* ballNode = scene_->CreateChild("Ball");
     ballNode->SetPosition(Vector3(Random(40.0f) - 20.0f, 5.0f, Random(40.0f) - 20.0f));
@@ -280,7 +276,7 @@ Node* SceneReplication::CreateControllableObject()
     StaticModel* ballObject = ballNode->CreateComponent<StaticModel>();
     ballObject->SetModel(cache->GetResource<Model>("Models/Sphere.mdl"));
     ballObject->SetMaterial(cache->GetResource<Material>("Materials/StoneSmall.xml"));
-    
+
     // Create the physics components
     RigidBody* body = ballNode->CreateComponent<RigidBody>();
     body->SetMass(1.0f);
@@ -290,12 +286,12 @@ Node* SceneReplication::CreateControllableObject()
     body->SetAngularDamping(0.5f);
     CollisionShape* shape = ballNode->CreateComponent<CollisionShape>();
     shape->SetSphere(1.0f);
-    
+
     // Create a random colored point light at the ball so that can see better where is going
     Light* light = ballNode->CreateComponent<Light>();
     light->SetRange(3.0f);
     light->SetColor(Color(0.5f + (Rand() & 1) * 0.5f, 0.5f + (Rand() & 1) * 0.5f, 0.5f + (Rand() & 1) * 0.5f));
-    
+
     return ballNode;
 }
 
@@ -305,10 +301,10 @@ void SceneReplication::MoveCamera()
     UI* ui = GetSubsystem<UI>();
     Input* input = GetSubsystem<Input>();
     ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
-    
+
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch and only move the camera
     // when the cursor is hidden
     if (!ui->GetCursor()->IsVisible())
@@ -318,10 +314,10 @@ void SceneReplication::MoveCamera()
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ = Clamp(pitch_, 1.0f, 90.0f);
     }
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Only move the camera / show instructions if we have a controllable object
     bool showInstructions = false;
     if (clientObjectID_)
@@ -330,13 +326,13 @@ void SceneReplication::MoveCamera()
         if (ballNode)
         {
             const float CAMERA_DISTANCE = 5.0f;
-            
+
             // Move camera some distance away from the ball
             cameraNode_->SetPosition(ballNode->GetPosition() + cameraNode_->GetRotation() * Vector3::BACK * CAMERA_DISTANCE);
             showInstructions = true;
         }
     }
-    
+
     instructionsText_->SetVisible(showInstructions);
 }
 
@@ -353,17 +349,17 @@ void SceneReplication::HandlePhysicsPreStep(StringHash eventType, VariantMap& ev
     // fixed rate, by default 30 FPS. The server will actually apply the controls (authoritative simulation.)
     Network* network = GetSubsystem<Network>();
     Connection* serverConnection = network->GetServerConnection();
-    
+
     // Client: collect controls
     if (serverConnection)
     {
         UI* ui = GetSubsystem<UI>();
         Input* input = GetSubsystem<Input>();
         Controls controls;
-        
+
         // Copy mouse yaw
         controls.yaw_ = yaw_;
-        
+
         // Only apply WASD controls if there is no focused UI element
         if (!ui->GetFocusElement())
         {
@@ -372,7 +368,7 @@ void SceneReplication::HandlePhysicsPreStep(StringHash eventType, VariantMap& ev
             controls.Set(CTRL_LEFT, input->GetKeyDown('A'));
             controls.Set(CTRL_RIGHT, input->GetKeyDown('D'));
         }
-        
+
         serverConnection->SetControls(controls);
         // In case the server wants to do position-based interest management using the NetworkPriority components, we should also
         // tell it our observer (camera) position. In this sample it is not in use, but eg. the NinjaSnowWar game uses it
@@ -382,7 +378,7 @@ void SceneReplication::HandlePhysicsPreStep(StringHash eventType, VariantMap& ev
     else if (network->IsServerRunning())
     {
         const Vector<SharedPtr<Connection> >& connections = network->GetClientConnections();
-        
+
         for (unsigned i = 0; i < connections.Size(); ++i)
         {
             Connection* connection = connections[i];
@@ -390,16 +386,16 @@ void SceneReplication::HandlePhysicsPreStep(StringHash eventType, VariantMap& ev
             Node* ballNode = serverObjects_[connection];
             if (!ballNode)
                 continue;
-            
+
             RigidBody* body = ballNode->GetComponent<RigidBody>();
-            
+
             // Get the last controls sent by the client
             const Controls& controls = connection->GetControls();
             // Torque is relative to the forward vector
             Quaternion rotation(0.0f, controls.yaw_, 0.0f);
-            
+
             const float MOVE_TORQUE = 3.0f;
-            
+
             // Movement torque is applied before each simulation step, which happen at 60 FPS. This makes the simulation
             // independent from rendering framerate. We could also apply forces (which would enable in-air control),
             // but want to emphasize that it's a ball which should only control its motion by rolling along the ground
@@ -421,11 +417,11 @@ void SceneReplication::HandleConnect(StringHash eventType, VariantMap& eventData
     String address = textEdit_->GetText().Trimmed();
     if (address.Empty())
         address = "localhost"; // Use localhost to connect if nothing else specified
-    
+
     // Connect to server, specify scene to use as a client for replication
     clientObjectID_ = 0; // Reset own object ID from possible previous connection
     network->Connect(address, SERVER_PORT, scene_);
-    
+
     UpdateButtons();
 }
 
@@ -447,7 +443,7 @@ void SceneReplication::HandleDisconnect(StringHash eventType, VariantMap& eventD
         network->StopServer();
         scene_->Clear(true, false);
     }
-    
+
     UpdateButtons();
 }
 
@@ -455,7 +451,7 @@ void SceneReplication::HandleStartServer(StringHash eventType, VariantMap& event
 {
     Network* network = GetSubsystem<Network>();
     network->StartServer(SERVER_PORT);
-    
+
     UpdateButtons();
 }
 
@@ -467,15 +463,15 @@ void SceneReplication::HandleConnectionStatus(StringHash eventType, VariantMap&
 void SceneReplication::HandleClientConnected(StringHash eventType, VariantMap& eventData)
 {
     using namespace ClientConnected;
-    
+
     // When a client connects, assign to scene to begin scene replication
     Connection* newConnection = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
     newConnection->SetScene(scene_);
-    
+
     // Then create a controllable object for that client
     Node* newObject = CreateControllableObject();
     serverObjects_[newConnection] = newObject;
-    
+
     // Finally send the object's node ID using a remote event
     VariantMap remoteEventData;
     remoteEventData[P_ID] = newObject->GetID();
@@ -485,13 +481,13 @@ void SceneReplication::HandleClientConnected(StringHash eventType, VariantMap& e
 void SceneReplication::HandleClientDisconnected(StringHash eventType, VariantMap& eventData)
 {
     using namespace ClientConnected;
-    
+
     // When a client disconnects, remove the controlled object
     Connection* connection = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
     Node* object = serverObjects_[connection];
     if (object)
         object->Remove();
-    
+
     serverObjects_.Erase(connection);
 }
 

+ 13 - 15
Source/Samples/18_CharacterDemo/Character.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
 #include <Urho3D/Graphics/AnimationController.h>
 #include <Urho3D/IO/MemoryBuffer.h>
@@ -46,7 +44,7 @@ Character::Character(Context* context) :
 void Character::RegisterObject(Context* context)
 {
     context->RegisterFactory<Character>();
-    
+
     // These macros register the class attributes to the Context for automatic load / save handling.
     // We specify the Default attribute mode which means it will be used both for saving into file, and network replication
     ATTRIBUTE("Controls Yaw", float, controls_.yaw_, 0.0f, AM_DEFAULT);
@@ -67,7 +65,7 @@ void Character::FixedUpdate(float timeStep)
     /// \todo Could cache the components for faster access instead of finding them each frame
     RigidBody* body = GetComponent<RigidBody>();
     AnimationController* animCtrl = GetComponent<AnimationController>();
-    
+
     // Update the in air timer. Reset if grounded
     if (!onGround_)
         inAirTimer_ += timeStep;
@@ -75,14 +73,14 @@ void Character::FixedUpdate(float timeStep)
         inAirTimer_ = 0.0f;
     // When character has been in air less than 1/10 second, it's still interpreted as being on ground
     bool softGrounded = inAirTimer_ < INAIR_THRESHOLD_TIME;
-    
+
     // Update movement & animation
     const Quaternion& rot = node_->GetRotation();
     Vector3 moveDir = Vector3::ZERO;
     const Vector3& velocity = body->GetLinearVelocity();
     // Velocity on the XZ plane
     Vector3 planeVelocity(velocity.x_, 0.0f, velocity.z_);
-    
+
     if (controls_.IsDown(CTRL_FORWARD))
         moveDir += Vector3::FORWARD;
     if (controls_.IsDown(CTRL_BACK))
@@ -91,20 +89,20 @@ void Character::FixedUpdate(float timeStep)
         moveDir += Vector3::LEFT;
     if (controls_.IsDown(CTRL_RIGHT))
         moveDir += Vector3::RIGHT;
-    
+
     // Normalize move vector so that diagonal strafing is not faster
     if (moveDir.LengthSquared() > 0.0f)
         moveDir.Normalize();
-    
+
     // If in air, allow control, but slower than when on ground
     body->ApplyImpulse(rot * moveDir * (softGrounded ? MOVE_FORCE : INAIR_MOVE_FORCE));
-    
+
     if (softGrounded)
     {
         // When on ground, apply a braking force to limit maximum ground velocity
         Vector3 brakeForce = -planeVelocity * BRAKE_FORCE;
         body->ApplyImpulse(brakeForce);
-        
+
         // Jump. Must release jump control inbetween jumps
         if (controls_.IsDown(CTRL_JUMP))
         {
@@ -117,7 +115,7 @@ void Character::FixedUpdate(float timeStep)
         else
             okToJump_ = true;
     }
-    
+
     // Play walk animation if moving on ground, otherwise fade it out
     if (softGrounded && !moveDir.Equals(Vector3::ZERO))
         animCtrl->PlayExclusive("Models/Jack_Walk.ani", 0, true, 0.2f);
@@ -125,7 +123,7 @@ void Character::FixedUpdate(float timeStep)
         animCtrl->Stop("Models/Jack_Walk.ani", 0.2f);
     // Set walk animation speed proportional to velocity
     animCtrl->SetSpeed("Models/Jack_Walk.ani", planeVelocity.Length() * 0.3f);
-    
+
     // Reset grounded flag for next frame
     onGround_ = false;
 }
@@ -134,16 +132,16 @@ void Character::HandleNodeCollision(StringHash eventType, VariantMap& eventData)
 {
     // Check collision contacts and see if character is standing on ground (look for a contact that has near vertical normal)
     using namespace NodeCollision;
-    
+
     MemoryBuffer contacts(eventData[P_CONTACTS].GetBuffer());
-    
+
     while (!contacts.IsEof())
     {
         Vector3 contactPosition = contacts.ReadVector3();
         Vector3 contactNormal = contacts.ReadVector3();
         /*float contactDistance = */contacts.ReadFloat();
         /*float contactImpulse = */contacts.ReadFloat();
-        
+
         // If contact is below node center and mostly vertical, assume it's a ground contact
         if (contactPosition.y_ < (node_->GetPosition().y_ + 1.0f))
         {

+ 0 - 4
Source/Samples/18_CharacterDemo/CharacterDemo.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Engine/Engine.h>
@@ -30,10 +28,8 @@
 #include <Urho3D/Graphics/Camera.h>
 #include <Urho3D/Graphics/Light.h>
 #include <Urho3D/Graphics/Material.h>
-#include <Urho3D/Graphics/Model.h>
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
-#include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Controls.h>
 #include <Urho3D/Input/Input.h>

+ 0 - 2
Source/Samples/18_CharacterDemo/Touch.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Input/Controls.h>

+ 9 - 11
Source/Samples/19_VehicleDemo/Vehicle.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
 #include <Urho3D/Graphics/Material.h>
 #include <Urho3D/Graphics/Model.h>
@@ -47,7 +45,7 @@ Vehicle::Vehicle(Context* context) :
 void Vehicle::RegisterObject(Context* context)
 {
     context->RegisterFactory<Vehicle>();
-    
+
     ATTRIBUTE("Controls Yaw", float, controls_.yaw_, 0.0f, AM_DEFAULT);
     ATTRIBUTE("Controls Pitch", float, controls_.pitch_, 0.0f, AM_DEFAULT);
     ATTRIBUTE("Steering", float, steering_, 0.0f, AM_DEFAULT);
@@ -64,13 +62,13 @@ void Vehicle::ApplyAttributes()
     // This function is called on each Serializable after the whole scene has been loaded. Reacquire wheel nodes from ID's
     // as well as all required physics components
     Scene* scene = GetScene();
-    
+
     frontLeft_ = scene->GetNode(frontLeftID_);
     frontRight_ = scene->GetNode(frontRightID_);
     rearLeft_ = scene->GetNode(rearLeftID_);
     rearRight_ = scene->GetNode(rearRightID_);
     hullBody_ = node_->GetComponent<RigidBody>();
-    
+
     GetWheelComponents();
 }
 
@@ -109,7 +107,7 @@ void Vehicle::FixedUpdate(float timeStep)
     {
         // Torques are applied in world space, so need to take the vehicle & wheel rotation into account
         Vector3 torqueVec = Vector3(ENGINE_POWER * accelerator, 0.0f, 0.0f);
-        
+
         frontLeftBody_->ApplyTorque(hullRot * steeringRot * torqueVec);
         frontRightBody_->ApplyTorque(hullRot * steeringRot * torqueVec);
         rearLeftBody_->ApplyTorque(hullRot * torqueVec);
@@ -125,7 +123,7 @@ void Vehicle::Init()
 {
     // This function is called only from the main program when initially creating the vehicle, not on scene load
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     StaticModel* hullObject = node_->CreateComponent<StaticModel>();
     hullBody_ = node_->CreateComponent<RigidBody>();
     CollisionShape* hullShape = node_->CreateComponent<CollisionShape>();
@@ -139,19 +137,19 @@ void Vehicle::Init()
     hullBody_->SetLinearDamping(0.2f); // Some air resistance
     hullBody_->SetAngularDamping(0.5f);
     hullBody_->SetCollisionLayer(1);
-    
+
     InitWheel("FrontLeft", Vector3(-0.6f, -0.4f, 0.3f), frontLeft_, frontLeftID_);
     InitWheel("FrontRight", Vector3(0.6f, -0.4f, 0.3f), frontRight_, frontRightID_);
     InitWheel("RearLeft", Vector3(-0.6f, -0.4f, -0.3f), rearLeft_, rearLeftID_);
     InitWheel("RearRight", Vector3(0.6f, -0.4f, -0.3f), rearRight_, rearRightID_);
-    
+
     GetWheelComponents();
 }
 
 void Vehicle::InitWheel(const String& name, const Vector3& offset, WeakPtr<Node>& wheelNode, unsigned& wheelNodeID)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     // Note: do not parent the wheel to the hull scene node. Instead create it on the root level and let the physics
     // constraint keep it together
     wheelNode = GetScene()->CreateChild(name);
@@ -161,7 +159,7 @@ void Vehicle::InitWheel(const String& name, const Vector3& offset, WeakPtr<Node>
     wheelNode->SetScale(Vector3(0.8f, 0.5f, 0.8f));
     // Remember the ID for serialization
     wheelNodeID = wheelNode->GetID();
-    
+
     StaticModel* wheelObject = wheelNode->CreateComponent<StaticModel>();
     RigidBody* wheelBody = wheelNode->CreateComponent<RigidBody>();
     CollisionShape* wheelShape = wheelNode->CreateComponent<CollisionShape>();

+ 0 - 2
Source/Samples/19_VehicleDemo/VehicleDemo.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Engine/Engine.h>

+ 19 - 21
Source/Samples/20_HugeObjectCount/HugeObjectCount.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/Profiler.h>
 #include <Urho3D/Engine/Engine.h>
@@ -60,13 +58,13 @@ void HugeObjectCount::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
-    
+
     // Hook up to the frame update events
     SubscribeToEvents();
 }
@@ -74,7 +72,7 @@ void HugeObjectCount::Start()
 void HugeObjectCount::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     if (!scene_)
         scene_ = new Scene(context_);
     else
@@ -82,7 +80,7 @@ void HugeObjectCount::CreateScene()
         scene_->Clear();
         boxNodes_.Clear();
     }
-    
+
     // Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
     // (-1000, -1000, -1000) to (1000, 1000, 1000)
     scene_->CreateComponent<Octree>();
@@ -94,7 +92,7 @@ void HugeObjectCount::CreateScene()
     zone->SetFogColor(Color(0.2f, 0.2f, 0.2f));
     zone->SetFogStart(200.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(-0.6f, -1.0f, -0.8f)); // The direction vector does not need to be normalized
@@ -104,7 +102,7 @@ void HugeObjectCount::CreateScene()
     if (!useGroups_)
     {
         light->SetColor(Color(0.7f, 0.35f, 0.0f));
-        
+
         // Create individual box StaticModels in the scene
         for (int y = -125; y < 125; ++y)
         {
@@ -123,7 +121,7 @@ void HugeObjectCount::CreateScene()
     {
         light->SetColor(Color(0.6f, 0.6f, 0.6f));
         light->SetSpecularIntensity(1.5f);
-        
+
         // Create StaticModelGroups in the scene
         StaticModelGroup* lastGroup = 0;
 
@@ -140,7 +138,7 @@ void HugeObjectCount::CreateScene()
                     lastGroup = boxGroupNode->CreateComponent<StaticModelGroup>();
                     lastGroup->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
                 }
-                
+
                 Node* boxNode = scene_->CreateChild("Box");
                 boxNode->SetPosition(Vector3(x * 0.3f, 0.0f, y * 0.3f));
                 boxNode->SetScale(0.25f);
@@ -164,7 +162,7 @@ void HugeObjectCount::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -185,7 +183,7 @@ void HugeObjectCount::CreateInstructions()
 void HugeObjectCount::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -202,23 +200,23 @@ void HugeObjectCount::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -233,7 +231,7 @@ void HugeObjectCount::MoveCamera(float timeStep)
 void HugeObjectCount::AnimateObjects(float timeStep)
 {
     PROFILE(AnimateObjects);
-    
+
     const float ROTATE_SPEED = 15.0f;
     // Rotate about the Z axis (roll)
     Quaternion rotateQuat(ROTATE_SPEED * timeStep, Vector3::FORWARD);
@@ -248,7 +246,7 @@ void HugeObjectCount::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Toggle animation with space
     Input* input = GetSubsystem<Input>();
     if (input->GetKeyPress(KEY_SPACE))
@@ -263,7 +261,7 @@ void HugeObjectCount::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
-    
+
     // Animate scene if enabled
     if (animate_)
         AnimateObjects(timeStep);

+ 18 - 20
Source/Samples/21_AngelScriptIntegration/AngelScriptIntegration.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -62,10 +60,10 @@ void AngelScriptIntegration::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -76,13 +74,13 @@ void AngelScriptIntegration::Start()
 void AngelScriptIntegration::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
     // (-1000, -1000, -1000) to (1000, 1000, 1000)
     scene_->CreateComponent<Octree>();
-    
+
     // Create a Zone component into a child scene node. The Zone controls ambient lighting and fog settings. Like the Octree,
     // it also defines its volume with a bounding box, but can be rotated (so it does not need to be aligned to the world X, Y
     // and Z axes.) Drawable objects "pick up" the zone they belong to and use it when rendering; several zones can exist
@@ -94,7 +92,7 @@ void AngelScriptIntegration::CreateScene()
     zone->SetFogColor(Color(0.1f, 0.2f, 0.3f));
     zone->SetFogStart(10.0f);
     zone->SetFogEnd(100.0f);
-    
+
     // Create randomly positioned and oriented box StaticModels in the scene
     const unsigned NUM_OBJECTS = 2000;
     for (unsigned i = 0; i < NUM_OBJECTS; ++i)
@@ -106,7 +104,7 @@ void AngelScriptIntegration::CreateScene()
         StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
         boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-        
+
         // Add our custom Rotator script object (using the ScriptInstance C++ component to instantiate / store it) which will
         // rotate the scene node each frame, when the scene sends its update event
         ScriptInstance* instance = boxNode->CreateComponent<ScriptInstance>();
@@ -116,13 +114,13 @@ void AngelScriptIntegration::CreateScene()
         parameters.Push(Vector3(10.0f, 20.0f, 30.0f));
         instance->Execute("void SetRotationSpeed(const Vector3&in)", parameters);
     }
-    
+
     // Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance, we can
     // bring the far clip plane closer for more effective culling of distant objects
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(100.0f);
-    
+
     // Create a point light to the camera scene node
     Light* light = cameraNode_->CreateComponent<Light>();
     light->SetLightType(LIGHT_POINT);
@@ -133,12 +131,12 @@ void AngelScriptIntegration::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText("Use WASD keys and mouse/touch to move");
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -148,7 +146,7 @@ void AngelScriptIntegration::CreateInstructions()
 void AngelScriptIntegration::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -165,23 +163,23 @@ void AngelScriptIntegration::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -199,7 +197,7 @@ void AngelScriptIntegration::HandleUpdate(StringHash eventType, VariantMap& even
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 14 - 16
Source/Samples/22_LuaIntegration/LuaIntegration.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -95,7 +93,7 @@ void LuaIntegration::CreateScene()
     zone->SetFogColor(Color(0.1f, 0.2f, 0.3f));
     zone->SetFogStart(10.0f);
     zone->SetFogEnd(100.0f);
-    
+
     LuaFile* scriptFile = cache->GetResource<LuaFile>("LuaScripts/Rotator.lua");
     if (!scriptFile)
         return;
@@ -111,12 +109,12 @@ void LuaIntegration::CreateScene()
         StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
         boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
         boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
-        
+
         // Add our custom Rotator script object (using the LuaScriptInstance C++ component to instantiate / store it) which will
         // rotate the scene node each frame, when the scene sends its update event
         LuaScriptInstance* instance = boxNode->CreateComponent<LuaScriptInstance>();
         instance->CreateObject(scriptFile, "Rotator");
-        
+
         // Call the script object's "SetRotationSpeed" function.
         LuaFunction* function = instance->GetScriptObjectFunction("SetRotationSpeed");
         if (function && function->BeginCall(instance))
@@ -125,13 +123,13 @@ void LuaIntegration::CreateScene()
             function->EndCall();
         }
     }
-    
+
     // Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance, we can
     // bring the far clip plane closer for more effective culling of distant objects
     cameraNode_ = scene_->CreateChild("Camera");
     Camera* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetFarClip(100.0f);
-    
+
     // Create a point light to the camera scene node
     Light* light = cameraNode_->CreateComponent<Light>();
     light->SetLightType(LIGHT_POINT);
@@ -142,12 +140,12 @@ void LuaIntegration::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText("Use WASD keys and mouse/touch to move");
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -157,7 +155,7 @@ void LuaIntegration::CreateInstructions()
 void LuaIntegration::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -174,23 +172,23 @@ void LuaIntegration::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -208,7 +206,7 @@ void LuaIntegration::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 0 - 3
Source/Samples/23_Water/Water.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -33,7 +31,6 @@
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Graphics/RenderSurface.h>
 #include <Urho3D/Graphics/Skybox.h>
-#include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Graphics/Terrain.h>
 #include <Urho3D/Graphics/Texture2D.h>
 #include <Urho3D/Graphics/Zone.h>

+ 0 - 2
Source/Samples/24_Urho2DSprite/Urho2DSprite.cpp

@@ -20,7 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
 
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
@@ -37,7 +36,6 @@
 #include <Urho3D/Urho2D/AnimatedSprite2D.h>
 #include <Urho3D/Urho2D/AnimationSet2D.h>
 #include <Urho3D/Urho2D/Sprite2D.h>
-#include <Urho3D/Urho2D/StaticSprite2D.h>
 
 #include "Urho2DSprite.h"
 

+ 0 - 3
Source/Samples/25_Urho2DParticle/Urho2DParticle.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -30,7 +28,6 @@
 #include <Urho3D/Graphics/Renderer.h>
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
-#include <Urho3D/Input/InputEvents.h>
 #include <Urho3D/Resource/ResourceCache.h>
 #include <Urho3D/Scene/Scene.h>
 #include <Urho3D/UI/Font.h>

+ 0 - 3
Source/Samples/26_ConsoleInput/ConsoleInput.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Core/Timer.h>
@@ -30,7 +28,6 @@
 #include <Urho3D/Engine/EngineEvents.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/IO/Log.h>
-#include <Urho3D/Math/Random.h>
 #include <Urho3D/UI/Button.h>
 
 #include "ConsoleInput.h"

+ 0 - 2
Source/Samples/27_Urho2DPhysics/Urho2DPhysics.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>

+ 0 - 2
Source/Samples/28_Urho2DPhysicsRope/Urho2DPhysicsRope.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>

+ 13 - 15
Source/Samples/29_SoundSynthesis/SoundSynthesis.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Audio/BufferedSoundStream.h>
 #include <Urho3D/Audio/SoundSource.h>
 #include <Urho3D/Core/CoreEvents.h>
@@ -56,10 +54,10 @@ void SoundSynthesis::Start()
 
     // Create the sound stream & start playback
     CreateSound();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Hook up to the frame update events
     SubscribeToEvents();
 }
@@ -69,11 +67,11 @@ void SoundSynthesis::CreateSound()
     // Sound source needs a node so that it is considered enabled
     node_ = new Node(context_);
     SoundSource* source = node_->CreateComponent<SoundSource>();
-    
+
     soundStream_ = new BufferedSoundStream();
     // Set format: 44100 Hz, sixteen bit, mono
     soundStream_->SetFormat(44100, true, false);
-    
+
     // Start playback. We don't have data in the stream yet, but the SoundSource will wait until there is data,
     // as the stream is by default in the "don't stop at end" mode
     source->Play(soundStream_);
@@ -86,11 +84,11 @@ void SoundSynthesis::UpdateSound()
     float requiredLength = targetLength - soundStream_->GetBufferLength();
     if (requiredLength < 0.0f)
         return;
-    
+
     unsigned numSamples = (unsigned)(soundStream_->GetFrequency() * requiredLength);
     if (!numSamples)
         return;
-    
+
     // Allocate a new buffer and fill it with a simple two-oscillator algorithm. The sound is over-amplified
     // (distorted), clamped to the 16-bit range, and finally lowpass-filtered according to the coefficient
     SharedArrayPtr<signed short> newData(new signed short[numSamples]);
@@ -98,12 +96,12 @@ void SoundSynthesis::UpdateSound()
     {
         osc1_ = fmodf(osc1_ + 1.0f, 360.0f);
         osc2_ = fmodf(osc2_ + 1.002f, 360.0f);
-        
+
         float newValue = Clamp((Sin(osc1_) + Sin(osc2_)) * 100000.0f, -32767.0f, 32767.0f);
         accumulator_ = Lerp(accumulator_, newValue, filter_);
         newData[i] = (int)accumulator_;
     }
-    
+
     // Queue buffer to the stream for playback
     soundStream_->AddData(newData, numSamples * sizeof(signed short));
 }
@@ -112,12 +110,12 @@ void SoundSynthesis::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     instructionText_ = ui->GetRoot()->CreateChild<Text>();
     instructionText_->SetText("Use cursor up and down to control sound filtering");
     instructionText_->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
-    
+
     // Position the text relative to the screen center
     instructionText_->SetTextAlignment(HA_CENTER);
     instructionText_->SetHorizontalAlignment(HA_CENTER);
@@ -137,7 +135,7 @@ void SoundSynthesis::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Use keys to control the filter constant
     Input* input = GetSubsystem<Input>();
     if (input->GetKeyDown(KEY_UP))
@@ -145,9 +143,9 @@ void SoundSynthesis::HandleUpdate(StringHash eventType, VariantMap& eventData)
     if (input->GetKeyDown(KEY_DOWN))
         filter_ -= timeStep * 0.5f;
     filter_ = Clamp(filter_, 0.01f, 1.0f);
-    
+
     instructionText_->SetText("Use cursor up and down to control sound filtering\n"
         "Coefficient: " + String(filter_));
-    
+
     UpdateSound();
 }

+ 18 - 21
Source/Samples/30_LightAnimation/LightAnimation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -33,7 +31,6 @@
 #include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Scene/Animatable.h>
 #include <Urho3D/Scene/ObjectAnimation.h>
 #include <Urho3D/Scene/Scene.h>
 #include <Urho3D/Scene/ValueAnimation.h>
@@ -62,7 +59,7 @@ void LightAnimation::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -73,15 +70,15 @@ void LightAnimation::Start()
 void LightAnimation::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
     // show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
     // is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
     // optimizing manner
     scene_->CreateComponent<Octree>();
-    
+
     // Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
     // plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
     // (100 x 100 world units)
@@ -90,8 +87,8 @@ void LightAnimation::CreateScene()
     StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
     planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
     planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
-    
-    // Create a point light to the world so that we can see something. 
+
+    // Create a point light to the world so that we can see something.
     Node* lightNode = scene_->CreateChild("PointLight");
     Light* light = lightNode->CreateComponent<Light>();
     light->SetLightType(LIGHT_POINT);
@@ -99,7 +96,7 @@ void LightAnimation::CreateScene()
 
     // Create light animation
     SharedPtr<ObjectAnimation> lightAnimation(new ObjectAnimation(context_));
-    
+
     // Create light position animation
     SharedPtr<ValueAnimation> positionAnimation(new ValueAnimation(context_));
     // Use spline interpolation method
@@ -153,12 +150,12 @@ void LightAnimation::CreateScene()
         mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
         mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
     }
-    
+
     // Create a scene node for the camera, which we will move around
     // The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
     cameraNode_ = scene_->CreateChild("Camera");
     cameraNode_->CreateComponent<Camera>();
-    
+
     // Set an initial position for the camera scene node above the plane
     cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
 }
@@ -167,13 +164,13 @@ void LightAnimation::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText("Use WASD keys and mouse/touch to move");
     Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
     instructionText->SetFont(font, 15);
-    
+
     // Position the text relative to the screen center
     instructionText->SetHorizontalAlignment(HA_CENTER);
     instructionText->SetVerticalAlignment(VA_CENTER);
@@ -190,7 +187,7 @@ void LightAnimation::CreateInstructions()
 void LightAnimation::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the camera
     // at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward / deferred) to
     // use, but now we just use full screen and default render path configured in the engine command line options
@@ -203,23 +200,23 @@ void LightAnimation::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     // Use the Translate() function (default local space) to move relative to the node's orientation.
     if (input->GetKeyDown('W'))
@@ -244,7 +241,7 @@ void LightAnimation::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 0 - 2
Source/Samples/31_MaterialAnimation/MaterialAnimation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>

+ 2 - 3
Source/Samples/32_Urho2DConstraints/Urho2DConstraints.cpp

@@ -20,11 +20,8 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Container/Vector.h>
 #include <Urho3D/Core/CoreEvents.h>
-#include <Urho3D/DebugNew.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
 #include <Urho3D/Graphics/DebugRenderer.h>
@@ -63,6 +60,8 @@
 
 #include "Urho2DConstraints.h"
 
+#include <Urho3D/DebugNew.h>
+
 DEFINE_APPLICATION_MAIN(Urho2DConstraints)
 
 Node* pickedNode;

+ 1 - 4
Source/Samples/33_Urho2DSpriterAnimation/Urho2DSpriterAnimation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -36,7 +34,6 @@
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/Urho2D/AnimatedSprite2D.h>
 #include <Urho3D/Urho2D/AnimationSet2D.h>
-#include <Urho3D/Urho2D/Drawable2D.h>
 
 #include "Urho2DSpriterAnimation.h"
 
@@ -96,7 +93,7 @@ void Urho2DSpriterAnimation::CreateScene()
     camera->SetOrthoSize((float)graphics->GetHeight() * PIXEL_SIZE);
     camera->SetZoom(1.5f * Min((float)graphics->GetWidth() / 1280.0f, (float)graphics->GetHeight() / 800.0f)); // Set zoom according to user's resolution to ensure full visibility (initial zoom (1.5) is set for full visibility at 1280x800 resolution)
 
-    ResourceCache* cache = GetSubsystem<ResourceCache>();  
+    ResourceCache* cache = GetSubsystem<ResourceCache>();
     AnimationSet2D* animationSet = cache->GetResource<AnimationSet2D>("Urho2D/imp/imp.scml");
     if (!animationSet)
         return;

+ 36 - 38
Source/Samples/34_DynamicGeometry/DynamicGeometry.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/Profiler.h>
 #include <Urho3D/Engine/Engine.h>
@@ -64,13 +62,13 @@ void DynamicGeometry::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateInstructions();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
-    
+
     // Hook up to the frame update events
     SubscribeToEvents();
 }
@@ -78,9 +76,9 @@ void DynamicGeometry::Start()
 void DynamicGeometry::CreateScene()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    
+
     scene_ = new Scene(context_);
-    
+
     // Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
     // (-1000, -1000, -1000) to (1000, 1000, 1000)
     scene_->CreateComponent<Octree>();
@@ -92,7 +90,7 @@ void DynamicGeometry::CreateScene()
     zone->SetFogColor(Color(0.2f, 0.2f, 0.2f));
     zone->SetFogStart(200.0f);
     zone->SetFogEnd(300.0f);
-    
+
     // Create a directional light
     Node* lightNode = scene_->CreateChild("DirectionalLight");
     lightNode->SetDirection(Vector3(-0.6f, -1.0f, -0.8f)); // The direction vector does not need to be normalized
@@ -100,7 +98,7 @@ void DynamicGeometry::CreateScene()
     light->SetLightType(LIGHT_DIRECTIONAL);
     light->SetColor(Color(0.4f, 1.0f, 0.4f));
     light->SetSpecularIntensity(1.5f);
-    
+
     // Get the original model and its unmodified vertices, which are used as source data for the animation
     Model* originalModel = cache->GetResource<Model>("Models/Box.mdl");
     if (!originalModel)
@@ -122,7 +120,7 @@ void DynamicGeometry::CreateScene()
             originalVertices_.Push(src);
         }
         buffer->Unlock();
-        
+
         // Detect duplicate vertices to allow seamless animation
         vertexDuplicates_.Resize(originalVertices_.Size());
         for (unsigned i = 0; i < originalVertices_.Size(); ++i)
@@ -143,7 +141,7 @@ void DynamicGeometry::CreateScene()
         LOGERROR("Failed to lock the model vertex buffer to get original vertices");
         return;
     }
-    
+
     // Create StaticModels in the scene. Clone the model for each so that we can modify the vertex data individually
     for (int y = -1; y <= 1; ++y)
     {
@@ -158,26 +156,26 @@ void DynamicGeometry::CreateScene()
             animatingBuffers_.Push(SharedPtr<VertexBuffer>(cloneModel->GetGeometry(0, 0)->GetVertexBuffer(0)));
         }
     }
-    
+
     // Finally create one model (pyramid shape) and a StaticModel to display it from scratch
     // Note: there are duplicated vertices to enable face normals. We will calculate normals programmatically
     {
         const unsigned numVertices = 18;
-        
+
         float vertexData[] = {
             // Position             Normal
             0.0f, 0.5f, 0.0f,       0.0f, 0.0f, 0.0f,
             0.5f, -0.5f, 0.5f,      0.0f, 0.0f, 0.0f,
             0.5f, -0.5f, -0.5f,     0.0f, 0.0f, 0.0f,
-            
+
             0.0f, 0.5f, 0.0f,       0.0f, 0.0f, 0.0f,
             -0.5f, -0.5f, 0.5f,     0.0f, 0.0f, 0.0f,
             0.5f, -0.5f, 0.5f,      0.0f, 0.0f, 0.0f,
-            
+
             0.0f, 0.5f, 0.0f,       0.0f, 0.0f, 0.0f,
             -0.5f, -0.5f, -0.5f,    0.0f, 0.0f, 0.0f,
             -0.5f, -0.5f, 0.5f,     0.0f, 0.0f, 0.0f,
-            
+
             0.0f, 0.5f, 0.0f,       0.0f, 0.0f, 0.0f,
             0.5f, -0.5f, -0.5f,     0.0f, 0.0f, 0.0f,
             -0.5f, -0.5f, -0.5f,    0.0f, 0.0f, 0.0f,
@@ -190,7 +188,7 @@ void DynamicGeometry::CreateScene()
             -0.5f, -0.5f, 0.5f,     0.0f, 0.0f, 0.0f,
             -0.5f, -0.5f, -0.5f,    0.0f, 0.0f, 0.0f
         };
-        
+
         const unsigned short indexData[] = {
             0, 1, 2,
             3, 4, 5,
@@ -199,7 +197,7 @@ void DynamicGeometry::CreateScene()
             12, 13, 14,
             15, 16, 17
         };
-        
+
         // Calculate face normals now
         for (unsigned i = 0; i < numVertices; i += 3)
         {
@@ -209,34 +207,34 @@ void DynamicGeometry::CreateScene()
             Vector3& n1 = *(reinterpret_cast<Vector3*>(&vertexData[6 * i + 3]));
             Vector3& n2 = *(reinterpret_cast<Vector3*>(&vertexData[6 * (i + 1) + 3]));
             Vector3& n3 = *(reinterpret_cast<Vector3*>(&vertexData[6 * (i + 2) + 3]));
-            
+
             Vector3 edge1 = v1 - v2;
             Vector3 edge2 = v1 - v3;
             n1 = n2 = n3 = edge1.CrossProduct(edge2).Normalized();
         }
-        
+
         SharedPtr<Model> fromScratchModel(new Model(context_));
         SharedPtr<VertexBuffer> vb(new VertexBuffer(context_));
         SharedPtr<IndexBuffer> ib(new IndexBuffer(context_));
         SharedPtr<Geometry> geom(new Geometry(context_));
-        
+
         // Shadowed buffer needed for raycasts to work, and so that data can be automatically restored on device loss
         vb->SetShadowed(true);
         vb->SetSize(numVertices, MASK_POSITION|MASK_NORMAL);
         vb->SetData(vertexData);
-        
+
         ib->SetShadowed(true);
         ib->SetSize(numVertices, false);
         ib->SetData(indexData);
-        
+
         geom->SetVertexBuffer(0, vb);
         geom->SetIndexBuffer(ib);
         geom->SetDrawRange(TRIANGLE_LIST, 0, numVertices);
-        
+
         fromScratchModel->SetNumGeometries(1);
         fromScratchModel->SetGeometry(0, 0, geom);
         fromScratchModel->SetBoundingBox(BoundingBox(Vector3(-0.5f, -0.5f, -0.5f), Vector3(0.5f, 0.5f, 0.5f)));
-        
+
         Node* node = scene_->CreateChild("FromScratchObject");
         node->SetPosition(Vector3(0.0f, 3.0f, 0.0f));
         StaticModel* object = node->CreateComponent<StaticModel>();
@@ -254,7 +252,7 @@ void DynamicGeometry::CreateInstructions()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Construct new Text object, set string to display and font to use
     Text* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
@@ -274,7 +272,7 @@ void DynamicGeometry::CreateInstructions()
 void DynamicGeometry::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -291,23 +289,23 @@ void DynamicGeometry::MoveCamera(float timeStep)
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
         return;
-    
+
     Input* input = GetSubsystem<Input>();
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     IntVector2 mouseMove = input->GetMouseMove();
     yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
     pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
     pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-    
+
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -322,15 +320,15 @@ void DynamicGeometry::MoveCamera(float timeStep)
 void DynamicGeometry::AnimateObjects(float timeStep)
 {
     PROFILE(AnimateObjects);
-    
+
     time_ += timeStep * 100.0f;
-    
+
     // Repeat for each of the cloned vertex buffers
     for (unsigned i = 0; i < animatingBuffers_.Size(); ++i)
     {
         float startPhase = time_ + i * 30.0f;
         VertexBuffer* buffer = animatingBuffers_[i];
-        
+
         // Lock the vertex buffer for update and rewrite positions with sine wave modulated ones
         // Cannot use discard lock as there is other data (normals, UVs) that we are not overwriting
         unsigned char* vertexData = (unsigned char*)buffer->Lock(0, buffer->GetVertexCount());
@@ -348,7 +346,7 @@ void DynamicGeometry::AnimateObjects(float timeStep)
                 dest.y_ = src.y_ * (1.0f + 0.1f * Sin(phase + 60.0f));
                 dest.z_ = src.z_ * (1.0f + 0.1f * Sin(phase + 120.0f));
             }
-            
+
             buffer->Unlock();
         }
     }
@@ -360,7 +358,7 @@ void DynamicGeometry::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Toggle animation with space
     Input* input = GetSubsystem<Input>();
     if (input->GetKeyPress(KEY_SPACE))
@@ -368,7 +366,7 @@ void DynamicGeometry::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
-    
+
     // Animate objects' vertex data if enabled
     if (animate_)
         AnimateObjects(timeStep);

+ 1 - 3
Source/Samples/35_SignedDistanceFieldText/SignedDistanceFieldText.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -120,7 +118,7 @@ void SignedDistanceFieldText::CreateScene()
         mushroomTitleText->SetFont(cache->GetResource<Font>("Fonts/BlueHighway.sdf"), 24);
 
         mushroomTitleText->SetColor(Color::RED);
-        
+
         if (i % 3 == 1)
         {
             mushroomTitleText->SetColor(Color::GREEN);

+ 0 - 2
Source/Samples/36_Urho2DTileMap/Urho2DTileMap.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>

+ 0 - 2
Source/Samples/37_UIDrag/UIDrag.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/UI/Button.h>
 #include <Urho3D/UI/Font.h>

+ 11 - 15
Source/Samples/38_SceneAndUILoad/SceneAndUILoad.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/Camera.h>
@@ -29,10 +27,8 @@
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
 #include <Urho3D/UI/Button.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/UI.h>
 #include <Urho3D/UI/UIEvents.h>
 
@@ -54,10 +50,10 @@ void SceneAndUILoad::Start()
 
     // Create the scene content
     CreateScene();
-    
+
     // Create the UI content
     CreateUI();
-    
+
     // Setup the viewport for displaying the scene
     SetupViewport();
 
@@ -88,7 +84,7 @@ void SceneAndUILoad::CreateUI()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UI* ui = GetSubsystem<UI>();
-    
+
     // Set up global UI style into the root UI element
     XMLFile* style = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
     ui->GetRoot()->SetDefaultStyle(style);
@@ -101,7 +97,7 @@ void SceneAndUILoad::CreateUI()
     // Set starting position of the cursor at the rendering window center
     Graphics* graphics = GetSubsystem<Graphics>();
     cursor->SetPosition(graphics->GetWidth() / 2, graphics->GetHeight() / 2);
-    
+
     // Load UI content prepared in the editor and add to the UI hierarchy
     SharedPtr<UIElement> layoutRoot = ui->LoadLayout(cache->GetResource<XMLFile>("UI/UILoadExample.xml"));
     ui->GetRoot()->AddChild(layoutRoot);
@@ -118,7 +114,7 @@ void SceneAndUILoad::CreateUI()
 void SceneAndUILoad::SetupViewport()
 {
     Renderer* renderer = GetSubsystem<Renderer>();
-    
+
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
     renderer->SetViewport(0, viewport);
@@ -136,16 +132,16 @@ void SceneAndUILoad::MoveCamera(float timeStep)
     UI* ui = GetSubsystem<UI>();
     Input* input = GetSubsystem<Input>();
     ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
-    
+
     // Do not move if the UI has a focused element
     if (ui->GetFocusElement())
         return;
-    
+
     // Movement speed as world units per second
     const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
-    
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     // Only move the camera when the cursor is hidden
     if (!ui->GetCursor()->IsVisible())
@@ -154,11 +150,11 @@ void SceneAndUILoad::MoveCamera(float timeStep)
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-        
+
         // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
         cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
     }
-    
+
     // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
     if (input->GetKeyDown('W'))
         cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
@@ -176,7 +172,7 @@ void SceneAndUILoad::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
-    
+
     // Move the camera, scale movement with time step
     MoveCamera(timeStep);
 }

+ 0 - 8
Source/Samples/39_CrowdNavigation/CrowdNavigation.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/Graphics/AnimatedModel.h>
@@ -31,24 +29,18 @@
 #include <Urho3D/Graphics/Graphics.h>
 #include <Urho3D/Graphics/Light.h>
 #include <Urho3D/Graphics/Material.h>
-#include <Urho3D/Graphics/Model.h>
 #include <Urho3D/Graphics/Octree.h>
 #include <Urho3D/Graphics/Renderer.h>
-#include <Urho3D/Graphics/StaticModel.h>
 #include <Urho3D/Graphics/Zone.h>
 #include <Urho3D/Input/Input.h>
-#include <Urho3D/Math/MathDefs.h>
 #include <Urho3D/Navigation/CrowdAgent.h>
-#include <Urho3D/Navigation/CrowdManager.h>
 #include <Urho3D/Navigation/DynamicNavigationMesh.h>
 #include <Urho3D/Navigation/Navigable.h>
 #include <Urho3D/Navigation/NavigationEvents.h>
 #include <Urho3D/Navigation/Obstacle.h>
 #include <Urho3D/Navigation/OffMeshConnection.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Resource/XMLFile.h>
 #include <Urho3D/Scene/Scene.h>
-#include <Urho3D/UI/Cursor.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/UI.h>

+ 6 - 8
Source/Samples/40_Localization/L10n.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Graphics/Material.h>
 #include <Urho3D/Graphics/Model.h>
@@ -82,7 +80,7 @@ void L10n::CreateGUI()
 {
     // Get localization subsystem
     Localization* l10n = GetSubsystem<Localization>();
-    
+
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     UIElement* root = GetSubsystem<UI>()->GetRoot();
     root->SetDefaultStyle(cache->GetResource<XMLFile>("UI/DefaultStyle.xml"));
@@ -114,14 +112,14 @@ void L10n::CreateGUI()
     window->AddChild(b);
     b->SetStyle("Button");
     b->SetMinHeight(24);
-    
+
     Text* t = b->CreateChild<Text>("ButtonTextChangeLang");
     // The showing text value will automatically change when language is changed
     t->SetAutoLocalizable(true);
     // The text value used as a string identifier in this mode.
     // Remember that a letter case of the id and of the lang name is important.
     t->SetText("Press this button");
-    
+
     t->SetAlignment(HA_CENTER, VA_CENTER);
     t->SetStyle("Text");
     SubscribeToEvent(b, E_RELEASED, HANDLER(L10n, HandleChangeLangButtonPressed));
@@ -133,10 +131,10 @@ void L10n::CreateGUI()
     t = b->CreateChild<Text>("ButtonTextQuit");
     t->SetAlignment(HA_CENTER, VA_CENTER);
     t->SetStyle("Text");
-    
+
     // Manually set text in the current language
     t->SetText(l10n->Get("quit"));
-    
+
     SubscribeToEvent(b, E_RELEASED, HANDLER(L10n, HandleQuitButtonPressed));
 }
 
@@ -148,7 +146,7 @@ void L10n::CreateScene()
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     scene_ = new Scene(context_);
     scene_->CreateComponent<Octree>();
-    
+
     Zone* zone = scene_->CreateComponent<Zone>();
     zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
     zone->SetAmbientColor(Color(0.5f, 0.5f, 0.5f));

+ 0 - 2
Source/Samples/41_DatabaseDemo/DatabaseDemo.cpp

@@ -20,8 +20,6 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/CoreEvents.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Database/Database.h>

File diff suppressed because it is too large
+ 143 - 152
Source/Tools/AssetImporter/AssetImporter.cpp


File diff suppressed because it is too large
+ 148 - 155
Source/Tools/OgreImporter/OgreImporter.cpp


+ 1 - 5
Source/Tools/PackageTool/PackageTool.cpp

@@ -20,20 +20,16 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
 #include <Urho3D/Container/ArrayPtr.h>
+#include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/IO/File.h>
 #include <Urho3D/IO/FileSystem.h>
-#include <Urho3D/Core/ProcessUtils.h>
 
 #ifdef WIN32
 #include <windows.h>
 #endif
 
-#include <cstdio>
-#include <cstring>
 #include <LZ4/lz4.h>
 #include <LZ4/lz4hc.h>
 

+ 17 - 21
Source/Tools/RampGenerator/RampGenerator.cpp

@@ -20,10 +20,7 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Container/ArrayPtr.h>
-#include <Urho3D/Math/MathDefs.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Core/StringUtils.h>
 
@@ -31,7 +28,6 @@
 #include <windows.h>
 #endif
 
-#include <STB/stb_image.h>
 #include <STB/stb_image_write.h>
 
 #include <Urho3D/DebugNew.h>
@@ -44,13 +40,13 @@ void Run(const Vector<String>& arguments);
 int main(int argc, char** argv)
 {
     Vector<String> arguments;
-    
+
     #ifdef WIN32
     arguments = ParseArguments(GetCommandLineW());
     #else
     arguments = ParseArguments(argc, argv);
     #endif
-    
+
     Run(arguments);
     return 0;
 }
@@ -59,59 +55,59 @@ void Run(const Vector<String>& arguments)
 {
     if (arguments.Size() < 3)
         ErrorExit("Usage: RampGenerator <output png file> <width> <power> [dimensions]\n");
-    
+
     int width = ToInt(arguments[1]);
     float power = ToFloat(arguments[2]);
-    
+
     int dimensions = 1;
     if (arguments.Size() > 3)
         dimensions = ToInt(arguments[3]);
-        
+
     if (width < 2)
         ErrorExit("Width must be at least 2");
-    
+
     if (dimensions < 1 || dimensions > 2)
         ErrorExit("Dimensions must be 1 or 2");
-    
+
     if (dimensions == 1)
     {
         SharedArrayPtr<unsigned char> data(new unsigned char[width]);
-        
+
         for (int i = 0; i < width; ++i)
         {
             float x = ((float)i) / ((float)(width - 1));
-            
+
             data[i] = (unsigned char)((1.0f - pow(x, power)) * 255.0f);
         }
-        
+
         // Ensure start is full bright & end is completely black
         data[0] = 255;
         data[width - 1] = 0;
-        
+
         stbi_write_png(arguments[0].CString(), width, 1, 1, data.Get(), 0);
     }
-    
+
     if (dimensions == 2)
     {
         SharedArrayPtr<unsigned char> data(new unsigned char[width * width]);
-        
+
         for (int y = 0; y < width; ++y)
         {
             for (int x = 0; x < width; ++x)
             {
                 unsigned i = y * width + x;
-                
+
                 float halfWidth = width * 0.5f;
                 float xf = (x - halfWidth + 0.5f) / (halfWidth - 0.5f);
                 float yf = (y - halfWidth + 0.5f) / (halfWidth - 0.5f);
                 float dist = sqrtf(xf * xf + yf * yf);
                 if (dist > 1.0f)
                     dist = 1.0f;
-                
+
                 data[i] = (unsigned char)((1.0f - pow(dist, power)) * 255.0f);
             }
         }
-        
+
         // Ensure the border is completely black
         for (int x = 0; x < width; ++x)
         {
@@ -120,7 +116,7 @@ void Run(const Vector<String>& arguments)
             data[x * width] = 0;
             data[x * width + (width - 1)] = 0;
         }
-        
+
         stbi_write_png(arguments[0].CString(), width, width, 1, data.Get(), 0);
     }
 }

+ 3 - 5
Source/Tools/ScriptCompiler/ScriptCompiler.cpp

@@ -20,14 +20,12 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
+#include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/IO/File.h>
 #include <Urho3D/IO/FileSystem.h>
 #include <Urho3D/IO/Log.h>
-#include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Resource/ResourceCache.h>
 #include <Urho3D/Script/Script.h>
 #include <Urho3D/Script/ScriptFile.h>
@@ -81,7 +79,7 @@ int main(int argc, char** argv)
     SharedPtr<Context> context(new Context());
     SharedPtr<Engine> engine(new Engine(context));
     context->RegisterSubsystem(new Script(context));
-    
+
     // In API dumping mode initialize the engine and instantiate LuaScript system if available so that we
     // can dump attributes from as many classes as possible
     if (dumpApiMode)
@@ -97,7 +95,7 @@ int main(int argc, char** argv)
         context->RegisterSubsystem(new LuaScript(context));
     #endif
     }
-    
+
     Log* log = context->GetSubsystem<Log>();
     // Register Log subsystem manually if compiled without logging support
     if (!log)

+ 7 - 15
Source/Tools/SpritePacker/SpritePacker.cpp

@@ -20,32 +20,24 @@
 // THE SOFTWARE.
 //
 
-#include <limits.h>
-
-#define STBRP_LARGE_RECTS
-#define STB_RECT_PACK_IMPLEMENTATION
-#include "stb_rect_pack.h"
-
-#include <Urho3D/Urho3D.h>
-
 #include <Urho3D/Core/Context.h>
-#include <Urho3D/Container/Vector.h>
 #include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Core/StringUtils.h>
-#include <Urho3D/Math/MathDefs.h>
-
-#include <Urho3D/Resource/Image.h>
-#include <Urho3D/IO/FileSystem.h>
 #include <Urho3D/IO/File.h>
+#include <Urho3D/IO/FileSystem.h>
+#include <Urho3D/IO/Log.h>
+#include <Urho3D/Resource/Image.h>
 #include <Urho3D/Resource/XMLElement.h>
 #include <Urho3D/Resource/XMLFile.h>
-#include <Urho3D/IO/Log.h>
-#include <Urho3D/Math/Color.h>
 
 #ifdef WIN32
 #include <windows.h>
 #endif
 
+#define STBRP_LARGE_RECTS
+#define STB_RECT_PACK_IMPLEMENTATION
+#include "stb_rect_pack.h"
+
 #include <Urho3D/DebugNew.h>
 
 using namespace Urho3D;

+ 2 - 5
Source/Tools/Urho3DPlayer/Urho3DPlayer.cpp

@@ -20,13 +20,10 @@
 // THE SOFTWARE.
 //
 
-#include <Urho3D/Urho3D.h>
-
+#include <Urho3D/Core/Main.h>
 #include <Urho3D/Engine/Engine.h>
 #include <Urho3D/IO/FileSystem.h>
 #include <Urho3D/IO/Log.h>
-#include <Urho3D/Core/Main.h>
-#include <Urho3D/Core/ProcessUtils.h>
 #include <Urho3D/Resource/ResourceCache.h>
 #include <Urho3D/Resource/ResourceEvents.h>
 
@@ -194,7 +191,7 @@ void Urho3DPlayer::Stop()
     {
     }
 #endif
-    
+
 #ifdef URHO3D_LUA
     else
     {

+ 0 - 2
Source/Urho3D/Precompiled.h

@@ -25,8 +25,6 @@
 #ifndef URHO3D_PCH_INCLUDED
 #define URHO3D_PCH_INCLUDED
 
-#include "Urho3D.h"
-
 #include "Container/HashMap.h"
 #include "Container/HashSet.h"
 #include "Container/Sort.h"

Some files were not shown because too many files changed in this diff