예제 #1
0
        private void SyncLoad()
        {
            mSyncLoadToken = null;

            mTexParams.TextureScales   = new Vector4(mData.TextureScales);
            mTexParams.SpecularFactors = new Vector4(mData.SpecularFactors);
            mTexParams.ChunkLine       = new Vector4(0.0f, 0.7f, 0.0f, 0.0f);
            mTexParams.AreaColour      = ChunkEditManager.Instance.GetAreaColour(mData.AreaId, mData.HasImpassFlag);

            mTexAnimBuffer       = new ConstantBuffer(WorldFrame.Instance.GraphicsContext);
            mTexAnimStore.Layer0 = mTexAnimStore.Layer1 = mTexAnimStore.Layer2 = mTexAnimStore.Layer3 = Matrix.Identity;
            mTexAnimBuffer.UpdateData(mTexAnimStore);
            mAlphaTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
            mAlphaTexture.UpdateMemory(64, 64, Format.R8G8B8A8_UNorm, mData.AlphaValues, 4 * 64);
            mHoleTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
            mHoleTexture.UpdateMemory(8, 8, Format.R8_UNorm, mData.HoleValues, 8);
            mScaleBuffer = new ConstantBuffer(WorldFrame.Instance.GraphicsContext);
            mScaleBuffer.UpdateData(mTexParams);
            mShaderTextures         = mData.Textures.ToArray();
            mShaderSpecularTextures = mData.SpecularTextures.ToArray();

            SetRenderMode(ChunkEditManager.Instance.ChunkRenderMode); //Set current render mode

            mIsSyncLoaded = true;
        }
예제 #2
0
        public Graphics.Texture GetTexture(string path)
        {
            if (string.IsNullOrEmpty(path))
                return new Graphics.Texture(mContext);

            var hash = path.ToUpperInvariant().GetHashCode();
            TextureWorkItem workItem;
            Graphics.Texture retTexture;
            lock (mCache)
            {
                WeakReference<Graphics.Texture> ret;
                if(mCache.TryGetValue(hash, out ret))
                {
                    if (ret.TryGetTarget(out retTexture))
                        return retTexture;

                    mCache.Remove(hash);
                }

                retTexture = new Graphics.Texture(mContext);
                mCache.Add(hash, new WeakReference<Graphics.Texture>(retTexture));
                workItem = new TextureWorkItem(path, retTexture);
            }

            lock (mWorkItems)
            {
                mWorkItems.Add(workItem);
                lock (mWorkEvent)
                    Monitor.Pulse(mWorkEvent);
            }

            return retTexture;
        }
예제 #3
0
        public override void Initialize()
        {
            mSkyTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
            WorldFrame.Instance.MapManager.SkySphere.UpdateSkyTexture(mSkyTexture);

            for (var i = 0; i < Storage.DbcStorage.Map.NumRows; ++i)
            {
                var id = Storage.DbcStorage.Map.GetRow(i).GetUint32(0);
                mSkies.Add(id, new MapSky(id));
            }
        }
예제 #4
0
 private void SyncLoad()
 {
     mAlphaTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     mAlphaTexture.UpdateMemory(64, 64, SharpDX.DXGI.Format.R8G8B8A8_UNorm, mData.AlphaValues, 4 * 64);
     mHoleTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     mHoleTexture.UpdateMemory(8, 8, SharpDX.DXGI.Format.R8_UNorm, mData.HoleValues, 8);
     mScaleBuffer = new ConstantBuffer(WorldFrame.Instance.GraphicsContext);
     mScaleBuffer.UpdateData(mData.TextureScales);
     mShaderTextures = mData.Textures.ToArray();
     mSyncLoaded     = true;
 }
예제 #5
0
        public override void Initialize()
        {
            mSkyTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
            WorldFrame.Instance.MapManager.SkySphere.UpdateSkyTexture(mSkyTexture);

            for (var i = 0; i < Storage.DbcStorage.Map.NumRows; ++i)
            {
                var id = Storage.DbcStorage.Map.GetRow(i).GetUint32(0);
                mSkies.Add(id, new MapSky(id));
            }
        }
예제 #6
0
파일: WmoMaterial.cs 프로젝트: veserine/Neo
 public WmoMaterial(WmoRoot root, int shader, int texture1, int texture2, int texture3, int blendMode, uint flags, uint materialFlags)
 {
     Textures      = new Graphics.Texture[0];
     MaterialFlags = materialFlags;
     mTexture1     = texture1;
     mTexture2     = texture2;
     mTexture3     = texture3;
     ShaderType    = shader;
     BlendMode     = blendMode;
     Flags1        = flags;
     LoadTextures(root);
 }
예제 #7
0
파일: WorldText.cs 프로젝트: veserine/Neo
        private void Dispose(bool disposing)
        {
            if (mTexture != null)
            {
                mTexture.Dispose();
                mTexture = null;
            }

            mFont  = null;
            mBrush = null;
            mText  = null;
        }
예제 #8
0
 public WmoMaterial(WmoRoot root, int shader, int texture1, int texture2, int texture3, int blendMode, uint flags, uint materialFlags)
 {
     Textures = new Graphics.Texture[0];
     MaterialFlags = materialFlags;
     mTexture1 = texture1;
     mTexture2 = texture2;
     mTexture3 = texture3;
     ShaderType = shader;
     BlendMode = blendMode;
     Flags1 = flags;
     LoadTextures(root);
 }
예제 #9
0
        private void Dispose(bool disposing)
        {
            var alphaTex    = mAlphaTexture;
            var holeTex     = mHoleTexture;
            var constBuffer = mScaleBuffer;
            var tanim       = mTexAnimBuffer;

            WorldFrame.Instance.Dispatcher.BeginInvoke(() =>
            {
                if (holeTex != null)
                {
                    holeTex.Dispose();
                }
                if (alphaTex != null)
                {
                    alphaTex.Dispose();
                }
                if (constBuffer != null)
                {
                    constBuffer.Dispose();
                }
                if (tanim != null)
                {
                    tanim.Dispose();
                }
            });

            lock (this)
            {
                // Sync load can be called even after the object has been disposed.
                if (mSyncLoadToken != null)
                {
                    WorldFrame.Instance.Dispatcher.Remove(mSyncLoadToken);
                    mSyncLoadToken = null;
                }
            }

            ChunkEditManager.Instance.OnChunkRenderModeChange -= SetRenderMode;
            ChunkEditManager.Instance.ForceRenderUpdate       -= ForceRenderMode;

            mAlphaTexture   = null;
            mHoleTexture    = null;
            mScaleBuffer    = null;
            mShaderTextures = null;
            mReferences     = null;
            mParent         = null;
        }
예제 #10
0
        public Graphics.Texture GetTexture(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(new Graphics.Texture(mContext));
            }

            var             hash = path.ToUpperInvariant().GetHashCode();
            TextureWorkItem workItem;

            Graphics.Texture retTexture;
            lock (mCache)
            {
                WeakReference <Graphics.Texture> ret;
                if (mCache.TryGetValue(hash, out ret))
                {
                    if (ret.TryGetTarget(out retTexture))
                    {
                        return(retTexture);
                    }

                    mCache.Remove(hash);
                }

                retTexture = new Graphics.Texture(mContext);
                mCache.Add(hash, new WeakReference <Graphics.Texture>(retTexture));
                workItem = new TextureWorkItem(path, retTexture);
            }

            lock (mWorkItems)
            {
                mWorkItems.Add(workItem);
                lock (mWorkEvent)
                    Monitor.Pulse(mWorkEvent);
            }

            return(retTexture);
        }
예제 #11
0
 private void SyncLoad()
 {
     mAlphaTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     mAlphaTexture.UpdateMemory(64, 64, SharpDX.DXGI.Format.R8G8B8A8_UNorm, mData.AlphaValues, 4 * 64);
     mHoleTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     mHoleTexture.UpdateMemory(8, 8, SharpDX.DXGI.Format.R8_UNorm, mData.HoleValues, 8);
     mScaleBuffer = new ConstantBuffer(WorldFrame.Instance.GraphicsContext);
     mScaleBuffer.UpdateData(mData.TextureScales);
     mShaderTextures = mData.Textures.ToArray();
     mSyncLoaded = true;
 }
예제 #12
0
 public void UpdateSkyTexture(Graphics.Texture tex)
 {
     mSkyTexture = tex;
 }
예제 #13
0
 public override void Initialize()
 {
     mLightCollection.FillLights();
     mSkyTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     WorldFrame.Instance.MapManager.SkySphere.UpdateSkyTexture(mSkyTexture);
 }
예제 #14
0
        private void Load()
        {
            //SizeMetrics fontSizeMetrics = Face.Size.Metrics;
            //Size glyphSlotSize = new Size(fontSizeMetrics.NominalWidth, fontSizeMetrics.Height.ToSingle());

            /*
             * FontFaceRenderMap renderMap = new FontFaceRenderMap(
             *  face,
             *  glyphSlotSize,
             *  fontSizeMetrics.NominalWidth,
             *  fontSizeMetrics.NominalHeight,
             *  fontSizeMetrics.Height.ToSingle(),
             *  fontSizeMetrics.Ascender.ToSingle(),
             *  fontSizeMetrics.Descender.ToSingle()
             * );
             */

            // adjust signs to respect Raccoon y-origin direction
            LineHeight         = ConvertPxToEm(Face.Size.Metrics.Height.ToSingle(), Size);
            Ascender           = -ConvertPxToEm(Face.Size.Metrics.Ascender.ToSingle(), Size);
            Descender          = Math.Abs(ConvertPxToEm(Face.Size.Metrics.Descender.ToSingle(), Size));
            UnderlinePosition  = Math.Abs(Face.UnderlinePosition / (float)Face.UnitsPerEM);
            UnderlineThickness = Face.UnderlineThickness / (float)Face.UnitsPerEM;

            // prepare texture
            int sideSize        = (int)(Util.Math.Ceiling(System.Math.Sqrt(Face.GlyphCount)) * GlyphSlotSize.Width),
                textureSideSize = Util.Math.CeilingPowerOfTwo(sideSize);

            if (Texture == null)
            {
                Texture = new Graphics.Texture(textureSideSize, textureSideSize);
            }
            else if (Texture.Width != textureSideSize || Texture.Height != textureSideSize)
            {
                Texture.Dispose();
                Texture = new Graphics.Texture(textureSideSize, textureSideSize);
            }

            // prepare texture data copying glyphs bitmaps
            Graphics.Color[] textureData = new Graphics.Color[textureSideSize * textureSideSize];

            Vector2 glyphPosition = Vector2.Zero;

            uint charCode = Face.GetFirstChar(out uint glyphIndex);

            while (glyphIndex != 0)
            {
                Face.LoadGlyph(glyphIndex, LoadFlags.Default, LoadTarget.Normal);
                Face.Glyph.RenderGlyph(RenderMode.Normal);

                FTBitmap ftBitmap = Face.Glyph.Bitmap;

                if (ftBitmap != null && ftBitmap.Width > 0 && ftBitmap.Rows > 0)
                {
                    if (ftBitmap.PixelMode != PixelMode.Gray)
                    {
                        throw new System.NotImplementedException("Supported PixelMode formats are: Gray");
                    }

                    // tests if glyph bitmap actually fits on current row
#if TIGHT_PACK_FACE_RENDER_MAP
                    if (glyphPosition.X + ftBitmap.Width >= textureSideSize)
                    {
                        glyphPosition.Y += GlyphSlotSize.Height;
                        glyphPosition.X  = 0;
                    }
#else
                    if (glyphPosition.X + GlyphSlotSize.Width >= textureSideSize)
                    {
                        glyphPosition.Y += GlyphSlotSize.Height;
                        glyphPosition.X  = 0;
                    }
#endif

                    CopyBitmapToDestinationArea(textureData, textureSideSize, glyphPosition, ftBitmap);

                    RegisterGlyph(
                        charCode,
                        new Rectangle(
                            glyphPosition,
                            new Size(ftBitmap.Width, ftBitmap.Rows)
                            ),
                        -ConvertPxToEm(Face.Glyph.Metrics.HorizontalBearingX.ToDouble(), Size),
                        -ConvertPxToEm(Face.Glyph.Metrics.HorizontalBearingY.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Metrics.Width.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Metrics.Height.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Advance.X.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Advance.Y.ToDouble(), Size)
                        );

                    // advance to next glyph area
#if TIGHT_PACK_FACE_RENDER_MAP
                    glyphPosition.X += ftBitmap.Width;
#else
                    glyphPosition.X += GlyphSlotSize.Width;
#endif
                }
                else
                {
                    RegisterGlyph(
                        charCode,
                        Rectangle.Empty,
                        -ConvertPxToEm(Face.Glyph.Metrics.HorizontalBearingX.ToDouble(), Size),
                        -ConvertPxToEm(Face.Glyph.Metrics.HorizontalBearingY.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Metrics.Width.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Metrics.Height.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Advance.X.ToDouble(), Size),
                        ConvertPxToEm(Face.Glyph.Advance.Y.ToDouble(), Size)
                        );
                }

                charCode = Face.GetNextChar(charCode, out glyphIndex);
            }

            // render glyphs
            Texture.SetData(textureData);
        }
예제 #15
0
파일: SkySphere.cs 프로젝트: veserine/Neo
 public void UpdateSkyTexture(Graphics.Texture tex)
 {
     mSkyTexture = tex;
 }
예제 #16
0
 public void Draw()
 {
     Graphics.Texture texture = Graphics.TextureManager.GetTile(Sheet, Texture);
     texture.Render(null);
 }
예제 #17
0
 public override void Initialize()
 {
     mLightCollection.FillLights();
     mSkyTexture = new Graphics.Texture(WorldFrame.Instance.GraphicsContext);
     WorldFrame.Instance.MapManager.SkySphere.UpdateSkyTexture(mSkyTexture);
 }
예제 #18
0
파일: WorldText.cs 프로젝트: veserine/Neo
        private void OnSyncLoad()
        {
            var ctx = WorldFrame.Instance.GraphicsContext;

            mTexture = new Graphics.Texture(ctx);
        }
예제 #19
0
 public void ChangeMap(Map map)
 {
     _texture = _contentManager
                .Load <Graphics.Texture>($"maps\\{map.MapId}\\{map.Texture.Asset}");
     _currentMap = map;
 }
예제 #20
0
 public TextureWorkItem(string file, Graphics.Texture tex)
 {
     Texture  = tex;
     FileName = file;
 }