示例#1
0
        public void Render(IVertexBuilder target, BlockRenderContext context, Int3 pos)
        {
            var current = context.Current[pos];

            BlockData[] neighbors =
            {
                pos.X == Chunk.RowLast
                    ? context.Neighbors[0][0,             pos.Y,         pos.Z]
                    : context.Current[pos.X + 1,          pos.Y,         pos.Z],
                pos.X == 0
                    ? context.Neighbors[1][Chunk.RowLast, pos.Y,         pos.Z]
                    : context.Current[pos.X - 1,          pos.Y,         pos.Z],
                pos.Y == Chunk.RowLast
                    ? context.Neighbors[2][pos.X,                     0, pos.Z]
                    : context.Current[pos.X,              pos.Y + 1,     pos.Z],
                pos.Y == 0
                    ? context.Neighbors[3][pos.X,         Chunk.RowLast, pos.Z]
                    : context.Current[pos.X,              pos.Y - 1,     pos.Z],
                pos.Z == Chunk.RowLast
                    ? context.Neighbors[4][pos.X,         pos.Y,              0]
                    : context.Current[pos.X,              pos.Y,         pos.Z + 1],
                pos.Z == 0
                    ? context.Neighbors[5][pos.X,         pos.Y,         Chunk.RowLast]
                    : context.Current[pos.X,              pos.Y,         pos.Z - 1]
            };
            // Right Left Top Bottom Front Back
            for (uint i = 0; i < 6; ++i)
            {
                if (AdjacentTest(current, neighbors[i]))
                {
                    target.Rect(pos, tex[i].Tex, i, 0, 15);
                }
            }
        }
示例#2
0
 public static void Render(IVertexBuilder target, int id, BlockRenderContext context, Int3 pos)
 {
     if (Renderers.Count > 0 && Renderers[id] != null)
     {
         Renderers[id].Render(target, context, pos);
     }
 }
        public static MemoryAccessInfo[] GetVertexAttributes(this IVertexBuilder firstVertex, int vertexCount, PackedEncoding vertexEncoding)
        {
            var tvg = firstVertex.GetGeometry().GetType();
            var tvm = firstVertex.GetMaterial().GetType();
            var tvs = firstVertex.GetSkinning().GetType();

            var attributes = new List <MemoryAccessInfo>();

            foreach (var finfo in tvg.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvm.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvs.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    var a = attribute.Value;
                    if (a.Name.StartsWith("JOINTS_", StringComparison.OrdinalIgnoreCase))
                    {
                        a.Encoding = vertexEncoding.JointsEncoding.Value;
                    }
                    if (a.Name.StartsWith("WEIGHTS_", StringComparison.OrdinalIgnoreCase))
                    {
                        a.Encoding = vertexEncoding.WeightsEncoding.Value;
                        if (a.Encoding != ENCODING.FLOAT)
                        {
                            a.Normalized = true;
                        }
                    }

                    attributes.Add(a);
                }
            }

            var array = attributes.ToArray();

            MemoryAccessInfo.SetInterleavedInfo(array, 0, vertexCount);

            return(array);
        }
示例#4
0
        public static IReadOnlyList <IVertexBuilder> GetMorphTargetVertices(this IMorphTargetReader morphTarget, int targetIndex, int vertexCount)
        {
            var c = new IVertexBuilder[vertexCount];

            for (int i = 0; i < vertexCount; ++i)
            {
                c[i] = morphTarget.GetVertexDisplacement(targetIndex, i);
            }

            return(c);
        }
示例#5
0
        public static MemoryAccessInfo[] GetVertexAttributes(this IVertexBuilder firstVertex, int vertexCount, Schema2.EncodingType jointEncoding)
        {
            var tvg = firstVertex.GetGeometry().GetType();
            var tvm = firstVertex.GetMaterial().GetType();
            var tvs = firstVertex.GetSkinning().GetType();

            var attributes = new List <MemoryAccessInfo>();

            foreach (var finfo in tvg.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvm.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvs.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    var a = attribute.Value;
                    if (a.Name.StartsWith("JOINTS_", StringComparison.OrdinalIgnoreCase))
                    {
                        a.Encoding = jointEncoding;
                    }

                    attributes.Add(a);
                }
            }

            var array = attributes.ToArray();

            MemoryAccessInfo.SetInterleavedInfo(array, 0, vertexCount);

            return(array);
        }
示例#6
0
        public static MemoryAccessInfo[] GetVertexAttributes(this IVertexBuilder firstVertex, int vertexCount)
        {
            var tvg = firstVertex.GetGeometry().GetType();
            var tvm = firstVertex.GetMaterial().GetType();
            var tvs = firstVertex.GetSkinning().GetType();

            var attributes = new List <MemoryAccessInfo>();

            foreach (var finfo in tvg.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvm.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            foreach (var finfo in tvs.GetFields())
            {
                var attribute = _GetMemoryAccessInfo(finfo);
                if (attribute.HasValue)
                {
                    attributes.Add(attribute.Value);
                }
            }

            var array = attributes.ToArray();

            MemoryAccessInfo.SetInterleavedInfo(array, 0, vertexCount);

            return(array);
        }
示例#7
0
        public override void Initialize()
        {
            Logger.Trace("init()");

            // import required services.
            this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage));
            this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera));
            this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer));
            this._fogger = (IFogger) this.Game.Services.GetService(typeof (IFogger));
            this.VertexBuilder = (IVertexBuilder) this.Game.Services.GetService(typeof (IVertexBuilder));
            this._timeRuler = (TimeRuler) this.Game.Services.GetService(typeof (TimeRuler));

            this.Generator = new BiomedTerrain(new RainForest());
            base.Initialize();
        }
示例#8
0
        public override void Initialize()
        {
            Logger.Trace("init()");

            // import required services.
            this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage));
            this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera));
            this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer));
            this._fogger = (IFogger) this.Game.Services.GetService(typeof (IFogger));
            this.VertexBuilder = (IVertexBuilder) this.Game.Services.GetService(typeof (IVertexBuilder));
            this._timeRuler = (TimeRuler) this.Game.Services.GetService(typeof (TimeRuler));

            this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager));
            if (this._assetManager == null)
                throw new NullReferenceException("Can not find asset manager component.");

            this.Generator = new BiomedTerrain(new RainForest());
            base.Initialize();
        }