Пример #1
0
        internal byte BindGL(GeoModel prev, ref GeoModel @this)
        {
            GeoMesh iter, piter;
            uint    iter_pos;

            for (iter = First, piter = Last, iter_pos = Count; 0 != iter_pos; piter = iter, iter = iter.Next, --iter_pos)
            {
                DrawLayerMask |= iter.BindGL(piter, ref iter);
            }
            return(DrawLayerMask);
        }
Пример #2
0
 internal GeoModel StartModel()
 {
     if (0 == ModelCount++)
     {
         FirstModel      = new GeoModel(this);
         FirstModel.Next = FirstModel;
         LastModel       = FirstModel;
     }
     else
     {
         LastModel.Next = (new GeoModel(this)
         {
             Next = LastModel.Next,
         });
         LastModel = LastModel.Next;
     }
     return(LastModel);
 }
Пример #3
0
        public GeoMesh(GeoModel Parent, Scripts.TempMesh128 Mesh, ref Dictionary <Scripts.TempVertex128, Scripts.TempVertex128> utilize)
        {
            Scripts.TempVertex128 viter;
            uint viterpos;

            this.Parent   = Parent;
            this.Options  = Mesh.value;
            this.Material = this.Options.getMaterial();
            this.texture  = Mesh.references.bmp;
            utilize       = Scripts.TempVertex128.Process(ref Mesh.references.list, utilize);
            var VertexCount = utilize.Count;

            this.VertexBuffer = new byte[VertexCount << 4];
            Array IndexBuffer;
            var   IndexSize = VertexCount > 256 ? VertexCount > (ushort.MaxValue + 1u) ? 4 : 2 : 1;

            this.IndexCount = (int)Mesh.references.list.count;
            byte IndexElementSize;
            uint NextIndex = 0;

            if (IndexSize > 1)
            {
                if (IndexSize > 2)
                {
                    var UIndexBuffer = new uint[IndexCount];
                    for (viterpos = Mesh.references.list.count, viter = Mesh.references.list.first; viterpos != 0; viter = viter.next, --viterpos)
                    {
                        unchecked
                        {
                            UIndexBuffer[(int)(Mesh.references.list.count - viterpos)] = viter.index;
                            if (NextIndex == viter.index)
                            {
                                StoreVertex(VertexBuffer, ref viter.value, (int)(NextIndex++) << 4);
                            }
                        }
                    }
                    IndexBuffer      = UIndexBuffer;
                    IndexElementSize = 4;
                }
                else
                {
                    var UIndexBuffer = new ushort[IndexCount];
                    for (viterpos = Mesh.references.list.count, viter = Mesh.references.list.first; viterpos != 0; viter = viter.next, --viterpos)
                    {
                        unchecked
                        {
                            UIndexBuffer[(int)(Mesh.references.list.count - viterpos)] = (ushort)viter.index;
                            if (NextIndex == viter.index)
                            {
                                StoreVertex(VertexBuffer, ref viter.value, (int)(NextIndex++) << 4);
                            }
                        }
                    }
                    IndexBuffer      = UIndexBuffer;
                    IndexElementSize = 2;
                }
            }
            else
            {
                var UIndexBuffer = new byte[IndexCount];
                for (viterpos = Mesh.references.list.count, viter = Mesh.references.list.first; viterpos != 0; viter = viter.next, --viterpos)
                {
                    unchecked
                    {
                        UIndexBuffer[(int)(Mesh.references.list.count - viterpos)] = (byte)viter.index;
                        if (NextIndex == viter.index)
                        {
                            StoreVertex(VertexBuffer, ref viter.value, (int)(NextIndex++) << 4);
                        }
                    }
                }
                IndexBuffer      = UIndexBuffer;
                IndexElementSize = 1;
            }
            this.IndexBuffer      = IndexBuffer;
            this.IndexElementSize = IndexElementSize;
            this.IndicesByteSize  = 2 == IndexElementSize ? IndexCount << 1 : 4 == IndexElementSize ? IndexCount << 2 : IndexCount;
            DrawLayerMask         = (byte)(1 << (Material.drawLayerBillboard & 7));
        }