예제 #1
0
        public void keepWidgetOnscreen(Widget widget)
        {
            bool       needsMoved = false;
            IntVector2 location   = new IntVector2(widget.Left, widget.Top);
            IntSize2   size       = new IntSize2(widget.Width, widget.Height);

            int viewWidth = RenderManager.Instance.ViewWidth;

            if (location.x + size.Width > viewWidth)
            {
                needsMoved = true;
                location.x = viewWidth - size.Width;
                if (location.x < 0)
                {
                    location.x = 0;
                }
            }

            int viewHeight = RenderManager.Instance.ViewHeight;

            if (location.y + size.Height > viewHeight)
            {
                needsMoved = true;
                location.y = viewHeight - size.Height;
                if (location.y < 0)
                {
                    location.y = 0;
                }
            }

            if (needsMoved)
            {
                widget.setPosition(location.x, location.y);
            }
        }
예제 #2
0
        void actionView_CanvasHeightChanged(int newSize)
        {
            IntSize2 canvasSize = scrollView.CanvasSize;

            canvasSize.Height     = newSize;
            scrollView.CanvasSize = canvasSize;
        }
예제 #3
0
        public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D<bool> visibilityMap, IntSize2 mapSize,
			Func<IntVector2, bool> blockerDelegate)
        {
            visibilityMap.Clear();

            if (blockerDelegate(viewerLocation) == true)
                return;

            for (int y = -visionRange; y <= visionRange; ++y)
            {
                for (int x = -visionRange; x <= visionRange; ++x)
                {
                    var dst = viewerLocation + new IntVector2(x, y);

                    if (mapSize.Contains(dst) == false)
                    {
                        visibilityMap[x, y] = false;
                        continue;
                    }

                    bool vis = FindLos(viewerLocation, dst, blockerDelegate);
                    visibilityMap[x, y] = vis;
                }
            }
        }
        public override void layout()
        {
            if (Child != null)
            {
                IntVector2 loc  = Location;
                IntSize2   size = WorkingSize;

                if (!autoAspectRatio)
                {
                    size.Height = (int)(size.Width * inverseAspectRatio);
                    if (size.Height > WorkingSize.Height) //Letterbox width
                    {
                        size.Height = WorkingSize.Height;
                        size.Width  = (int)(size.Height * (1 / inverseAspectRatio));
                        loc.x      += (WorkingSize.Width - size.Width) / 2;

                        borderPanel0.setCoord(Location.x, Location.y, loc.x - Location.x, WorkingSize.Height);
                        borderPanel1.setCoord(loc.x + size.Width, Location.y, loc.x - Location.x + 1, WorkingSize.Height);
                    }
                    else
                    {
                        loc.y += (WorkingSize.Height - size.Height) / 2;

                        borderPanel0.setCoord(Location.x, Location.y, WorkingSize.Width, loc.y - Location.y);
                        borderPanel1.setCoord(Location.x, loc.y + size.Height, WorkingSize.Width, loc.y - Location.y + 1);
                    }
                }

                Child.Location    = loc;
                Child.WorkingSize = size;
                Child.layout();
            }
        }
예제 #5
0
 public UcRenderTextureImage(IntSize2 size, bool hasTransparency = false)
     : base(ResourceVolatility.Volatile)
 {
     Size            = size;
     HasTransparency = hasTransparency;
     Texture         = new RenderTexture(Size.Width, Size.Height, 24, GraphicsFormat.R8G8B8A8_SRGB);
 }
예제 #6
0
        public IRichTextBoxLayout Build(IRichText text, IntSize2 size, float padding)
        {
            text.Normalize();
            var lspans = new List <RichTextBoxLayoutSpan>();
            var externalLayoutSpans = new List <RichTextBoxLayoutSpan>();
            var context             = new BuildingContext
            {
                Text                = text,
                LayoutSpans         = lspans,
                ExternalLayoutSpans = externalLayoutSpans,
                RemainingShape      = new AaRectangle2(new Vector2(padding), new Vector2(size.Width, size.Height) - new Vector2(padding))
            };

            for (var i = 0; i < text.Paragraphs.Count; i++)
            {
                BuildParagraph(context, i);
            }

            if (lspans.Count == 0)
            {
                var defaultStyle = text.Paragraphs[0].Spans[0].Style;
                lspans.Add(new RichTextBoxLayoutSpan
                {
                    TextAbsPosition = 0,
                    TextRelPosition = new RtPosition(),
                    Bounds          = new AaRectangle2(new Vector2(0, 0), new Vector2(1f, defaultStyle.Size)),
                    Strip           = new AaRectangle2(new Vector2(0, 0), new Vector2(1f, defaultStyle.Size)),
                    Style           = defaultStyle,
                    Text            = "",
                    CharOffsets     = EmptyArrays <float> .Array
                });
            }

            return(new RichTextBoxLayout(text, lspans, externalLayoutSpans));
        }
예제 #7
0
        public static void SetVirtualTextureMemoryUsageMode(VTMemoryMode mode)
        {
            switch (mode)
            {
            case VTMemoryMode.Small:
                MaxStagingVirtualTextureUploadsPerFrame = int.MaxValue;
                VirtualTextureStagingBufferCount        = 20;
                TextureCacheSize    = 100 * 1024 * 1024;
                FeedbackBufferSize  = new IntSize2(256, 128);
                PhysicalTextureSize = new IntSize2(2048, 2048);
                PageSize            = 64;
                break;

            case VTMemoryMode.Normal:
                MaxStagingVirtualTextureUploadsPerFrame = int.MaxValue;
                VirtualTextureStagingBufferCount        = 20;
                TextureCacheSize    = 100 * 1024 * 1024;
                FeedbackBufferSize  = new IntSize2(256, 128);
                PhysicalTextureSize = new IntSize2(4096, 4096);
                PageSize            = 128;
                break;

            case VTMemoryMode.Large:
                MaxStagingVirtualTextureUploadsPerFrame = int.MaxValue;
                VirtualTextureStagingBufferCount        = 20;
                TextureCacheSize    = 500 * 1024 * 1024;
                FeedbackBufferSize  = new IntSize2(256, 128);
                PhysicalTextureSize = new IntSize2(8192, 8192);
                PageSize            = 128;
                break;
            }
        }
예제 #8
0
        public void changeSize(IntRect newRect, ResizeType resizeType, IntSize2 bounds)
        {
            bool changesMade = false;

            if ((resizeType & ResizeType.Top) == ResizeType.Top)
            {
                marginTop = newRect.Top;
                if (marginTop < 0)
                {
                    marginTop = 0;
                }
                changesMade = true;
            }

            if ((resizeType & ResizeType.Height) == ResizeType.Height)
            {
                marginBottom = newRect.Height;
                if (marginBottom < 0)
                {
                    marginBottom = 0;
                }
                changesMade = true;
            }

            if (changesMade)
            {
                fireRefreshEditInterface();
            }
        }
        public override TexturePageHandle createTexturePageHandle(VTexPage page, IndirectionTexture indirectionTexture, int padding, int padding2, int textelsPerPage, int mipOffset)
        {
            PixelBox sourceBox;
            int      mipCount = image.NumMipmaps;

            if (mipCount == 0) //We always have to take from the largest size
            {
                sourceBox = image.getPixelBox(0, 0);
            }
            else
            {
                sourceBox = image.getPixelBox(0, (uint)(page.mip - mipOffset));
            }

            IntSize2 largestSupportedPageIndex = indirectionTexture.NumPages;

            largestSupportedPageIndex.Width  >>= page.mip;
            largestSupportedPageIndex.Height >>= page.mip;
            if (page.x != 0 && page.y != 0 && page.x + 1 != largestSupportedPageIndex.Width && page.y + 1 != largestSupportedPageIndex.Height)
            {
                //Can grab a complete page from the texture
                sourceBox.Rect = new IntRect(page.x * textelsPerPage - padding, page.y * textelsPerPage - padding, textelsPerPage + padding2, textelsPerPage + padding2);
            }
            else
            {
                //Have to get a partial page
                sourceBox.Rect = new IntRect(page.x * textelsPerPage, page.y * textelsPerPage, textelsPerPage, textelsPerPage);
            }

            return(new TexturePageHandle(sourceBox, this));
        }
        public override void layout()
        {
            IntVector2 currentLocation = startLocation + Location;

            if (layoutType == LayoutType.Horizontal)
            {
                foreach (LayoutContainer child in children)
                {
                    IntSize2 childSize = child.DesiredSize;
                    childSize.Height  = WorkingSize.Height;
                    child.WorkingSize = childSize;
                    child.Location    = currentLocation;
                    child.layout();
                    currentLocation.x += childSize.Width + padding;
                }
            }
            else
            {
                foreach (LayoutContainer child in children)
                {
                    IntSize2 childSize = child.DesiredSize;
                    childSize.Width   = WorkingSize.Width;
                    child.WorkingSize = childSize;
                    child.Location    = currentLocation;
                    child.layout();
                    currentLocation.y += childSize.Height + padding;
                }
            }
        }
예제 #11
0
        static NoiseMap CreateTerrainNoiseMap(Module noise, IntSize2 size)
        {
            var map = new NoiseMap();

            var build = new SharpNoise.Builders.PlaneNoiseMapBuilder()
            {
                DestNoiseMap   = map,
                EnableSeamless = false,
                SourceModule   = noise,
            };

            double x = 1;
            double y = 1;
            double w = size.Width / 256.0;
            double h = size.Height / 256.0;

            build.SetDestSize(size.Width, size.Height);
            build.SetBounds(x, x + w, y, y + h);
            build.Build();

            //map.BorderValue = 1;
            //map = NoiseMap.BilinearFilter(map, this.Width, this.Height);

            return(map);
        }
        public void sendUpdate(Clock clock)
        {
            if (animating)
            {
                currentTime += clock.DeltaSeconds;
                if (currentTime < animationLength)
                {
                    alpha       = EasingFunctions.Ease(currentEasing, 0, 1.0f, currentTime, animationLength);
                    currentSize = new IntSize2((int)(oldSize.Width + sizeDelta.Width * alpha), WorkingSize.Height);
                }
                else
                {
                    currentTime = animationLength;
                    alpha       = 1.0f;
                    currentSize = new IntSize2(oldSize.Width + sizeDelta.Width, WorkingSize.Height);

                    finishAnimation();
                    oldChildContainer = null;
                }
                if (childContainer != null && oldChildContainer != null)
                {
                    childContainer.setAlpha(alpha);
                }
                invalidate();
            }
        }
예제 #13
0
 public RawImage(ResourceVolatility volatility, IntSize2 size, bool hasTransparency, byte[] rawData)
     : base(volatility)
 {
     Size            = size;
     HasTransparency = hasTransparency;
     RawData         = rawData;
 }
 private void getDesiredSizes(out IntSize2 leftDesired, out IntSize2 rightDesired, out IntSize2 topDesired, out IntSize2 bottomDesired)
 {
     leftDesired = left != null ? left.DesiredSize : new IntSize2();
     rightDesired = right != null ? right.DesiredSize : new IntSize2();
     topDesired = top != null ? top.DesiredSize : new IntSize2();
     bottomDesired = bottom != null ? bottom.DesiredSize : new IntSize2();
 }
            void view_ViewResized(ViewHost view)
            {
                if (!view.Animating || lastWorkingParentHeight == int.MinValue)
                {
                    bool  changeScale = false;
                    float ratio       = 1.0f;
                    if (displayManager.VectorMode)
                    {
                        IntSize2 rigidParentSize = view.Container.RigidParentWorkingSize;
                        if (rigidParentSize.Height != lastWorkingParentHeight)
                        {
                            ratio = rigidParentSize.Height / (float)Slideshow.BaseSlideScale * displayManager.AdditionalZoomMultiple;
                            lastWorkingParentHeight = rigidParentSize.Height;
                            changeScale             = true;
                        }
                    }
                    else if (lastWorkingParentHeight != int.MaxValue)
                    {
                        ratio                   = displayManager.AdditionalZoomMultiple;
                        changeScale             = true;
                        lastWorkingParentHeight = int.MaxValue;
                    }

                    if (changeScale)
                    {
                        foreach (var host in viewHosts.Values)
                        {
                            SlidePanel panel = masterStrategy.panels[host.View.ElementName];
                            host.changeScale(ratio);
                        }
                    }
                }
            }
 public TextureSceneViewPool(SceneViewController sceneViewController, String baseName, IntSize2 size)
 {
     pool = new LifecycleObjectPool <PooledSceneView>(createSceneViewWrapper, destroySceneViewWrapper);
     this.sceneViewController = sceneViewController;
     this.size     = size;
     this.baseName = baseName;
 }
예제 #17
0
 public RawImage(ResourceVolatility volatility, IntSize2 size, byte[] rawData)
     : base(volatility)
 {
     Size            = size;
     RawData         = rawData;
     HasTransparency = GraphicsHelper.HasTransparency(Size, RawData);
 }
            public IntSize2 layoutView(LayoutContainer layoutContainer, IntSize2 originalSize, MyGUIView view)
            {
                float ratio = 1.0f;

                if (displayManager.VectorMode)
                {
                    ratio = layoutContainer.RigidParentWorkingSize.Height / (float)Slideshow.BaseSlideScale;
                }
                ratio *= displayManager.AdditionalZoomMultiple;
                SlidePanel panel = masterStrategy.panels[view.ElementName];
                int        size  = (int)(ScaleHelper.Scaled(panel.Size) * ratio);

                switch (view.ElementName.LocationHint)
                {
                case ViewLocations.Left:
                    return(new IntSize2(size, originalSize.Height));

                case ViewLocations.Right:
                    return(new IntSize2(size, originalSize.Height));

                case ViewLocations.Top:
                    return(new IntSize2(originalSize.Width, size));

                case ViewLocations.Bottom:
                    return(new IntSize2(originalSize.Width, size));

                default:
                    return(new IntSize2(size, size));
                }
            }
예제 #19
0
        private void setColorFeedEnabled(bool enabled, KinectSensor sensor)
        {
            lock (colorPixelsLock)
            {
                if (enabled)
                {
                    if (colorFrameReader == null)
                    {
                        colorFrameReader = sensor.ColorFrameSource.OpenReader();
                        colorFrameReader.FrameArrived += colorFrameReader_FrameArrived;
                        FrameDescription colorFrameDescription = sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
                        ColorFrameSize = new IntSize2(colorFrameDescription.Width, colorFrameDescription.Height);
                        colorPixels    = new byte[colorFrameDescription.LengthInPixels * 4];
                    }
                }
                else
                {
                    if (colorFrameReader != null)
                    {
                        colorFrameReader.Dispose();
                        colorFrameReader = null;
                        colorPixels      = null;
                    }
                }

                if (ColorFeedChanged != null)
                {
                    ThreadManager.invoke(() => ColorFeedChanged.Invoke(this));
                }
            }
        }
        private IndirectionTexture setupNormalOpacityTextures(MaterialDescription description, Pass pass)
        {
            normalTexture.createTextureUnit(pass);
            if (createOpacityTexture)
            {
                opacityTexture.createTextureUnit(pass);
            }
            IndirectionTexture indirectionTexture;
            String             fileName    = description.localizePath(description.NormalMapName + normalTextureFormatExtension);
            IntSize2           textureSize = getTextureSize(fileName);

            if (virtualTextureManager.createOrRetrieveIndirectionTexture(description.TextureSet, textureSize, description.KeepHighestMipLoaded, out indirectionTexture)) //Slow key
            {
                if (description.KeepHighestMipLoaded)
                {
                    indirectionTexture.KeepHighestMip = true;
                }

                indirectionTexture.addOriginalTexture("NormalMap", fileName, textureSize);

                if (createOpacityTexture)
                {
                    fileName = description.localizePath(description.OpacityMapName + textureFormatExtension);
                    indirectionTexture.addOriginalTexture("Opacity", fileName, getTextureSize(fileName));
                }
            }
            setupIndirectionTexture(pass, indirectionTexture);
            return(indirectionTexture);
        }
예제 #21
0
        public override void refreshData()
        {
            IntSize2 value = (IntSize2)Property.getRealValue(1);

            width.Value  = value.Width;
            height.Value = value.Height;
        }
        public void startLayout(ButtonGrid buttonGrid)
        {
            this.buttonGrid = buttonGrid;
            this.canvasSize = buttonGrid.ScrollView.CanvasSize;
            allowNewlines   = false;

            int totalWidth = ItemWidth + ItemPaddingX;

            if (!center)
            {
                totalWidth -= ItemPaddingX; //Don't need padding on last element if not centered.
            }
            int numElements = canvasSize.Width / totalWidth;

            if (numElements > 0)
            {
                int totalElementWidth = numElements * totalWidth;
                calculatedPadding = (canvasSize.Width - totalElementWidth) / numElements;
                xStartPosition    = center ? calculatedPadding / 2 : 0;
            }
            else
            {
                calculatedPadding = ItemPaddingX;
                xStartPosition    = 0;
            }

            currentPosition = new IntVector2(xStartPosition, 0);
        }
예제 #23
0
        internal void processPage(float u, float v, byte mip)
        {
            ++numRequests;
            VTexPage page;

            if (mip >= highestMip)
            {
                page = new VTexPage(0, 0, (byte)(highestMip - 1), id);
            }
            else
            {
                IntSize2 mipLevelNumPages = numPages / (1 << mip);
                byte     x = (byte)(u * mipLevelNumPages.Width);
                byte     y = (byte)(v * mipLevelNumPages.Height);
                if (x == mipLevelNumPages.Width)
                {
                    --x;
                }
                if (y == mipLevelNumPages.Height)
                {
                    --y;
                }
                page = new VTexPage(x, y, mip, id);
            }
            if (activePages.Contains(page))
            {
                visibleThisUpdate.Add(page);
            }
            else
            {
                addedPages.Add(page);
            }
        }
예제 #24
0
        public String addImage(Object resourceKey, FreeImageBitmap image, out IntSize2 imageSize)
        {
            String guidStr = UniqueKeyGenerator.generateStringKey();

            guidDictionary.Add(resourceKey, guidStr);
            createImage(guidStr, image, out imageSize);
            return(guidStr);
        }
예제 #25
0
 public ImageAtlas(String name, IntSize2 imageSize)
 {
     this.name      = name;
     this.imageSize = imageSize;
     MyGUIInterface.Instance.CommonResourceGroup.addResource(name, "Memory", true);
     memoryArchive = MemoryArchiveFactory.Instance.getArchive(name);
     ResizeMode    = ImageResizeMode.Both;
 }
예제 #26
0
        /// <summary>
        /// Set a new width for the grid and layout again.
        /// </summary>
        /// <param name="newWidth"></param>
        public void resizeAndLayout(int newWidth)
        {
            IntSize2 canvasSize = scrollView.CanvasSize;

            canvasSize.Width      = newWidth;
            scrollView.CanvasSize = canvasSize;
            layout();
        }
예제 #27
0
 public void animatedResizeCompleted(IntSize2 finalSize)
 {
     //This class eats this event, it sets up the child to be stretched again.
     child.Widget.Align = Align.HStretch | Align.VStretch;
     child.Widget.setPosition(childPosition.x, childPosition.y);
     child.Widget.setSize(finalSize.Width - childSizeOffset.Width, finalSize.Height - childSizeOffset.Height);
     allowSizeUpdates = true;
 }
예제 #28
0
 public SysDrawImage(Image image)
     : base(ResourceVolatility.Immutable)
 {
     Image = image;
     Size  = new IntSize2(image.Width, image.Height);
     using (var bitmap = new Bitmap(image))
         HasTransparency = GetTransparency(bitmap);
 }
 public override void animatedResizeCompleted(IntSize2 finalSize)
 {
     base.animatedResizeCompleted(finalSize);
     if (AnimatedResizeCompleted != null)
     {
         AnimatedResizeCompleted.Invoke(finalSize);
     }
 }
        public RocketRenderQueueListener(Context context, RenderInterfaceOgre3D renderInterface)
        {
            this.context         = context;
            this.renderInterface = renderInterface;
            Vector2i dimensions = context.Dimensions;

            renderDimensions = new IntSize2(dimensions.X, dimensions.Y);
        }
예제 #31
0
        private static Ray3 GenGlobalRayFromMousePos(ICamera camera, IntSize2 viewportSize, float aspectRatio, IntVector2 pointerPixelPos)
        {
            var hmgnPointerPos = new Vector2(
                -1f + 2f / viewportSize.Width * pointerPixelPos.X,
                1f - 2f / viewportSize.Height * pointerPixelPos.Y);

            return(camera.GetGlobalRayForHmgnPointer(aspectRatio, hmgnPointerPos));
        }
예제 #32
0
        public void SetGridSize(IntSize2 size)
        {
            if (size.Width == this.Width && size.Height == this.Height)
                return;

            this.Grid = new RenderTileData[size.Height, size.Width];

            this.Width = size.Width;
            this.Height = size.Height;
        }
예제 #33
0
        public void SetGridSize(IntSize2 size)
        {
            if (size.Width == this.Width && size.Height == this.Height)
                return;

            this.Grid = new RenderTileData[size.Height, size.Width];

            for (int y = 0; y < size.Height; ++y)
                for (int x = 0; x < size.Width; ++x)
                    this.Grid[y, x] = new RenderTileData();

            this.Width = size.Width;
            this.Height = size.Height;
        }
예제 #34
0
		public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D<bool> visibilityMap, IntSize2 mapSize,
			Func<IntVector2, bool> blockerDelegate)
		{
			visibilityMap.Clear();

			if (blockerDelegate(viewerLocation) == true)
				return;

			visibilityMap[0, 0] = true;

			SCRData data = new SCRData()
			{
				ViewerLocation = viewerLocation,
				VisionRange = visionRange,
				VisionRangeSquared = (visionRange + 1) * (visionRange + 1),	// +1 to get a bit bigger view area
				VisibilityMap = visibilityMap,
				MapSize = mapSize,
				BlockerDelegate = blockerDelegate,
			};

			for (int octant = 0; octant < 8; ++octant)
				Calculate(ref data, 1, octant, 0.0, 1.0, 1);
		}
예제 #35
0
        public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D<bool> visibilityMap, IntSize2 mapSize,
			Func<IntVector2, bool> blockerDelegate)
        {
            visibilityMap.Clear();

            if (blockerDelegate(viewerLocation) == true)
                return;

            var g = new IntGrid2(new IntVector2(), mapSize);
            g = g.Offset(-viewerLocation.X, -viewerLocation.Y);
            var vr = new IntVector2(visionRange, visionRange);
            g = g.Intersect(new IntGrid2(vr, -vr));

            int visionRangeSquared = (visionRange + 1) * (visionRange + 1);	// +1 to get a bit bigger view area

            foreach (var dst in g.Range())
            {
                if (dst.X * dst.X + dst.Y * dst.Y > visionRangeSquared)
                    continue;

                bool vis = FindLos(viewerLocation, dst, blockerDelegate);
                visibilityMap[dst] = vis;
            }
        }
예제 #36
0
 void MapControl_GridSizeChanged(object ob, IntSize2 gridSize)
 {
     m_renderData.SetGridSize(gridSize);
 }
예제 #37
0
        void Calc(IntVector2 viewerLocation, int visionRange, Grid2D<bool> visibilityMap, IntSize2 mapSize,
			Func<IntVector2, bool> blockerDelegate)
        {
            m_algoDel(viewerLocation, visionRange, visibilityMap, mapSize, blockerDelegate);
        }
예제 #38
0
        void UpdateTileLayout(Size renderSize)
        {
            var tileSize = this.TileSize;

            var renderWidth = (int)Math.Ceiling(renderSize.Width);
            var renderHeight = (int)Math.Ceiling(renderSize.Height);

            var columns = (int)Math.Ceiling(renderSize.Width / tileSize + 1) | 1;
            var rows = (int)Math.Ceiling(renderSize.Height / tileSize + 1) | 1;

            var gridSize = new IntSize2(columns, rows);

            if (gridSize != m_gridSize)
                InvalidateTileData();

            m_gridSize = gridSize;

            var renderOffsetX = (renderWidth - tileSize * m_gridSize.Width) / 2;
            var renderOffsetY = (renderHeight - tileSize * m_gridSize.Height) / 2;

            var cx = -(this.CenterPos.X - Math.Round(this.CenterPos.X)) * this.TileSize;
            var cy = -(this.CenterPos.Y - Math.Round(this.CenterPos.Y)) * this.TileSize;

            m_renderOffset = new Point(Math.Round(renderOffsetX + cx), Math.Round(renderOffsetY + cy));

            m_tileLayoutInvalid = true;

            trace.TraceVerbose("UpdateTileLayout(rs {0}, gs {1}, ts {2}) -> Off {3:F2}, Grid {4}", renderSize, m_gridSize, tileSize,
                m_renderOffset, m_gridSize);

            InvalidateTileRender();
        }
예제 #39
0
        public void SetRenderTarget(Texture2D renderTexture)
        {
            SetupRenderTarget(renderTexture);

            var renderWidth = renderTexture.Description.Width;
            var renderHeight = renderTexture.Description.Height;
            var renderTargetSize = new IntSize2(renderWidth, renderHeight);

            m_pixelShader.SetupTileBuffer(renderTargetSize);
        }
예제 #40
0
        bool UpdateGridSize(Size renderSize, double tileSize)
        {
            var renderWidth = MyMath.Ceiling(renderSize.Width);
            var renderHeight = MyMath.Ceiling(renderSize.Height);

            var columns = MyMath.Ceiling(renderSize.Width / tileSize + 1) | 1;
            var rows = MyMath.Ceiling(renderSize.Height / tileSize + 1) | 1;

            var newGridSize = new IntSize2(columns, rows);

            if (this.GridSize != newGridSize)
            {
                this.GridSize = newGridSize;
                InvalidateTileData();
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #41
0
 void OnTileLayoutChanged(IntSize2 gridSize, double tileSize, Point centerPos)
 {
     UpdateHoverTileInfo(false);
 }
        void OnTileLayoutChanged(IntSize2 gridSize, double tileSize, Point centerPos)
        {
            var pos = Mouse.GetPosition(m_mapControl);

            if (m_selecting)
                UpdateSelection(pos);

            UpdateSelectionRect();
        }
예제 #43
0
        void OnTileLayoutChanged(IntSize2 gridSize, double tileSize)
        {
            var iscp = this.ScreenCenterPos.ToIntVector3();

            m_contentOffset = new Vector(iscp.X - gridSize.Width / 2, iscp.Y - gridSize.Height / 2);
        }
예제 #44
0
        void OnTileArrangementChanged(IntSize2 gridSize, double tileSize, Point centerPos)
        {
            //System.Diagnostics.Debug.Print("OnTileArrangementChanged( gs {0}, ts {1:F2}, cp {2:F2} )", gridSize, tileSize, centerPos);

            m_renderView.SetSize(gridSize);

            m_renderView.CenterPos = new IntPoint3((int)Math.Round(centerPos.X), (int)Math.Round(centerPos.Y), this.Z);
        }
예제 #45
0
        public void SetupTileBuffer(IntSize2 renderTargetSize)
        {
            RemoveAndDispose(ref m_tileBuffer);
            RemoveAndDispose(ref m_tileBufferView);

            const int minTileSize = 2;
            var tileBufferWidth = (int)System.Math.Ceiling((double)renderTargetSize.Width / minTileSize + 1) | 1;
            var tileBufferHeight = (int)System.Math.Ceiling((double)renderTargetSize.Height / minTileSize + 1) | 1;

            m_tileBuffer = ToDispose(new SharpDX.Direct3D11.Buffer(m_device, new BufferDescription()
            {
                BindFlags = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.BufferStructured,
                SizeInBytes = tileBufferWidth * tileBufferHeight * Marshal.SizeOf(typeof(RenderTile)),
                StructureByteStride = Marshal.SizeOf(typeof(RenderTile)),
                Usage = ResourceUsage.Dynamic,
            }));

            m_tileBufferView = ToDispose(new ShaderResourceView(m_device, m_tileBuffer, new ShaderResourceViewDescription()
            {
                Format = SharpDX.DXGI.Format.Unknown,
                Dimension = ShaderResourceViewDimension.Buffer,
                Buffer = new ShaderResourceViewDescription.BufferResource()
                {
                    ElementWidth = tileBufferWidth * tileBufferHeight,
                    ElementOffset = 0,
                },
            }));

            var context = m_device.ImmediateContext;
            context.PixelShader.SetShaderResource(2, m_tileBufferView);
        }
예제 #46
0
        void OnTileArrangementChanged(IntSize2 gridSize, double tileSize, Point centerPos)
        {
            if (SomethingChanged != null)
                SomethingChanged();

            m_renderView.SetGridSize(gridSize);
        }
 void OnTileLayoutChanged(IntSize2 gridSize, double tileSize, Point centerPos)
 {
     UpdateTranslateTransform();
     UpdateScaleTransform();
 }
예제 #48
0
        static NoiseMap CreateTerrainNoiseMap(Module noise, IntSize2 size)
        {
            var map = new NoiseMap();

            var build = new SharpNoise.Builders.PlaneNoiseMapBuilder()
            {
                DestNoiseMap = map,
                EnableSeamless = false,
                SourceModule = noise,
            };

            double x = 1;
            double y = 1;
            double w = size.Width / 256.0;
            double h = size.Height / 256.0;

            build.SetDestSize(size.Width, size.Height);
            build.SetBounds(x, x + w, y, y + h);
            build.Build();

            //map.BorderValue = 1;
            //map = NoiseMap.BilinearFilter(map, this.Width, this.Height);

            return map;
        }