Пример #1
0
        static public dynamic mesh(LispList args, LispEnvironment env)
        {
            IEnumerator <dynamic> arg = args.GetEnumerator();

            arg.MoveNext();
            var topology = arg.Current.Eval(env);

            arg.MoveNext();
            var layout = arg.Current.Eval(env);

            var resource = new MeshResource();

            resource.elementSize = layout.elementSize;

            resource.inputLayout       = layout.elements;
            resource.primitiveTopology = topology;

            env.Add(new LispSymbol("vertexSize"), new LispInteger(resource.elementSize));

            arg.MoveNext();
            resource.vertexstream = arg.Current.Eval(env);
            resource.elementCount = (int)resource.vertexstream.Length / resource.elementSize;

            if (arg.MoveNext())
            {
                resource.indexed = true;
                if (resource.elementCount <= ushort.MaxValue)
                {
                    env.Add(new LispSymbol("indexes"), VertexFormats.R16UIntIndexes);
                    resource.indexFormat = SlimDX.DXGI.Format.R16_UInt;
                }
                else
                {
                    env.Add(new LispSymbol("indexes"), VertexFormats.R32UIntIndexes);
                    resource.indexFormat = SlimDX.DXGI.Format.R32_UInt;
                }
                resource.indexstream = arg.Current.Eval(env);
                if (resource.indexFormat == SlimDX.DXGI.Format.R16_UInt)
                {
                    resource.indexCount = (int)resource.indexstream.Length / 2;
                }
                else
                {
                    resource.indexCount = (int)resource.indexstream.Length / 4;
                }
            }
            else
            {
                resource.indexed     = false;
                resource.indexFormat = SlimDX.DXGI.Format.Unknown;
            }

            return(resource);
        }
Пример #2
0
        static public dynamic element(LispList args, LispEnvironment env)
        {
            LispSymbol name   = args[0].Eval(env);
            LispString format = args[1].Eval(env);

            env.Add(name, VertexFormats.getParserFor(format.Value));

            return(new InputElement(name.Value, 0, VertexFormats.getDXFormatOf(format.Value), 0, 0));
        }