Browse Source

Added Billboards sample.
Some code cleanup/formatting of the other samples.

Lasse Öörni 12 years ago
parent
commit
a9eb0e1e61

+ 1 - 1
Source/Samples/03_Sprites/Sprites.cpp

@@ -34,7 +34,7 @@
 // Number of sprites to draw
 static const unsigned NUM_SPRITES = 100;
 
-// User variable identifier for storing sprite velocity within the UI element
+// Custom variable identifier for storing sprite velocity within the UI element
 static const ShortStringHash VAR_VELOCITY("Velocity");
 
 // Expands to this example's entry-point

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

@@ -83,8 +83,8 @@ void StaticScene::CreateScene()
     // plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
     // (100 x 100 world units)
     Node* planeNode = scene_->CreateChild("Plane");
-    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
     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/Stone.xml"));
     
@@ -106,10 +106,10 @@ void StaticScene::CreateScene()
     for (unsigned i = 0; i < NUM_OBJECTS; ++i)
     {
         Node* mushroomNode = scene_->CreateChild("Mushroom");
-        StaticModel* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
         mushroomNode->SetPosition(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
         mushroomNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
         mushroomNode->SetScale(1.0f + Random(1.0f));
+        StaticModel* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
         mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
         mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
     }

+ 2 - 1
Source/Samples/05_AnimatingScene/AnimatingScene.cpp

@@ -98,12 +98,13 @@ void AnimatingScene::CreateScene()
     for (unsigned i = 0; i < NUM_OBJECTS; ++i)
     {
         Node* boxNode = scene_->CreateChild("Box");
-        StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
         boxNode->SetPosition(Vector3(Random(200.0f) - 100.0f, Random(200.0f) - 100.0f, Random(200.0f) - 100.0f));
         // Orient using random pitch, yaw and roll Euler angles
         boxNode->SetRotation(Quaternion(Random(360.0f), Random(360.0f), Random(360.0f)));
+        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>();

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

@@ -30,7 +30,7 @@
 #include "Font.h"
 #include "Graphics.h"
 #include "Input.h"
-#include "Log.h"
+#include "Light.h"
 #include "Material.h"
 #include "Model.h"
 #include "Octree.h"
@@ -87,8 +87,8 @@ void SkeletalAnimation::CreateScene()
     
     // Create scene node & StaticModel component for showing a static plane
     Node* planeNode = scene_->CreateChild("Plane");
-    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
     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/Stone.xml"));
     
@@ -116,9 +116,9 @@ void SkeletalAnimation::CreateScene()
     for (unsigned i = 0; i < NUM_OBJECTS; ++i)
     {
         Node* modelNode = scene_->CreateChild("Jack");
-        AnimatedModel* modelObject = modelNode->CreateComponent<AnimatedModel>();
         modelNode->SetPosition(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
         modelNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
+        AnimatedModel* modelObject = modelNode->CreateComponent<AnimatedModel>();
         modelObject->SetModel(cache->GetResource<Model>("Models/Jack.mdl"));
         modelObject->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
         modelObject->SetCastShadows(true);

+ 1 - 1
Source/Samples/06_SkeletalAnimation/SkeletalAnimation.h

@@ -31,7 +31,7 @@ using namespace Urho3D;
 /// Skeletal animation example.
 /// This sample demonstrates:
 ///     - Populating a 3D scene with skeletally animated AnimatedModel components;
-///     - Moving the aniamted models and advancing their animation;
+///     - Moving the animated models and advancing their animation;
 ///     - Enabling a cascaded shadow map on a directional light, which allows high-quality shadows from
 ///       over a large area (typically used in outdoor scenes for shadows cast by sunlight);
 ///     - Displaying renderer debug geometry;

+ 349 - 0
Source/Samples/07_Billboards/Billboards.cpp

@@ -0,0 +1,349 @@
+//
+// Copyright (c) 2008-2013 the Urho3D project.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#include "BillboardSet.h"
+#include "Camera.h"
+#include "CoreEvents.h"
+#include "DebugRenderer.h"
+#include "Engine.h"
+#include "Font.h"
+#include "Graphics.h"
+#include "Input.h"
+#include "Light.h"
+#include "Material.h"
+#include "Model.h"
+#include "Octree.h"
+#include "Renderer.h"
+#include "ResourceCache.h"
+#include "StaticModel.h"
+#include "Text.h"
+#include "UI.h"
+#include "Zone.h"
+
+#include "Billboards.h"
+
+#include "DebugNew.h"
+
+// Custom variable identifier for storing light angle into the light scene nodes
+static const ShortStringHash VAR_ANGLE("Angle");
+
+// Expands to this example's entry-point
+DEFINE_APPLICATION_MAIN(Billboards)
+
+Billboards::Billboards(Context* context) :
+    Sample(context),
+    yaw_(0.0f),
+    pitch_(0.0f),
+    drawDebug_(false)
+{
+}
+
+void Billboards::Start()
+{
+    // Execute base class startup
+    Sample::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 and render post-update events
+    SubscribeToEvents();
+}
+
+void Billboards::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). 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 color control
+    Node* zoneNode = scene_->CreateChild("Zone");
+    Zone* zone = zoneNode->CreateComponent<Zone>();
+    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
+    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("Light");
+    lightNode->SetDirection(Vector3(0.5f, -1.0f, 0.5f));
+    Light* light = lightNode->CreateComponent<Light>();
+    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)
+    {
+        for (int x = -5; x <= 5; ++x)
+        {
+            Node* floorNode = scene_->CreateChild("FloorTile");
+            floorNode->SetPosition(Vector3(x * 20.5f, -0.5f, y * 20.5f));
+            floorNode->SetScale(Vector3(20.0f, 1.0f, 20.f));
+            StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
+            floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
+            floorObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
+        }
+    }
+    
+    // Create groups of mushrooms, which act as shadows casters
+    const unsigned NUM_MUSHROOMGROUPS = 20;
+    const unsigned NUM_MUSHROOMS = 50;
+    
+    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(180.0f) - 90.0f, 0.0f, Random(180.0f) - 90.0f));
+        
+        for (unsigned j = 0; j < NUM_MUSHROOMS; ++j)
+        {
+            Node* mushroomNode = groupNode->CreateChild("Mushroom");
+            mushroomNode->SetPosition(Vector3(Random(20.0f) - 10.0f, 0.0f, Random(20.0f) - 10.0f));
+            mushroomNode->SetRotation(Quaternion(0.0f, Random() * 360.0f, 0.0f));
+            mushroomNode->SetScale(1.0f + Random() * 2.0f);
+            StaticModel* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
+            mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
+            mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
+            mushroomObject->SetCastShadows(true);
+        }
+    }
+    
+    // Create billboard sets (floating smoke)
+    const unsigned NUM_BILLBOARDNODES = 30;
+    const unsigned NUM_BILLBOARDS = 15;
+
+    for (unsigned i = 0; i < NUM_BILLBOARDNODES; ++i)
+    {
+        Node* smokeNode = scene_->CreateChild("Smoke");
+        smokeNode->SetPosition(Vector3(Random(200.0f) - 100.0f, Random(15.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);
+            bb->position_ = Vector3(Random(15.0f) - 7.5f, Random(8.0f) - 4.0f, Random(15.0f) - 7.5f);
+            bb->size_ = Vector2(Random(2.0f) + 3.0f, Random(2.0f) + 3.0f);
+            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 = 20;
+    
+    for (unsigned i = 0; i < NUM_LIGHTS; ++i)
+    {
+        Node* lightNode = scene_->CreateChild("Light");
+        Light* light = lightNode->CreateComponent<Light>();
+
+        Vector3 position(Random(150.0f) - 75.0f, Random(30.f) + 30.0f, Random(150.0f) - 75.0f);
+        Color color((Rand() & 1) * 0.5f + 0.5f, (Rand() & 1) * 0.5f + 0.5f, (Rand() & 1) * 0.5f + 0.5f);
+        // If color is dark grey, use white instead
+        if (color.r_ == 0.5f && color.g_ == 0.5f && color.b_ == 0.5f)
+            color = Color(1.0f, 1.0f, 1.0f);
+
+        float angle = Random() * 360.0f;
+
+        lightNode->SetPosition(position);
+        lightNode->SetDirection(Vector3(sinf(angle * M_DEGTORAD), -1.0f, cosf(angle * M_DEGTORAD)));
+        // Store the original angle as a custom variable of the node
+        lightNode->SetVar(VAR_ANGLE, angle);
+        
+        light->SetLightType(LIGHT_SPOT);
+        light->SetRange(75.0f);
+        light->SetRampTexture(cache->GetResource<Texture2D>("Textures/RampExtreme.png"));
+        light->SetFov(15.0f);
+        light->SetColor(color);
+        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 CPU performance
+        light->SetShadowDistance(200.0f);
+        light->SetShadowFadeDistance(150.0f);
+        // Set half resolution for the shadow maps for increased performance
+        light->SetShadowResolution(0.5f);
+        // The spot lights will not have anything near them, so move the near plane of the shadow camera farther
+        // 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));
+}
+
+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("Use WASD keys and mouse to move\nSpace to toggle debug geometry\n");
+    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);
+    instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
+}
+
+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);
+}
+
+void Billboards::MoveCamera(float timeStep)
+{
+    // Do not move if the UI has a focused element (the console)
+    UI* ui = GetSubsystem<UI>();
+    if (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_->TranslateRelative(Vector3::FORWARD * MOVE_SPEED * timeStep);
+    if (input->GetKeyDown('S'))
+        cameraNode_->TranslateRelative(Vector3::BACK * MOVE_SPEED * timeStep);
+    if (input->GetKeyDown('A'))
+        cameraNode_->TranslateRelative(Vector3::LEFT * MOVE_SPEED * timeStep);
+    if (input->GetKeyDown('D'))
+        cameraNode_->TranslateRelative(Vector3::RIGHT * MOVE_SPEED * timeStep);
+}
+
+void Billboards::AnimateScene(float timeStep)
+{
+    // Get the light and billboard scene nodes
+    PODVector<Node*> lightNodes;
+    PODVector<Node*> billboardNodes;
+    scene_->GetChildrenWithComponent<Light>(lightNodes);
+    scene_->GetChildrenWithComponent<BillboardSet>(billboardNodes);
+    
+    const float LIGHT_ROTATION_SPEED = 10.0f;
+    const float BILLBOARD_ROTATION_SPEED = 50.0f;
+    
+    // Rotate the lights
+    for (unsigned i = 0; i < lightNodes.Size(); ++i)
+    {
+        Node* lightNode = lightNodes[i];
+        
+        float angle = lightNode->GetVar(VAR_ANGLE).GetFloat();
+        angle += LIGHT_ROTATION_SPEED * timeStep;
+        lightNode->SetDirection(Vector3(sinf(angle * M_DEGTORAD), -1.0f, cosf(angle * M_DEGTORAD)));
+        lightNode->SetVar(VAR_ANGLE, angle);
+    }
+    
+    // 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();
+    }
+}
+
+void Billboards::SubscribeToEvents()
+{
+    // Subscribes HandleUpdate() method for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(Billboards, HandleUpdate));
+    
+    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, sent after Renderer subsystem is
+    // done with defining the draw calls for the viewports (but before actually executing them)
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Billboards, HandlePostRenderUpdate));
+}
+
+void Billboards::HandleUpdate(StringHash eventType, VariantMap& eventData)
+{
+    // Event parameters are always defined inside a namespace corresponding to the event's name
+    using namespace Update;
+
+    // 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);
+    
+    // Check for space pressed and toggle debug geometry
+    if (GetSubsystem<Input>()->GetKeyPress(KEY_SPACE))
+        drawDebug_ = !drawDebug_;
+}
+
+void Billboards::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
+{
+    // If draw debug mode is enabled, draw viewport debug geometry. This time use depth test, as otherwise the result becomes
+    // hard to interpret due to large object count
+    if (drawDebug_)
+        GetSubsystem<Renderer>()->DrawDebugGeometry(true);
+}

+ 76 - 0
Source/Samples/07_Billboards/Billboards.h

@@ -0,0 +1,76 @@
+//
+// Copyright (c) 2008-2013 the Urho3D project.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "Sample.h"
+#include "Scene.h"
+
+// All Urho3D classes reside in namespace Urho3D
+using namespace Urho3D;
+
+/// Billboard example.
+/// This sample demonstrates:
+///     - Populating a 3D scene with billboard sets and several shadow casting spotlights;
+///     - Parenting scene nodes to allow more intuitive creation of groups of objects;
+///     - Examining rendering performance with a somewhat large object and light count;
+class Billboards : public Sample
+{
+    // Mandatory when deriving from Object, enables type information
+    OBJECT(Billboards)
+
+public:
+    /// Construct.
+    Billboards(Context* context);
+
+    /// Setup after engine initialization and before running the main loop.
+    virtual void Start();
+
+private:
+    /// Constructs the scene content.
+    void CreateScene();
+    /// Constructs an instruction text to the UI.
+    void CreateInstructions();
+    /// Sets up a viewport for displaying the scene.
+    void SetupViewport();
+    /// Reads input and moves the camera.
+    void MoveCamera(float timeStep);
+    /// Animates the scene.
+    void AnimateScene(float timeStep);
+    /// Subscribe to application-wide logic update events.
+    void SubscribeToEvents();
+    /// Callback method invoked when a logic update event is dispatched.
+    void HandleUpdate(StringHash eventType, VariantMap& eventData);
+    /// Callback method invoked when the post-render update event is dispatched.
+    void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
+    
+    /// Scene.
+    SharedPtr<Scene> scene_;
+    /// Camera scene node.
+    SharedPtr<Node> cameraNode_;
+    /// Camera yaw angle.
+    float yaw_;
+    /// Camera pitch angle.
+    float pitch_;
+    /// Flag for drawing debug geometry.
+    bool drawDebug_;
+};

+ 32 - 0
Source/Samples/07_Billboards/CMakeLists.txt

@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2008-2013 the Urho3D project.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+# Define target name
+set (TARGET_NAME 07_Billboards)
+
+# Define source files
+file (GLOB CPP_FILES *.cpp)
+file (GLOB H_FILES *.h)
+set (SOURCE_FILES ${CPP_FILES} ${H_FILES} ${COMMON_SAMPLE_H_FILES})
+
+# Setup target with resource copying
+setup_main_executable ()

+ 1 - 0
Source/Samples/CMakeLists.txt

@@ -43,3 +43,4 @@ add_subdirectory (03_Sprites)
 add_subdirectory (04_StaticScene)
 add_subdirectory (05_AnimatingScene)
 add_subdirectory (06_SkeletalAnimation)
+add_subdirectory (07_Billboards)