X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fmodel3d-view%2Fmodel3d-view-example.cpp;h=721bd5f6c68cb35fa9b8d017cf25ac8d24d13f79;hb=2e182925204bf3ef9f2a36cbfbf998e79fbafaf5;hp=40cf6ebca173861a079a7eecde5cd809c09016fa;hpb=e74b8b44afcf8bb20a7fe3da25ececb0e01e7469;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/model3d-view/model3d-view-example.cpp b/examples/model3d-view/model3d-view-example.cpp index 40cf6eb..721bd5f 100644 --- a/examples/model3d-view/model3d-view-example.cpp +++ b/examples/model3d-view/model3d-view-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -57,7 +57,16 @@ class Model3dViewController : public ConnectionTracker public: Model3dViewController( Application& application ) - : mApplication( application ) + : mApplication( application ), + mModelCounter( 0 ), + mModel3dView(), + mButtonLayer(), + mTapDetector(), + mIlluminationShader( Model3dView::DIFFUSE ), + mRotationAnimation(), + mLightAnimation(), + mPlaying( false ), + mScaled( false ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &Model3dViewController::Create ); @@ -77,18 +86,18 @@ public: //Add background Toolkit::ImageView backView = Toolkit::ImageView::New( BACKGROUND_IMAGE ); - backView.SetParentOrigin( ParentOrigin::CENTER ); - backView.SetAnchorPoint( AnchorPoint::CENTER ); + backView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + backView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); stage.Add( backView ); mModelCounter = 0; mModel3dView = Model3dView::New( MODEL_FILE[0], MATERIAL_FILE[0], IMAGE_PATH ); - mModel3dView.SetParentOrigin( ParentOrigin::CENTER ); - mModel3dView.SetAnchorPoint( AnchorPoint::CENTER ); - mModel3dView.SetName( "model3dViewControl" ); + mModel3dView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mModel3dView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + mModel3dView.SetProperty( Dali::Actor::Property::NAME, "model3dViewControl" ); mModel3dView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - mModel3dView.SetSize(screenSize); + mModel3dView.SetProperty( Actor::Property::SIZE, screenSize); mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0)); @@ -98,35 +107,35 @@ public: mButtonLayer = Layer::New(); mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mButtonLayer.SetParentOrigin( ParentOrigin::CENTER ); - mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER ); + mButtonLayer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mButtonLayer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); stage.Add(mButtonLayer); // Create button for model changing Toolkit::PushButton editButton = Toolkit::PushButton::New(); editButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); editButton.ClickedSignal().Connect( this, &Model3dViewController::OnChangeModelClicked); - editButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); - editButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - editButton.SetLabelText( "Change Model" ); + editButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + editButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + editButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Model" ); mButtonLayer.Add( editButton ); // Create button for shader changing editButton = Toolkit::PushButton::New(); editButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); editButton.ClickedSignal().Connect( this, &Model3dViewController::OnChangeLightingClicked); - editButton.SetParentOrigin( ParentOrigin::TOP_RIGHT ); - editButton.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); - editButton.SetLabelText( "Change Shader" ); + editButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT ); + editButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT ); + editButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Shader" ); mButtonLayer.Add( editButton ); // Create button for pause/resume animation editButton = Toolkit::PushButton::New(); editButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); editButton.ClickedSignal().Connect( this, &Model3dViewController::OnPauseAnimationsClicked); - editButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); - editButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); - editButton.SetLabelText( "Pause Animations" ); + editButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER ); + editButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); + editButton.SetProperty( Toolkit::Button::Property::LABEL, "Pause Animations" ); mButtonLayer.Add( editButton ); //Create animations @@ -161,8 +170,8 @@ public: { if (mScaled) { - mModel3dView.SetScale(1.0); - mModel3dView.SetPosition(0,0,0); + mModel3dView.SetProperty( Actor::Property::SCALE, 1.0f ); + mModel3dView.SetProperty( Actor::Property::POSITION, Vector3( 0, 0, 0 ) ); mScaled = false; } else @@ -176,8 +185,8 @@ public: float size = 2.5; - mModel3dView.SetScale(size); - mModel3dView.SetPosition(-position.x * size,-position.y * size, 0); + mModel3dView.SetProperty( Actor::Property::SCALE, size ); + mModel3dView.SetProperty( Actor::Property::POSITION, Vector3( -position.x * size, -position.y * size, 0 ) ); mScaled = true; } } @@ -285,20 +294,10 @@ private: bool mScaled; }; -void RunTest( Application& application ) -{ - Model3dViewController test( application ); - - application.MainLoop(); -} - -// Entry point for Linux & Tizen applications -// int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv ); - - RunTest( application ); - + Model3dViewController test( application ); + application.MainLoop(); return 0; }