diff options
author | Adeel Kazmi <adeel.kazmi@samsung.com> | 2016-09-09 05:56:30 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2016-09-09 05:56:30 -0700 |
commit | 20e45260c9c0c97343adfd8a5d41a54fb77651b8 (patch) | |
tree | 8cd00358cd796f43441b708b7e53f4ba5b469c1e | |
parent | 29d0fc514b6296cf070f187fda8ff5af92158661 (diff) | |
parent | 30dca3a59678006c31ec36499386d181a8b02ab2 (diff) | |
download | dali-demo-20e45260c9c0c97343adfd8a5d41a54fb77651b8.tar.gz dali-demo-20e45260c9c0c97343adfd8a5d41a54fb77651b8.tar.bz2 dali-demo-20e45260c9c0c97343adfd8a5d41a54fb77651b8.zip |
Merge "[3.0] Removed 3D layer dependency of Model3dView and Mesh Visual." into tizen
-rw-r--r-- | examples/mesh-visual/mesh-visual-example.cpp | 45 | ||||
-rw-r--r-- | examples/model3d-view/model3d-view-example.cpp | 21 |
2 files changed, 24 insertions, 42 deletions
diff --git a/examples/mesh-visual/mesh-visual-example.cpp b/examples/mesh-visual/mesh-visual-example.cpp index 8376f61c..e8674c9c 100644 --- a/examples/mesh-visual/mesh-visual-example.cpp +++ b/examples/mesh-visual/mesh-visual-example.cpp @@ -95,25 +95,19 @@ public: Stage stage = Stage::GetCurrent(); stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) ); - //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 ); + //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 ); //Place models on the scene. - SetupModels( baseLayer ); + SetupModels( rootLayer ); //Place buttons on the scene. - SetupButtons( baseLayer ); + SetupButtons( rootLayer ); //Add a light to the scene. - SetupLight( baseLayer ); + SetupLight( rootLayer ); //Allow for exiting of the application via key presses. stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent ); @@ -129,7 +123,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].TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); + mContainers[i].TouchSignal().Connect( this, &MeshVisualController::OnTouch ); layer.Add( mContainers[i] ); } @@ -284,7 +278,7 @@ public: SetLightImage(); //Connect to touch signal for dragging. - mLightSource.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); + mLightSource.TouchSignal().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(); @@ -396,14 +390,11 @@ 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 TouchEvent& event ) + bool OnTouch( Actor actor, const TouchData& touch ) { - //Get primary touch point. - const Dali::TouchPoint& point = event.GetPoint( 0 ); - - switch( point.state ) + switch( touch.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { //Determine what was touched. actor.GetProperty( actor.GetPropertyIndex( "Tag" ) ).Get( mTag ); @@ -417,13 +408,13 @@ public: mModels[mSelectedModelIndex].rotationAnimation.Pause(); //Store start points. - mPanStart = point.screen; + mPanStart = touch.GetScreenPosition( 0 ); mRotationStart = mModels[mSelectedModelIndex].rotation; } break; } - case TouchPoint::Motion: + case PointState::MOTION: { //Switch on the kind of actor we're interacting with. switch( mTag ) @@ -431,7 +422,7 @@ public: case MODEL_TAG: //Rotate model { //Calculate displacement and corresponding rotation. - Vector2 displacement = point.screen - mPanStart; + Vector2 displacement = touch.GetScreenPosition( 0 ) - 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) * @@ -445,7 +436,7 @@ public: case LIGHT_TAG: //Drag light { //Set light source to new position and update the models accordingly. - mLightSource.SetPosition( Vector3( point.screen ) ); + mLightSource.SetPosition( Vector3( touch.GetScreenPosition( 0 ) ) ); UpdateLight(); break; @@ -454,8 +445,8 @@ public: break; } - case TouchPoint::Interrupted: //Same as finished. - case TouchPoint::Finished: + case PointState::INTERRUPTED: //Same as finished. + case PointState::FINISHED: { if( mTag == MODEL_TAG ) { diff --git a/examples/model3d-view/model3d-view-example.cpp b/examples/model3d-view/model3d-view-example.cpp index 5adb9456..6c9d3e86 100644 --- a/examples/model3d-view/model3d-view-example.cpp +++ b/examples/model3d-view/model3d-view-example.cpp @@ -76,18 +76,10 @@ public: Vector2 screenSize = stage.GetSize(); //Add background - 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 ); + Toolkit::ImageView backView = Toolkit::ImageView::New( BACKGROUND_IMAGE ); + backView.SetParentOrigin( ParentOrigin::CENTER ); + backView.SetAnchorPoint( AnchorPoint::CENTER ); + stage.Add( backView ); mModelCounter = 0; @@ -100,7 +92,7 @@ public: mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0)); - m3DLayer.Add( mModel3dView ); + backView.Add( mModel3dView ); mIlluminationShader = Model3dView::IlluminationType(mModel3dView.GetProperty<int>(Model3dView::Property::ILLUMINATION_TYPE)); @@ -108,7 +100,7 @@ public: mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mButtonLayer.SetParentOrigin( ParentOrigin::CENTER ); mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER ); - stage.GetRootLayer().Add(mButtonLayer); + stage.Add( mButtonLayer ); // Create button for model changing Toolkit::PushButton editButton = Toolkit::PushButton::New(); @@ -281,7 +273,6 @@ private: int mModelCounter; Model3dView mModel3dView; - Layer m3DLayer; Layer mButtonLayer; TapGestureDetector mTapDetector; |