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

C# Graphics.BasicEffect类代码示例

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

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



BasicEffect类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了BasicEffect类的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: Initialize

        public override void Initialize()
        {
            Effect = new BasicEffect(Device, null);

            /** Bottom Face **/
            var btmTL = new Vector3(0.0f, 0.0f, 0.0f);
            var btmTR = new Vector3(Size.X, 0.0f, 0.0f);
            var btmBR = new Vector3(Size.X, 0.0f, Size.Z);
            var btmBL = new Vector3(0.0f, 0.0f, Size.Z);

            /** Top face **/
            var topTL = new Vector3(0.0f, Size.Y, 0.0f);
            var topTR = new Vector3(Size.X, Size.Y, 0.0f);
            var topBR = new Vector3(Size.X, Size.Y, Size.Z);
            var topBL = new Vector3(0.0f, Size.Y, Size.Z);

            GeomList = new List<VertexPositionColor>();
            AddQuad(Color, topTL, topTR, topBR, topBL);
            AddQuad(Color.Yellow, btmTL, btmTR, btmBR, btmBL);
            AddQuad(Color.Green, topTL, topTR, btmTR, btmTL);
            AddQuad(Color.Blue, topBL, topTL, btmTL, btmBL);
            AddQuad(Color.Orange, topBR, topTR, btmTR, btmBR);
            AddQuad(Color.White, topBL, topBR, btmBR, btmBL);

            Geom = GeomList.ToArray();
        }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:26,代码来源:3DCube.cs


示例3: LD

 public LD(GraphicsDevice gd)
 {
     effect = new BasicEffect(gd);
     effect.VertexColorEnabled = true;
     vertices = new VertexPositionColor[ushort.MaxValue];
     vertexCount = 0;
 }
开发者ID:reignstudios,项目名称:jitterphysics,代码行数:7,代码来源:LD.cs


示例4: setBasicEffect

 protected override void setBasicEffect(BasicEffect be)
 {
     be.DiffuseColor = _isLonger
         ? new Vector3(0.8f, 0.2f, 0.2f)
         : new Vector3(0.2f, 0.8f, 0.2f);
     be.Alpha = SerpentStatus == SerpentStatus.Alive ? 1 : 0.5f;
 }
开发者ID:danbystrom,项目名称:Serpent,代码行数:7,代码来源:EnemySerpent.cs


示例5: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            zNear = 0.001f;
            zFar = 1000.0f;
            fov = MathHelper.Pi * 70.0f / 180.0f;
            eye = new Vector3(0.0f, 0.7f, 1.5f);
            at = new Vector3(0.0f, 0.0f, 0.0f);
            up = new Vector3(0.0f, 1.0f, 0.0f);

            cube = new VertexPositionColor[8];
            cube[0] = new VertexPositionColor(new Vector3(-0.5f, -0.5f, -0.5f), new Color(0.0f, 0.0f, 0.0f));
            cube[1] = new VertexPositionColor(new Vector3(-0.5f, -0.5f,  0.5f), new Color(0.0f, 0.0f, 1.0f));
            cube[2] = new VertexPositionColor(new Vector3(-0.5f,  0.5f, -0.5f), new Color(0.0f, 1.0f, 0.0f));
            cube[3] = new VertexPositionColor(new Vector3(-0.5f,  0.5f,  0.5f), new Color(0.0f, 1.0f, 1.0f));
            cube[4] = new VertexPositionColor(new Vector3( 0.5f, -0.5f, -0.5f), new Color(1.0f, 0.0f, 0.0f));
            cube[5] = new VertexPositionColor(new Vector3( 0.5f, -0.5f,  0.5f), new Color(1.0f, 0.0f, 1.0f));
            cube[6] = new VertexPositionColor(new Vector3( 0.5f,  0.5f, -0.5f), new Color(1.0f, 1.0f, 0.0f));
            cube[7] = new VertexPositionColor(new Vector3( 0.5f,  0.5f,  0.5f), new Color(1.0f, 1.0f, 1.0f));

            vertexBuffer = new DynamicVertexBuffer(graphics.GraphicsDevice, typeof(VertexPositionColor), 8, BufferUsage.WriteOnly);
            indexBuffer = new DynamicIndexBuffer(graphics.GraphicsDevice, typeof(ushort), 36, BufferUsage.WriteOnly);

            basicEffect = new BasicEffect(graphics.GraphicsDevice); //(device, null);
            basicEffect.LightingEnabled = false;
            basicEffect.VertexColorEnabled = true;
            basicEffect.TextureEnabled = false;

            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            base.Initialize();
        }
开发者ID:BrainSlugs83,项目名称:MonoGame,代码行数:37,代码来源:Game1.cs


示例6: Draw

        /// <summary>
        /// Draw a bounding frustrum representation
        /// </summary>
        /// <param name="frustum">Frustrum</param>
        /// <param name="camera">Camera</param>
        /// <param name="color">Color</param>
        public static void Draw(BoundingFrustum frustum, BaseCamera camera, Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(YnG.GraphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3[] corners = frustum.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                vertices[i].Position = corners[i];
                vertices[i].Color = color;
            }

            effect.View = camera.View;
            effect.Projection = camera.Projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                YnG.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, vertices, 0, 8, indices, 0, indices.Length / 2);
            }
        }
开发者ID:shaoleibo,项目名称:YnaEngine,代码行数:31,代码来源:BoundingFrustrumRenderer.cs


示例7: Draw

 /// <summary>
 /// Draw
 /// </summary>
 /// <param name="graphicsDevice"></param>
 /// <param name="basicEffect"></param>
 /// <param name="spriteBatch"></param>
 public virtual void Draw(GraphicsDevice graphicsDevice, BasicEffect basicEffect, SpriteBatch spriteBatch)
 {
     if (this._model != null)
     {
         this._model.Draw(graphicsDevice, basicEffect);
     }
 }
开发者ID:Zuver,项目名称:capture-the-flag,代码行数:13,代码来源:AbstractEntity.cs


示例8: Draw

        public static void Draw(this BoundingFrustum frustum, GraphicsDevice graphicsDevice, Matrix view, Matrix projection, Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3[] corners = frustum.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;
            foreach (var t in effect.Techniques)
                foreach (var p in t.Passes)
                {
                    p.Apply();

                    graphicsDevice.DrawUserIndexedPrimitives(
                        PrimitiveType.LineList, verts, 0, 8,
                        indices, 0, indices.Length / 2);

                }
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:29,代码来源:FrustumPrimitive.cs


示例9: Renderer

 public Renderer(GraphicsDevice device, RenderState renderState)
 {
     RenderState  = renderState;
     Device = device;
     _effect = new BasicEffect(Device);
     _bufferedInstructions = new List<IEnumerable<RenderInstruction>>();
 }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:7,代码来源:Renderer.cs


示例10: Draw

        public void Draw(Matrix parentMatrix, BasicEffect effect, float value, float headTurn)
        {
            Matrix headTranslation = Matrix.CreateTranslation(new Vector3(-4, 0, -4));
            headTranslation *= Matrix.CreateFromYawPitchRoll(headTurn, (float)Math.Sin(value * 8) / 10, 0);
            //headTranslation *= Matrix.CreateRotationX((float)Math.Sin(value * 8) / 10);
            //headTranslation *= Matrix.CreateRotationY(headTurn);
            headTranslation *= Matrix.CreateTranslation(new Vector3(4, 0, 4));

            //Matrix headTranslation = MatrixExtensions.CreateRotationX(new Vector3(4, 0, 4), (float)Math.Sin(value * 8) / 10);
            //headTranslation *= Matrix.;
            headModel.Draw(headTranslation * Matrix.CreateTranslation(0, 12, -2) * parentMatrix, effect);

            bodyModel.Draw(parentMatrix, effect);

            Matrix armLeftTranslation = MatrixExtensions.CreateRotationX(new Vector3(2, 10, 2), (float)Math.Sin(value * 5) / 2);
            armLeftTranslation *= MatrixExtensions.CreateRotationZ(new Vector3(2, 10, 2), (float)Math.Sin(value * 9) / 8 - 1.0f / 8.0f);
            armModelLeft.Draw(armLeftTranslation * Matrix.CreateTranslation(-4, 0, 0) * parentMatrix, effect);

            Matrix armRightTranslation = MatrixExtensions.CreateRotationX(new Vector3(2, 10, 2), (float)Math.Sin(value * 5 - Math.PI) / 2);
            armRightTranslation *= MatrixExtensions.CreateRotationZ(new Vector3(2, 10, 2), (float)Math.Sin(value * 9 - Math.PI) / 8 + 1.0f / 8.0f);
            armModelRight.Draw(armRightTranslation * Matrix.CreateTranslation(8, 0, 0) * parentMatrix, effect);

            Matrix legLeftTranslation = MatrixExtensions.CreateRotationX(new Vector3(2, 12, 2), (float)Math.Sin(value * 7) / 1);
            legModelLeft.Draw(legLeftTranslation * Matrix.CreateTranslation(0, -12, 0) * parentMatrix, effect);

            Matrix legRightTranslation = MatrixExtensions.CreateRotationX(new Vector3(2, 12, 2), (float)Math.Sin(value * 7 - Math.PI) / 1);
            legModelRight.Draw(legRightTranslation * Matrix.CreateTranslation(4, -12, 0) * parentMatrix, effect);
        }
开发者ID:OctoOsmo,项目名称:DeveMazeGenerator,代码行数:28,代码来源:PlayerModel.cs


示例11: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            lineEffect = new BasicEffect(graphics.GraphicsDevice);
            lineEffect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f);

            base.Initialize();
        }
开发者ID:myko,项目名称:tempusfugit,代码行数:13,代码来源:TempusFugitGame.cs


示例12: LineBatch

        public LineBatch(GraphicsDevice graphicsDevice)
        {
            // assign the graphics device parameter after safety-checking
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }
            this.graphicsDevice = graphicsDevice;

            // create and configure the effect
            this.effect = new BasicEffect(graphicsDevice);
            this.effect.VertexColorEnabled = true;
            this.effect.TextureEnabled = false;
            this.effect.LightingEnabled = false;
            // configure the effect
            this.effect.World = Matrix.Identity;
            this.effect.View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward,
                Vector3.Up);
            
            // create the vertex declaration
            //this.vertexDeclaration = new VertexDeclaration(graphicsDevice,
            //    VertexPositionColor.VertexElements);
            this.vertexDeclaration = new VertexDeclaration(new VertexElement());

            // create the vertex array
            this.vertices = new VertexPositionColor[maxVertexCount];
        }
开发者ID:JoeMarsh,项目名称:Astro-Flare-Rampage,代码行数:27,代码来源:LineBatch.cs


示例13: SimpleTree

 public SimpleTree(GraphicsDevice device, TreeSkeleton skeleton)
 {
     this.device = device;
     this.skeleton = skeleton;
     BoneEffect = new BasicEffect(device, new EffectPool());
     UpdateSkeleton();
 }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:7,代码来源:SimpleTree.cs


示例14: ImmediateModeDebug

 public ImmediateModeDebug(GraphicsDevice GraphicsDevice)
 {
     this.GraphicsDevice = GraphicsDevice;
     this.Effect = new BasicEffect(GraphicsDevice);
     Effect.TextureEnabled = false;
     Effect.VertexColorEnabled = true;
 }
开发者ID:Blecki,项目名称:coerceo,代码行数:7,代码来源:ImmediateModeDebug.cs


示例15: CoordCross

        public CoordCross(GraphicsDevice device)
        {
            this.device = device;
            basicEffect = new BasicEffect(device);

            InitVertices();
        }
开发者ID:kamilk,项目名称:asteroids,代码行数:7,代码来源:CoordCross.cs


示例16: drawSquarre

        public void drawSquarre(VertexPositionNormalTexture[] vertexData, int[] indexData, Camera came, BasicEffect effect, GraphicsDevice graphicsDevice)
        {
            Texture2D texture = Tools.Quick.groundTexture[BiomeType.SubtropicalDesert];
            effect.Projection = projectionMatrix;
            effect.Texture = texture;
            effect.TextureEnabled = true; ;

            graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
            graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

            //   effect.DiffuseColor = Color.Red.ToVector3();
            effect.CurrentTechnique.Passes[0].Apply();

            effect.View = came.getview();
            effect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);

            /*  // Draw wireframe box
              graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
              graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

              effect.TextureEnabled = false;
             // effect.DiffuseColor = Color.Black.ToVector3();
              effect.CurrentTechnique.Passes[0].Apply();

              graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
                 */
        }
开发者ID:Jupotter,项目名称:Nameless-Tales,代码行数:28,代码来源:DrawThings.cs


示例17: DrawWrapper

        public DrawWrapper(SpriteBatch batch, GraphicsDevice device, AssetManager assetsManager)
        {
            GlobalScale = 1f;

            spriteBatch = batch;
            graphicsDevice = device;
            deviceWidth = graphicsDevice.Viewport.Width;

            Assets = assetsManager;

            basicEffect = new BasicEffect(device)
            {
                VertexColorEnabled = true,
                World = Matrix.Identity,
                View = Matrix.Identity,
            };

            guiEffect = (BasicEffect) basicEffect.Clone();

            SetProjectionMatrix(standardWidth, standardHeight);
            ScreenSize = new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);

            displayWidth = standardWidth;
            displayHeight = standardHeight;
        }
开发者ID:rubna,项目名称:MetroidClone,代码行数:25,代码来源:DrawWrapper.cs


示例18: Snowflake

        public Snowflake(Vector3 position, float snowflakeTemperature)
        {
            float diameter = Snowflake.CalculateDiameter(snowflakeTemperature);
            this.mass      = Snowflake.CalculateMass    (snowflakeTemperature, diameter);

            this.basicEffect = new BasicEffect(this.graphicsDevice);

            this.basicEffect.World = this.camera.World;
            this.basicEffect.View = this.camera.View;
            this.basicEffect.Projection = this.camera.Projection;
            this.basicEffect.TextureEnabled = true;

            if (this.showLeaf)
            {
                this.quad = new Quad(diameter * 2);
                Texture2D texture = this.contentManager.Load<Texture2D>("leaf_" + (int)(Snowflake.random.NextDouble() * numTextures));
                this.basicEffect.Texture = texture;
            }
            else
            {
                this.quad = new Quad(diameter);
                Texture2D texture = this.contentManager.Load<Texture2D>("flake_" + (int)(Snowflake.random.NextDouble() * numTextures));
                this.basicEffect.Texture = texture;
            }

            this.Position = position;
            this.velocity = new Vector3(0f, -0.1f, 0f);
        }
开发者ID:faint32,项目名称:COGR_Snowflake,代码行数:28,代码来源:Snowflake.cs


示例19: Camera

        /// <summary>
        /// Constructor de la clase camara, se inicializan las matrices y se añaden al effect.
        /// </summary>
        /// <param name="effect">Effecto que se usa para dibujar.</param>
        /// <param name="device">El device actual.</param>
        public Camera(BasicEffect effect, GraphicsDevice device)
        {
            this.effect = effect;
            this.device = device;

            //Angulos inciales de la camara
            angleXZ = MathHelper.Pi / 4;
            angleYZ = MathHelper.Pi / 6;

            yaw = 0;
            pitch = 0;
            roll = 0;

            rotation = Quaternion.Identity;

            //Posicicón y destino inicial de la camara
            posicion.Y = 20 * (float)Math.Sin(angleYZ);
            posicion.X = 20 * (float)Math.Cos(angleYZ) * (float)Math.Sin(angleXZ);
            posicion.Z = 20 * (float)Math.Cos(angleYZ) * (float)Math.Cos(angleXZ);
            destino = new Vector3(0, 0, 0);

            //Se definen las matrices
            setCamera();
            worldMatrix = Matrix.Identity;
            projection = Matrix.CreateOrthographic(device.Viewport.Width / 8, device.Viewport.Height / 8, -200.0f, 200.0f);
            //projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1.0f, 200.0f);

            //Se añaden al effect
            effect.World = worldMatrix;
            effect.View = viewMatrix;
            effect.Projection = projection;
        }
开发者ID:alejopelaez,项目名称:eshcerworld,代码行数:37,代码来源:Camera.cs


示例20: Draw

        public void Draw(GraphicsDevice graphicsDevice, BasicEffect basicEffect)
        {
            if (this.lines.Count > 0)
            {
                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                        PrimitiveType.LineList,
                        this.GetPointsAsArray(),
                        0,  // vertex buffer offset to add to each element of the index buffer
                        this.points.Count,  // number of vertices in pointList
                        this.GetLinesAsIndexArray(),  // the index buffer
                        0,  // first index element to read
                        this.lines.Count   // number of primitives to draw
                    );
                }
            }

            basicEffect.TextureEnabled = true;
            using (var batch = new SpriteBatch(graphicsDevice))
            {
                batch.Begin(0, null, null, null, null, basicEffect);
                foreach (var vertex in this.GetPointsAsArray())
                {
                    batch.Draw(GlobalTextures.pixelTexture, new Vector2(vertex.Position.X - 3, vertex.Position.Y - 3), vertex.Color);
                }
                batch.End();
            }

            basicEffect.TextureEnabled = false;
        }
开发者ID:geoffreylhart,项目名称:MathExp,代码行数:32,代码来源:GeometryCollection.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.BlendState类代码示例发布时间:2022-05-26
下一篇:
C# GamerServices.SignedInGamer类代码示例发布时间: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