KeyEvent class pimpling
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scene3d-view / gltf-loader.cpp
index e1d9d34..35bdd42 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -22,7 +22,7 @@
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/adaptor-framework/file-loader.h>
+#include <dali/devel-api/adaptor-framework/file-stream.h>
 
 namespace Dali
 {
@@ -236,21 +236,19 @@ void FitBuffer( Dali::Vector<Vector4>& bufferDestination, Dali::Vector<T>& buffe
 template <typename T>
 bool ReadBinFile( Vector<T> &dataBuffer, std::string url, int32_t offset, int32_t count )
 {
-  std::streampos bufferSize = 0;
-  Dali::Vector<char> fileBuffer;
-  if( !Dali::FileLoader::ReadFile( url, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+  Dali::FileStream fileStream( url, FileStream::READ | FileStream::BINARY );
+  FILE* fp = fileStream.GetFile();
+  if( !fp )
   {
     return false;
   }
 
-  FILE* fp = fmemopen( &fileBuffer[0], bufferSize, "rb" );
   dataBuffer.Resize( count );
   ssize_t result = -1;
   if( !fseek( fp, offset, SEEK_SET ) )
   {
     result = fread( &dataBuffer[0], sizeof( T ), count, fp );
   }
-  fclose( fp );
 
   return ( result >= 0 );
 }
@@ -1293,8 +1291,8 @@ void Loader::LoadCamera( Scene3dView& scene3dView )
     }
 
     CameraActor cameraActor = CameraActor::New();
-    cameraActor.SetParentOrigin( ParentOrigin::CENTER );
-    cameraActor.SetAnchorPoint( AnchorPoint::CENTER );
+    cameraActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    cameraActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
 
     if( cameraInfo.type == "orthographic" )
     {
@@ -1430,7 +1428,7 @@ bool Loader::LoadSceneNodes( Scene3dView& scene3dView )
   for( auto nodeIter = tempNode->CBegin(), end = tempNode->CEnd(); nodeIter != end; ++nodeIter )
   {
     Actor actor = AddNode( scene3dView, ( ( *nodeIter ).second ).GetInteger() );
-    actor.SetParentOrigin( ParentOrigin::CENTER );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     scene3dView.GetRoot().Add( actor );
   }
 
@@ -1583,14 +1581,14 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
     renderer.SetTextures( textureSet );
 
     anchorPoint = meshInfo.pivot;
-    actor.SetAnchorPoint( anchorPoint );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT, anchorPoint );
 
-    actor.SetSize( Vector3( meshInfo.size.x, meshInfo.size.y, meshInfo.size.z ) );
+    actor.SetProperty( Actor::Property::SIZE, Vector3( meshInfo.size.x, meshInfo.size.y, meshInfo.size.z ) );
     actor.AddRenderer( renderer );
 
-    actor.SetScale( scale );
+    actor.SetProperty( Actor::Property::SCALE, scale );
     actor.RotateBy( orientation );
-    actor.SetPosition( translation );
+    actor.SetProperty( Actor::Property::POSITION, translation );
 
     shader.RegisterProperty( "uLightType", ( scene3dView.GetLightType() & ~Toolkit::Scene3dView::LightType::IMAGE_BASED_LIGHT ) );
     shader.RegisterProperty( "uLightVector", scene3dView.GetLightVector() );
@@ -1650,10 +1648,10 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
   }
   else
   {
-    actor.SetAnchorPoint( AnchorPoint::CENTER );
-    actor.SetPosition( translation );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    actor.SetProperty( Actor::Property::POSITION, translation );
     actor.RotateBy( orientation );
-    actor.SetSize( actorSize );
+    actor.SetProperty( Actor::Property::SIZE, actorSize );
   }
 
   tempNode = node->GetChild( "camera" );
@@ -1672,7 +1670,7 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
   {
     std::string nameString;
     ReadString( tempNode, nameString );
-    actor.SetName( nameString );
+    actor.SetProperty( Dali::Actor::Property::NAME, nameString );
   }
 
   SetActorCache( actor, index );
@@ -1681,7 +1679,7 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
     for( auto childIter = tempNode->CBegin(), end = tempNode->CEnd(); childIter != end; ++childIter )
     {
       Actor childActor = AddNode( scene3dView, ( ( *childIter ).second ).GetInteger() );
-      childActor.SetParentOrigin( anchorPoint );
+      childActor.SetProperty( Actor::Property::PARENT_ORIGIN, anchorPoint );
       actor.Add( childActor );
     }
   }