當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.VertexDeclaration類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.VertexDeclaration的典型用法代碼示例。如果您正苦於以下問題:C# VertexDeclaration類的具體用法?C# VertexDeclaration怎麽用?C# VertexDeclaration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VertexDeclaration類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了VertexDeclaration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Create

        public override void Create()
        {
            buffer = Plane(xCount, yCount);

            //Load the correct shader and set up the parameters
            IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)GameInstance.Services.GetService(typeof(IGraphicsDeviceService));

            effect = SpacewarGame.ContentManager.Load<Effect>(SpacewarGame.Settings.MediaPath + @"shaders\sun");

            worldParam = effect.Parameters["world"];
            worldViewProjectionParam = effect.Parameters["worldViewProjection"];
            sun0TextureParam = effect.Parameters["Sun_Tex0"];
            sun1TextureParam = effect.Parameters["Sun_Tex1"];
            blendFactor = effect.Parameters["blendFactor"];

            //Preload the textures into the cache
            int numFrames = 5;
            sun = new Texture2D[numFrames];

            sun[0] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest1");
            sun[1] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest2");
            sun[2] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest3");
            sun[3] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest4");
            sun[4] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest5");

            vertexDecl = new VertexDeclaration(graphicsService.GraphicsDevice, VertexPositionColor.VertexElements);
        }
開發者ID:gitaishhub,項目名稱:cs4803mpg,代碼行數:27,代碼來源:EvolvedSun.cs

示例2: CreateVertexBuffer

        private void CreateVertexBuffer()
        {
            vertexDeclaration = new VertexDeclaration(new VertexElement[1]
                {
                    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0)
                }
            );

            vertexBuffer = new VertexBuffer(
                GraphicsDevice,
                vertexDeclaration,
                number_of_vertices,
                BufferUsage.None
                );

            Vector3[] vertices = new Vector3[number_of_vertices];
            vertices[0] = new Vector3(-1, 0, 0); // cw
            vertices[1] = new Vector3(0, 1, 0);
            vertices[2] = new Vector3(0, 0, 0);
            vertices[3] = new Vector3(0, 0, 0); // ccw
            vertices[4] = new Vector3(1, 0, 0);
            vertices[5] = new Vector3(0, 1, 0);

            vertexBuffer.SetData(vertices);

        }
開發者ID:Nailz,項目名稱:MonoGame-Samples,代碼行數:26,代碼來源:Game1.cs

示例3: LoadContent

    public void LoadContent()
    {
#if gradient
      generateTextureEffect = game.Content.Load<Effect>(@"effects\GenerateTerrainTextureGradient");
      gradientTexture = game.Content.Load<Texture2D>(@"textures\gradient_01");

      generateTextureEffect.Parameters["gradient"].SetValue(gradientTexture);

#else
      string[] textureNames = { 
                                "dirt_01", "dirt_03",
                                "sand_02", "sand_03",
                                "grass_01", "grass_02", "grass_03",
                                "water_01", "stone_02", "stone_03",
                                "snow_01", "snow_03"
                              };

      generateTextureEffect = game.Content.Load<Effect>(@"effects\GenerateTerrainTexturePack");
      slopemapTexture = game.Content.Load<Texture2D>(@"textures\slopemap");

      // load diffuse textures
      textures = new Texture2D[textureNames.Length];
      for (int i = 0; i < textures.Length; i++)
        textures[i] = game.Content.Load<Texture2D>(@"textures\" + textureNames[i]);


#endif

      // texture declaration
      vertexPositionTexture = VertexPositionTexture.VertexDeclaration; // new VertexDeclaration(device, VertexPositionTexture.VertexElements);
    }
開發者ID:TrinityGaming,項目名稱:Planet_40,代碼行數:31,代碼來源:TerrainTextureGenerator.cs

示例4: WheelMenuEntry

        WheelMenu wheel; // the parent wheel

        #endregion Fields

        #region Constructors

        public WheelMenuEntry( WheelMenu wheel, Texture2D texture )
        {
            this.wheel = wheel;
              this.texture = texture;

              segments = 10;

              extendedSpring = new SpringInterpolater( 1, 800, SpringInterpolater.GetCriticalDamping( 800 ) );
              extendedSpring.SetSource( 0 );
              extendedSpring.SetDest( 0 );
              extendedSpring.Active = true;

              growSpring = new SpringInterpolater( 1, 700, .25f * SpringInterpolater.GetCriticalDamping( 700 ) );
              growSpring.SetSource( 0 );
              growSpring.SetDest( 0 );
              growSpring.Active = true;

              float height = WheelMenu.EntryIdleSize;
              float width = height * (float)texture.Width / (float)texture.Height;
              GenerateVerts( width, height, segments, out idleVerts );
              GenerateVerts( width * WheelMenu.EntryActiveScale, height * WheelMenu.EntryActiveScale, segments, out activeVerts );

              vertexBuffer = new VertexPositionNormalTexture[( segments + 1 ) * 2];
              vertexDeclaration = new VertexDeclaration( wheel.Screen.ScreenManager.GraphicsDevice,
                                                 VertexPositionNormalTexture.VertexElements );
        }
開發者ID:yxrkt,項目名稱:AvatarHamsterPanic,代碼行數:32,代碼來源:WheelMenuEntry.cs

示例5: LoadContent

		public override void LoadContent()
		{
			vertexDecl = VertexPositionTexture.VertexDeclaration;

			verts = new VertexPositionTexture[]
            {
                new VertexPositionTexture(
                    new Vector3(0,0,1),
                    new Vector2(1,1)),
                new VertexPositionTexture(
                    new Vector3(0,0,1),
                    new Vector2(0,1)),
                new VertexPositionTexture(
                    new Vector3(0,0,1),
                    new Vector2(0,0)),
                new VertexPositionTexture(
                    new Vector3(0,0,1),
                    new Vector2(1,0))
            };

			ib = new short[] { 0, 1, 2, 2, 3, 0 }; // 0 -- 1
												   // |    |
												   // 2 -- 3

			base.LoadContent();
		}
開發者ID:CC-Ricers,項目名稱:XNA-4.0-Dual-Paraboloid-Reflection-Mapping,代碼行數:26,代碼來源:Quad.cs

示例6: LoadContent

        public void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            if (_dEffect == null)
                _dEffect = content.Load<Effect>("Content/Effects/Series4Effects");

            _texture1 = content.Load<Texture2D>("Content/Textures/Ground/sand");
            _texture2 = content.Load<Texture2D>("Content/Textures/Ground/grass");
            _texture3 = content.Load<Texture2D>("Content/Textures/Ground/rock");
            _texture4 = content.Load<Texture2D>("Content/Textures/Ground/snow");

            _skyDome = content.Load<Model>("Content/Models/dome");
            _skyDome.Meshes[0].MeshParts[0].Effect = _dEffect.Clone();

            _cloudMap = content.Load<Texture2D>("Content/Models/cloudMap");

            //PresentationParameters pp = _dDevice.PresentationParameters;
            //refractionRenderTarget = new RenderTarget2D(_dDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, pp.BackBufferFormat, pp.DepthStencilFormat);
            //reflectionRenderTarget = new RenderTarget2D(_dDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, pp.BackBufferFormat, pp.DepthStencilFormat);

            SetUpWaterVertices();

            waterBumpMap = content.Load<Texture2D>("Content/Textures/Ground/water");

            VertexPositionTexture[] fullScreenVertices = SetUpFullscreenVertices();
            //fullScreenVertexDeclaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);

            VertexDeclaration vertexDeclaration = new VertexDeclaration(VertexMultitextured.VertexElements);
            fullScreenBuffer = new VertexBuffer(_dDevice, vertexDeclaration, fullScreenVertices.Length, BufferUsage.WriteOnly);
            fullScreenBuffer.SetData(fullScreenVertices);

            fullScreenVertexDeclaration = new VertexDeclaration(VertexPositionTexture.VertexDeclaration.GetVertexElements());
        }
開發者ID:mrommel,項目名稱:MiRo.SimHexWorld,代碼行數:32,代碼來源:HexMesh.cs

示例7: Flush

        public virtual void Flush()
        {
            if (this.vertexCount > 0)
            {
                if (this.declaration == null || this.declaration.IsDisposed)
                    this.declaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);

                device.VertexDeclaration = this.declaration;

                Effect effect = this.Effect;
                //  set the only parameter this effect takes.
                effect.Parameters["viewProjection"].SetValue(this.View * this.Projection);

                EffectTechnique technique = effect.CurrentTechnique;
                effect.Begin();
                EffectPassCollection passes = technique.Passes;
                for (int i = 0; i < passes.Count; i++)
                {
                    EffectPass pass = passes[i];
                    pass.Begin();

                    device.DrawUserIndexedPrimitives<VertexPositionTexture>(
                        PrimitiveType.TriangleList, this.vertices, 0, this.vertexCount,
                        this.indices, 0, this.indexCount / 3);

                    pass.End();
                }
                effect.End();

                this.vertexCount = 0;
                this.indexCount = 0;
            }
        }
開發者ID:mikecann,項目名稱:Portal2D-XNA,代碼行數:33,代碼來源:cPostProcessBatch.cs

示例8: loadContent

        public void loadContent(ContentManager contentManager, GraphicsDeviceManager graphicsManager, ModelGeometry collisionGeometry)
        {
            mGraphicsDevice = graphicsManager.GraphicsDevice;

            mInstanceVertexDeclaration = new VertexDeclaration(new[]
            {
                new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 2),
                new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 3),
                new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 4),
                new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 5)
            });

            mCollidingFacesVertexDeclaration = new VertexDeclaration(new[]
            {
                // ideally we'd use Byte4 for Color0 but it's so much easier to fill vertex buffers with Vector3. There's only very little data anyway
                new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0 ),
                new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0 ),
                new VertexElement(24, VertexElementFormat.Vector3, VertexElementUsage.Color, 0 )
            });

            mCollidingFacesVertices = new VertexBuffer(mGraphicsDevice, mCollidingFacesVertexDeclaration, collisionGeometry.faces.Length * 3, BufferUsage.WriteOnly);

            // load collisions shader and configure material properties
            mCollisionsShader = contentManager.Load<Effect>("Effects/CollisionsShader");
            mCollisionsShader.Parameters["MaterialColor"].SetValue(new Vector3(0.39f, 0.8f, 1f));

            mAlphaBlendState = new BlendState();
            mAlphaBlendState.ColorSourceBlend = Blend.SourceAlpha;
            mAlphaBlendState.AlphaSourceBlend = Blend.SourceAlpha;
            mAlphaBlendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
            mAlphaBlendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
        }
開發者ID:xboxlife,項目名稱:xna-bounce,代碼行數:32,代碼來源:Renderer.cs

示例9: SkyBox

        public SkyBox(ContentReader input)
        {
            // Graphics Device-Instanz abrufen
              this.GraphicsDevice = ((IGraphicsDeviceService)input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService))).GraphicsDevice;

              // Vertices einlesen und Vertex Buffer initialisieren
              VertexPositionTexture[] vertices = input.ReadObject<VertexPositionTexture[]>();
              this.vertexBuffer = new VertexBuffer(this.GraphicsDevice, typeof(VertexPositionTexture), vertices.Length, BufferUsage.None);
              this.vertexBuffer.SetData<VertexPositionTexture>(vertices);

              // Anzahl der Vertices speichern
              this.numVertices = vertices.Length;

              // Division durch 3 ergibt die Anzahl der Primitive, da eine Dreiecksliste verwendet wird
              this.numPrimitives = this.numPrimitives / 3;

              // Vertex-Beschreibung erzeugen
              this.vertexDeclaration = new VertexDeclaration(VertexPositionTexture.VertexDeclaration.GetVertexElements());

              // BasicEffect-Instanz erzeugen
              this.effect = new BasicEffect(this.GraphicsDevice);

              // Texturen einlesen
              this.frontTexture = input.ReadExternalReference<Texture2D>();
              this.backTexture = input.ReadExternalReference<Texture2D>();
              this.leftTexture = input.ReadExternalReference<Texture2D>();
              this.rightTexture = input.ReadExternalReference<Texture2D>();
              this.topTexture = input.ReadExternalReference<Texture2D>();
              this.bottomTexture = input.ReadExternalReference<Texture2D>();
        }
開發者ID:urmuelle,項目名稱:MonoGameBallerburg,代碼行數:30,代碼來源:SkyBox.cs

示例10: VertexPositionColorTexture

		static VertexPositionColorTexture()
		{
			VertexDeclaration = new VertexDeclaration(
				new VertexElement[]
				{
					new VertexElement(
						0,
						VertexElementFormat.Vector3,
						VertexElementUsage.Position,
						0
					),
					new VertexElement(
						12,
						VertexElementFormat.Color,
						VertexElementUsage.Color,
						0
					),
					new VertexElement(
						16,
						VertexElementFormat.Vector2,
						VertexElementUsage.TextureCoordinate,
						0
					)
				}
			);
		}
開發者ID:BlueLineGames,項目名稱:FNA,代碼行數:26,代碼來源:VertexPositionColorTexture.cs

示例11: VertexBufferObject

 /// <summary>
 /// Constructor of VertexBufferObject class
 /// </summary>
 /// <param name="device">Graphics device</param>
 /// <param name="type">Type of buffer to use</param>
 /// <param name="buffer">Underlying vertex buffer</param>
 internal VertexBufferObject(GraphicsDevice device, BufferType type, VertexBuffer buffer)
 {
     _device = device;
     _bufferType = type;
     _vertexDeclaration = buffer.VertexDeclaration;
     CreateWrapper(buffer);
 }
開發者ID:Julien-Pires,項目名稱:Pulsar,代碼行數:13,代碼來源:VertexBufferObject.cs

示例12: SkyplaneEngine

        public SkyplaneEngine(InfiniminerGame gameInstance)
        {
            this.gameInstance = gameInstance;

            // Generate a noise texture.
            randGen = new Random();
            texNoise = new Texture2D(gameInstance.GraphicsDevice, 64, 64);
            uint[] noiseData = new uint[64*64];
            for (int i = 0; i < 64 * 64; i++)
                if (randGen.Next(32) == 0)
                    noiseData[i] = Color.White.PackedValue;
                else
                    noiseData[i] = Color.Black.PackedValue;
            texNoise.SetData(noiseData);

            // Load the effect file.
            effect = gameInstance.Content.Load<Effect>("effect_skyplane");

            // Create our vertices.
            vertexDeclaration = new VertexDeclaration(gameInstance.GraphicsDevice, VertexPositionTexture.VertexElements);
            vertices = new VertexPositionTexture[6];
            vertices[0] = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
            vertices[1] = new VertexPositionTexture(new Vector3(274, 100, -210), new Vector2(1, 0));
            vertices[2] = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
            vertices[3] = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
            vertices[4] = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
            vertices[5] = new VertexPositionTexture(new Vector3(-210, 100, 274), new Vector2(0, 1));
        }
開發者ID:GlennSandoval,項目名稱:Infiniminer,代碼行數:28,代碼來源:SkyboxEngine.cs

示例13: Initialize

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            int iWidth = graphics.Viewport.Width;
            int iHeight = graphics.Viewport.Height;

            for (int i = 0; i < DefaultBufferSize; i++)
            {
                vertices[i] = new VertexPositionColor();
                vertices[i].Position.X = rand.Next(iWidth);
                vertices[i].Position.Y = rand.Next(iHeight);
                vertices[i].Color = Color.White; //new Color(128, 128, 128);
            }
            graphics.RenderState.PointSize = 1;

            // create a vertex declaration, which tells the graphics card what kind of
            // data to expect during a draw call. We're drawing using
            // VertexPositionColors, so we'll use those vertex elements.
            vertexDeclaration = new VertexDeclaration(graphics,
                VertexPositionColor.VertexElements);

            // set up a new basic effect, and enable vertex colors.
            basicEffect = new BasicEffect(graphics, null);
            basicEffect.VertexColorEnabled = true;

            // projection uses CreateOrthographicOffCenter to create 2d projection
            // matrix with 0,0 in the upper left.
            basicEffect.Projection = Matrix.CreateOrthographicOffCenter
                (0, iWidth,
                iHeight, 0,
                0, 1);

            base.Initialize();
        }
開發者ID:funkjunky,項目名稱:Revenge-of-the-Morito-2-,代碼行數:37,代碼來源:StarryBackground.cs

示例14: QuadRenderComponent

        // Constructor
        public QuadRenderComponent(Game game)
            : base(game)
        {
            IGraphicsDeviceService graphicsService =
                    (IGraphicsDeviceService)base.Game.Services.GetService(
                                                typeof(IGraphicsDeviceService));

            vertexDecl = new VertexDeclaration(VertexPositionTexture.VertexDeclaration.GetVertexElements());

            verts = new VertexPositionTexture[]
                        {
                            new VertexPositionTexture(
                                new Vector3(0,0,0),
                                new Vector2(1,1)),
                            new VertexPositionTexture(
                                new Vector3(0,0,0),
                                new Vector2(0,1)),
                            new VertexPositionTexture(
                                new Vector3(0,0,0),
                                new Vector2(0,0)),
                            new VertexPositionTexture(
                                new Vector3(0,0,0),
                                new Vector2(1,0))
                        };

            ib = new short[] { 0, 1, 2, 2, 3, 0 };
        }
開發者ID:razvanalex,項目名稱:XNAEnvironment,代碼行數:28,代碼來源:QuadRenderComponent.cs

示例15: InstancedModelDrawer

        public InstancedModelDrawer(Game game)
            : base(game)
        {
#if WINDOWS
            var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.WindowsPhysicsResources.ResourceManager);
#elif XBOX360
            var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.Xbox360PhysicsResources.ResourceManager);
#else
            ResourceContentManager resourceContentManager = null;
#endif
            instancingEffect = resourceContentManager.Load<Effect>("InstancedEffect");

            worldTransformsParameter = instancingEffect.Parameters["WorldTransforms"];
            textureIndicesParameter = instancingEffect.Parameters["TextureIndices"];
            viewParameter = instancingEffect.Parameters["View"];
            projectionParameter = instancingEffect.Parameters["Projection"];

            instancingEffect.Parameters["LightDirection1"].SetValue(Vector3.Normalize(new Vector3(.8f, -1.5f, -1.2f)));
            instancingEffect.Parameters["DiffuseColor1"].SetValue(new Vector3(.66f, .66f, .66f));
            instancingEffect.Parameters["LightDirection2"].SetValue(Vector3.Normalize(new Vector3(-.8f, 1.5f, 1.2f)));
            instancingEffect.Parameters["DiffuseColor2"].SetValue(new Vector3(.3f, .3f, .5f));
            instancingEffect.Parameters["AmbientAmount"].SetValue(.5f);

            instancingEffect.Parameters["Texture0"].SetValue(textures[0]);
            instancingEffect.Parameters["Texture1"].SetValue(textures[1]);
            instancingEffect.Parameters["Texture2"].SetValue(textures[2]);
            instancingEffect.Parameters["Texture3"].SetValue(textures[3]);
            instancingEffect.Parameters["Texture4"].SetValue(textures[4]);
            instancingEffect.Parameters["Texture5"].SetValue(textures[5]);
            instancingEffect.Parameters["Texture6"].SetValue(textures[6]);
            instancingEffect.Parameters["Texture7"].SetValue(textures[7]);

            //This vertex declaration could be compressed or made more efficient, but such optimizations weren't critical.
            instancingVertexDeclaration = new VertexDeclaration(new[] {new VertexElement(0, VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1)});
        }
開發者ID:VICOGameStudio-Ujen,項目名稱:igf,代碼行數:35,代碼來源:InstancedModelDrawer.cs


注:本文中的Microsoft.Xna.Framework.Graphics.VertexDeclaration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。