/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdlib.h>
#include <cmath>
#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/object/handle-devel.h>
#include "dali-test-suite-utils/dali-test-suite-utils.h"
actor.SetType( Dali::Camera::LOOK_AT_TARGET );
DALI_TEST_EQUALS( actor.GetType(), Dali::Camera::LOOK_AT_TARGET, TEST_LOCATION );
- std::string sValue;
- actor.GetProperty( CameraActor::Property::TYPE ).Get( sValue );
- std::string result( "LOOK_AT_TARGET");
- DALI_TEST_EQUALS( result, sValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( "LOOK_AT_TARGET", actor.GetProperty< std::string >( CameraActor::Property::TYPE ), TEST_LOCATION );
+ DALI_TEST_EQUALS( "LOOK_AT_TARGET", DevelHandle::GetCurrentProperty< std::string >( actor, CameraActor::Property::TYPE ), TEST_LOCATION );
END_TEST;
}
DALI_TEST_ASSERT( e, "camera", TEST_LOCATION );
}
- DALI_TEST_EQUALS( (int)cameraType, (int)Dali::Camera::FREE_LOOK, TEST_LOCATION );
+ DALI_TEST_EQUALS( cameraType, Dali::Camera::FREE_LOOK, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-//todor
int UtcDaliCameraActorSetAspectRatioP(void)
{
TestApplication application;
actor.GetProperty( CameraActor::Property::FAR_PLANE_DISTANCE ).Get( value );
DALI_TEST_EQUALS( 4245.f, value, FLOAT_EPSILON, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
END_TEST;
}
DALI_TEST_EQUALS( nearClippingPlane, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION );
DALI_TEST_EQUALS( farClippingPlane, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
END_TEST;
}
Vector3 pos = actor.GetCurrentPosition();
DALI_TEST_EQUALS( defaultPos.z, pos.z, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
END_TEST;
}
actor.GetProperty( CameraActor::Property::BOTTOM_PLANE_DISTANCE ).Get( value );
DALI_TEST_EQUALS( 500.0f, value, FLOAT_EPSILON, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
END_TEST;
}
actor.GetProperty( CameraActor::Property::BOTTOM_PLANE_DISTANCE ).Get( value );
DALI_TEST_EQUALS( 500.0f, value, FLOAT_EPSILON, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
std::string stringValue;
actor.GetProperty( CameraActor::Property::PROJECTION_MODE ).Get( stringValue );
DALI_TEST_EQUALS( stringValue, "ORTHOGRAPHIC_PROJECTION", TEST_LOCATION );
actor.SetProjectionMode( Dali::Camera::PERSPECTIVE_PROJECTION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION );
actor.SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION );
// Check setting the property.
Property::Value setValue = "PERSPECTIVE_PROJECTION";
actor.SetProperty( CameraActor::Property::PROJECTION_MODE, setValue );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
END_TEST;
}
CameraActor actor = CameraActor::New();
actor.SetOrthographicProjection( Size::ONE );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION );
actor.SetPerspectiveProjection( Size( 100.f, 150.f ) );
- DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
// Check getting the property.
std::string stringValue;
tet_infoline( "Testing Dali::CameraActor DefaultProperties" );
CameraActor actor = CameraActor::New();
+ Stage stage = Stage::GetCurrent();
+ stage.Add(actor);
+ stage.GetRenderTaskList().GetTask(0).SetCameraActor( actor );
actor.SetAspectRatio( TEST_ASPECT_RATIO );
Stage::GetCurrent().Add( actor );
BufferImage image = CreateBufferImage();
- ImageActor actor = ImageActor::New( image );
+ Actor actor = CreateRenderableActor(image);
actor.SetSize( 100.0f, 100.0f );
actor.SetPosition( 20.0f, 30.0f, 40.0f );
actor.SetParentOrigin( ParentOrigin::CENTER );
application.Render();
application.SendNotification();
Image image = CreateBufferImage();
- ImageActor imageActor = ImageActor::New( image );
- imageActor.SetSize( 100.0f, 100.0f );
- Stage::GetCurrent().Add( imageActor );
+ Actor actor = CreateRenderableActor( image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE );
+ actor.SetSize( 100.0f, 100.0f );
+ Stage::GetCurrent().Add( actor );
Matrix projectionMatrix;
Matrix viewMatrix;
camera.GetProperty( CameraActor::CameraActor::Property::PROJECTION_MATRIX ).Get( projectionMatrix );
camera.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( viewMatrix );
- ShaderEffect shaderEffect = ShaderEffect::New( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE );
- imageActor.SetShaderEffect( shaderEffect );
-
- shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
- shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
+ actor.RegisterProperty( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
+ actor.RegisterProperty( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
- Property::Index projectionMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME );
- Property::Index viewMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME );
+ Property::Index projectionMatrixPropertyIndex = actor.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME );
+ Property::Index viewMatrixPropertyIndex = actor.GetPropertyIndex( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME );
- Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( shaderEffect, projectionMatrixPropertyIndex, EqualToConstraint() );
+ Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( actor, projectionMatrixPropertyIndex, EqualToConstraint() );
projectionMatrixConstraint.AddSource( Source( camera, CameraActor::Property::PROJECTION_MATRIX ) );
- Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( shaderEffect, viewMatrixPropertyIndex, EqualToConstraint() );
+ Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( actor, viewMatrixPropertyIndex, EqualToConstraint() );
viewMatrixConstraint.AddSource( Source( camera, CameraActor::Property::VIEW_MATRIX ) );
projectionMatrixConstraint.Apply();
stage.Add( target );
stage.Add( freeLookCameraActor );
stage.Add( lookAtCameraActor );
+ stage.GetRenderTaskList().GetTask(0).SetCameraActor( freeLookCameraActor );
// Create an arbitrary vector
for( float x=-1.0f; x<=1.0f; x+=0.1f )
application.SendNotification();
application.Render();
Matrix freeLookViewMatrix;
- Matrix lookAtViewMatrix;
freeLookCameraActor.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( freeLookViewMatrix );
- lookAtCameraActor.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( lookAtViewMatrix );
Matrix freeLookWorld = freeLookCameraActor.GetCurrentWorldMatrix();
Matrix freeLookTest( false );
Matrix::Multiply( freeLookTest, freeLookViewMatrix, freeLookWorld );
DALI_TEST_EQUALS( freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION );
-
- DALI_TEST_EQUALS( freeLookViewMatrix, lookAtViewMatrix, 0.01, TEST_LOCATION );
}
}
}
+
END_TEST;
}
Actor cameraAnchor = Actor::New();
cameraAnchor.Add( freeLookCameraActor );
stage.Add( cameraAnchor );
+ stage.GetRenderTaskList().GetTask(0).SetCameraActor( freeLookCameraActor );
for( float angle = 1.0f; angle <= 180.0f; angle += 1.0f )
{