X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Frendering-basic-pbr%2Frendering-basic-pbr-example.cpp;h=38c3ce251ef787d295d9bc6aa5d48af5d43b797b;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=931f5fbd6ae4d32e90e68334a8e5f43d3440605d;hpb=e13c79d13e85fc0b6f4215f98fbcced48dc64ebc;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp index 931f5fb..38c3ce2 100644 --- a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp +++ b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ #include "ktx-loader.h" #include "model-skybox.h" #include "model-pbr.h" +#include +#include using namespace Dali; using namespace Toolkit; @@ -102,18 +104,14 @@ public: // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { - // Disable indicator - Dali::Window winHandle = application.GetWindow(); - winHandle.ShowIndicator( Dali::Window::INVISIBLE ); - - // Get a handle to the stage - Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( Color::BLACK ); + // Get a handle to the window + Window window = application.GetWindow(); + window.SetBackgroundColor( Color::BLACK ); mAnimation = Animation::New( 1.0f ); mLabel = TextLabel::New( "R:1 M:0" ); - mLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - mLabel.SetParentOrigin( ParentOrigin::TOP_CENTER ); - mLabel.SetSize( stage.GetSize().width * 0.5f, stage.GetSize().height * 0.083f ); + mLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); + mLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + 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, Color::WHITE ); @@ -127,11 +125,11 @@ public: // Step 3. Initialise Main Actor InitActors(); - // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchSignal().Connect( this, &BasicPbrController::OnTouch ); + // Respond to a click anywhere on the window + window.GetRootLayer().TouchedSignal().Connect( this, &BasicPbrController::OnTouch ); // Respond to key events - stage.KeyEventSignal().Connect( this, &BasicPbrController::OnKeyEvent ); + window.KeyEventSignal().Connect( this, &BasicPbrController::OnKeyEvent ); mDoubleTapTime = Timer::New(150); mDoubleTapTime.TickSignal().Connect( this, &BasicPbrController::OnDoubleTapTime ); @@ -147,7 +145,7 @@ public: /** * This function will change the material Roughness, Metalness or the model orientation when touched */ - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch( Actor actor, const TouchEvent& touch ) { const PointState::Type state = touch.GetState( 0 ); @@ -170,8 +168,8 @@ public: } case PointState::MOTION: { - const Stage stage = Stage::GetCurrent(); - const Size size = stage.GetSize(); + const Window window = mApplication.GetWindow(); + const Size size = window.GetSize(); const float scaleX = size.width; const float scaleY = size.height; const Vector2 point = touch.GetScreenPosition(0); @@ -221,9 +219,9 @@ public: const Quaternion yawRot(Radian(Degree(angle2 * -200.0f)), modelOrientation.Rotate( Vector3::YAXIS ) ); mModelOrientation = mModelOrientation * yawRot * pitchRot ; - mSkybox.GetActor().SetOrientation( mModelOrientation ); - actor1.SetOrientation( mModelOrientation ); - actor2.SetOrientation( mModelOrientation ); + mSkybox.GetActor().SetProperty( Actor::Property::ORIENTATION, mModelOrientation ); + actor1.SetProperty( Actor::Property::ORIENTATION, mModelOrientation ); + actor2.SetProperty( Actor::Property::ORIENTATION, mModelOrientation ); mPointZ = point; } @@ -254,7 +252,7 @@ public: */ 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 ) ) { @@ -268,7 +266,8 @@ public: */ void InitActors() { - Stage stage = Stage::GetCurrent(); + Window window = mApplication.GetWindow(); + Vector2 windowSize = window.GetSize(); mSkybox.Init( SKYBOX_SCALE ); mModel[0].Init( mShader, SPHERE_URL, Vector3::ZERO, SPHERE_SCALE ); @@ -281,40 +280,40 @@ public: // Creating root and camera actor for rendertask for 3D Scene rendering mUiRoot = Actor::New(); m3dRoot = Actor::New(); - CameraActor cameraUi = CameraActor::New(stage.GetSize()); - cameraUi.SetAnchorPoint(AnchorPoint::CENTER); - cameraUi.SetParentOrigin(ParentOrigin::CENTER); + CameraActor cameraUi = CameraActor::New(window.GetSize()); + cameraUi.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); + cameraUi.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); - RenderTask rendertask = Stage::GetCurrent().GetRenderTaskList().CreateTask(); + RenderTask rendertask = window.GetRenderTaskList().CreateTask(); rendertask.SetCameraActor( cameraUi ); rendertask.SetSourceActor( mUiRoot ); - mUiRoot.SetAnchorPoint(AnchorPoint::TOP_LEFT); - mUiRoot.SetParentOrigin(ParentOrigin::TOP_LEFT); - mUiRoot.SetSize(stage.GetSize()); + mUiRoot.SetProperty(Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); + mUiRoot.SetProperty(Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + mUiRoot.SetProperty(Actor::Property::SIZE, Vector2(window.GetSize()) ); - m3dRoot.SetAnchorPoint(AnchorPoint::CENTER); - m3dRoot.SetParentOrigin(ParentOrigin::CENTER); + m3dRoot.SetProperty(Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); + m3dRoot.SetProperty(Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); // Setting camera parameters for 3D Scene - mSkybox.GetActor().SetPosition( CAMERA_DEFAULT_POSITION ); - CameraActor camera3d = stage.GetRenderTaskList().GetTask(0).GetCameraActor(); + mSkybox.GetActor().SetProperty( Actor::Property::POSITION, CAMERA_DEFAULT_POSITION ); + CameraActor camera3d = window.GetRenderTaskList().GetTask(0).GetCameraActor(); camera3d.SetInvertYAxis( true ); - camera3d.SetPosition( CAMERA_DEFAULT_POSITION ); + camera3d.SetProperty( Actor::Property::POSITION, CAMERA_DEFAULT_POSITION ); camera3d.SetNearClippingPlane( CAMERA_DEFAULT_NEAR ); camera3d.SetFarClippingPlane( CAMERA_DEFAULT_FAR ); camera3d.SetFieldOfView( Radian( Degree( CAMERA_DEFAULT_FOV ) ) ); - stage.Add( cameraUi ); - stage.Add( mUiRoot ); - stage.Add( m3dRoot ); + window.Add( cameraUi ); + window.Add( mUiRoot ); + window.Add( m3dRoot ); m3dRoot.Add( mSkybox.GetActor() ); m3dRoot.Add( mModel[0].GetActor() ); m3dRoot.Add( mModel[1].GetActor() ); - if( (stage.GetSize().x > 360.0f) && (stage.GetSize().y > 360.0f) ) + if( (windowSize.x > 360.0f) && (windowSize.y > 360.0f) ) { mUiRoot.Add( mLabel ); } @@ -390,7 +389,8 @@ public: */ bool LoadShaderCode( const std::string& fullpath, std::vector& output ) { - FILE* file = fopen( fullpath.c_str(), "rb" ); + Dali::FileStream fileStream( fullpath, FileStream::READ | FileStream::BINARY ); + FILE* file = fileStream.GetFile(); if( NULL == file ) { return false; @@ -411,7 +411,7 @@ public: retValue = ( result >= 0 ); } } - fclose( file ); + return retValue; }