Exemplo n.º 1
0
 public CollisionTriangleList(int ID)
 {
     id      = ID;
     texture = TextureFormats.ColorTexture(
         Color4b.HSV(60 + ID * 39, (14 - (3 + ((ID >> 3) & 7))) / 14.0, (4 - ((ID >> 6) & 3)) / 4.0)
         );
 }
Exemplo n.º 2
0
        internal Texture2D(TextureFormats.Raw handle, int width, int height)
        {
            if (null == handle)
            {
                throw new ArgumentNullException("handle");
            }

            this.raw    = handle;
            this.width  = width;
            this.height = height;
        }
Exemplo n.º 3
0
 internal static void UpdateHandle(
     TextureFormats.Raw bitmap,
     ref GraphicsHandle.Texture handle)
 {
     /*
      * using (var bmp = bitmap.ToBitmap())
      *      if (null == (object)bmp)
      *      {
      *              handle.Delete();
      *      }
      *      else*/
     LoadTextureHandle(/*bmp*/ bitmap, handle);
 }
Exemplo n.º 4
0
        public static unsafe Bitmap ToBitmap(this TextureFormats.Raw bitmap)
        {
            if (null == (object)bitmap)
                return(null);

            fixed(byte *argb = bitmap.ARGB)
            return(new Bitmap(
                       bitmap.Width,
                       bitmap.Height,
                       (int)bitmap.Width << 2,
                           System.Drawing.Imaging.PixelFormat.Format32bppArgb,
                           (IntPtr)argb));
        }
Exemplo n.º 5
0
        private unsafe static void LoadTextureHandle(TextureFormats.Raw bitmap, int id)
        {
            GL.BindTexture(TextureTarget.Texture2D, id);

            fixed(byte *buf = bitmap.ARGB)
            GL.TexImage2D(TextureTarget.Texture2D,
                          0,
                          PixelInternalFormat.Rgba,
                          bitmap.Width, bitmap.Height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
                          PixelType.UnsignedByte,
                          (IntPtr)buf);

            LoadTextureHandlePostTexImage2D();
        }
Exemplo n.º 6
0
        public static Texture2D LoadTexture(TextureFormats.Raw bitmap, int s, int t)
        {
            if (null == bitmap)
            {
                return(null);
            }
            else
            {
                if (bitmap.CreateHandle(out GraphicsHandle.Texture handle))
                {
                    UpdateHandle(bitmap, ref handle);
                }

                return(handle.Alive != GraphicsHandle.Null ?
                       new Texture2D(bitmap, bitmap.Width, bitmap.Height)
                {
                    TextureParamS = s, TextureParamT = t,
                } :
                       null);
            }
        }
Exemplo n.º 7
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));
        }