当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.BasicEffect类代码示例

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


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


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