src/Foundation/Presentation/Gimela.Presentation.Transitions/Transition3D.cs
/// <summary>
/// Generates a flat mesh starting at origin with sides equal to u and v vecotrs
/// </summary>
/// <param name="origin"></param>
/// <param name="u"></param>
/// <param name="v"></param>
/// <param name="usteps"></param>
/// <param name="vsteps"></param>
/// <param name="textureBounds"></param>
/// <returns></returns>
Generates a flat mesh starting at origin with sides equal to u and v vecotrs
Generates a flat mesh starting at origin with sides equal to u and v vecotrs
public static MeshGeometry3D CreateMesh(Point3D origin, Vector3D u, Vector3D v, int usteps, int vsteps, Rect textureBounds)
        {
            u = 1.0 / usteps * u;
            v = 1.0 / vsteps * v;
            MeshGeometry3D mesh = new MeshGeometry3D();
            for (int i = 0; i <= usteps; i++)
            {
                for (int j = 0; j <= vsteps; j++)
                {
                    mesh.Positions.Add(origin + i * u + j * v);
                    mesh.TextureCoordinates.Add(new Point(textureBounds.X + textureBounds.Width * i / usteps,
                                                          textureBounds.Y + textureBounds.Height * j / vsteps));
                    if (i > 0 && j > 0)
                    {
                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 1));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 0));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 1));
                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 1));
                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 0));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 0));
                    }
                }
            }
            return mesh;
        }
public static MeshGeometry3D CreateMesh ( Point3D origin , Vector3D u , Vector3D v , int usteps , int vsteps , Rect textureBounds ) { u = 1.0 / usteps * u ; v = 1.0 / vsteps * v ; MeshGeometry3D mesh = new MeshGeometry3D ( ) ; for ( int i = 0 ; i <= usteps ; i ++ ) { for ( int j = 0 ; j <= vsteps ; j ++ ) { mesh . Positions . Add ( origin + i * u + j * v ) ; mesh . TextureCoordinates . Add ( new Point ( textureBounds . X + textureBounds . Width * i / usteps , textureBounds . Y + textureBounds . Height * j / vsteps ) ) ; if ( i > 0 && j > 0 ) { mesh . TriangleIndices . Add ( ( i - 1 ) * ( vsteps + 1 ) + ( j - 1 ) ) ; mesh . TriangleIndices . Add ( ( i - 0 ) * ( vsteps + 1 ) + ( j - 0 ) ) ; mesh . TriangleIndices . Add ( ( i - 0 ) * ( vsteps + 1 ) + ( j - 1 ) ) ; mesh . TriangleIndices . Add ( ( i - 1 ) * ( vsteps + 1 ) + ( j - 1 ) ) ; mesh . TriangleIndices . Add ( ( i - 1 ) * ( vsteps + 1 ) + ( j - 0 ) ) ; mesh . TriangleIndices . Add ( ( i - 0 ) * ( vsteps + 1 ) + ( j - 0 ) ) ; } } } return mesh ; }
Generates a flat mesh starting at origin with sides equal to u and v vecotrs
Generates a flat mesh starting at origin with sides equal to u and v vecotrs
None
origin
Point3D
None
u
Vector3D
None
v
Vector3D
None
usteps
int
None
vsteps
int
None
textureBounds
Rect
None