Commit cb0e00ff08dc95283d757c2e4993ad56760991b5

Authored by Andrew Poor
1 parent 280e1b5a

Removed 3D layer dependency of Model3dView and Mesh Visual.

In addition, the use of the deprecated TouchedSignal has been replaced.

Change-Id: Ia2d6999f2d1a86f39dfe4018478d7051746eb108
examples/mesh-visual/mesh-visual-example.cpp
@@ -95,25 +95,19 @@ public: @@ -95,25 +95,19 @@ public:
95 Stage stage = Stage::GetCurrent(); 95 Stage stage = Stage::GetCurrent();
96 stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) ); 96 stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) );
97 97
98 - //Set up layer to place objects on.  
99 - Layer baseLayer = Layer::New();  
100 - baseLayer.SetParentOrigin( ParentOrigin::CENTER );  
101 - baseLayer.SetAnchorPoint( AnchorPoint::CENTER );  
102 - baseLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );  
103 - baseLayer.SetBehavior( Layer::LAYER_2D ); //We use a 2D layer as this is closer to UI work than full 3D scene creation.  
104 - baseLayer.SetDepthTestDisabled( false ); //Enable depth testing, as otherwise the 2D layer would not do so.  
105 - baseLayer.RegisterProperty( "Tag", LAYER_TAG ); //Used to differentiate between different kinds of actor.  
106 - baseLayer.TouchedSignal().Connect( this, &MeshVisualController::OnTouch );  
107 - stage.Add( baseLayer ); 98 + //Set up root layer to receive touch gestures.
  99 + Layer rootLayer = stage.GetRootLayer();
  100 + rootLayer.RegisterProperty( "Tag", LAYER_TAG ); //Used to differentiate between different kinds of actor.
  101 + rootLayer.TouchSignal().Connect( this, &MeshVisualController::OnTouch );
108 102
109 //Place models on the scene. 103 //Place models on the scene.
110 - SetupModels( baseLayer ); 104 + SetupModels( rootLayer );
111 105
112 //Place buttons on the scene. 106 //Place buttons on the scene.
113 - SetupButtons( baseLayer ); 107 + SetupButtons( rootLayer );
114 108
115 //Add a light to the scene. 109 //Add a light to the scene.
116 - SetupLight( baseLayer ); 110 + SetupLight( rootLayer );
117 111
118 //Allow for exiting of the application via key presses. 112 //Allow for exiting of the application via key presses.
119 stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent ); 113 stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent );
@@ -129,7 +123,7 @@ public: @@ -129,7 +123,7 @@ public:
129 mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); 123 mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
130 mContainers[i].RegisterProperty( "Tag", MODEL_TAG ); //Used to differentiate between different kinds of actor. 124 mContainers[i].RegisterProperty( "Tag", MODEL_TAG ); //Used to differentiate between different kinds of actor.
131 mContainers[i].RegisterProperty( "Model", Property::Value( i ) ); //Used to index into the model. 125 mContainers[i].RegisterProperty( "Model", Property::Value( i ) ); //Used to index into the model.
132 - mContainers[i].TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); 126 + mContainers[i].TouchSignal().Connect( this, &MeshVisualController::OnTouch );
133 layer.Add( mContainers[i] ); 127 layer.Add( mContainers[i] );
134 } 128 }
135 129
@@ -284,7 +278,7 @@ public: @@ -284,7 +278,7 @@ public:
284 SetLightImage(); 278 SetLightImage();
285 279
286 //Connect to touch signal for dragging. 280 //Connect to touch signal for dragging.
287 - mLightSource.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); 281 + mLightSource.TouchSignal().Connect( this, &MeshVisualController::OnTouch );
288 282
289 //Place the light source on a layer above the base, so that it is rendered above everything else. 283 //Place the light source on a layer above the base, so that it is rendered above everything else.
290 Layer upperLayer = Layer::New(); 284 Layer upperLayer = Layer::New();
@@ -396,14 +390,11 @@ public: @@ -396,14 +390,11 @@ public:
396 390
397 //If the light source is touched, move it by dragging it. 391 //If the light source is touched, move it by dragging it.
398 //If a model is touched, rotate it by panning around. 392 //If a model is touched, rotate it by panning around.
399 - bool OnTouch( Actor actor, const TouchEvent& event ) 393 + bool OnTouch( Actor actor, const TouchData& touch )
400 { 394 {
401 - //Get primary touch point.  
402 - const Dali::TouchPoint& point = event.GetPoint( 0 );  
403 -  
404 - switch( point.state ) 395 + switch( touch.GetState( 0 ) )
405 { 396 {
406 - case TouchPoint::Down: 397 + case PointState::DOWN:
407 { 398 {
408 //Determine what was touched. 399 //Determine what was touched.
409 actor.GetProperty( actor.GetPropertyIndex( "Tag" ) ).Get( mTag ); 400 actor.GetProperty( actor.GetPropertyIndex( "Tag" ) ).Get( mTag );
@@ -417,13 +408,13 @@ public: @@ -417,13 +408,13 @@ public:
417 mModels[mSelectedModelIndex].rotationAnimation.Pause(); 408 mModels[mSelectedModelIndex].rotationAnimation.Pause();
418 409
419 //Store start points. 410 //Store start points.
420 - mPanStart = point.screen; 411 + mPanStart = touch.GetScreenPosition( 0 );
421 mRotationStart = mModels[mSelectedModelIndex].rotation; 412 mRotationStart = mModels[mSelectedModelIndex].rotation;
422 } 413 }
423 414
424 break; 415 break;
425 } 416 }
426 - case TouchPoint::Motion: 417 + case PointState::MOTION:
427 { 418 {
428 //Switch on the kind of actor we're interacting with. 419 //Switch on the kind of actor we're interacting with.
429 switch( mTag ) 420 switch( mTag )
@@ -431,7 +422,7 @@ public: @@ -431,7 +422,7 @@ public:
431 case MODEL_TAG: //Rotate model 422 case MODEL_TAG: //Rotate model
432 { 423 {
433 //Calculate displacement and corresponding rotation. 424 //Calculate displacement and corresponding rotation.
434 - Vector2 displacement = point.screen - mPanStart; 425 + Vector2 displacement = touch.GetScreenPosition( 0 ) - mPanStart;
435 mModels[mSelectedModelIndex].rotation = Vector2( mRotationStart.x - displacement.y / Y_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis 426 mModels[mSelectedModelIndex].rotation = Vector2( mRotationStart.x - displacement.y / Y_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis
436 mRotationStart.y + displacement.x / X_ROTATION_DISPLACEMENT_FACTOR ); // X displacement rotates around Y axis 427 mRotationStart.y + displacement.x / X_ROTATION_DISPLACEMENT_FACTOR ); // X displacement rotates around Y axis
437 Quaternion rotation = Quaternion( Radian( mModels[mSelectedModelIndex].rotation.x ), Vector3::XAXIS) * 428 Quaternion rotation = Quaternion( Radian( mModels[mSelectedModelIndex].rotation.x ), Vector3::XAXIS) *
@@ -445,7 +436,7 @@ public: @@ -445,7 +436,7 @@ public:
445 case LIGHT_TAG: //Drag light 436 case LIGHT_TAG: //Drag light
446 { 437 {
447 //Set light source to new position and update the models accordingly. 438 //Set light source to new position and update the models accordingly.
448 - mLightSource.SetPosition( Vector3( point.screen ) ); 439 + mLightSource.SetPosition( Vector3( touch.GetScreenPosition( 0 ) ) );
449 UpdateLight(); 440 UpdateLight();
450 441
451 break; 442 break;
@@ -454,8 +445,8 @@ public: @@ -454,8 +445,8 @@ public:
454 445
455 break; 446 break;
456 } 447 }
457 - case TouchPoint::Interrupted: //Same as finished.  
458 - case TouchPoint::Finished: 448 + case PointState::INTERRUPTED: //Same as finished.
  449 + case PointState::FINISHED:
459 { 450 {
460 if( mTag == MODEL_TAG ) 451 if( mTag == MODEL_TAG )
461 { 452 {
examples/model3d-view/model3d-view-example.cpp
@@ -76,18 +76,10 @@ public: @@ -76,18 +76,10 @@ public:
76 Vector2 screenSize = stage.GetSize(); 76 Vector2 screenSize = stage.GetSize();
77 77
78 //Add background 78 //Add background
79 - Toolkit::ImageView backView = Toolkit::ImageView::New(BACKGROUND_IMAGE);  
80 - backView.SetAnchorPoint( AnchorPoint::TOP_LEFT );  
81 - stage.Add(backView);  
82 -  
83 - //Add 3D model control  
84 - m3DLayer = Layer::New();  
85 - stage.GetRootLayer().Add(m3DLayer);  
86 -  
87 - //3D models require 3D based rendering method, so it can use depth buffer, etc.  
88 - m3DLayer.SetBehavior(Layer::LAYER_3D);  
89 - m3DLayer.SetParentOrigin( ParentOrigin::CENTER );  
90 - m3DLayer.SetAnchorPoint( AnchorPoint::CENTER ); 79 + Toolkit::ImageView backView = Toolkit::ImageView::New( BACKGROUND_IMAGE );
  80 + backView.SetParentOrigin( ParentOrigin::CENTER );
  81 + backView.SetAnchorPoint( AnchorPoint::CENTER );
  82 + stage.Add( backView );
91 83
92 mModelCounter = 0; 84 mModelCounter = 0;
93 85
@@ -100,7 +92,7 @@ public: @@ -100,7 +92,7 @@ public:
100 92
101 mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0)); 93 mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0));
102 94
103 - m3DLayer.Add( mModel3dView ); 95 + backView.Add( mModel3dView );
104 96
105 mIlluminationShader = Model3dView::IlluminationType(mModel3dView.GetProperty<int>(Model3dView::Property::ILLUMINATION_TYPE)); 97 mIlluminationShader = Model3dView::IlluminationType(mModel3dView.GetProperty<int>(Model3dView::Property::ILLUMINATION_TYPE));
106 98
@@ -108,7 +100,7 @@ public: @@ -108,7 +100,7 @@ public:
108 mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); 100 mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
109 mButtonLayer.SetParentOrigin( ParentOrigin::CENTER ); 101 mButtonLayer.SetParentOrigin( ParentOrigin::CENTER );
110 mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER ); 102 mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER );
111 - stage.GetRootLayer().Add(mButtonLayer); 103 + stage.Add(mButtonLayer);
112 104
113 // Create button for model changing 105 // Create button for model changing
114 Toolkit::PushButton editButton = Toolkit::PushButton::New(); 106 Toolkit::PushButton editButton = Toolkit::PushButton::New();
@@ -281,7 +273,6 @@ private: @@ -281,7 +273,6 @@ private:
281 int mModelCounter; 273 int mModelCounter;
282 Model3dView mModel3dView; 274 Model3dView mModel3dView;
283 275
284 - Layer m3DLayer;  
285 Layer mButtonLayer; 276 Layer mButtonLayer;
286 TapGestureDetector mTapDetector; 277 TapGestureDetector mTapDetector;
287 278