- stage.GetRootLayer().TouchedSignal().Connect( this, &MetaballExplosionController::OnTouch );
-}
-
-Geometry MetaballExplosionController::CreateGeometry()
-{
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- // Create vertices and specify their color
- float xsize = mScreenSize.x * 0.5;
-
- //We create the meshdata for the metaballs
- struct VertexPosition { Vector2 position; };
- struct VertexTexture { Vector2 texture; };
- struct VertexNormal { Vector3 normal; };
-
- VertexPosition vertices[] = {
- { Vector2( -xsize, -xsize * aspect) },
- { Vector2( xsize, -xsize * aspect) },
- { Vector2( -xsize, xsize * aspect) },
- { Vector2( xsize, xsize * aspect) }
- };
-
- VertexTexture textures[] = {
- { Vector2(0.0f, 0.0f) },
- { Vector2(1.0f, 0.0f) },
- { Vector2(0.0f, 1.0f * aspect) },
- { Vector2(1.0f, 1.0f * aspect) }
- };
-
- int indices[] = { 0, 3, 1, 0, 2, 3 };
-
- unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
-
- //Vertices
- Property::Map positionVertexFormat;
- positionVertexFormat["aPosition"] = Property::VECTOR2;
- PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
- positionVertices.SetData( vertices, numberOfVertices );
-
- //Textures
- Property::Map textureVertexFormat;
- textureVertexFormat["aTexture"] = Property::VECTOR2;
- PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
- textureVertices.SetData( textures, numberOfVertices );
-
- //Indices
- Property::Map indicesVertexFormat;
- indicesVertexFormat["aIndices"] = Property::INTEGER;
- PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat );
- indicesToVertices.SetData( indices, 6 );
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( positionVertices );
- texturedQuadGeometry.AddVertexBuffer( textureVertices );
-
- texturedQuadGeometry.SetIndexBuffer ( indicesToVertices );
-
- return texturedQuadGeometry;