コード例 #1
0
        // determines if this stage affects the map coordinates specified
        // returns true always, except for Blend
        public bool Affects(int mapx, int mapy, int mapwidth, int mapheight)
        {
            //Console.WriteLine("Affects");
            if (Operation == OperationType.Nop)
            {
                //  Console.WriteLine("return false: Nop");
                return(false);
            }
            if (Operation != OperationType.Blend)
            {
                //Console.WriteLine("return true: !Blend");
                return(true);
            }
            int texturex = (blendtexture.Width * mapx) / mapwidth;
            int texturey = (blendtexture.Height * mapy) / mapheight;

            //int texturex = ( blendtexture.AlphaData.GetUpperBound(0) * mapx ) / mapwidth;
            //int texturey = (blendtexture.AlphaData.GetUpperBound(1) * mapy) / mapheight;
            try
            {
                if (blendtexture.GetRed(texturex, texturey) > 0)
                //if (blendtexture.AlphaData[texturex, texturey] > 0)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw new Exception("texturex: " + texturex + " " + texturey + " mapx " + mapx + " mapy " + mapy + " mapwidth " + mapwidth + " " + mapheight);
            }
            return(false);
        }
コード例 #2
0
ファイル: GlTexture.cs プロジェクト: beyonddiana/osmp-cs
        // reads R channel as alpha channel
        void LoadImageToOpenGlAsAlpha(ImageWrapper image)
        {
            width  = image.Width;
            height = image.Height;
            LogFile.WriteLine("loading texture " + filename + " width: " + width + " height: " + height);

            alphadata = new byte[width, height];
            byte[] dataforgl = new byte[width * height];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    int gloffset = y * width + x;
                    alphadata[x, y]     = image.GetRed(x, y);
                    dataforgl[gloffset] = image.GetRed(x, y);
                }
            }

            Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlReference);
            Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_ALPHA8, width, height, 0, Gl.GL_ALPHA, Gl.GL_UNSIGNED_BYTE, dataforgl);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
        }
コード例 #3
0
 void LoadTextureData(MapTextureStageModel maptexturestage)
 {
     LogFile.WriteLine("PaintTexture.LoadTextureData( " + maptexturestage);
     thistexture = maptexturestage.blendtexture;
     if (thistexture != null)
     {
         texturewidth  = thistexture.Width;
         textureheight = thistexture.Height;
         LogFile.WriteLine("edittexture width " + texturewidth + " height " + textureheight);
         alphadata = new double[texturewidth, textureheight];
         for (int x = 0; x < texturewidth; x++)
         {
             for (int y = 0; y < textureheight; y++)
             {
                 alphadata[x, y] = thistexture.GetRed(x, y);
             }
         }
     }
 }
コード例 #4
0
ファイル: PaintTexture.cs プロジェクト: hughperkins/osmp-cs
 void LoadTextureData( MapTextureStageModel maptexturestage )
 {
     LogFile.WriteLine( "PaintTexture.LoadTextureData( " + maptexturestage );
     thistexture = maptexturestage.blendtexture;
     if (thistexture != null)
     {
         texturewidth = thistexture.Width;
         textureheight = thistexture.Height;
         LogFile.WriteLine( "edittexture width " + texturewidth + " height " + textureheight );
         alphadata = new double[texturewidth, textureheight];
         for (int x = 0; x < texturewidth; x++)
         {
             for (int y = 0; y < textureheight; y++)
             {
                 alphadata[x, y] = thistexture.GetRed( x, y );
             }
         }
     }
 }