Merge "Changes following "Remove Geometry scene object"" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / model3d-view / obj-loader.cpp
index c950b9d..635115a 100644 (file)
@@ -164,7 +164,7 @@ void ObjLoader::CenterAndScale(bool center, Dali::Vector<Vector3>& points)
 void ObjLoader::CreateGeometryArray(Dali::Vector<Vertex> & vertices,
                                     Dali::Vector<Vector2> & textures,
                                     Dali::Vector<VertexExt> & verticesExt,
-                                    Dali::Vector<int> & indices)
+                                    Dali::Vector<unsigned short> & indices)
 {
   //If we don't have tangents, calculate them
   //we need to recalculate the normals too, because we need just one normal,tangent, bitangent per vertex
@@ -259,7 +259,7 @@ bool ObjLoader::Load(char* objBuffer, std::streampos fileSize, std::string& mate
   std::string line;
   std::getline(ss, line);
 
-   while (std::getline(ss, line))
+  while (std::getline(ss, line))
   {
     std::istringstream isline(line, std::istringstream::in);
     std::string tag;
@@ -419,16 +419,8 @@ bool ObjLoader::Load(char* objBuffer, std::streampos fileSize, std::string& mate
 
   if (iniObj)
   {
-    pntAcum += (int)mPoints.Size();
-    texAcum += (int)mTextures.Size();
-    nrmAcum += (int)mNormals.Size();
-
     CenterAndScale(true, mPoints);
-
-    face = 0;
-
     mSceneLoaded = true;
-
     return true;
   }
 
@@ -499,7 +491,7 @@ Geometry ObjLoader::CreateGeometry(Toolkit::Model3dView::IlluminationType illumi
   Dali::Vector<Vertex> vertices;
   Dali::Vector<Vector2> textures;
   Dali::Vector<VertexExt> verticesExt;
-  Dali::Vector<int> indices;
+  Dali::Vector<unsigned short> indices;
 
   CreateGeometryArray(vertices, textures, verticesExt, indices);
 
@@ -507,8 +499,8 @@ Geometry ObjLoader::CreateGeometry(Toolkit::Model3dView::IlluminationType illumi
   Property::Map vertexFormat;
   vertexFormat["aPosition"] = Property::VECTOR3;
   vertexFormat["aNormal"] = Property::VECTOR3;
-  PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat, vertices.Size() );
-  surfaceVertices.SetData( &vertices[0] );
+  PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat );
+  surfaceVertices.SetData( &vertices[0], vertices.Size() );
 
   Geometry surface = Geometry::New();
   surface.AddVertexBuffer( surfaceVertices );
@@ -518,8 +510,8 @@ Geometry ObjLoader::CreateGeometry(Toolkit::Model3dView::IlluminationType illumi
   {
     Property::Map textureFormat;
     textureFormat["aTexCoord"] = Property::VECTOR2;
-    PropertyBuffer extraVertices = PropertyBuffer::New( textureFormat, textures.Size() );
-    extraVertices.SetData( &textures[0] );
+    PropertyBuffer extraVertices = PropertyBuffer::New( textureFormat );
+    extraVertices.SetData( &textures[0], textures.Size() );
 
     surface.AddVertexBuffer( extraVertices );
   }
@@ -530,25 +522,18 @@ Geometry ObjLoader::CreateGeometry(Toolkit::Model3dView::IlluminationType illumi
     Property::Map vertexExtFormat;
     vertexExtFormat["aTangent"] = Property::VECTOR3;
     vertexExtFormat["aBiNormal"] = Property::VECTOR3;
-    PropertyBuffer extraVertices = PropertyBuffer::New( vertexExtFormat, verticesExt.Size() );
-    extraVertices.SetData( &verticesExt[0] );
+    PropertyBuffer extraVertices = PropertyBuffer::New( vertexExtFormat );
+    extraVertices.SetData( &verticesExt[0], verticesExt.Size() );
 
     surface.AddVertexBuffer( extraVertices );
   }
 
   if (indices.Size())
   {
-    //Indices
-    Property::Map indicesVertexFormat;
-    indicesVertexFormat["aIndices"] = Property::INTEGER;
-    PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat, indices.Size() );
-    indicesToVertices.SetData(&indices[0]);
-
-    surface.SetIndexBuffer ( indicesToVertices );
+    surface.SetIndexBuffer ( &indices[0], indices.Size() );
   }
 
   surface.SetRequiresDepthTesting(true);
-  //surface.SetProperty(Geometry::Property::GEOMETRY_HALF_EXTENTS, GetSize() * 0.5);
 
   vertices.Clear();
   verticesExt.Clear();