Improve the CameraActor defaults 11/24711/7
authorPaul Wisbey <p.wisbey@samsung.com>
Fri, 18 Jul 2014 10:35:53 +0000 (11:35 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Tue, 22 Jul 2014 12:16:00 +0000 (13:16 +0100)
Default Camera behavior is confusing since FREE_LOOK is more useful,
but it's not the default. When setting this mode, the Camera ends up
looking in the wrong direction i.e. unless manually rotated.

Change-Id: Icb2422c2115b8fab21932f00779047ff478dab1a
Signed-off-by: Paul Wisbey <p.wisbey@samsung.com>
dali/internal/event/actors/camera-actor-impl.cpp
dali/internal/update/node-attachments/scene-graph-camera-attachment.cpp
dali/public-api/actors/camera-actor.h

index de8ef6f..95f397e 100644 (file)
@@ -182,6 +182,10 @@ CameraActorPtr CameraActor::New( const Size& size )
 
   actor->SetPerspectiveProjection( size );
 
+  // By default Actors face in the positive Z direction in world space
+  // CameraActors should face in the negative Z direction, towards the other actors
+  actor->SetRotation( Quaternion( Math::PI, Vector3::YAXIS ) );
+
   return actor;
 }
 
index ad6f08f..7a1572f 100644 (file)
@@ -136,7 +136,7 @@ void Orthographic(Matrix& result, float left, float right, float bottom, float t
 
 } // unnamed namespace
 
-const Dali::Camera::Type CameraAttachment::DEFAULT_TYPE( Dali::Camera::LOOK_AT_TARGET );
+const Dali::Camera::Type CameraAttachment::DEFAULT_TYPE( Dali::Camera::FREE_LOOK );
 const Dali::Camera::ProjectionMode CameraAttachment::DEFAULT_MODE( Dali::Camera::PERSPECTIVE_PROJECTION );
 const bool  CameraAttachment::DEFAULT_INVERT_Y_AXIS( false );
 const float CameraAttachment::DEFAULT_FIELD_OF_VIEW( 45.0f*(M_PI/180.0f) );
index 875cb66..dbb6d8c 100644 (file)
@@ -56,13 +56,14 @@ enum ProjectionMode
  *
  * Allows the developer to use actor semantics to control a camera.
  *
- * There are two types of camera actor, LookAt and FreeLook. A LookAt
- * camera actor ignores the actor rotation, and instead points towards
- * TargetPosition in world coordinates. This is the default behaviour.
+ * There are two types of camera actor, FREE_LOOK and LOOK_AT_TARGET. By default
+ * the camera actor will be FREE_LOOK.
  *
- * A FreeLook camera uses the camera actor's world rotation to control
- * where the camera is looking. If no rotation is specified, then the camera
- * looks along the negative Z axis.
+ * A FREE_LOOK camera uses actor's rotation to control where the camera is looking.
+ * If no additional rotations are specified, the camera looks in the negative Z direction.
+ *
+ * For LOOK_AT_TARGET the actor's rotation is ignored, instead the camera looks at TARGET_POSITION
+ * in world coordinates.
  *
  */
 class CameraActor : public Actor
@@ -70,20 +71,20 @@ class CameraActor : public Actor
 public:
 
   // Default Properties; additional to Actor properties
-  static const Property::Index TYPE;                         ///< Property::STRING,   // "type"                 // Not animatable
-  static const Property::Index PROJECTION_MODE;              ///< Property::STRING,   // "projection-mode"      // Not animatable
-  static const Property::Index FIELD_OF_VIEW;                ///< Property::FLOAT,    // "field-of-view"        // Not animatable
-  static const Property::Index ASPECT_RATIO;                 ///< Property::FLOAT,    // "aspect-ratio"         // Not animatable
-  static const Property::Index NEAR_PLANE_DISTANCE;          ///< Property::FLOAT,    // "near-plane-distance"  // Not animatable
-  static const Property::Index FAR_PLANE_DISTANCE;           ///< Property::FLOAT,    // "far-plane-distance"   // Not animatable
-  static const Property::Index LEFT_PLANE_DISTANCE;          ///< Property::FLOAT,    // "left-plane-distance"  // Not animatable
-  static const Property::Index RIGHT_PLANE_DISTANCE;         ///< Property::FLOAT,    // "right-plane-distance" // Not animatable
-  static const Property::Index TOP_PLANE_DISTANCE;           ///< Property::FLOAT,    // "top-plane-distance"   // Not animatable
-  static const Property::Index BOTTOM_PLANE_DISTANCE;        ///< Property::FLOAT,    // "bottom-plane-distance"// Not animatable
-  static const Property::Index TARGET_POSITION;              ///< Property::VECTOR3,  // "target"               // Not animatable
-  static const Property::Index PROJECTION_MATRIX;            ///< Property::MATRIX,   // "projection-matrix"    // Constraint input, not animatable
-  static const Property::Index VIEW_MATRIX;                  ///< Property::MATRIX,   // "view-matrix"          // constraint input, not abimatable
-  static const Property::Index INVERT_Y_AXIS;                ///< Property::BOOLEAN,  // "invert-y-axis"        // Not animatable
+  static const Property::Index TYPE;                         ///< Property::STRING,   // "type"                  // Not animatable
+  static const Property::Index PROJECTION_MODE;              ///< Property::STRING,   // "projection-mode"       // Not animatable
+  static const Property::Index FIELD_OF_VIEW;                ///< Property::FLOAT,    // "field-of-view"         // Not animatable
+  static const Property::Index ASPECT_RATIO;                 ///< Property::FLOAT,    // "aspect-ratio"          // Not animatable
+  static const Property::Index NEAR_PLANE_DISTANCE;          ///< Property::FLOAT,    // "near-plane-distance"   // Not animatable
+  static const Property::Index FAR_PLANE_DISTANCE;           ///< Property::FLOAT,    // "far-plane-distance"    // Not animatable
+  static const Property::Index LEFT_PLANE_DISTANCE;          ///< Property::FLOAT,    // "left-plane-distance"   // Not animatable
+  static const Property::Index RIGHT_PLANE_DISTANCE;         ///< Property::FLOAT,    // "right-plane-distance"  // Not animatable
+  static const Property::Index TOP_PLANE_DISTANCE;           ///< Property::FLOAT,    // "top-plane-distance"    // Not animatable
+  static const Property::Index BOTTOM_PLANE_DISTANCE;        ///< Property::FLOAT,    // "bottom-plane-distance" // Not animatable
+  static const Property::Index TARGET_POSITION;              ///< Property::VECTOR3,  // "target-position"       // Not animatable
+  static const Property::Index PROJECTION_MATRIX;            ///< Property::MATRIX,   // "projection-matrix"     // Constraint input, not animatable
+  static const Property::Index VIEW_MATRIX;                  ///< Property::MATRIX,   // "view-matrix"           // Constraint input, not animatable
+  static const Property::Index INVERT_Y_AXIS;                ///< Property::BOOLEAN,  // "invert-y-axis"         // Not animatable
 
   /**
    * @brief Create an uninitialized CameraActor handle.
@@ -135,7 +136,7 @@ public:
 
   /**
    * @brief Set the camera type.
-   * The default type is Dali::Camera::LookAtTarget
+   * The default type is Dali::Camera::FREE_LOOK
    * @param[in] type The camera type
    */
   void SetType( Dali::Camera::Type type );
@@ -150,14 +151,14 @@ public:
   /**
    * @brief Set the projection mode.
    *
-   * @param[in] mode One of PerspectiveProjection or OrthographicProjection
+   * @param[in] mode One of PERSPECTIVE_PROJECTION or ORTHOGRAPHIC_PROJECTION
    */
   void SetProjectionMode( Dali::Camera::ProjectionMode mode );
 
   /**
    * @brief Get the projection mode.
    *
-   * @return One of PerspectiveProjection or OrthographicProjection
+   * @return One of PERSPECTIVE_PROJECTION or ORTHOGRAPHIC_PROJECTION
    */
   Dali::Camera::ProjectionMode GetProjectionMode() const;
 
@@ -225,7 +226,7 @@ public:
   /**
    * @brief Set the target position of the camera.
    *
-   * @pre Camera type is LookAtTarget
+   * @pre Camera type is LOOK_AT_TARGET
    * @param[in] targetPosition The position of the target to look at
    */
   void SetTargetPosition( const Vector3& targetPosition );
@@ -234,7 +235,7 @@ public:
    * @brief Get Camera Target position.
    *
    * The target position is Vector3::ZERO
-   * @pre Camera type is LookAtTarget
+   * @pre Camera type is LOOK_AT_TARGET
    * @return The target position of the camera
    */
   Vector3 GetTargetPosition() const;