Пример #1
0
 public Vertex(DX.Vector3 position, DX.Vector2 texCoord, DX.Vector3 n, float a)
 {
     this.position = position;
     this.texCoord = texCoord;
     n.Normalize();
     this.normal = new DX.Vector4(n.X, n.Y, n.Z, a);
 }
Пример #2
0
        /// <summary>
        /// Función virtual que inicializa el contorno y las normales.
        /// </summary>
        virtual protected void initContour()
        {
            contour[0] = new Microsoft.DirectX.Vector2[8];
            contour[1] = new Microsoft.DirectX.Vector2[8];
            int i = 0;

            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, 0);

            i = 0;
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(-1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(-1, 0);

            buildHighStressCover();
            buildHighLODCover();
        }
Пример #3
0
        // --------------------------------------------------------------------
        // Tell a Direct3D.Sprite object how to render this sprite
        // --------------------------------------------------------------------
        public void Draw(Direct3D.Sprite renderer, Camera camera)
        {
            // calculate the actual width and height:
            float w = XScale * Width;
            float h = YScale * Height;

            // calculate the actual anchor point in sprite coordinates:
            DirectX.Vector2 scaledanchor = anchor;
            scaledanchor.X *= w;
            scaledanchor.Y *= h;

            DirectX.Vector2 newoffset = offset;
            newoffset.X -= scaledanchor.X;
            newoffset.Y -= scaledanchor.Y;


            renderer.Draw(
                texture,
                rect,
                scaling,
                scaledanchor,
                angle,
                newoffset - camera.Offset,
                color);
        }
Пример #4
0
        public Main()
        {
            //Makes form closing faster
            FormClosing += (_, __) => System.Diagnostics.Process.GetCurrentProcess().Kill();

            instance = this;
            InitializeComponent();
            Level.InitCommands();

            Shown   += RunLoop;
            KeyDown += (object sender, KeyEventArgs e) => keyDown[(int)e.KeyCode] = true;
            KeyUp   += (object sender, KeyEventArgs e) => keyDown[(int)e.KeyCode] = false;
            int mX = 0, mY = 0;

            MouseMove += (object sender, MouseEventArgs e) =>
            {
                mouseDelta = new DX.Vector2(mX - e.X, mY - e.Y);
                if (e.Button == System.Windows.Forms.MouseButtons.Middle)
                {
                    Editor.camera.Rotate(mouseDelta, 0.01f);
                }
                mX = e.X; mY = e.Y;
            };
            MouseDown += (object sender, MouseEventArgs e) =>
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    selectObject = true;
                }
            };
            MouseWheel += (object sender, MouseEventArgs e) => { mouseDeltaZ = e.Delta; };
        }
Пример #5
0
 void UpdateFrame(float time)
 {
     Editor.Update(time);
     for (int i = 0; i < keyDown.Length; i++)
     {
         prevKeyDown[i] = keyDown[i];
     }
     mouseDelta  = DX.Vector2.Empty;
     mouseDeltaZ = 0;
 }
Пример #6
0
        private void Restart()
        {
            //TODO kod pro restart hry

            Logger.AddImportant("Game Restart!");
            this.game.Restart();
            this.input.Stop();
            this.actions.Clear();
            this.direction = new Vector2();
            this.input.Start();
        }
Пример #7
0
        // --------------------------------------------------------------------
        // Constructor
        // --------------------------------------------------------------------
        public Sprite()
        {
            // no texture
            texture = null;

            // scaling default
            scaling = new DirectX.Vector2(1.0f, 1.0f);

            // no coloring
            color = Drawing.Color.White;
        }
Пример #8
0
        public override void DrawLine(Point a, Point b, Color color)
        {
            mDevice.DrawBuffer.Flush();

            Vector2[] pts = new Vector2[2];

            pts[0] = new Vector2(a.X, a.Y);
            pts[1] = new Vector2(b.X, b.Y);


            mLine.Begin();
            mLine.Draw(pts, color.ToArgb());
            mLine.End();
        }
Пример #9
0
        public override void DrawRect(RectangleF rect, Color color)
        {
            mDevice.DrawBuffer.Flush();

            Vector2[] pts = new Vector2[5];

            pts[0] = new Vector2(rect.X, rect.Y);
            pts[1] = new Vector2(rect.X + rect.Width, rect.Y);
            pts[2] = new Vector2(rect.X + rect.Width, rect.Y + rect.Height);
            pts[3] = new Vector2(rect.X, rect.Y + rect.Height);
            pts[4] = pts[0];

            mLine.Begin();
            mLine.Draw(pts, color.ToArgb());
            mLine.End();
        }
Пример #10
0
        public override void DrawLines(Point[] pt, Color color)
        {
            mDevice.DrawBuffer.Flush();

            Vector2[] pts = new Vector2[pt.Length];

            for (int i = 0; i < pt.Length; i++)
            {
                pts[i] = new Vector2(pt[i].X, pt[i].Y);
            }


            mLine.Begin();
            mLine.Draw(pts, color.ToArgb());
            mLine.End();
        }
Пример #11
0
 public void Render(DrawArgs drawArgs)
 {
     if (this.m_Visible)
     {
         if (this.m_HandleTexture == null)
         {
             this.Initialize(drawArgs);
         }
         if (((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - 10)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.ClientSize.Width) + 10))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y + 5)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.ClientSize.Height) + 5))))
         {
             if (!this.m_isMouseInside)
             {
                 this.m_isMouseInside = true;
                 this.OnMouseEnter(null);
                 if (this.OnMouseEnterEvent != null)
                 {
                     this.OnMouseEnterEvent(this, null);
                 }
             }
         }
         else if (this.m_isMouseInside)
         {
             this.m_isMouseInside = false;
             this.OnMouseLeave(null);
             if (this.OnMouseLeaveEvent != null)
             {
                 this.OnMouseLeaveEvent(this, null);
             }
         }
         if (DateTime.Now.Subtract(this.frameTime) > frameTimeSpan)
         {
             if (!this.m_isMouseInside)
             {
                 if (this.m_Opacity > m_MinimumOpacity)
                 {
                     this.m_Opacity       = (byte)(this.m_Opacity - m_OpacityRate);
                     this.m_HandleOpacity = this.m_Opacity;
                 }
                 else
                 {
                     this.m_HandleOpacity = 0;
                     this.m_Opacity       = m_MinimumOpacity;
                 }
             }
             else
             {
                 if (this.m_Opacity < (0xff - m_OpacityRate))
                 {
                     this.m_Opacity = (byte)(this.m_Opacity + m_OpacityRate);
                 }
                 else
                 {
                     this.m_Opacity = 0xff;
                 }
                 this.m_HandleOpacity = this.m_Opacity;
             }
             this.frameTime = DateTime.Now;
         }
         if ((((this.m_HandleTexture != null) && (this.m_currentHandleUri != this.m_HandleUri)) || ((this.m_LowImageTexture != null) && (this.m_currentLowImageUri != this.m_LowImageUri))) || ((this.m_HighImageTexture != null) && (this.m_currentHighImageUri != this.m_HighImageUri)))
         {
             this.Initialize(drawArgs);
         }
         Utilities.DrawBox(this.AbsoluteLocation.X, this.AbsoluteLocation.Y, this.ClientSize.Width, this.ClientSize.Height, 0f, this.m_BackgroundColor.ToArgb(), drawArgs.device);
         Utilities.DrawBox(this.AbsoluteLocation.X + this.m_StickLocation.X, this.AbsoluteLocation.Y + this.m_StickLocation.Y, this.m_StickSize.Width, this.m_StickSize.Height, 0f, this.m_StickBackgroundColor.ToArgb(), drawArgs.device);
         Microsoft.DirectX.Vector2[] linePoints = new Microsoft.DirectX.Vector2[5];
         linePoints[0].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[0].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         linePoints[1].X = (this.AbsoluteLocation.X + this.m_StickLocation.X) + this.m_StickSize.Width;
         linePoints[1].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         linePoints[2].X = (this.AbsoluteLocation.X + this.m_StickLocation.X) + this.m_StickSize.Width;
         linePoints[2].Y = (this.AbsoluteLocation.Y + this.m_StickLocation.Y) + this.m_StickSize.Height;
         linePoints[3].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[3].Y = (this.AbsoluteLocation.Y + this.m_StickLocation.Y) + this.m_StickSize.Height;
         linePoints[4].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[4].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         Utilities.DrawLine(linePoints, Color.FromArgb(this.m_Opacity, this.m_ForeColor.R, this.m_ForeColor.G, this.m_ForeColor.B).ToArgb(), drawArgs.device);
         if ((this.m_HandleTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_HandleTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point  = new Point(this.AbsoluteLocation.X + this.m_HandleLocation.X, this.AbsoluteLocation.Y + this.m_HandleLocation.Y);
             Point point2 = new Point((this.AbsoluteLocation.X + this.m_HandleLocation.X) + this.m_HandleSize.Width, this.AbsoluteLocation.Y + this.m_HandleLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_HandleLocation.X, (this.AbsoluteLocation.Y + this.m_HandleLocation.Y) + this.m_HandleSize.Height);
             Point point3 = new Point((this.AbsoluteLocation.X + this.m_HandleLocation.X) + this.m_HandleSize.Width, (this.AbsoluteLocation.Y + this.m_HandleLocation.Y) + this.m_HandleSize.Height);
             if (this.m_HandleSprite == null)
             {
                 this.m_HandleSprite = new Sprite(drawArgs.device);
             }
             this.m_HandleSprite.Begin(SpriteFlags.AlphaBlend);
             float x = ((float)(point2.X - point.X)) / ((float)this.m_HandlesurfaceDescription.Width);
             float y = ((float)(point3.Y - point2.Y)) / ((float)this.m_HandlesurfaceDescription.Height);
             this.m_HandleSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(x, y, 0f);
             this.m_HandleSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point.X + point2.X), 0.5f * (point2.Y + point3.Y), 0f);
             this.m_HandleSprite.Draw(this.m_HandleTexture, new Microsoft.DirectX.Vector3((float)(this.m_HandlesurfaceDescription.Width / 2), (float)(this.m_HandlesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_HandleOpacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_HandleSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_HandleSprite.End();
         }
         if ((this.m_LowImageTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_LowImageTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point4 = new Point(this.AbsoluteLocation.X + this.m_LowImageLocation.X, this.AbsoluteLocation.Y + this.m_LowImageLocation.Y);
             Point point5 = new Point((this.AbsoluteLocation.X + this.m_LowImageLocation.X) + this.m_LowImageSize.Width, this.AbsoluteLocation.Y + this.m_LowImageLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_LowImageLocation.X, (this.AbsoluteLocation.Y + this.m_LowImageLocation.Y) + this.m_LowImageSize.Height);
             Point point6 = new Point((this.AbsoluteLocation.X + this.m_LowImageLocation.X) + this.m_LowImageSize.Width, (this.AbsoluteLocation.Y + this.m_LowImageLocation.Y) + this.m_LowImageSize.Height);
             if (this.m_LowImageSprite == null)
             {
                 this.m_LowImageSprite = new Sprite(drawArgs.device);
             }
             this.m_LowImageSprite.Begin(SpriteFlags.AlphaBlend);
             float num3 = ((float)(point5.X - point4.X)) / ((float)this.m_LowImagesurfaceDescription.Width);
             float num4 = ((float)(point6.Y - point5.Y)) / ((float)this.m_LowImagesurfaceDescription.Height);
             this.m_LowImageSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(num3, num4, 0f);
             this.m_LowImageSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point4.X + point5.X), 0.5f * (point5.Y + point6.Y), 0f);
             this.m_LowImageSprite.Draw(this.m_LowImageTexture, new Microsoft.DirectX.Vector3((float)(this.m_LowImagesurfaceDescription.Width / 2), (float)(this.m_LowImagesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_Opacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_LowImageSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_LowImageSprite.End();
         }
         if ((this.m_HighImageTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_HighImageTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point7 = new Point(this.AbsoluteLocation.X + this.m_HighImageLocation.X, this.AbsoluteLocation.Y + this.m_HighImageLocation.Y);
             Point point8 = new Point((this.AbsoluteLocation.X + this.m_HighImageLocation.X) + this.m_HighImageSize.Width, this.AbsoluteLocation.Y + this.m_HighImageLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_HighImageLocation.X, (this.AbsoluteLocation.Y + this.m_HighImageLocation.Y) + this.m_HighImageSize.Height);
             Point point9 = new Point((this.AbsoluteLocation.X + this.m_HighImageLocation.X) + this.m_HighImageSize.Width, (this.AbsoluteLocation.Y + this.m_HighImageLocation.Y) + this.m_HighImageSize.Height);
             if (this.m_HighImageSprite == null)
             {
                 this.m_HighImageSprite = new Sprite(drawArgs.device);
             }
             this.m_HighImageSprite.Begin(SpriteFlags.AlphaBlend);
             float num5 = ((float)(point8.X - point7.X)) / ((float)this.m_HighImagesurfaceDescription.Width);
             float num6 = ((float)(point9.Y - point8.Y)) / ((float)this.m_HighImagesurfaceDescription.Height);
             this.m_HighImageSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(num5, num6, 0f);
             this.m_HighImageSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point7.X + point8.X), 0.5f * (point8.Y + point9.Y), 0f);
             this.m_HighImageSprite.Draw(this.m_HighImageTexture, new Microsoft.DirectX.Vector3((float)(this.m_HighImagesurfaceDescription.Width / 2), (float)(this.m_HighImagesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_Opacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_HighImageSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_HighImageSprite.End();
         }
     }
 }
Пример #12
0
 public Vertex(DX.Vector3 position, DX.Vector2 texCoord, DX.Vector4 c)
 {
     this.position = position;
     this.texCoord = texCoord;
     this.normal   = c;
 }
Пример #13
0
		public override void RenderContents(DrawArgs drawArgs)
		{
			m_DrawArgs = drawArgs;
			try
			{
				if(itemFont == null)
				{
					itemFont = drawArgs.CreateFont( World.Settings.LayerManagerFontName, 
						World.Settings.LayerManagerFontSize, World.Settings.LayerManagerFontStyle );

					// TODO: Fix wingdings menu problems
					System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
					headerFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

					System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
					wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

					AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
					fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Font worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
					worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
				}

				this.updateList();
				
				this.worldwinddingsFont.DrawText(
					null,
					"E",
					new System.Drawing.Rectangle(this.Right - 16, this.Top + 2, 20, topBorder),
					DrawTextFormat.None,
					TextColor);

				int numItems = GetNumberOfUncollapsedItems();
				int totalHeight = GetItemsHeight(drawArgs);//numItems * ItemHeight;
				showScrollbar = totalHeight > ClientHeight;
				if(showScrollbar)
				{
					double percentHeight = (double)ClientHeight / totalHeight;
					int scrollbarHeight = (int)(ClientHeight * percentHeight);

					int maxScroll = totalHeight-ClientHeight;

					if(scrollBarPosition < 0)
						scrollBarPosition = 0;
					else if(scrollBarPosition > maxScroll)
						scrollBarPosition = maxScroll;

					// Smooth scroll
					const float scrollSpeed = 0.3f;
					float smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*scrollSpeed;
					float absDelta = Math.Abs(smoothScrollDelta);
					if(absDelta > 100f || absDelta < 3f) 
						// Scroll > 100 pixels and < 1.5 pixels faster
						smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*(float)Math.Sqrt(scrollSpeed);
					
					scrollSmoothPosition += smoothScrollDelta;

					if(scrollSmoothPosition > maxScroll)
						scrollSmoothPosition = maxScroll;

					int scrollPos = (int)((float)percentHeight * scrollBarPosition );

					int color = isScrolling ? World.Settings.scrollbarHotColor : World.Settings.scrollbarColor;
					MenuUtils.DrawBox(
						Right - ScrollBarSize + 2,
						ClientTop + scrollPos,
						ScrollBarSize - 3,
						scrollbarHeight + 1,
						0.0f,
						color,
						drawArgs.device);

					scrollbarLine[0].X = this.Right - ScrollBarSize;
					scrollbarLine[0].Y = this.ClientTop;
					scrollbarLine[1].X = this.Right - ScrollBarSize;
					scrollbarLine[1].Y = this.Bottom;
					MenuUtils.DrawLine(scrollbarLine, 
						DialogColor,
						drawArgs.device);
				}

				this.headerFont.DrawText(
					null, "Layer Manager",
					new System.Drawing.Rectangle( Left+5, Top+1, Width, topBorder-2 ),
					DrawTextFormat.VerticalCenter, TextColor);

				Microsoft.DirectX.Vector2[] headerLinePoints = new Microsoft.DirectX.Vector2[2];
				headerLinePoints[0].X = this.Left;
				headerLinePoints[0].Y = this.Top + topBorder - 1;

				headerLinePoints[1].X = this.Right;
				headerLinePoints[1].Y = this.Top + topBorder - 1;

				MenuUtils.DrawLine(headerLinePoints, DialogColor, drawArgs.device);

				int runningItemHeight = 0;
				if( showScrollbar )
					runningItemHeight = -(int)Math.Round(scrollSmoothPosition);

				// Set the Direct3D viewport to match the layer manager client area
				// to clip the text to the window when scrolling
				Viewport lmClientAreaViewPort = new Viewport();
				lmClientAreaViewPort.X = ClientLeft;
				lmClientAreaViewPort.Y = ClientTop;
				lmClientAreaViewPort.Width = ClientWidth;
				lmClientAreaViewPort.Height = ClientHeight;
				Viewport defaultViewPort = drawArgs.device.Viewport;
				drawArgs.device.Viewport = lmClientAreaViewPort;
				for(int i = 0; i < _itemList.Count; i++)
				{
					if(runningItemHeight > ClientHeight)
						// No more space for items
						break;
					LayerMenuItem lmi = (LayerMenuItem)_itemList[i];
					runningItemHeight += lmi.Render(
						drawArgs, 
						ClientLeft,
						ClientTop,
						runningItemHeight,
						ClientWidth,
						ClientBottom,
						itemFont,
						wingdingsFont,
						worldwinddingsFont, 
						MouseOverItem);
				}
				drawArgs.device.Viewport = defaultViewPort;
			}
			catch(Exception caught)
			{
				Log.Write( caught );
			}
		}
Пример #14
0
        /// <summary>
        /// Renders all graphics per frame.
        /// </summary>
        public static void Render()
        {
            // clear device and fill with background color
            device.Clear(ClearFlags.Target, bgColor, 0, 0);

            // begin drawing scene
            device.BeginScene();

            // begin sprite and make sure alphablending is enabled
            sprite.Begin(SpriteFlags.AlphaBlend);

            // for each object that needs to be drawn...
            foreach (DrawObjectInfo drawObjectInfo in objectsToDraw)
            {
                // get it's x and y coordinates (corresponds to pixels))
                int x = (int)drawObjectInfo.pos.X;
                int y = (int)drawObjectInfo.pos.Y;

                // if the object has a rotation...
                if (drawObjectInfo.rotation != 0)
                {
                    // convert rotation to radians TODO: move to GameObject
                    float rotation = drawObjectInfo.rotation * (float)(Math.PI / 180);

                    // Create matrix to transform the sprite to rotate it aproperiatly
                    Microsoft.DirectX.Vector2 rotationCenter = new Microsoft.DirectX.Vector2(x, y);
                    sprite.Transform = Matrix.Transformation2D(v2_0, 0, v2_1, rotationCenter, -rotation, v2_0);
                }

                // draw object
                sprite.Draw(drawObjectInfo.texture, rect_0, drawObjectInfo.center, drawObjectInfo.pos, drawObjectInfo.tint);

                //reset transformation
                sprite.Transform = Matrix.Identity;
            }

            // draw debug information if needed
            if (GameForm.showDebug)
            {
                // draw engine name and version
                fonts[0].DrawText(sprite, "Vixeria Engine v0.1", new Point(0, 0), Color.White);
                // draw fps and ms counters
                int     FPScount = (int)Math.Round(1000 / (msTimeList.Average() + 0.001m));
                decimal msTime   = Math.Round(msTimeList.Average());
                fonts[0].DrawText(sprite, string.Format("{0}FPS\n{1}ms", FPScount, msTime), new Point(0, 17), Color.White);

                // draw additional debug info
                fonts[0].DrawText(sprite, GameForm.debug1, new Point(0, device.Viewport.Height - 15), Color.White);
                fonts[0].DrawText(sprite, GameForm.debug2, new Point(0, device.Viewport.Height - 30), Color.White);
                fonts[0].DrawText(sprite, GameForm.debug3, new Point(0, device.Viewport.Height - 45), Color.White);
            }

            sprite.End();

            // end drawing scene
            device.EndScene();
            // present the drawn information to the player
            device.Present();

            // clear list of objects to draw
            objectsToDraw.Clear();
        }
Пример #15
0
        /// <summary>
        /// Función virtual que inicializa el contorno y las normales.
        /// </summary>
        protected virtual void initContour()
        {
            contour[0] = new Microsoft.DirectX.Vector2[8];
            contour[1] = new Microsoft.DirectX.Vector2[8];
            int i = 0;
            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, -1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[0][i++] = new Microsoft.DirectX.Vector2(1, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, 1);
            contour[0][i++] = new Microsoft.DirectX.Vector2(-1, 0);

            i = 0;
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, -1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(0, 1);
            contour[1][i++] = new Microsoft.DirectX.Vector2(-1, 0);
            contour[1][i++] = new Microsoft.DirectX.Vector2(-1, 0);

            buildHighStressCover();
            buildHighLODCover();
        }
Пример #16
0
        /// <summary>
        /// 渲染菜单内容
        /// </summary>
        /// <param name="drawArgs">绘制参数</param>
        public override void RenderContents(DrawArgs drawArgs)
        {
            m_DrawArgs = drawArgs;
            try
            {
                if (itemFont == null)
                {
                    itemFont = drawArgs.CreateFont(World.Settings.LayerManagerFontName,
                                                   World.Settings.LayerManagerFontSize, World.Settings.LayerManagerFontStyle);

                    // TODO: Fix wingdings menu problems
                    System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Bold);
                    headerFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

                    System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
                    wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

                    string fontFile = Path.Combine(World.Settings.DataDirectory, "Earth\\World Wind Dings 1.04.ttf");
                    AddFontResource(fontFile);
                    System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
                    fpc.AddFontFile(fontFile);
                    System.Drawing.Font worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
                    worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
                }

                this.updateList();

                this.worldwinddingsFont.DrawText(
                    null,
                    "E",
                    new System.Drawing.Rectangle(this.Right - 16, this.Top + 2, 20, topBorder),
                    DrawTextFormat.None,
                    TextColor);

                int numItems    = GetNumberOfUncollapsedItems();
                int totalHeight = GetItemsHeight(drawArgs);//numItems * ItemHeight;
                showScrollbar = totalHeight > ClientHeight;
                if (showScrollbar)
                {
                    double percentHeight   = (double)ClientHeight / totalHeight;
                    int    scrollbarHeight = (int)(ClientHeight * percentHeight);

                    int maxScroll = totalHeight - ClientHeight;

                    if (scrollBarPosition < 0)
                    {
                        scrollBarPosition = 0;
                    }
                    else if (scrollBarPosition > maxScroll)
                    {
                        scrollBarPosition = maxScroll;
                    }

                    // Smooth scroll
                    const float scrollSpeed       = 0.3f;
                    float       smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition) * scrollSpeed;
                    float       absDelta          = Math.Abs(smoothScrollDelta);
                    if (absDelta > 100f || absDelta < 3f)
                    {
                        // Scroll > 100 pixels and < 1.5 pixels faster
                        smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition) * (float)Math.Sqrt(scrollSpeed);
                    }

                    scrollSmoothPosition += smoothScrollDelta;

                    if (scrollSmoothPosition > maxScroll)
                    {
                        scrollSmoothPosition = maxScroll;
                    }

                    int scrollPos = (int)((float)percentHeight * scrollBarPosition);

                    int color = isScrolling ? World.Settings.scrollbarHotColor : World.Settings.scrollbarColor;
                    MenuUtils.DrawBox(
                        Right - ScrollBarSize + 2,
                        ClientTop + scrollPos,
                        ScrollBarSize - 3,
                        scrollbarHeight + 1,
                        0.0f,
                        color,
                        drawArgs.device);

                    scrollbarLine[0].X = this.Right - ScrollBarSize;
                    scrollbarLine[0].Y = this.ClientTop;
                    scrollbarLine[1].X = this.Right - ScrollBarSize;
                    scrollbarLine[1].Y = this.Bottom;
                    MenuUtils.DrawLine(scrollbarLine,
                                       DialogColor,
                                       drawArgs.device);
                }

                this.headerFont.DrawText(
                    null, "图层管理",
                    new System.Drawing.Rectangle(Left + 5, Top + 1, Width, topBorder - 2),
                    DrawTextFormat.VerticalCenter, TextColor);

                Microsoft.DirectX.Vector2[] headerLinePoints = new Microsoft.DirectX.Vector2[2];
                headerLinePoints[0].X = this.Left;
                headerLinePoints[0].Y = this.Top + topBorder - 1;

                headerLinePoints[1].X = this.Right;
                headerLinePoints[1].Y = this.Top + topBorder - 1;

                MenuUtils.DrawLine(headerLinePoints, DialogColor, drawArgs.device);

                int runningItemHeight = 0;
                if (showScrollbar)
                {
                    runningItemHeight = -(int)Math.Round(scrollSmoothPosition);
                }

                // Set the Direct3D viewport to match the layer manager client area
                // to clip the text to the window when scrolling
                Viewport lmClientAreaViewPort = new Viewport();
                lmClientAreaViewPort.X      = ClientLeft;
                lmClientAreaViewPort.Y      = ClientTop;
                lmClientAreaViewPort.Width  = ClientWidth;
                lmClientAreaViewPort.Height = ClientHeight;
                Viewport defaultViewPort = drawArgs.device.Viewport;
                drawArgs.device.Viewport = lmClientAreaViewPort;
                for (int i = 0; i < _itemList.Count; i++)
                {
                    if (runningItemHeight > ClientHeight)
                    {
                        // No more space for items
                        break;
                    }
                    LayerMenuItem lmi = (LayerMenuItem)_itemList[i];
                    runningItemHeight += lmi.Render(
                        drawArgs,
                        ClientLeft,
                        ClientTop,
                        runningItemHeight,
                        ClientWidth,
                        ClientBottom,
                        itemFont,
                        wingdingsFont,
                        worldwinddingsFont,
                        MouseOverItem);
                }
                drawArgs.device.Viewport = defaultViewPort;
            }
            catch (Exception caught)
            {
                MessageBox.Show(caught.ToString());
                Log.Write(caught);
            }
        }
Пример #17
0
		public static Matrix AffineTransformation2D (float scaling, Vector2 rotationCenter, float rotation, Vector2 translation)
		{
			throw new NotImplementedException ();
		}