public GameObject(float Position_X, float Position_Y, float Position_Z, float Width, float Height, string Type, bool Visible, float X_Offset, float Y_Offset, float Z_Offset, string TextureFilename, D3D.Device m_device)
 {
     position_X = Position_X;
     position_Y = Position_Y;
     position_Z = Position_Z;
     width = Width;
     height = Height;
     type = Type;
     visible = Visible;
     x_Offset = X_Offset;
     y_Offset = Y_Offset;
     z_Offset = Z_Offset;
     texture = TextureLoader.FromFile(m_device, TextureFilename, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.FromArgb(0, 0, 0, 0).ToArgb());
     vertices = new CustomVertex.PositionTextured[6];
     vertices[0].Position = new Vector3(position_X + (width / 2.0f), position_Y + (height / 2.0f), position_Z);
     vertices[0].Tu = 0;
     vertices[0].Tv = 0;
     vertices[1].Position = new Vector3(position_X - (width / 2.0f), position_Y - (height / 2.0f), position_Z);
     vertices[1].Tu = 1;
     vertices[1].Tv = 1;
     vertices[2].Position = new Vector3(position_X + (width / 2.0f), position_Y - (height / 2.0f), position_Z);
     vertices[2].Tu = 0;
     vertices[2].Tv = 1;
     vertices[3].Position = new Vector3(position_X - (width / 2.0f), position_Y - (height / 2.0f), position_Z);
     vertices[3].Tu = 1;
     vertices[3].Tv = 1;
     vertices[4].Position = new Vector3(position_X + (width / 2.0f), position_Y + (height / 2.0f), position_Z);
     vertices[4].Tu = 0;
     vertices[4].Tv = 0;
     vertices[5].Position = new Vector3(position_X - (width / 2.0f), position_Y + (height / 2.0f), position_Z);
     vertices[5].Tu = 1;
     vertices[5].Tv = 0;
 }
        public GameObject(float Position_X1, float Position_X2, float Position_X3, float Position_X4, float Position_Y1, float Position_Y2, float Position_Y3, float Position_Y4, float Position_Z1, float Position_Z2, float Position_Z3, float Position_Z4, string Type, bool Visible, string TextureFilename, D3D.Device m_device)
        {
            position_X = Position_X1;
            position_Y = Position_Y1;
            position_Z = Position_Z1;
            width = 0.0f;
            height = 0.0f;
            type = Type;
            visible = Visible;
            x_Offset = 0.0f;
            y_Offset = 0.0f;
            z_Offset = 0.0f;
            texture = TextureLoader.FromFile(m_device, TextureFilename, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.FromArgb(0, 0, 0, 0).ToArgb());
            vertices = new CustomVertex.PositionTextured[6];

            vertices[0].Position = new Vector3(Position_X1, Position_Y1, Position_Z1);
            vertices[0].Tu = 0;
            vertices[0].Tv = 0;
            vertices[1].Position = new Vector3(Position_X3, Position_Y3, Position_Z3);
            vertices[1].Tu = 1;
            vertices[1].Tv = 1;
            vertices[2].Position = new Vector3(Position_X4, Position_Y4, Position_Z4);
            vertices[2].Tu = 0;
            vertices[2].Tv = 1;

            vertices[3].Position = new Vector3(Position_X3, Position_Y3, Position_Z3);
            vertices[3].Tu = 1;
            vertices[3].Tv = 1;
            vertices[4].Position = new Vector3(Position_X1, Position_Y1, Position_Z1);
            vertices[4].Tu = 0;
            vertices[4].Tv = 0;
            vertices[5].Position = new Vector3(Position_X2, Position_Y2, Position_Z2);
            vertices[5].Tu = 1;
            vertices[5].Tv = 0;
        }
예제 #3
0
 /// <summary>
 /// Creates a DirectX texture object.
 /// </summary>
 /// <param name="tex">Texture to contain in the object.</param>
 /// <param name="filename">Filename to the original texture file.</param>
 public Texture( D3D.Texture tex, string filename )
 {
     _texture = tex;
     Initialize();
     _name = filename;
     _file = filename;
 }
예제 #4
0
        /// <summary>
        ///		Default constructor.
        /// </summary>
        public Driver(D3D.AdapterInformation adapterInfo)
        {
            this.desktopMode = adapterInfo.CurrentDisplayMode;
            this.name = adapterInfo.Information.DriverName;
            this.description = adapterInfo.Information.Description;
            this.adapterNum = adapterInfo.Adapter;

            videoModeList = new VideoModeCollection();
        }
 public void Draw(D3D.Device device)
 {
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         foreach (BasicSprite sprite in sprites) {
             sprite.Draw(d3dSprite);
         }
         d3dSprite.End();
     }
 }
예제 #6
0
파일: Material.cs 프로젝트: zpconn/Gas
        /// <summary>
        /// Builds the material using a standard Direct3D material structure and the name of the VisualEffect.
        /// </summary>
        public Material( Renderer renderer, Direct3D.Material material, string visualEffectName )
        {
            if ( renderer == null )
                throw new ArgumentNullException( "renderer",
                    "Cannot create a material with a null renderer reference." );

            this.renderer = renderer;
            d3dMaterial = material;
            this.visualEffectName = visualEffectName;
        }
예제 #7
0
        public Material(Renderer renderer, Direct3D.Material material,
            string diffuseMapFilename)
        {
            if (renderer == null)
                throw new ArgumentNullException("renderer",
                    "Cannot create a material with a null renderer reference.");

            this.renderer = renderer;
            d3dMaterial = material;
            diffuseMap = new Texture(renderer, diffuseMapFilename);
        }
예제 #8
0
        public SplashButton(System.Windows.Forms.Form frm, 
                            D3D.Device device3D, Point location, Size dimension,
                            string normalFileName, string mouseOverFileName,
                            string mouseDownFileName, string disableFileName)
        {
            device3d = device3D;
            Location = location;
            size = dimension;

            int h = Location.Y + size.Height;
            int w = Location.X + size.Width;
            vertices = new D3D.CustomVertex.TransformedTextured[6];
            vertices[0] = new D3D.CustomVertex.TransformedTextured(new Vector4(location.X, location.Y, 0f, 1f), 0, 0);
            vertices[1] = new D3D.CustomVertex.TransformedTextured(new Vector4(w, location.Y, 0f, 1f), 1, 0);
            vertices[2] = new D3D.CustomVertex.TransformedTextured(new Vector4(location.X, h, 0f, 1f), 0, 1);
            vertices[3] = new D3D.CustomVertex.TransformedTextured(new Vector4(location.X, h, 0f, 1f), 0, 1);
            vertices[4] = new D3D.CustomVertex.TransformedTextured(new Vector4(w, location.Y, 0f, 1f), 1, 0);
            vertices[5] = new D3D.CustomVertex.TransformedTextured(new Vector4(w, h, 0f, 1f), 1, 1);
            normalTexture = D3D.TextureLoader.FromFile(device3d, normalFileName);
            mouseOverTexture = D3D.TextureLoader.FromFile(device3d, mouseOverFileName);
            mouseDownTexture = D3D.TextureLoader.FromFile(device3d, mouseDownFileName);
            disableTexture = D3D.TextureLoader.FromFile(device3d, disableFileName);
            Enable = true;
            //
            // set mouse device
            //
            try
            {
                MouseDevice = new DI.Device(DI.SystemGuid.Mouse);
                MouseDevice.SetDataFormat(DI.DeviceDataFormat.Mouse);
                MouseDevice.Acquire();
            }
            catch (DirectXException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, ex.Source);
            }
            finally
            {
                frm.MouseMove += new System.Windows.Forms.MouseEventHandler(frm_MouseMove);
            }
        }
예제 #9
0
 public static void GetBoundingBox(D3D.Mesh mesh, float scale, out DX.Vector3 min, out DX.Vector3 max)
 {
     D3D.VertexBuffer verts = mesh.VertexBuffer;
     DX.GraphicsStream stream = verts.Lock(0, 0, D3D.LockFlags.None);
     D3D.Geometry.ComputeBoundingBox(stream, mesh.NumberVertices, mesh.VertexFormat, out min, out max);
     verts.Unlock();
     stream = null;
     verts = null;
 }
        public TexturedObject(int PositionX, int PositionY, float Width, float Height, string TextureFilename, D3D.Device m_device)
        {
            positionX = PositionX;
            positionY = PositionY;
            width = Width;
            height = Height;
            //texture = TextureLoader.FromFile(m_device, TextureFilename);
            texture = TextureLoader.FromFile(m_device, TextureFilename, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.FromArgb(255,0,255).ToArgb());

            vertices = new CustomVertex.PositionTextured[6];
            vertices[0].Position = new Vector3(positionX + (width / 2.0f), positionY + (height / 2.0f), 0f);
            vertices[0].Tu = 0;
            vertices[0].Tv = 0;
            vertices[1].Position = new Vector3(positionX - (width / 2.0f), positionY - (height / 2.0f), 0f);
            vertices[1].Tu = 1;
            vertices[1].Tv = 1;
            vertices[2].Position = new Vector3(positionX + (width / 2.0f), positionY - (height / 2.0f), 0f);
            vertices[2].Tu = 0;
            vertices[2].Tv = 1;
            vertices[3].Position = new Vector3(positionX - (width / 2.0f), positionY - (height / 2.0f), 0f);
            vertices[3].Tu = 1;
            vertices[3].Tv = 1;
            vertices[4].Position = new Vector3(positionX + (width / 2.0f), positionY + (height / 2.0f), 0f);
            vertices[4].Tu = 0;
            vertices[4].Tv = 0;
            vertices[5].Position = new Vector3(positionX - (width / 2.0f), positionY + (height / 2.0f), 0f);
            vertices[5].Tu = 1;
            vertices[5].Tv = 0;
        }
 internal D3DFragmentProgram(string name, D3D.Device device, string syntaxCode)
     : base(name, GpuProgramType.Fragment, device, syntaxCode)
 {
 }
 internal D3DVertexProgram(string name, D3D.Device device, string syntaxCode)
     : base(name, GpuProgramType.Vertex, device, syntaxCode)
 {
 }
예제 #13
0
 public MeshObject(D3D.Device dev, Stream stream)
 { this.FillMesh(dev, stream); }
예제 #14
0
		/// <summary>
		/// Measures the rectangle dimensions of the specified text string when
		/// drawn with the specified <see cref="Microsoft.DirectX.Direct3D.Sprite">
		/// Microsoft.DirectX.Direct3D.Sprite</see> object.
		/// </summary>
		/// <param name="font">
		/// The Direct3D font for which to measure the specified text.
		/// </param>
		/// <param name="sprite">
		/// A <see cref="Microsoft.DirectX.Direct3D.Sprite">Sprite</see> object that
		/// contains the string.
		/// </param>
		/// <param name="text">String to measure.</param>
		/// <param name="width">Maximum width of the string.</param>
		/// <param name="color">Color of the text.</param>
		/// <returns>
		/// A Rectangle structure that contains the rectangle, in logical coordinates, that
		/// encompasses the formatted text string.
		/// </returns>
		public static Rectangle MeasureString(Direct3D.Font font, Sprite sprite, String text, int width, Color color) {
			return font.MeasureString(sprite, WrapString(sprite, font, text, width, color), DrawTextFormat.None, color);
		}
예제 #15
0
        //PaintAlphabet
        //-----------------------------------------------------------------------------
        // Name: InitializeDeviceObjects
        // Desc: Initialize the device objects
        //-----------------------------------------------------------------------------
        public void InitializeDeviceObjects(Direct3D.Device dev)
        {
            if (dev != null)
            {
                // Set up our events
                dev.DeviceReset += this.RestoreDeviceObjects;
            }

            // Keep a local copy of the device
            device = dev;
            textureState0 = device.TextureState[0];
            textureState1 = device.TextureState[1];
            samplerState0 = device.SamplerState[0];
            renderState = device.RenderState;

            // Create a bitmap on which to measure the alphabet
            Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.TextContrast = 0;

            // Establish the font and texture size
            textureScale = 1f;
            // Draw fonts into texture without scaling

            // Calculate the dimensions for the smallest power-of-two texture which can
            // hold all the printable characters
            textureWidth = 128;
            textureHeight = 128;
            while (true)
            {
                try
                {
                    // Measure the alphabet
                    PaintAlphabet(g, true);
                    break; // TODO: might not be correct. Was : Exit While
                }
                catch (InvalidOperationException)
                {
                    // Scale up the texture size and try again
                    textureWidth *= 2;
                    textureHeight *= 2;
                }
            }

            // If requested texture is too big, use a smaller texture and smaller font,
            // and scale up when rendering.
            Direct3D.Caps d3dCaps = device.DeviceCaps;

            // If the needed texture is too large for the video card...
            if (textureWidth > d3dCaps.MaxTextureWidth)
            {
                // Scale the font size down to fit on the largest possible texture
                textureScale = (float)d3dCaps.MaxTextureWidth / (float)textureWidth;
                textureWidth = d3dCaps.MaxTextureWidth;
                textureHeight = d3dCaps.MaxTextureWidth;

                while (true)
                {
                    // Create a new, smaller font
                    ourFontHeight = (int)Math.Floor(ourFontHeight * textureScale);
                    systemFont = new System.Drawing.Font(systemFont.Name, ourFontHeight, systemFont.Style);

                    try
                    {
                        // Measure the alphabet
                        PaintAlphabet(g, true);
                        break; // TODO: might not be correct. Was : Exit While
                    }
                    catch (InvalidOperationException)
                    {
                        // If that still doesn't fit, scale down again and continue
                        textureScale *= 0.9f;
                    }

                }
            }

            // Release the bitmap used for measuring and create one for drawing
            bmp.Dispose();
            bmp = new Bitmap(textureWidth, textureHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            g = Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.TextContrast = 0;

            // Draw the alphabet
            PaintAlphabet(g, false);

            // Create a new texture for the font from the bitmap we just created
            fontTexture = Texture.FromBitmap(device, bmp, 0, Pool.Managed);
            RestoreDeviceObjects(null, null);
        }
        /// <summary>
        ///		Default constructor.
        /// </summary>
        /// <param name="device">Reference to a Direct3D device.</param>
        public D3DHardwareOcclusionQuery(D3D.Device device)
        {
            this.device = device;

            // check if queries are supported
            isSupported = Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.HardwareOcculusion);

            if(isSupported) {
                // attempt to create an occlusion query
                query = new D3D.Query(device, QueryType.Occlusion);
            }
        }
예제 #17
0
파일: Text.cs 프로젝트: mansehr/Race
        public Text(Direct3D.Device d3dDevice, System.Drawing.Font font, 
					string text, int x, int y, Color color)
        {
            this.font = new Direct3D.Font(d3dDevice, font);
            this.setVariables(text, x, y, color);
        }
예제 #18
0
파일: Text.cs 프로젝트: mansehr/Race
 /**********************************************************************
 *
 *
 *  CONSTRUCTOR
 *
 *
 **********************************************************************/
 public Text(Direct3D.Device d3dDevice, System.Drawing.Font font)
 {
     this.font = new Direct3D.Font(d3dDevice, font);
 }
예제 #19
0
 public MeshObject(D3D.Device dev, D3D.Mesh mesh, D3D.Material[] materials, D3D.Texture[] textures)
 {
     //this._owner = dev;
     this._mesh = mesh;
     this._materials = materials;
     this._textures = textures;
 }
예제 #20
0
 public MeshObject(D3D.Device dev, D3D.Mesh mesh)
     : this(dev, mesh, new D3D.Material[0], new D3D.Texture[0])
 { }
예제 #21
0
        /// <summary>
        /// Saves the current rendering to a screenshot file.
        /// </summary>
        /// <param name="filename">The name of the file to create or overwrite.</param>
        /// <param name="fileFormat">The image format of the image to create.</param>
        public void TakeScreenshot( string filename, D3D.ImageFileFormat fileFormat )
        {
            D3D.Surface buffer = _viewport.Device.GetBackBuffer( 0, 0, D3D.BackBufferType.Mono );

            D3D.SurfaceLoader.Save( filename, fileFormat, buffer );
        }
예제 #22
0
		// Adds a token to text result.
		private static String AddToken(Direct3D.Font font, Sprite sprite, int width, String text, ref String currLine, String token, Color color) {
			Rectangle r = font.MeasureString(sprite, currLine + token, DrawTextFormat.None, color);
			if (r.Width <= width || currLine == "") {
				text += token;
				currLine += token;
			} 
			else {
				if (token == " ") token = "";
				text += ("\n" + token);
				currLine = token;
			}
			return text;
		}
 internal D3DGpuProgramManager(D3D.Device device)
 {
     this.device = device;
 }
 public void WriteScore(D3D.Device device, int score)
 {
     Rectangle nixiePosition = new Rectangle(nixiesTileSet.XOrigin,nixiesTileSet.YOrigin,nixiesTileSet.ExtentX*2,nixiesTileSet.ExtentY*2);
     int digit;
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         for (int digitCount = 1; digitCount <= maxScoreDigits; digitCount++) {
             digit = score % 10;
             score /= 10;
             nixiePosition.X = nixiesTileSet.XOrigin + ( digit % nixiesTileSet.NumberFrameColumns ) * nixiesTileSet.ExtentX*2;
             nixiePosition.Y = nixiesTileSet.YOrigin; //we know it's only one row
             Vector3 position = new Vector3((float)this.Width/2 - digitCount*nixiesTileSet.ExtentX*2,
                 (float)this.Height-60f, 0f);
             d3dSprite.Draw(nixiesTileSet.Texture, nixiePosition,
                 new Vector3(), position, Color.FromArgb(255,255,255,255));
         }
         d3dSprite.End();
     }
 }
예제 #25
0
		/// <summary>
		/// Wraps the specified text string, given the specified width and
		/// <see cref="Microsoft.DirectX.Direct3D.Sprite">
		/// Microsoft.DirectX.Direct3D.Sprite</see> object.
		/// </summary>
		/// <param name="sprite">
		/// A <see cref="Microsoft.DirectX.Direct3D.Sprite">Sprite</see> object that
		/// contains the string.
		/// </param>
		/// <param name="font">
		/// The Direct3D font for which to measure the specified text.
		/// </param>
		/// <param name="text">String to wrap.</param>
		/// <param name="width">Maximum width of the string.</param>
		/// <param name="color">Color of the text.</param>
		/// <returns>
		/// A string that has been wrapped with the specified width.
		/// </returns>
		public static String WrapString(Sprite sprite, Direct3D.Font font, String text, int width, Color color) {
			char[] sepChar = new char[1];
			sepChar[0] = ' ';
			String[] tokens = text.Split(sepChar);

			String result = "";
			String currLine = "";

			bool nonEmptyToken = false;
			for (int i = 0; i < tokens.Length; i++) {
				String token = tokens[i];

				if (token != "") nonEmptyToken = true;

				if (i > 0 && token != "") {
					result = AddToken(font, sprite, width, result, ref currLine, " ", color);
				}

				if (token == "") token = " ";

				result = AddToken(font, sprite, width, result, ref currLine, token, color);
			}
			if (!nonEmptyToken) result = AddToken(font, sprite, width, result, ref currLine, " ", color);


			return result;
		}
예제 #26
0
 //***************************************************************************
 // Class Constructors
 // 
 public MeshObject(D3D.Device dev, string filename)
 { this.FillMesh(dev, filename); }
예제 #27
0
        /// <summary>
        /// Draws the TurretBarrel to the given Device. Overloaded to allow a 
        /// special draw position used to keep the barrels from running away
        /// during animation.
        /// </summary>
        /// <param name="device">The Device to draw to</param>
        public override void draw(D3D.Device device)
        {
            //do transformations
            device.Transform.World = Matrix.Multiply(
                Matrix.RotationYawPitchRoll(rotation.X, rotation.Y, rotation.Z),
                Matrix.Translation(drawLocation.X, drawLocation.Y, drawLocation.Z));

            foreach (Model model in models)
            {
                model.draw(device);
            }

            foreach (Prefab child in children)
            {
                child.draw(device);
            }
        }
예제 #28
0
 /// <summary>
 ///		Accepts a existing Direct3D.DisplayMode object.
 /// </summary>
 public VideoMode(D3D.DisplayMode videoMode)
 {
     modeNum = ++modeCount;
     displayMode = videoMode;
 }
예제 #29
0
 public void Render(Dx3D.Effect shader)
 {
     if (IsComplete)
     {
         _WinSign.Render();
     }
     foreach (var item in _Items)
         item.Render(shader);
     if (_Selected != null)
     {
         Game.Current.SetColor(shader, _SelectedColor);
         _Selected.Render(shader);
     }
 }
 public D3DGpuProgram(string name, GpuProgramType type, D3D.Device device, string syntaxCode)
     : base(name, type, syntaxCode)
 {
     this.device = device;
 }