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 95 Stage stage = Stage::GetCurrent();
96 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 103 //Place models on the scene.
110   - SetupModels( baseLayer );
  104 + SetupModels( rootLayer );
111 105  
112 106 //Place buttons on the scene.
113   - SetupButtons( baseLayer );
  107 + SetupButtons( rootLayer );
114 108  
115 109 //Add a light to the scene.
116   - SetupLight( baseLayer );
  110 + SetupLight( rootLayer );
117 111  
118 112 //Allow for exiting of the application via key presses.
119 113 stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent );
... ... @@ -129,7 +123,7 @@ public:
129 123 mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
130 124 mContainers[i].RegisterProperty( "Tag", MODEL_TAG ); //Used to differentiate between different kinds of actor.
131 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 127 layer.Add( mContainers[i] );
134 128 }
135 129  
... ... @@ -284,7 +278,7 @@ public:
284 278 SetLightImage();
285 279  
286 280 //Connect to touch signal for dragging.
287   - mLightSource.TouchedSignal().Connect( this, &MeshVisualController::OnTouch );
  281 + mLightSource.TouchSignal().Connect( this, &MeshVisualController::OnTouch );
288 282  
289 283 //Place the light source on a layer above the base, so that it is rendered above everything else.
290 284 Layer upperLayer = Layer::New();
... ... @@ -396,14 +390,11 @@ public:
396 390  
397 391 //If the light source is touched, move it by dragging it.
398 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 399 //Determine what was touched.
409 400 actor.GetProperty( actor.GetPropertyIndex( "Tag" ) ).Get( mTag );
... ... @@ -417,13 +408,13 @@ public:
417 408 mModels[mSelectedModelIndex].rotationAnimation.Pause();
418 409  
419 410 //Store start points.
420   - mPanStart = point.screen;
  411 + mPanStart = touch.GetScreenPosition( 0 );
421 412 mRotationStart = mModels[mSelectedModelIndex].rotation;
422 413 }
423 414  
424 415 break;
425 416 }
426   - case TouchPoint::Motion:
  417 + case PointState::MOTION:
427 418 {
428 419 //Switch on the kind of actor we're interacting with.
429 420 switch( mTag )
... ... @@ -431,7 +422,7 @@ public:
431 422 case MODEL_TAG: //Rotate model
432 423 {
433 424 //Calculate displacement and corresponding rotation.
434   - Vector2 displacement = point.screen - mPanStart;
  425 + Vector2 displacement = touch.GetScreenPosition( 0 ) - mPanStart;
435 426 mModels[mSelectedModelIndex].rotation = Vector2( mRotationStart.x - displacement.y / Y_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis
436 427 mRotationStart.y + displacement.x / X_ROTATION_DISPLACEMENT_FACTOR ); // X displacement rotates around Y axis
437 428 Quaternion rotation = Quaternion( Radian( mModels[mSelectedModelIndex].rotation.x ), Vector3::XAXIS) *
... ... @@ -445,7 +436,7 @@ public:
445 436 case LIGHT_TAG: //Drag light
446 437 {
447 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 440 UpdateLight();
450 441  
451 442 break;
... ... @@ -454,8 +445,8 @@ public:
454 445  
455 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 451 if( mTag == MODEL_TAG )
461 452 {
... ...
examples/model3d-view/model3d-view-example.cpp
... ... @@ -76,18 +76,10 @@ public:
76 76 Vector2 screenSize = stage.GetSize();
77 77  
78 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 84 mModelCounter = 0;
93 85  
... ... @@ -100,7 +92,7 @@ public:
100 92  
101 93 mModel3dView.SetProperty(Model3dView::Property::LIGHT_POSITION, Vector3(5,10.,0));
102 94  
103   - m3DLayer.Add( mModel3dView );
  95 + backView.Add( mModel3dView );
104 96  
105 97 mIlluminationShader = Model3dView::IlluminationType(mModel3dView.GetProperty<int>(Model3dView::Property::ILLUMINATION_TYPE));
106 98  
... ... @@ -108,7 +100,7 @@ public:
108 100 mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
109 101 mButtonLayer.SetParentOrigin( ParentOrigin::CENTER );
110 102 mButtonLayer.SetAnchorPoint( AnchorPoint::CENTER );
111   - stage.GetRootLayer().Add(mButtonLayer);
  103 + stage.Add(mButtonLayer);
112 104  
113 105 // Create button for model changing
114 106 Toolkit::PushButton editButton = Toolkit::PushButton::New();
... ... @@ -281,7 +273,6 @@ private:
281 273 int mModelCounter;
282 274 Model3dView mModel3dView;
283 275  
284   - Layer m3DLayer;
285 276 Layer mButtonLayer;
286 277 TapGestureDetector mTapDetector;
287 278  
... ...