From a56865a02b14746e3c2fe9c1c5d2334c6b9c7336 Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Wed, 20 Apr 2016 16:11:56 +0100 Subject: [PATCH] Changes following "Remove geometry scvene object" Change-Id: I8138d652252f76ef24becc0fcfce3cef15321cad --- examples/line-mesh/line-mesh-example.cpp | 49 ++++------------------ examples/mesh-sorting/mesh-sorting-example.cpp | 8 +--- .../metaball-explosion-example.cpp | 18 ++------ .../metaball-refrac/metaball-refrac-example.cpp | 19 ++------- examples/new-window/new-window-example.cpp | 8 +--- examples/radial-menu/radial-sweep-view-impl.cpp | 8 +--- examples/textured-mesh/textured-mesh-example.cpp | 8 +--- 7 files changed, 23 insertions(+), 95 deletions(-) diff --git a/examples/line-mesh/line-mesh-example.cpp b/examples/line-mesh/line-mesh-example.cpp index 5c8779b..f2caf45 100644 --- a/examples/line-mesh/line-mesh-example.cpp +++ b/examples/line-mesh/line-mesh-example.cpp @@ -62,43 +62,11 @@ void main() } ); -PropertyBuffer CreateIndexBuffer( Geometry::GeometryType geometryType ) -{ - // Create indices - const unsigned int indexDataLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 }; - const unsigned int indexDataLoops[] = { 0, 1, 2, 3, 4 }; - const unsigned int indexDataStrips[] = { 0, 1, 2, 3, 4, 0 }; - - // Create index buffer if doesn't exist - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - - // Update buffer - switch( geometryType ) - { - case Geometry::LINES: - { - indices.SetData( indexDataLines, sizeof(indexDataLines)/sizeof(indexDataLines[0]) ); - break; - } - case Geometry::LINE_LOOP: - { - indices.SetData( indexDataLoops, sizeof(indexDataLoops)/sizeof(indexDataLoops[0]) ); - break; - } - case Geometry::LINE_STRIP: - { - indices.SetData( indexDataStrips, sizeof(indexDataStrips)/sizeof(indexDataStrips[0]) ); - break; - } - default: // this will never happen, but compilers yells - { - } - } - - return indices; -} +const unsigned short indexLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 }; +const unsigned short indexLoop[] = { 0, 1, 2, 3, 4 }; +const unsigned short indexStrip[] = { 0, 1, 2, 3, 4, 0 }; +const unsigned short* indices[3] = { &indexLines[0], &indexLoop[0], &indexStrip[0] }; +const unsigned int indicesSize[3] = { sizeof(indexLines)/sizeof(indexLines[0]), sizeof(indexLoop)/sizeof(indexLoop[0]), sizeof(indexStrip)/sizeof(indexStrip[0])}; Geometry CreateGeometry() { @@ -127,13 +95,11 @@ Geometry CreateGeometry() PropertyBuffer pentagonVertices = PropertyBuffer::New( pentagonVertexFormat ); pentagonVertices.SetData(pentagonVertexData, 5); - // Create indices - PropertyBuffer indices = CreateIndexBuffer( Geometry::LINES ); // Create the geometry object Geometry pentagonGeometry = Geometry::New(); pentagonGeometry.AddVertexBuffer( pentagonVertices ); - pentagonGeometry.SetIndexBuffer( indices ); + pentagonGeometry.SetIndexBuffer( indices[0], indicesSize[0] ); pentagonGeometry.SetGeometryType( Geometry::LINES ); return pentagonGeometry; } @@ -316,8 +282,7 @@ public: index = 2; } - PropertyBuffer indices = CreateIndexBuffer( geomTypes[ index ] ); - mGeometry.SetIndexBuffer( indices ); + mGeometry.SetIndexBuffer( indices[index], indicesSize[index] ); mGeometry.SetGeometryType( geomTypes[ index ] ); return true; diff --git a/examples/mesh-sorting/mesh-sorting-example.cpp b/examples/mesh-sorting/mesh-sorting-example.cpp index 95c091d..28d7f9f 100644 --- a/examples/mesh-sorting/mesh-sorting-example.cpp +++ b/examples/mesh-sorting/mesh-sorting-example.cpp @@ -102,16 +102,12 @@ Geometry CreateGeometry() texturedQuadVertices.SetData( texturedQuadVertexData, 4 ); // Create indices - unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 }; - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - indices.SetData( indexData, 6 ); + unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices ); - texturedQuadGeometry.SetIndexBuffer( indices ); + texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(unsigned short) ); return texturedQuadGeometry; } diff --git a/examples/metaball-explosion/metaball-explosion-example.cpp b/examples/metaball-explosion/metaball-explosion-example.cpp index 07f57c3..39519b8 100644 --- a/examples/metaball-explosion/metaball-explosion-example.cpp +++ b/examples/metaball-explosion/metaball-explosion-example.cpp @@ -373,8 +373,6 @@ Geometry MetaballExplosionController::CreateGeometry() { Vector2(1.0f, 1.0f * aspect) } }; - int indices[] = { 0, 3, 1, 0, 2, 3 }; - unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); //Vertices @@ -390,17 +388,14 @@ Geometry MetaballExplosionController::CreateGeometry() textureVertices.SetData( textures, numberOfVertices ); //Indices - Property::Map indicesVertexFormat; - indicesVertexFormat["aIndices"] = Property::INTEGER; - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); - indicesToVertices.SetData( indices, 6 ); + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); texturedQuadGeometry.AddVertexBuffer( positionVertices ); texturedQuadGeometry.AddVertexBuffer( textureVertices ); - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); return texturedQuadGeometry; } @@ -431,8 +426,6 @@ Geometry MetaballExplosionController::CreateGeometryComposition() { Vector2(1.0f, 1.0f) } }; - int indices[] = { 0, 3, 1, 0, 2, 3 }; - unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); //Vertices @@ -448,17 +441,14 @@ Geometry MetaballExplosionController::CreateGeometryComposition() textureVertices.SetData( textures, numberOfVertices ); //Indices - Property::Map indicesVertexFormat; - indicesVertexFormat["aIndices"] = Property::INTEGER; - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); - indicesToVertices.SetData( indices, 6 ); + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); texturedQuadGeometry.AddVertexBuffer( positionVertices ); texturedQuadGeometry.AddVertexBuffer( textureVertices ); - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); return texturedQuadGeometry; } diff --git a/examples/metaball-refrac/metaball-refrac-example.cpp b/examples/metaball-refrac/metaball-refrac-example.cpp index 46bf2b0..995977c 100644 --- a/examples/metaball-refrac/metaball-refrac-example.cpp +++ b/examples/metaball-refrac/metaball-refrac-example.cpp @@ -322,8 +322,6 @@ Geometry MetaballRefracController::CreateGeometry() { Vector3(0.0f, 0.0f, 1.0f) } }; - int indices[] = { 0, 3, 1, 0, 2, 3 }; - unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); //Vertices @@ -345,11 +343,7 @@ Geometry MetaballRefracController::CreateGeometry() normalVertices.SetData( normals, numberOfVertices ); //Indices - Property::Map indicesVertexFormat; - indicesVertexFormat["aIndices"] = Property::INTEGER; - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); - indicesToVertices.SetData( indices, 6 ); - + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); @@ -357,7 +351,7 @@ Geometry MetaballRefracController::CreateGeometry() texturedQuadGeometry.AddVertexBuffer( textureVertices ); texturedQuadGeometry.AddVertexBuffer( normalVertices ); - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); + texturedQuadGeometry.SetIndexBuffer ( &indices[0], 6 ); return texturedQuadGeometry; } @@ -398,8 +392,6 @@ Geometry MetaballRefracController::CreateGeometryComposition() { Vector3(0.0f, 0.0f, 1.0f) } }; - int indices[] = { 0, 3, 1, 0, 2, 3 }; - unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); //Vertices @@ -421,10 +413,7 @@ Geometry MetaballRefracController::CreateGeometryComposition() normalVertices.SetData( normals, numberOfVertices ); //Indices - Property::Map indicesVertexFormat; - indicesVertexFormat["aIndices"] = Property::INTEGER; - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); - indicesToVertices.SetData( indices, 6 ); + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); @@ -432,7 +421,7 @@ Geometry MetaballRefracController::CreateGeometryComposition() texturedQuadGeometry.AddVertexBuffer( textureVertices ); texturedQuadGeometry.AddVertexBuffer( normalVertices ); - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); return texturedQuadGeometry; } diff --git a/examples/new-window/new-window-example.cpp b/examples/new-window/new-window-example.cpp index d1ea946..022c15a 100644 --- a/examples/new-window/new-window-example.cpp +++ b/examples/new-window/new-window-example.cpp @@ -450,16 +450,12 @@ Geometry NewWindowController::CreateMeshGeometry() vertices.SetData( vertexData, 5 ); // Specify all the faces - unsigned int indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 }; - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - indices.SetData( indexData, 12 ); + unsigned short indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 }; // Create the geometry object Geometry geometry = Geometry::New(); geometry.AddVertexBuffer( vertices ); - geometry.SetIndexBuffer( indices ); + geometry.SetIndexBuffer( &indexData[0], 12 ); return geometry; } diff --git a/examples/radial-menu/radial-sweep-view-impl.cpp b/examples/radial-menu/radial-sweep-view-impl.cpp index c072f58..495e2ec 100644 --- a/examples/radial-menu/radial-sweep-view-impl.cpp +++ b/examples/radial-menu/radial-sweep-view-impl.cpp @@ -330,15 +330,11 @@ void RadialSweepViewImpl::CreateStencil( Radian initialSector ) PropertyBuffer vertices = PropertyBuffer::New( vertexFormat ); vertices.SetData( vertexData, 7u ); - unsigned int indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 }; - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - indices.SetData( indexData, 15u ); + unsigned short indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 }; Geometry meshGeometry = Geometry::New(); meshGeometry.AddVertexBuffer( vertices ); - meshGeometry.SetIndexBuffer( indices ); + meshGeometry.SetIndexBuffer( &indexData[0], sizeof( indexData )/sizeof(indexData[0]) ); // Create shader std::ostringstream vertexShaderStringStream; diff --git a/examples/textured-mesh/textured-mesh-example.cpp b/examples/textured-mesh/textured-mesh-example.cpp index b445fcc..1de4316 100644 --- a/examples/textured-mesh/textured-mesh-example.cpp +++ b/examples/textured-mesh/textured-mesh-example.cpp @@ -79,16 +79,12 @@ Geometry CreateGeometry() texturedQuadVertices.SetData( texturedQuadVertexData, 4 ); // Create indices - unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 }; - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) ); + unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 }; // Create the geometry object Geometry texturedQuadGeometry = Geometry::New(); texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices ); - texturedQuadGeometry.SetIndexBuffer( indices ); + texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(indexData[0]) ); return texturedQuadGeometry; } -- 2.7.4