• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.VertexPositionTexture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexPositionTexture的典型用法代码示例。如果您正苦于以下问题:C# VertexPositionTexture类的具体用法?C# VertexPositionTexture怎么用?C# VertexPositionTexture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VertexPositionTexture类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了VertexPositionTexture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadContent

        public void LoadContent(ContentManager content, GraphicsDeviceManager graphicsDeviceManager)
        {
            texture = content.Load<Texture2D>("brick_texture_map");

            wall = new VertexPositionTexture[22];
            wall[0] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[1] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 0));
            wall[2] = new VertexPositionTexture(new Vector3(0, 0, 200), new Vector2(0, 2));
            wall[3] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(2, 2));
            wall[4] = new VertexPositionTexture(new Vector3(0, 0, 220), new Vector2(0, 0));
            wall[5] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(2, 0));
            wall[6] = new VertexPositionTexture(new Vector3(200, 0, 220), new Vector2(0, 2));
            wall[7] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 2));
            wall[8] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[9] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 0));
            wall[10] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 2));
            wall[11] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(0, 2));
            wall[12] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(0, 0));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), wall.Length, BufferUsage.None);
            vertexBuffer.SetData(wall);

            // Initialize the BasicEffect
            effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
        }
开发者ID:Woodje,项目名称:3DGame,代码行数:26,代码来源:Wall.cs


示例2: BoardTexture

        // To get the texture you want to draw
        public BoardTexture()
        {
            // Initialization of each value
            this.pos = Vector3.Zero;
            this.scale = Vector3.One;
            this.rotation = Vector3.Zero;
            this.alpha = 1.0f;

            // Effects creation
            this.basicEffect = Game1.basicEffect;
            // I authorize the use of texture
            this.basicEffect.TextureEnabled = true;

            // Create a vertex buffer
            this.vertexBuffer = new VertexBuffer(
                                        Game1.graphics.GraphicsDevice,
                                        typeof(VertexPositionTexture),
                                        4,
                                        BufferUsage.None);

            // I want to create the vertex data
            VertexPositionTexture[] vertices = new VertexPositionTexture[4];
            // I want to set the value of each vertex
            vertices[0] = new VertexPositionTexture(new Vector3(-1.0f, 1.0f, 1.0f),
                                                new Vector2(0.0f, 0.0f));
            vertices[1] = new VertexPositionTexture(new Vector3(1.0f, 1.0f, 1.0f),
                                                new Vector2(1.0f, 0.0f));
            vertices[2] = new VertexPositionTexture(new Vector3(-1.0f, -1.0f, 1.0f),
                                                new Vector2(0.0f, 1.0f));
            vertices[3] = new VertexPositionTexture(new Vector3(1.0f, -1.0f, 1.0f),
                                                new Vector2(1.0f, 1.0f));

            // I write in the vertex buffer vertex data
            this.vertexBuffer.SetData(vertices);
        }
开发者ID:BrandonGohNianZhou,项目名称:FinalYearProject2014,代码行数:36,代码来源:BoardTexture.cs


示例3: Render

        public static void Render(GraphicsDevice device, Color color)
        {
            BasicEffect _effect = new BasicEffect(device);
            _effect.Texture = new Texture2D(device, 1, 1);
            _effect.Texture.SetData<Color>(new Microsoft.Xna.Framework.Color[] { color });
            _effect.TextureEnabled = true;
            //_effect.VertexColorEnabled = true;

            VertexPositionTexture[] _vertices = new VertexPositionTexture[3];

            _vertices[0].Position = new Vector3(.5f,.5f,0);
            _vertices[1].Position = new Vector3(-.5f, -.5f, 0);
            _vertices[2].Position = new Vector3(.5f, 0f, 0);

            foreach (var pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives<VertexPositionTexture>
                (
                    PrimitiveType.TriangleStrip, // same result with TriangleList
                    _vertices,
                    0,
                    _vertices.Length,
                    new int[] { 0, 1, 2 },
                    0,
                    1
                );
            }

        }
开发者ID:charbean,项目名称:StrategyClean,代码行数:31,代码来源:PlanetMap.cs


示例4: InitializeParticleVertices

        private void InitializeParticleVertices()
        {
            verts = new VertexPositionTexture[maxParticles * 4];
            vertexColorArray = new Color[maxParticles];

            Color[] colors = new Color[particleColorsTexture.Width * particleColorsTexture.Height];
            particleColorsTexture.GetData(colors);

            for (int i = 0; i < maxParticles; ++i)
            {
                float size = (float)rand.NextDouble() * particleSettings.maxSize;

                Vector3 position = new Vector3(rand.Next(-(int)maxPosition.X,(int)maxPosition.X),rand.Next(-(int)maxPosition.Y,(int)maxPosition.Y),maxPosition.Z);

                verts[i * 4] = new VertexPositionTexture(position,new Vector2(0,0));

                verts[(i * 4) + 1] = new VertexPositionTexture(new Vector3(position.X, position.Y + size, position.Z), new Vector2(0,1));

                verts[(i * 4) + 2] = new VertexPositionTexture(new Vector3(position.X + size, position.Y, position.Z), new Vector2(1, 0));

                verts[(i * 4) + 3] = new VertexPositionTexture(new Vector3(position.X + size, position.Y + size, position.Z), new Vector2(1, 1));

                vertexColorArray[i] = colors[(rand.Next(0,particleColorsTexture.Height) *  particleColorsTexture.Width) + rand.Next(0,particleColorsTexture.Width)];
            }

            particleVertexBuffer = new VertexBuffer(graphicDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None);
        }
开发者ID:kozupi,项目名称:--,代码行数:27,代码来源:ParticleStarSheet.cs


示例5: Draw

        public void Draw(GraphicsDevice device, BasicEffect effect)
        {
            if (buf == null)
            {
                buf = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.None);
                var vpt = new VertexPositionTexture[4]{
                    new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0,0)),
                    new VertexPositionTexture(new Vector3(SIZE, 0, 0), new Vector2(1,0)),
                    new VertexPositionTexture(new Vector3(0, 0, SIZE), new Vector2(0,1)),
                    new VertexPositionTexture(new Vector3(SIZE, 0, SIZE), new Vector2(1,1))
                };

                buf.SetData(vpt);
            }

            device.SetVertexBuffer(buf);

            effect.TextureEnabled = true;
            effect.Texture = texture;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            }
        }
开发者ID:wistery-k,项目名称:Mjai3D,代码行数:26,代码来源:Taku.cs


示例6: initialize

        public static void initialize()
        {
            vertex = new VertexPositionTexture[4];
            vertex[0].Position = new Vector3(-0.5f,-0.5f, 0.0f);
            vertex[0].TextureCoordinate = new Vector2(0.0f, 1.0f);
            //vertex[0].Color = new Color(1, 1, 1, 1);
            vertex[1].Position = new Vector3(-0.5f, 0.5f, 0.0f);
            vertex[1].TextureCoordinate = new Vector2(0.0f, 0.0f);
            //vertex[1].Color = new Color(1, 1, 1, 1);
            vertex[2].Position = new Vector3(0.5f, -0.5f, 0.0f);
            vertex[2].TextureCoordinate = new Vector2(1.0f, 1.0f);
            //vertex[2].Color = new Color(1, 1, 1, 1);
            vertex[3].Position = new Vector3(0.5f, 0.5f, 0.0f);
            vertex[3].TextureCoordinate = new Vector2(1.0f, 0.0f);
            //vertex[3].Color = new Color(1, 1, 1, 1);

            vertexUVs = new VertexPositionTexture[4];
            vertexUVs[0].Position = new Vector3(-0.5f, -0.5f, 0.0f);
            //vertexUVs[0].Color = new Color(1, 1, 1, 1);
            vertexUVs[1].Position = new Vector3(-0.5f, 0.5f, 0.0f);
            //vertexUVs[1].Color = new Color(1, 1, 1, 1);
            vertexUVs[2].Position = new Vector3(0.5f, -0.5f, 0.0f);
            //vertexUVs[2].Color = new Color(1, 1, 1, 1);
            vertexUVs[3].Position = new Vector3(0.5f, 0.5f, 0.0f);
            //vertexUVs[3].Color = new Color(1, 1, 1, 1);
        }
开发者ID:doanhtdpl,项目名称:naughty-invaders,代码行数:26,代码来源:QuadRenderer.cs


示例7:

 void CréerTableauSommets()
 {
    PtsTexture = new Vector2[NbColonnes + 1, NbRangées + 1];
    PtsSommets = new Vector3[NbColonnes + 1, NbRangées - 1]; //-1, texture occupe le haut et le bas, donc 2 rangées de moins dans les ptsSommets
    Sommets = new VertexPositionTexture[NbSommets];
    CréerTableauPointsTexture();
 }
开发者ID:XavPro444,项目名称:PROJET-4,代码行数:7,代码来源:Cylindre.cs


示例8: 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


示例9: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Initialize vertices
            verts = new VertexPositionTexture[4];
            verts[0] = new VertexPositionTexture(
                new Vector3(-1, 1, 0), new Vector2(0, 0));
            verts[1] = new VertexPositionTexture(
                new Vector3(1, 1, 0), new Vector2(1, 0));
            verts[2] = new VertexPositionTexture(
                new Vector3(-1, -1, 0), new Vector2(0, 1));
            verts[3] = new VertexPositionTexture(
                new Vector3(1, -1, 0), new Vector2(1, 1));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None);
            vertexBuffer.SetData(verts);

            // Initialize the BasicEffect
            effect = new BasicEffect(GraphicsDevice);

            // Load texture
            texture = Content.Load<Texture2D>(@"Textures\trees");
           
        }
开发者ID:JackieWang,项目名称:Exercise.WP7,代码行数:31,代码来源:Game1.cs


示例10: SetUpVertices

        private void SetUpVertices()
        {
            // Fill in texture coordinates to display full texture
            // on quad
            Vector2 textureUpperLeft = new Vector2(0.0f, 0.0f);
            Vector2 textureUpperRight = new Vector2(1.0f, 0.0f);
            Vector2 textureLowerLeft = new Vector2(0.0f, 1.0f);
            Vector2 textureLowerRight = new Vector2(1.0f, 1.0f);

            // Create 4 vertices
            vertices[0] = new VertexPositionTexture(LowerLeft, textureLowerLeft);
            vertices[1] = new VertexPositionTexture(UpperLeft, textureUpperLeft);
            vertices[2] = new VertexPositionTexture(LowerRight, textureLowerRight);
            vertices[3] = new VertexPositionTexture(UpperRight, textureUpperRight);

            // Set the index buffer for each vertex, using
            // clockwise winding
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 2;
            indices[4] = 1;
            indices[5] = 3;

            // Initialize the VertexBuffer, and insert the data
            this.vertexBuffer = new VertexBuffer(Device, typeof(VertexPositionTexture), vertices.Length, BufferUsage.WriteOnly);
            this.vertexBuffer.SetData(vertices);

            // Initialize the IndexBuffer, and insert the data
            indexBuffer = new IndexBuffer(Device, typeof(short), indices.Length, BufferUsage.WriteOnly);
            indexBuffer.SetData(indices);
        }
开发者ID:araguzers,项目名称:Rabies-X,代码行数:32,代码来源:Quad.cs


示例11: draw

        public void draw()
        {
            if (show)
            {
                //Lägg spriten på en triangel
                VertexPositionTexture[] vertices = new VertexPositionTexture[6];
                //vertices[0] = new VertexPositionTexture(position, new Vector2(1, 1));
                vertices[0] = new VertexPositionTexture(position, new Vector2(1, 1));
                vertices[1] = new VertexPositionTexture(position, new Vector2(0, 0));
                vertices[2] = new VertexPositionTexture(position, new Vector2(1, 0));

                vertices[3] = new VertexPositionTexture(position, new Vector2(1, 1));
                vertices[4] = new VertexPositionTexture(position, new Vector2(0, 1));
                vertices[5] = new VertexPositionTexture(position, new Vector2(0, 0));

                Globals.effect.CurrentTechnique = Globals.effect.Techniques["PointSprites"];
                Globals.effect.Parameters["xWorld"].SetValue(Matrix.Identity);
                Globals.effect.Parameters["xProjection"].SetValue(Globals.player.camera.projection);
                Globals.effect.Parameters["xView"].SetValue(Globals.player.camera.view);
                Globals.effect.Parameters["xCamPos"].SetValue(Globals.player.camera.position);
                Globals.effect.Parameters["xTexture"].SetValue(sprite[frame]);
                Globals.effect.Parameters["xCamUp"].SetValue(Globals.player.camera.up);
                Globals.effect.Parameters["xPointSpriteSize"].SetValue(100f);

                if (frame >= sprite.Length - 40) Globals.device.BlendState = BlendState.Additive;

                foreach (EffectPass pass in Globals.effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    Globals.device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2);
                }

                if (frame >= sprite.Length - 40) Globals.device.BlendState = BlendState.Opaque;
            }
        }
开发者ID:andva,项目名称:Eulerian-ShootEmUp,代码行数:35,代码来源:Blood.cs


示例12: DrawPolygons

        public void DrawPolygons(Vector2 position, float angle, float scale,
            Texture2D texture, VertexPositionTexture[] vertices, BlendState blendMode)
        {
            effect.World = Matrix.CreateRotationZ(angle) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(new Vector3(position, 0));
            effect.Texture = texture;

            GraphicsDevice device = GameEngine.Instance.GraphicsDevice;

            if (blendMode == BlendState.AlphaBlend)
            {
                device.BlendState = BlendState.AlphaBlend;
            }
            else if (blendMode == BlendState.Additive)
            {
                device.BlendState = BlendState.Additive;
            }
            SamplerState s = new SamplerState();
            s.AddressU = TextureAddressMode.Wrap;
            s.AddressV = TextureAddressMode.Wrap;
            device.SamplerStates[0] = s;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
                //pass.Apply();
            }
        }
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:30,代码来源:PolygonDrawer.cs


示例13: Tile

        public Tile(Texture2D texture2D, GraphicsDeviceManager graphicsDeviceManager, Vector3 position, Vector3 dimension)
        {
            texture = texture2D;

            tile = new VertexPositionTexture[14];
            tile[0] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(0, 0));
            tile[1] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(1, 0));
            tile[2] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
            tile[3] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z), new Vector2(1, 1));
            tile[4] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[5] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(0, 1));
            tile[6] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(0, 0));
            tile[7] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(1, 1));
            tile[8] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[9] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
            tile[10] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(0, 0));
            tile[11] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[12] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(0, 1));
            tile[13] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(1, 1));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), tile.Length, BufferUsage.None);
            vertexBuffer.SetData(tile);

            // Initialize the BasicEffect
            effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
        }
开发者ID:Woodje,项目名称:3DGame,代码行数:27,代码来源:Tile.cs


示例14: Billboard

        public Billboard(GraphicsDevice graphicsDevice, Effect effect)
        {
            this.graphicsDevice = graphicsDevice;
            this.effect = effect;

            LifeTime = 1f;
            Scale = 1f;
            Alpha = 1f;
            Angle = 0f;
            Diffuse = Color.White;
            Age = 0f;

            PositionFunc = x => Position;
            AlphaFunc = x => Alpha;
            ScaleFunc = x => Scale;
            AngleFunc = x => Angle;
            DiffuseFunc = x => Diffuse;

            vertices[0] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 0));
            vertices[1] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 0));
            vertices[2] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 1));
            vertices[3] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 0));
            vertices[4] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 1));
            vertices[5] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 1));
        }
开发者ID:myko,项目名称:Eternia,代码行数:25,代码来源:Billboard.cs


示例15: Draw

        public override void Draw(GameTime gameTime)
        {
            VertexPositionTexture[] bulletVertices = new VertexPositionTexture[6];
            int i = 0;
            Vector3 center = Position + (Vector3.Up * 0.75f);

            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 1));
            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 0));
            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 0));

            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 1));
            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 1));
            bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 0));

            effects.CurrentTechnique = effects.Techniques["PointSprites"];
            effects.Parameters["xWorld"].SetValue(Matrix.Identity);
            effects.Parameters["xProjection"].SetValue(camera.projectionMatrix);
            effects.Parameters["xView"].SetValue(camera.viewMatrix);
            effects.Parameters["xTexture"].SetValue(Texture);
            effects.Parameters["xCamPos"].SetValue(camera.cameraPos);
            effects.Parameters["xCamUp"].SetValue(Vector3.Up);
            effects.Parameters["xPointSpriteSize"].SetValue(0.5f);

            graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;

            foreach (EffectPass pass in effects.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, bulletVertices, 0, 2);
            }
            graphics.GraphicsDevice.BlendState = BlendState.Opaque;

            base.Draw(gameTime);
        }
开发者ID:ArghyV,项目名称:Peliohjelmointi-s2011,代码行数:34,代码来源:MissileSpell.cs


示例16: FlatTarget

        /// <summary>
        /// A new 2D target which will spin in place.
        /// </summary>
        public FlatTarget(GraphicsDevice graphicsDevice, Texture2D texture, 
            Vector3 bottomLeft, Vector3 topLeft,
            Vector3 bottomRight, Vector3 topRight, float size, Boolean moving)
        {
            this.graphicsDevice = graphicsDevice;
            this.bottomLeft = bottomLeft;
            this.topLeft = topLeft;
            this.bottomRight = bottomRight;
            this.topRight = topRight;

            this.moving = moving;
            this.movingBack = true;
            this.movingForward = false;

            // Initialize verticies
            verts = new VertexPositionTexture[4];
            verts[0] = new VertexPositionTexture(bottomLeft, new Vector2(0, 1));
            verts[1] = new VertexPositionTexture(topLeft, new Vector2(0, 0));
            verts[2] = new VertexPositionTexture(bottomRight, new Vector2(1, 1));
            verts[3] = new VertexPositionTexture(topRight, new Vector2(1, 0));

            vertexBuffer = new VertexBuffer(this.graphicsDevice, typeof(VertexPositionTexture),
                                            verts.Length, BufferUsage.None);
            vertexBuffer.SetData(verts);

            // Initialize the BasicEffect to draw background left
            effect = new BasicEffect(this.graphicsDevice);
            this.texture = texture;
        }
开发者ID:richardshelby,项目名称:TargetPractice,代码行数:32,代码来源:FlatTarget.cs


示例17: TerrainComponent

        public TerrainComponent(HouseRenderState state)
        {
            var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/");
            var grass = Texture2D.FromFile(GameFacade.GraphicsDevice, Path.Combine(textureBase, "gr.tga"));
            Texture = grass;

            Effect = new BasicEffect(GameFacade.GraphicsDevice, null);
            Effect.TextureEnabled = true;
            Effect.Texture = Texture;

            Geom = new VertexPositionTexture[4];

            var repeatX = state.Size / 2.5f;
            var repeatY = repeatX;

            var tl = state.GetWorldFromTile(new Vector2(1, 1));
            var tr = state.GetWorldFromTile(new Vector2(state.Size-1, 1));
            var bl = state.GetWorldFromTile(new Vector2(1, state.Size-1));
            var br = state.GetWorldFromTile(new Vector2(state.Size-1, state.Size-1));

            Geom[0] = new VertexPositionTexture(tl, new Vector2(0, 0));
            Geom[1] = new VertexPositionTexture(tr, new Vector2(repeatX, 0));
            Geom[2] = new VertexPositionTexture(br, new Vector2(repeatX, repeatY));
            Geom[3] = new VertexPositionTexture(bl, new Vector2(0, repeatY));
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:25,代码来源:TerrainComponent.cs


示例18: CreateUVSphere

 public static void CreateUVSphere(int Width, int Height, out VertexPositionTexture[] UVSphere, out int[] IndexBuffer)
 {
     UVSphere = new VertexPositionTexture[Width * Height];
     for (int x = 0; x < Width; x++)
     {
         for (int y = 0; y < Height; y++)
         {
             UVSphere[x + y * Width] = new VertexPositionTexture(
                 new Vector3((float)Math.Cos((double)x / (Width - 1.0) * 2.0 * Math.PI)
                         * (float)Math.Sin((double)y / (Height - 1.0) * Math.PI)
                     , -(float)Math.Cos((double)y / (Height - 1.0) * Math.PI)
                     , (float)(Math.Sin((double)x / (Width - 1.0) * 2.0 * Math.PI))
                         * (float)Math.Sin((double)y / (Height - 1.0) * Math.PI))
                 , new Vector2((float)x / (Width - 1.0f), (float)y / (Height - 1.0f)));
         }
     }
     int counter = 0;
     IndexBuffer = new int[6 * (Width - 1) * (Height - 1)];
     for (int x = 0; x < Width - 1; x++)
     {
         for (int y = 0; y < Height - 1; y++)
         {
             IndexBuffer[counter++] = x + y * Width;
             IndexBuffer[counter++] = x + 1 + y * Width;
             IndexBuffer[counter++] = x + 1 + (y + 1) * Width;
             IndexBuffer[counter++] = x + y * Width;
             IndexBuffer[counter++] = x + 1 + (y + 1) * Width;
             IndexBuffer[counter++] = x + (y + 1) * Width;
         }
     }
 }
开发者ID:kaysoky,项目名称:AstronomicalSimulator,代码行数:31,代码来源:Body.cs


示例19: LoadModel

        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            VertexPositionTexture[] billboardVertices = new VertexPositionTexture[positions.Count * 6];
            int i = 0;

            foreach (var position in positions)
            {
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 1));

                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 1));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 1));
            }


            VertexBuffer vertexBufferS = factory.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, billboardVertices.Count(), BufferUsage.WriteOnly);
            vertexBufferS.SetData(billboardVertices);
            int noVertices = billboardVertices.Count();
            int noTriangles = noVertices / 3;

            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, 0, noTriangles, 0, 0, VertexPositionTexture.VertexDeclaration, VertexPositionTexture.VertexDeclaration.VertexStride, BatchType.NORMAL);
            b[0].VertexBuffer = vertexBufferS;
            b[0].IndexBuffer = null;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, diffuseTextureName, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:34,代码来源:StaticBilboardModel.cs


示例20: VBScreen

            /// <summary>
            /// Create VB screen
            /// </summary>
            public VBScreen()
            {
                VertexPositionTexture[] vertices = new VertexPositionTexture[]
                {
                    new VertexPositionTexture(
                        new Vector3(-1.0f, -1.0f, 0.5f),
                        new Vector2(0, 1)),
                    new VertexPositionTexture(
                        new Vector3(-1.0f, 1.0f, 0.5f),
                        new Vector2(0, 0)),
                    new VertexPositionTexture(
                        new Vector3(1.0f, -1.0f, 0.5f),
                        new Vector2(1, 1)),
                    new VertexPositionTexture(
                        new Vector3(1.0f, 1.0f, 0.5f),
                        new Vector2(1, 0)),
                };

                vbScreen = new VertexBuffer(
                    BaseGame.Device,
                    typeof(VertexPositionTexture),
                    vertices.Length,
                    BufferUsage.WriteOnly);

                vbScreen.SetData(vertices);
            }
开发者ID:fhlviana,项目名称:XNA-4-Racing-Game-Kit,代码行数:29,代码来源:VBScreenHelper.cs



注:本文中的Microsoft.Xna.Framework.Graphics.VertexPositionTexture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.Viewport类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.VertexPositionNormalTexture类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap