- mPanGestureDetector.Attach( container1 );
- mPanGestureDetector.Attach( container2 );
- mPanGestureDetector.DetectedSignal().Connect( this, &SharedMeshRendererController::OnPan );
-
- //Create actors to display meshes.
- Control control1 = Control::New();
- control1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- control1.SetParentOrigin( ParentOrigin::CENTER );
- control1.SetAnchorPoint( AnchorPoint::CENTER );
- container1.Add( control1 );
-
- Control control2 = Control::New();
- control2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- control2.SetParentOrigin( ParentOrigin::CENTER );
- control2.SetAnchorPoint( AnchorPoint::CENTER );
- container2.Add( control2 );
-
- //Make actors spin to demonstrate 3D.
- Animation rotationAnimation1 = Animation::New( 15.0f );
- rotationAnimation1.AnimateBy( Property( control1, Actor::Property::ORIENTATION ),
- Quaternion( Degree( 0.0f ), Degree( 360.0f ), Degree( 0.0f ) ) );
- rotationAnimation1.SetLooping( true );
- rotationAnimation1.Play();
-
- Animation rotationAnimation2 = Animation::New( 15.0f );
- rotationAnimation2.AnimateBy( Property( control2, Actor::Property::ORIENTATION ),
- Quaternion( Degree( 0.0f ), Degree( -360.0f ), Degree( 0.0f ) ) );
- rotationAnimation2.SetLooping( true );
- rotationAnimation2.Play();
-
- //Store model information in corresponding structs.
- mModels[0].control = control1;
- mModels[0].rotation.x = 0.0f;
- mModels[0].rotation.y = 0.0f;
- mModels[0].rotationAnimation = rotationAnimation1;
-
- mModels[1].control = control2;
- mModels[1].rotation.x = 0.0f;
- mModels[1].rotation.y = 0.0f;
- mModels[1].rotationAnimation = rotationAnimation2;
-
- //Calling this sets the model in the two actors.
+ mPanGestureDetector.DetectedSignal().Connect( this, &MeshRendererController::OnPan );
+
+ //Add containers to house each renderer-holding-actor.
+ for( int i = 0; i < NUM_MESHES; i++ )
+ {
+ mContainers[i] = Actor::New();
+ mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mContainers[i].RegisterProperty( "Tag", Property::Value( i ) ); //Used to identify the actor and index into the model.
+
+ //Position each container on screen
+ if( i == 0 )
+ {
+ //Main, central model
+ mContainers[i].SetSizeModeFactor( Vector3( MODEL_SCALE, MODEL_SCALE, 0.0f ) );
+ mContainers[i].SetParentOrigin( ParentOrigin::CENTER );
+ mContainers[i].SetAnchorPoint( AnchorPoint::CENTER );
+ }
+ else if( i == 1 )
+ {
+ //Top left model
+ mContainers[i].SetSizeModeFactor( Vector3( MODEL_SCALE / 3.0f, MODEL_SCALE / 3.0f, 0.0f ) );
+ mContainers[i].SetParentOrigin( Vector3( 0.05, 0.03, 0.5 ) ); //Offset from top left
+ mContainers[i].SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ }
+ else if( i == 2 )
+ {
+ //Top right model
+ mContainers[i].SetSizeModeFactor( Vector3( MODEL_SCALE / 3.0f, MODEL_SCALE / 3.0f, 0.0f ) );
+ mContainers[i].SetParentOrigin( Vector3( 0.95, 0.03, 0.5 ) ); //Offset from top right
+ mContainers[i].SetAnchorPoint( AnchorPoint::TOP_RIGHT );
+ }
+
+ mPanGestureDetector.Attach( mContainers[i] );
+ layer.Add( mContainers[i] );
+ }
+
+ //Set up models
+ for( int i = 0; i < NUM_MESHES; i++ )
+ {
+ //Create control to display model
+ Control control = Control::New();
+ control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ control.SetParentOrigin( ParentOrigin::CENTER );
+ control.SetAnchorPoint( AnchorPoint::CENTER );
+ mContainers[i].Add( control );
+
+ //Make model spin to demonstrate 3D
+ Animation rotationAnimation = Animation::New( 15.0f );
+ float spin = i % 2 == 0 ? 1.0f : -1.0f; //Make actors spin in different directions to better show independence.
+ rotationAnimation.AnimateBy( Property( control, Actor::Property::ORIENTATION ),
+ Quaternion( Degree( 0.0f ), Degree( spin * 360.0f ), Degree( 0.0f ) ) );
+ rotationAnimation.SetLooping( true );
+ rotationAnimation.Play();
+
+ //Store model information in corresponding structs.
+ mModels[i].control = control;
+ mModels[i].rotation.x = 0.0f;
+ mModels[i].rotation.y = 0.0f;
+ mModels[i].rotationAnimation = rotationAnimation;
+ }
+
+ //Calling this sets the model in the controls.