From 348c046fe7009aaad707ab856c1900695cb30609 Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Tue, 15 Nov 2016 14:15:57 +0900 Subject: [PATCH] Revert "[3.0] Removed 3D layer dependency of Model3dView and Mesh Visual." This reverts commit 30dca3a59678006c31ec36499386d181a8b02ab2. Change-Id: I9e438de0c5be532d41654c9b8e46ac8c1bd4f31d --- examples/mesh-visual/mesh-visual-example.cpp | 45 +++++++++++++++----------- examples/model3d-view/model3d-view-example.cpp | 21 ++++++++---- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/examples/mesh-visual/mesh-visual-example.cpp b/examples/mesh-visual/mesh-visual-example.cpp index e8674c9..8376f61 100644 --- a/examples/mesh-visual/mesh-visual-example.cpp +++ b/examples/mesh-visual/mesh-visual-example.cpp @@ -95,19 +95,25 @@ public: Stage stage = Stage::GetCurrent(); stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) ); - //Set up root layer to receive touch gestures. - Layer rootLayer = stage.GetRootLayer(); - rootLayer.RegisterProperty( "Tag", LAYER_TAG ); //Used to differentiate between different kinds of actor. - rootLayer.TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + //Set up layer to place objects on. + Layer baseLayer = Layer::New(); + baseLayer.SetParentOrigin( ParentOrigin::CENTER ); + baseLayer.SetAnchorPoint( AnchorPoint::CENTER ); + baseLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + baseLayer.SetBehavior( Layer::LAYER_2D ); //We use a 2D layer as this is closer to UI work than full 3D scene creation. + baseLayer.SetDepthTestDisabled( false ); //Enable depth testing, as otherwise the 2D layer would not do so. + baseLayer.RegisterProperty( "Tag", LAYER_TAG ); //Used to differentiate between different kinds of actor. + baseLayer.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); + stage.Add( baseLayer ); //Place models on the scene. - SetupModels( rootLayer ); + SetupModels( baseLayer ); //Place buttons on the scene. - SetupButtons( rootLayer ); + SetupButtons( baseLayer ); //Add a light to the scene. - SetupLight( rootLayer ); + SetupLight( baseLayer ); //Allow for exiting of the application via key presses. stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent ); @@ -123,7 +129,7 @@ public: mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mContainers[i].RegisterProperty( "Tag", MODEL_TAG ); //Used to differentiate between different kinds of actor. mContainers[i].RegisterProperty( "Model", Property::Value( i ) ); //Used to index into the model. - mContainers[i].TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + mContainers[i].TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); layer.Add( mContainers[i] ); } @@ -278,7 +284,7 @@ public: SetLightImage(); //Connect to touch signal for dragging. - mLightSource.TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + mLightSource.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); //Place the light source on a layer above the base, so that it is rendered above everything else. Layer upperLayer = Layer::New(); @@ -390,11 +396,14 @@ public: //If the light source is touched, move it by dragging it. //If a model is touched, rotate it by panning around. - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch( Actor actor, const TouchEvent& event ) { - switch( touch.GetState( 0 ) ) + //Get primary touch point. + const Dali::TouchPoint& point = event.GetPoint( 0 ); + + switch( point.state ) { - case PointState::DOWN: + case TouchPoint::Down: { //Determine what was touched. actor.GetProperty( actor.GetPropertyIndex( "Tag" ) ).Get( mTag ); @@ -408,13 +417,13 @@ public: mModels[mSelectedModelIndex].rotationAnimation.Pause(); //Store start points. - mPanStart = touch.GetScreenPosition( 0 ); + mPanStart = point.screen; mRotationStart = mModels[mSelectedModelIndex].rotation; } break; } - case PointState::MOTION: + case TouchPoint::Motion: { //Switch on the kind of actor we're interacting with. switch( mTag ) @@ -422,7 +431,7 @@ public: case MODEL_TAG: //Rotate model { //Calculate displacement and corresponding rotation. - Vector2 displacement = touch.GetScreenPosition( 0 ) - mPanStart; + Vector2 displacement = point.screen - mPanStart; mModels[mSelectedModelIndex].rotation = Vector2( mRotationStart.x - displacement.y / Y_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis mRotationStart.y + displacement.x / X_ROTATION_DISPLACEMENT_FACTOR ); // X displacement rotates around Y axis Quaternion rotation = Quaternion( Radian( mModels[mSelectedModelIndex].rotation.x ), Vector3::XAXIS) * @@ -436,7 +445,7 @@ public: case LIGHT_TAG: //Drag light { //Set light source to new position and update the models accordingly. - mLightSource.SetPosition( Vector3( touch.GetScreenPosition( 0 ) ) ); + mLightSource.SetPosition( Vector3( point.screen ) ); UpdateLight(); break; @@ -445,8 +454,8 @@ public: break; } - case PointState::INTERRUPTED: //Same as finished. - case PointState::FINISHED: + case TouchPoint::Interrupted: //Same as finished. + case TouchPoint::Finished: { if( mTag == MODEL_TAG ) { diff --git a/examples/model3d-view/model3d-view-example.cpp b/examples/model3d-view/model3d-view-example.cpp index 6c9d3e8..5adb945 100644 --- a/examples/model3d-view/model3d-view-example.cpp +++ b/examples/model3d-view/model3d-view-example.cpp @@ -76,10 +76,18 @@ public: Vector2 screenSize = stage.GetSize(); //Add background - Toolkit::ImageView backView = Toolkit::ImageView::New( BACKGROUND_IMAGE ); - backView.SetParentOrigin( ParentOrigin::CENTER ); - backView.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( backView ); + Toolkit::ImageView backView = Toolkit::ImageView::New(BACKGROUND_IMAGE); + backView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + stage.Add(backView); + + //Add 3D model control + m3DLayer = Layer::New(); + stage.GetRootLayer().Add(m3DLayer); + + //3D models require 3D based rendering method, so it can use depth buffer, etc. + m3DLayer.SetBehavior(Layer::LAYER_3D); + m3DLayer.SetParentOrigin( ParentOrigin::CENTER ); + m3DLayer.SetAnchorPoint( AnchorPoint::CENTER ); mModelCounter = 0; @@ -92,7 +100,7 @@ public: mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0)); - backView.Add( mModel3dView ); + m3DLayer.Add( mModel3dView ); mIlluminationShader = Model3dView::IlluminationType(mModel3dView.GetProperty(Model3dView::Property::ILLUMINATION_TYPE)); @@ -100,7 +108,7 @@ public: mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mButtonLayer.SetParentOrigin( ParentOrigin::CENTER ); mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( mButtonLayer ); + stage.GetRootLayer().Add(mButtonLayer); // Create button for model changing Toolkit::PushButton editButton = Toolkit::PushButton::New(); @@ -273,6 +281,7 @@ private: int mModelCounter; Model3dView mModel3dView; + Layer m3DLayer; Layer mButtonLayer; TapGestureDetector mTapDetector; -- 2.7.4