X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Frendering-basic-light%2Frendering-basic-light-example.cpp;h=6d92c0d00ed622347436364c4e2e661fb4ab7b62;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=f9b960b78709eb19a2955980b41b98163abaf1a5;hpb=694dced621016315f10a5bdbd3f4552f5e29e380;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/rendering-basic-light/rendering-basic-light-example.cpp b/examples/rendering-basic-light/rendering-basic-light-example.cpp index f9b960b..6d92c0d 100644 --- a/examples/rendering-basic-light/rendering-basic-light-example.cpp +++ b/examples/rendering-basic-light/rendering-basic-light-example.cpp @@ -15,8 +15,8 @@ * */ -#include #include +#include using namespace Dali; using namespace Toolkit; @@ -25,49 +25,49 @@ using namespace Toolkit; namespace { - -const char* BASIC_LIGHT_THEME( DEMO_STYLE_DIR "basic-light-theme.json" ); +const char* BASIC_LIGHT_THEME(DEMO_STYLE_DIR "basic-light-theme.json"); const char* const CUSTOM_BASIC_LIGHT_THEME = "BasicLightButton"; struct Material { - const char *name; - Vector3 ambient; - Vector3 diffuse; - Vector3 specular; - float shininess; + const char* name; + Vector3 ambient; + Vector3 diffuse; + Vector3 specular; + float shininess; }; Material material[] = -{ - {"Emerald", Vector3( 0.0215f, 0.1745f, 0.0215f ), Vector3( 0.07568f, 0.61424f, 0.07568f ), Vector3( 0.633, 0.727811f, 0.633f ), 0.6f }, - {"Jade", Vector3( 0.135f, 0.2225f, 0.1575f ), Vector3( 0.54f, 0.89f, 0.63f ), Vector3( 0.316228f, 0.316228f, 0.316228f ), 0.1f }, - {"Obsidian", Vector3( 0.05375f, 0.05f, 0.06625f ), Vector3( 0.18275f, 0.17f, 0.22525f ), Vector3( 0.332741f, 0.328634f, 0.346435f ), 0.3f }, - {"Perl", Vector3( 0.25f, 0.20725f, 0.20725f ), Vector3( 1.0f, 0.829f, 0.829f ), Vector3( 0.296648f, 0.296648f, 0.296648f ), 0.088f }, - {"Ruby", Vector3( 0.1745f, 0.01175f, 0.01175f ), Vector3( 0.61424f, 0.04136f, 0.04136f ), Vector3( 0.727811f, 0.626959f, 0.626959f ), 0.6f }, - {"Turquoise", Vector3( 0.1f, 0.18725f, 0.1745f ), Vector3( 0.396f, 0.74151f, 0.69102f ), Vector3( 0.297254, 0.30829f, 0.306678f ), 0.1f }, - {"Brass", Vector3( 0.329412f, 0.223529f, 0.027451f ), Vector3( 0.780392f, 0.568627f, 0.113725f ), Vector3( 0.992157f, 0.941176f, 0.807843f ), 0.21794872f }, - {"Bronze", Vector3( 0.2125f, 0.1275f, 0.054f ), Vector3( 0.714f, 0.4284f, 0.18144f ), Vector3( 0.393548f, 0.271906f, 0.166721f ), 0.2f }, - {"Chrome", Vector3( 0.25f, 0.25f, 0.25f ), Vector3( 0.4f, 0.4f, 0.4f), Vector3( 0.774597f, 0.774597f, 0.774597f ), 0.6f }, - {"Copper", Vector3( 0.19125f, 0.0735f, 0.0225f ), Vector3( 0.7038f, 0.27048f, 0.0828f ), Vector3( 0.256777f, 0.137622f, 0.086014f ), 0.1f }, - {"Gold", Vector3( 0.24725f, 0.1995f, 0.0745f ), Vector3( 0.75164f, 0.60648f, 0.22648f ), Vector3( 0.628281f, 0.555802f, 0.366065f ), 0.4f }, - {"Silver", Vector3( 0.19225f, 0.19225f, 0.19225f ), Vector3( 0.50754f, 0.50754f, 0.50754f ), Vector3( 0.508273f, 0.508273f, 0.508273f ), 0.4f }, - {"Black plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.01f, 0.01f, 0.01f ), Vector3( 0.50f, 0.50f, 0.50f ), 0.25f }, - {"Cyan plastic", Vector3( 0.0f, 0.1f, 0.06f ), Vector3( 0.0f, 0.50980392f, 0.50980392f ), Vector3( 0.50196078f, 0.50196078f, 0.50196078f ), 0.25f }, - {"Green plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.1f, 0.35f, 0.1f ), Vector3( 0.45, 0.55, 0.45 ), 0.25f }, - {"Red plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.5f, 0.0f, 0.0f ), Vector3( 0.7f, 0.6f, 0.6f ), 0.25f }, - {"White plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.55f, 0.55f, 0.55f ), Vector3( 0.7f, 0.7f, 0.7f ), 0.25f }, - {"Yellow plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.5f, 0.5f, 0.0f ), Vector3( 0.6f, 0.6f, 0.5f ), 0.25f }, - {"Black rubber", Vector3( 0.02f, 0.02f, 0.02f ), Vector3( 0.01f, 0.01f, 0.01f ), Vector3( 0.4f, 0.4f, 0.4f ), 0.078125f }, - {"Cyan rubber", Vector3( 0.0f, 0.05f, 0.05f ), Vector3( 0.4f, 0.5f, 0.5f ), Vector3( 0.04f, 0.7f, 0.7f ), 0.078125f }, - {"Green rubber", Vector3( 0.0f, 0.05f, 0.0f ), Vector3( 0.4f, 0.5f, 0.4f ), Vector3( 0.04f, 0.7f, 0.04f ), 0.078125f }, - {"Red rubber", Vector3( 0.05f, 0.0f, 0.0f ), Vector3( 0.5f, 0.4f, 0.4f ), Vector3( 0.7f, 0.04f, 0.04f ), 0.078125f }, - {"White rubber", Vector3( 0.05f, 0.05f, 0.05f ), Vector3( 0.5f, 0.5f, 0.5f ), Vector3( 0.7f, 0.7f, 0.7f ), 0.078125f }, - {"Yellow rubber", Vector3( 0.05f, 0.05f, 0.0f ), Vector3( 0.5f, 0.5f, 0.4f ), Vector3( 0.7f, 0.7f, 0.04f ), 0.078125f } -}; + { + {"Emerald", Vector3(0.0215f, 0.1745f, 0.0215f), Vector3(0.07568f, 0.61424f, 0.07568f), Vector3(0.633, 0.727811f, 0.633f), 0.6f}, + {"Jade", Vector3(0.135f, 0.2225f, 0.1575f), Vector3(0.54f, 0.89f, 0.63f), Vector3(0.316228f, 0.316228f, 0.316228f), 0.1f}, + {"Obsidian", Vector3(0.05375f, 0.05f, 0.06625f), Vector3(0.18275f, 0.17f, 0.22525f), Vector3(0.332741f, 0.328634f, 0.346435f), 0.3f}, + {"Perl", Vector3(0.25f, 0.20725f, 0.20725f), Vector3(1.0f, 0.829f, 0.829f), Vector3(0.296648f, 0.296648f, 0.296648f), 0.088f}, + {"Ruby", Vector3(0.1745f, 0.01175f, 0.01175f), Vector3(0.61424f, 0.04136f, 0.04136f), Vector3(0.727811f, 0.626959f, 0.626959f), 0.6f}, + {"Turquoise", Vector3(0.1f, 0.18725f, 0.1745f), Vector3(0.396f, 0.74151f, 0.69102f), Vector3(0.297254, 0.30829f, 0.306678f), 0.1f}, + {"Brass", Vector3(0.329412f, 0.223529f, 0.027451f), Vector3(0.780392f, 0.568627f, 0.113725f), Vector3(0.992157f, 0.941176f, 0.807843f), 0.21794872f}, + {"Bronze", Vector3(0.2125f, 0.1275f, 0.054f), Vector3(0.714f, 0.4284f, 0.18144f), Vector3(0.393548f, 0.271906f, 0.166721f), 0.2f}, + {"Chrome", Vector3(0.25f, 0.25f, 0.25f), Vector3(0.4f, 0.4f, 0.4f), Vector3(0.774597f, 0.774597f, 0.774597f), 0.6f}, + {"Copper", Vector3(0.19125f, 0.0735f, 0.0225f), Vector3(0.7038f, 0.27048f, 0.0828f), Vector3(0.256777f, 0.137622f, 0.086014f), 0.1f}, + {"Gold", Vector3(0.24725f, 0.1995f, 0.0745f), Vector3(0.75164f, 0.60648f, 0.22648f), Vector3(0.628281f, 0.555802f, 0.366065f), 0.4f}, + {"Silver", Vector3(0.19225f, 0.19225f, 0.19225f), Vector3(0.50754f, 0.50754f, 0.50754f), Vector3(0.508273f, 0.508273f, 0.508273f), 0.4f}, + {"Black plastic", Vector3(0.0f, 0.0f, 0.0f), Vector3(0.01f, 0.01f, 0.01f), Vector3(0.50f, 0.50f, 0.50f), 0.25f}, + {"Cyan plastic", Vector3(0.0f, 0.1f, 0.06f), Vector3(0.0f, 0.50980392f, 0.50980392f), Vector3(0.50196078f, 0.50196078f, 0.50196078f), 0.25f}, + {"Green plastic", Vector3(0.0f, 0.0f, 0.0f), Vector3(0.1f, 0.35f, 0.1f), Vector3(0.45, 0.55, 0.45), 0.25f}, + {"Red plastic", Vector3(0.0f, 0.0f, 0.0f), Vector3(0.5f, 0.0f, 0.0f), Vector3(0.7f, 0.6f, 0.6f), 0.25f}, + {"White plastic", Vector3(0.0f, 0.0f, 0.0f), Vector3(0.55f, 0.55f, 0.55f), Vector3(0.7f, 0.7f, 0.7f), 0.25f}, + {"Yellow plastic", Vector3(0.0f, 0.0f, 0.0f), Vector3(0.5f, 0.5f, 0.0f), Vector3(0.6f, 0.6f, 0.5f), 0.25f}, + {"Black rubber", Vector3(0.02f, 0.02f, 0.02f), Vector3(0.01f, 0.01f, 0.01f), Vector3(0.4f, 0.4f, 0.4f), 0.078125f}, + {"Cyan rubber", Vector3(0.0f, 0.05f, 0.05f), Vector3(0.4f, 0.5f, 0.5f), Vector3(0.04f, 0.7f, 0.7f), 0.078125f}, + {"Green rubber", Vector3(0.0f, 0.05f, 0.0f), Vector3(0.4f, 0.5f, 0.4f), Vector3(0.04f, 0.7f, 0.04f), 0.078125f}, + {"Red rubber", Vector3(0.05f, 0.0f, 0.0f), Vector3(0.5f, 0.4f, 0.4f), Vector3(0.7f, 0.04f, 0.04f), 0.078125f}, + {"White rubber", Vector3(0.05f, 0.05f, 0.05f), Vector3(0.5f, 0.5f, 0.5f), Vector3(0.7f, 0.7f, 0.7f), 0.078125f}, + {"Yellow rubber", Vector3(0.05f, 0.05f, 0.0f), Vector3(0.5f, 0.5f, 0.4f), Vector3(0.7f, 0.7f, 0.04f), 0.078125f}}; int MaterialID = 0; +// clang-format off + /* * Vertex shader */ @@ -133,20 +133,20 @@ void main()\n gl_FragColor = vec4(result, 1.0);\n }\n ); +// clang-format on -} +} // namespace // This example shows per-pixel lighting of materials with different ambient, diffuse, specular and shininess parameters // class BasicLightController : public ConnectionTracker { public: - - BasicLightController( Application& application ) - : mApplication( application ) + BasicLightController(Application& application) + : mApplication(application) { // Connect to the Application's Init signal - mApplication.InitSignal().Connect( this, &BasicLightController::Create ); + mApplication.InitSignal().Connect(this, &BasicLightController::Create); } ~BasicLightController() @@ -155,27 +155,27 @@ public: } // The Init signal is received once (only) during the Application lifetime - void Create( Application& application ) + void Create(Application& application) { // Get a handle to the window Window window = application.GetWindow(); - window.SetBackgroundColor( Color::BLACK ); - mLabel = TextLabel::New( material[MaterialID].name ); - mLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); - mLabel.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.0f, 0.5f ) ); - mLabel.SetProperty( Actor::Property::SIZE, Vector2( window.GetSize().GetWidth() * 0.5f, window.GetSize().GetHeight() * 0.083f ) ); - mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); - mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); - mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f )); - window.Add( mLabel ); + window.SetBackgroundColor(Color::BLACK); + mLabel = TextLabel::New(material[MaterialID].name); + mLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); + mLabel.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5f, 0.0f, 0.5f)); + mLabel.SetProperty(Actor::Property::SIZE, Vector2(window.GetSize().GetWidth() * 0.5f, window.GetSize().GetHeight() * 0.083f)); + mLabel.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER"); + mLabel.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER"); + mLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + window.Add(mLabel); mButton = PushButton::New(); - mButton.SetProperty( Button::Property::LABEL, "Exit" ); - mButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - mButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); - mButton.ClickedSignal().Connect( this, &BasicLightController::OnExit ); - mButton.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.1f, 0.5f ) ); + mButton.SetProperty(Button::Property::LABEL, "Exit"); + mButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + mButton.ClickedSignal().Connect(this, &BasicLightController::OnExit); + mButton.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5f, 0.1f, 0.5f)); mButton.SetStyleName(CUSTOM_BASIC_LIGHT_THEME); - mButton.SetProperty( Actor::Property::COLOR, Vector4( material[MaterialID].diffuse) + Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); + mButton.SetProperty(Actor::Property::COLOR, Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f)); window.Add(mButton); // Step 1. Create shader @@ -194,28 +194,28 @@ public: PlayAnimation(); // Respond to a click anywhere on the window - window.GetRootLayer().TouchSignal().Connect( this, &BasicLightController::OnTouch ); + window.GetRootLayer().TouchedSignal().Connect(this, &BasicLightController::OnTouch); // Respond to key events - window.KeyEventSignal().Connect( this, &BasicLightController::OnKeyEvent ); + window.KeyEventSignal().Connect(this, &BasicLightController::OnKeyEvent); } /** * This function will change the material of the cube when touched */ - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch(Actor actor, const TouchEvent& touch) { if(touch.GetState(0) == PointState::UP) { - MaterialID++; - MaterialID %= MATERIALS_MAX; - - mShader.SetProperty( mShader.GetPropertyIndex( "material.ambient" ), material[MaterialID].ambient ); - mShader.SetProperty( mShader.GetPropertyIndex( "material.diffuse" ), material[MaterialID].diffuse ); - mShader.SetProperty( mShader.GetPropertyIndex( "material.specular" ), material[MaterialID].specular ); - mShader.SetProperty( mShader.GetPropertyIndex( "material.shininess" ), material[MaterialID].shininess * 128.0f ); - mLabel.SetProperty( TextLabel::Property::TEXT, material[MaterialID].name ); - mButton.SetProperty( Actor::Property::COLOR, Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f) ); + MaterialID++; + MaterialID %= MATERIALS_MAX; + + mShader.SetProperty(mShader.GetPropertyIndex("material.ambient"), material[MaterialID].ambient); + mShader.SetProperty(mShader.GetPropertyIndex("material.diffuse"), material[MaterialID].diffuse); + mShader.SetProperty(mShader.GetPropertyIndex("material.specular"), material[MaterialID].specular); + mShader.SetProperty(mShader.GetPropertyIndex("material.shininess"), material[MaterialID].shininess * 128.0f); + mLabel.SetProperty(TextLabel::Property::TEXT, material[MaterialID].name); + mButton.SetProperty(Actor::Property::COLOR, Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f)); } return true; } @@ -223,10 +223,10 @@ public: /** * This function will the terminate the application when the exit button is pressed */ - bool OnExit( Button button ) + bool OnExit(Button button) { - mApplication.Quit(); - return true; + mApplication.Quit(); + return true; } /** @@ -235,11 +235,11 @@ public: * Will use this to quit the application if Back or the Escape key is received * @param[in] event The key event information */ - void OnKeyEvent( const KeyEvent& event ) + void OnKeyEvent(const KeyEvent& event) { - if( event.state == KeyEvent::Down ) + if(event.GetState() == KeyEvent::DOWN) { - if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) { mApplication.Quit(); } @@ -258,81 +258,68 @@ public: Vector3 aNormal; }; - const Vector3 NORMAL0(-1.0f, 0.0f, 0.0f ); - const Vector3 NORMAL1( 0.0f, 1.0f, 0.0f ); - const Vector3 NORMAL2( 0.0f,-1.0f, 0.0f ); - const Vector3 NORMAL3( 0.0f, 0.0f, 1.0f ); - const Vector3 NORMAL4( 1.0f, 0.0f, 0.0f ); - const Vector3 NORMAL5( 0.0f, 0.0f,-1.0f ); + const Vector3 NORMAL0(-1.0f, 0.0f, 0.0f); + const Vector3 NORMAL1(0.0f, 1.0f, 0.0f); + const Vector3 NORMAL2(0.0f, -1.0f, 0.0f); + const Vector3 NORMAL3(0.0f, 0.0f, 1.0f); + const Vector3 NORMAL4(1.0f, 0.0f, 0.0f); + const Vector3 NORMAL5(0.0f, 0.0f, -1.0f); Vertex vertices[] = { - { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL5 }, - { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL5 }, - { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL5 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL3 }, - { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL3 }, - { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL3 }, - { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL4 }, - { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL4 }, - { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL4 }, - { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL1 }, - { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL1 }, - { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL1 }, - { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL0 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL0 }, - { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL0 }, - { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL2 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL2 }, - { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL2 }, - { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL5 }, - { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL5 }, - { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL5 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL3 }, - { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL3 }, - { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL3 }, - { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL4 }, - { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL4 }, - { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL4 }, - { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL1 }, - { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL1 }, - { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL1 }, - { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL0 }, - { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL0 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL0 }, - { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL2 }, - { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL2 }, - { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL2 }, + {Vector3(1.0f, -1.0f, -1.0f), NORMAL5}, + {Vector3(-1.0f, 1.0f, -1.0f), NORMAL5}, + {Vector3(1.0f, 1.0f, -1.0f), NORMAL5}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL3}, + {Vector3(1.0f, -1.0f, 1.0f), NORMAL3}, + {Vector3(1.0f, 1.0f, 1.0f), NORMAL3}, + {Vector3(1.0f, 1.0f, 1.0f), NORMAL4}, + {Vector3(1.0f, -1.0f, -1.0f), NORMAL4}, + {Vector3(1.0f, 1.0f, -1.0f), NORMAL4}, + {Vector3(1.0f, -1.0f, 1.0f), NORMAL1}, + {Vector3(-1.0f, -1.0f, -1.0f), NORMAL1}, + {Vector3(1.0f, -1.0f, -1.0f), NORMAL1}, + {Vector3(-1.0f, -1.0f, -1.0f), NORMAL0}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL0}, + {Vector3(-1.0f, 1.0f, -1.0f), NORMAL0}, + {Vector3(1.0f, 1.0f, -1.0f), NORMAL2}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL2}, + {Vector3(1.0f, 1.0f, 1.0f), NORMAL2}, + {Vector3(1.0f, -1.0f, -1.0f), NORMAL5}, + {Vector3(-1.0f, -1.0f, -1.0f), NORMAL5}, + {Vector3(-1.0f, 1.0f, -1.0f), NORMAL5}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL3}, + {Vector3(-1.0f, -1.0f, 1.0f), NORMAL3}, + {Vector3(1.0f, -1.0f, 1.0f), NORMAL3}, + {Vector3(1.0f, 1.0f, 1.0f), NORMAL4}, + {Vector3(1.0f, -1.0f, 1.0f), NORMAL4}, + {Vector3(1.0f, -1.0f, -1.0f), NORMAL4}, + {Vector3(1.0f, -1.0f, 1.0f), NORMAL1}, + {Vector3(-1.0f, -1.0f, 1.0f), NORMAL1}, + {Vector3(-1.0f, -1.0f, -1.0f), NORMAL1}, + {Vector3(-1.0f, -1.0f, -1.0f), NORMAL0}, + {Vector3(-1.0f, -1.0f, 1.0f), NORMAL0}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL0}, + {Vector3(1.0f, 1.0f, -1.0f), NORMAL2}, + {Vector3(-1.0f, 1.0f, -1.0f), NORMAL2}, + {Vector3(-1.0f, 1.0f, 1.0f), NORMAL2}, }; Property::Map property; - property.Insert( "aPosition", Property::VECTOR3 ); - property.Insert( "aNormal", Property::VECTOR3 ); + property.Insert("aPosition", Property::VECTOR3); + property.Insert("aNormal", Property::VECTOR3); - PropertyBuffer vertexBuffer = PropertyBuffer::New( property ); + VertexBuffer vertexBuffer = VertexBuffer::New(property); - vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vertex) ); + vertexBuffer.SetData(vertices, sizeof(vertices) / sizeof(Vertex)); // create indices const unsigned short INDEX_CUBE[] = { - 2, 1, 0, - 5, 4, 3, - 8, 7, 6, - 11, 10, 9, - 14, 13, 12, - 17, 16, 15, - 20, 19, 18, - 23, 22, 21, - 26, 25, 24, - 29, 28, 27, - 32, 31, 30, - 35, 34, 33 - }; + 2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12, 17, 16, 15, 20, 19, 18, 23, 22, 21, 26, 25, 24, 29, 28, 27, 32, 31, 30, 35, 34, 33}; mGeometry = Geometry::New(); - mGeometry.AddVertexBuffer( vertexBuffer ); - mGeometry.SetIndexBuffer( INDEX_CUBE, - sizeof(INDEX_CUBE)/sizeof(INDEX_CUBE[0]) - ); - mGeometry.SetType( Geometry::TRIANGLES ); + mGeometry.AddVertexBuffer(vertexBuffer); + mGeometry.SetIndexBuffer(INDEX_CUBE, + sizeof(INDEX_CUBE) / sizeof(INDEX_CUBE[0])); + mGeometry.SetType(Geometry::TRIANGLES); } /** @@ -343,17 +330,17 @@ public: */ void CreateCubeShader() { - mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + mShader = Shader::New(VERTEX_SHADER, FRAGMENT_SHADER); float scale = 120.0f; - mShader.RegisterProperty( "light.position",Vector3( 1.2 * scale, scale, 2.0 * scale ) ); - mShader.RegisterProperty( "light.color", Vector3( 1.0f, 1.0f, 1.0f ) ); - mShader.RegisterProperty( "viewPos", Vector3( 0, 0, 3.0 * scale ) ); - - mShader.RegisterProperty( "material.ambient", material[MaterialID].ambient ); - mShader.RegisterProperty( "material.diffuse", material[MaterialID].diffuse ); - mShader.RegisterProperty( "material.specular", material[MaterialID].specular ); - mShader.RegisterProperty( "material.shininess", material[MaterialID].shininess * 128.0f ); + mShader.RegisterProperty("light.position", Vector3(1.2 * scale, scale, 2.0 * scale)); + mShader.RegisterProperty("light.color", Vector3(1.0f, 1.0f, 1.0f)); + mShader.RegisterProperty("viewPos", Vector3(0, 0, 3.0 * scale)); + + mShader.RegisterProperty("material.ambient", material[MaterialID].ambient); + mShader.RegisterProperty("material.diffuse", material[MaterialID].diffuse); + mShader.RegisterProperty("material.specular", material[MaterialID].specular); + mShader.RegisterProperty("material.shininess", material[MaterialID].shininess * 128.0f); } /** @@ -361,11 +348,11 @@ public: */ void CreateRenderer() { - mRenderer = Renderer::New( mGeometry, mShader ); + mRenderer = Renderer::New(mGeometry, mShader); // Face culling is enabled to hide the backwards facing sides of the cube // This is sufficient to render a single object; for more complex scenes depth-testing might be required - mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); + mRenderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK); } /** @@ -376,13 +363,13 @@ public: Window window = mApplication.GetWindow(); float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f; - mActor = Actor::New(); - mActor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 1.0f, 0.6f, 1.0f ) ); - mActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); - mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - mActor.SetProperty( Actor::Property::SIZE, Vector3( quarterWindowWidth, quarterWindowWidth, quarterWindowWidth ) ); - mActor.AddRenderer( mRenderer ); - window.Add( mActor ); + mActor = Actor::New(); + mActor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 1.0f, 0.6f, 1.0f)); + mActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + mActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowWidth, quarterWindowWidth, quarterWindowWidth)); + mActor.AddRenderer(mRenderer); + window.Add(mActor); } /** @@ -390,29 +377,29 @@ public: */ void PlayAnimation() { - mAnimation = Animation::New( 15.0f ); - mAnimation.SetLooping( true ); - mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::ZAXIS ) ); - mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::YAXIS ) ); - mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::XAXIS ) ); + mAnimation = Animation::New(15.0f); + mAnimation.SetLooping(true); + mAnimation.AnimateBy(Property(mActor, Actor::Property::ORIENTATION), Quaternion(Radian(Degree(360)), Vector3::ZAXIS)); + mAnimation.AnimateBy(Property(mActor, Actor::Property::ORIENTATION), Quaternion(Radian(Degree(360)), Vector3::YAXIS)); + mAnimation.AnimateBy(Property(mActor, Actor::Property::ORIENTATION), Quaternion(Radian(Degree(360)), Vector3::XAXIS)); mAnimation.Play(); } private: - Application& mApplication; - TextLabel mLabel; - PushButton mButton; - Renderer mRenderer; - Shader mShader; - Geometry mGeometry; - Actor mActor; - Animation mAnimation; + Application& mApplication; + TextLabel mLabel; + PushButton mButton; + Renderer mRenderer; + Shader mShader; + Geometry mGeometry; + Actor mActor; + Animation mAnimation; }; -int DALI_EXPORT_API main( int argc, char **argv ) +int DALI_EXPORT_API main(int argc, char** argv) { - Application application = Application::New( &argc, &argv, BASIC_LIGHT_THEME); - BasicLightController test( application ); + Application application = Application::New(&argc, &argv, BASIC_LIGHT_THEME); + BasicLightController test(application); application.MainLoop(); return 0; }