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


C# Effect.Clone方法代码示例

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


在下文中一共展示了Effect.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        private void Initialize()
        {
            // create Camera
            _camera = new ArcBallCamera(MapData.GetWorldPosition(20, 20), 0, MathHelper.PiOver2 * 0.5f * 0.8f * 0.8f, 0, MathHelper.PiOver2, CameraDistance, 30, 100, Manager.GraphicsDevice);

            // zooming
            zooming = new Zooming("Middle", "VeryFar", 2f, "Far", 1.3f, "Middle", 1.0f, "Near", 0.7f, "VeryNear", 0.5f, "Detail", 0.2f);
            zooming.ZoomChanged += delegate(float zoom) { _camera.Distance = CameraDistance * zoom; };

            _effect = Manager.Content.Load<Effect>("Content/Effects/Series4Effects");

            Mouse.SetPosition(Manager.GraphicsDevice.Viewport.Width / 2, Manager.GraphicsDevice.Viewport.Height / 2);

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

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

            _mapRenderer.Initialize();
            _mapRenderer.LoadContent();

            // init complete view
            defaultViewport = new Viewport();
            defaultViewport.X = 0;
            defaultViewport.Y = 0;
            defaultViewport.Width = Manager.GraphicsDevice.Viewport.Width;
            defaultViewport.Height = Manager.GraphicsDevice.Viewport.Height;

            // init control view
            controlViewport = new Viewport();
            controlViewport.X = 4;
            controlViewport.Y = 27;
            controlViewport.Width = Manager.GraphicsDevice.Viewport.Width - 8;
            controlViewport.Height = Manager.GraphicsDevice.Viewport.Height - 32;
        }
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:35,代码来源:GameMapBox.cs

示例2: SetModelEffect

        public void SetModelEffect(Effect effect, bool CopyEffect)
        {
            foreach (ModelMesh mesh in Model.Meshes)
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    Effect toSet = effect;

                    // Copy the effect if necessary
                    if (CopyEffect)
                        toSet = effect.Clone();

                    MeshTag tag = ((MeshTag)part.Tag);

                    // If this ModelMeshPart has a texture, set it to the effect
                    if (tag.Texture != null)
                    {
                        setEffectParameter(toSet, "BasicTexture", tag.Texture);
                        setEffectParameter(toSet, "TextureEnabled", true);
                    }
                    else
                    {
                        setEffectParameter(toSet, "TextureEnabled", false);
                    }

                    // Set our remaining parameters to the effect
                    setEffectParameter(toSet, "DiffuseColor", tag.Color);
                    setEffectParameter(toSet, "SpecularPower", tag.SpecularPower);

                    part.Effect = toSet;
                }
        }
开发者ID:blackEagle2012,项目名称:XNA-Game-project,代码行数:31,代码来源:SkyModel.cs

示例3: Material

        public Material(
            Effect effect, string techniqueName = null,
            Action<DeviceManager>[] beginHandlers = null,
            Action<DeviceManager>[] endHandlers = null
            )
            : this()
        {
            if (techniqueName != null) {
                Effect = effect.Clone();
                var technique = Effect.Techniques[techniqueName];

                if (technique != null)
                    Effect.CurrentTechnique = technique;
                else {
                    throw new ArgumentException("techniqueName");
                }
            } else {
                Effect = effect;
            }

            OwningThread = Thread.CurrentThread;

            // FIXME: This should probably never be null.
            if (Effect != null) {
                Parameters = new DefaultMaterialSetEffectParameters(Effect);
                _COMEffect = Effect.GetID3DXEffect();
            } else {
                _COMEffect = null;
            }

            BeginHandlers = beginHandlers;
            EndHandlers   = endHandlers;
        }
开发者ID:sq,项目名称:Fracture,代码行数:33,代码来源:Materials.cs

示例4: LoadContent

 public override void LoadContent()
 {
     skyDome = game.Content.Load<Model>("Models\\dome");
     effect = game.Content.Load<Effect>("Series4Effects");
     skyDome.Meshes[0].MeshParts[0].Effect = effect.Clone();
     cloudMap = game.Content.Load<Texture2D>("Models\\cloudMap");
     base.LoadContent();
 }
开发者ID:Ritsuki,项目名称:XsNotAlone-Game,代码行数:8,代码来源:XsScSkyDome.cs

示例5: SkyDome

        public SkyDome(GraphicsDevice device, ContentManager Content)
        {
            this.device = device;
            this.effect = Content.Load<Effect>("Effects/TexturedEffect");
            skyDome = Content.Load<Model>("Models/SkyDome/dome");

            cloudMap = Content.Load<Texture2D>("Models/SkyDome/cloudMap");
               skyDome.Meshes[0].MeshParts[0].Effect = effect.Clone();
        }
开发者ID:MenosGrandes,项目名称:mrowisko-pbl,代码行数:9,代码来源:SkyDome.cs

示例6: Enemy

 public Enemy(Game game, Effect effect)
     : base(game)
 {
     mechEffect = effect;
     mech = game.Content.Load<Model>("mech8");
     texCube = game.Content.Load<TextureCube>("CubeMap");
     effect.Parameters["cubetex"].SetValue(texCube);
     foreach(ModelMesh mesh in mech.Meshes)
         foreach (ModelMeshPart meshPart in mesh.MeshParts)
             meshPart.Effect = mechEffect.Clone();
 }
开发者ID:silenthunter,项目名称:MPG4803,代码行数:11,代码来源:Enemy.cs

示例7: load

        public override void load(ContentManager content, Effect effect)
        {
            mModel = content.Load<Model>("dome");
            cloudMap = content.Load<Texture2D>("cloud_texture");

            foreach (ModelMesh mesh in mModel.Meshes)
            {
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = effect.Clone();
                }
            }
        }
开发者ID:mattgmg1990,项目名称:Computer-Graphics-Final-Project,代码行数:13,代码来源:SkyDome.cs

示例8: Terrain

        public Terrain(float CellSize, float Height, float TextureTiling, int size, Vector3 Position,
                        Effect effect, Texture2D BaseTexture, Type type = Type.Flat, int depth = 0,
                        Texture2D RedTexture = null, Texture2D GreenTexture = null, Texture2D WeightTexture = null)
        {
            this.type = type;
            this.Size = size;
            this.depth = depth;
            this.CellSize = CellSize;
            this.Height = Height;
            this.Position = Position;
            this.baseTexture = BaseTexture;
            this.redTexture = RedTexture;
            this.greenTexture = GreenTexture;
            this.weightTexture = WeightTexture;
            this.TextureTiling = TextureTiling;
            this.PersistantRot = Matrix.Identity;
            this.waterSphere = new BoundingSphere(Vector3.Zero, PlanetRadius + Planet.HeightMag);
            this.MyRawHeightBorders = new List<float>[4];
            this.OtherRawHeightBorders = new List<float>[4];
            this.MyHeightBorders = new List<float>[4];
            this.nVertices = Size * Size;
            this.vertices = new VertexPositionNormalTexture[nVertices];

            //2 tris per cell, 3 indices per tris
            nIndices = (Size - 1) * (Size - 1) * 6;

            this.effect = effect.Clone();
            this.cachedEffect = effect.Clone();

            this.effect.Parameters["DiffuseColor"].SetValue(new Vector3(1));
            this.cachedEffect.Parameters["DiffuseColor"].SetValue(new Vector3(1));

            this.effect.Parameters["AmbientColor"].SetValue(new Vector3(0.75f));
            this.cachedEffect.Parameters["AmbientColor"].SetValue(new Vector3(0.75f));

            this.effect.Parameters["BasicTexture"].SetValue(baseTexture);
            this.cachedEffect.Parameters["BasicTexture"].SetValue(baseTexture);
        }
开发者ID:Infinity-Universe-Community,项目名称:infinity-universe,代码行数:38,代码来源:Terrain.cs

示例9: BaseMaterial

        public BaseMaterial(PipeEngine engine, Effect eff)
        {
            this.engine = engine;
            if(eff == null)
            {
                throw new ArgumentException("effect");
            }

            this.effect = eff.Clone(engine.GraphicsDevice);
            this.effect.CurrentTechnique = this.effect.Techniques[0];

            g_world = this.effect.Parameters["gWorld"];
            g_view = this.effect.Parameters["gView"];
        }
开发者ID:konlil,项目名称:pipe,代码行数:14,代码来源:BaseMaterial.cs

示例10: load

        public override void load(ContentManager content, Effect effect)
        {
            mModel = content.Load<Model>("xwing");

            mNoiseArray = loadPerlinNoiseFromFile();

            foreach (ModelMesh mesh in mModel.Meshes)
            {
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = effect.Clone();
                }
            }
        }
开发者ID:mattgmg1990,项目名称:Computer-Graphics-Final-Project,代码行数:14,代码来源:XWing.cs

示例11: LoadModel

        public static Model LoadModel(string assetName, out Texture2D[] textures, ContentManager content, Effect effect)
        {
            Model newModel = content.Load<Model>(assetName);
            textures = new Texture2D[newModel.Meshes.Count];
            int i = 0;
            foreach (ModelMesh mesh in newModel.Meshes)
                foreach (BasicEffect currentEffect in mesh.Effects)
                    textures[i++] = currentEffect.Texture;

            foreach (ModelMesh mesh in newModel.Meshes)
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                    meshPart.Effect = effect.Clone();

            return newModel;
        }
开发者ID:skakri09,项目名称:LabyrinthExplorer-XNA-3D-game,代码行数:15,代码来源:AssetLoader.cs

示例12: Material

        public Material(ContentManager contentManager, GraphicsDevice graphicsDevice,
            Effect baseEffect)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }
            device = graphicsDevice;

            if (contentManager == null)
            {
                throw new ArgumentNullException("contentManager");
            }
            content = contentManager;

            if (baseEffect == null)
            {
                throw new ArgumentNullException("baseEffect");
            }

            //////////////////////////////////////////////////////////////
            // Example 2.1                                              //
            //                                                          //
            // There are many ways to store and organize the constants  //
            // used for a material.  For this example, an entiire       //
            // Effect instance is cloned from the basic material shader //
            // and the material parameters are bound to that instance.  //
            // The result is a vastly simplified way of rendering a     //
            // material by simply setting the appropriate shader and    //
            // starting to draw.  This is also a very efficient         //
            // technique on the XBox 360, but typically less so on a    //
            // PC.                                                      //
            //////////////////////////////////////////////////////////////
            effectInstance = baseEffect.Clone(device);
            effectInstance.CurrentTechnique =
                effectInstance.Techniques[0];
            device = graphicsDevice;

            // Set the defaults for the effect
            effectInstance.Parameters["specularPower"].SetValue(specularPowerValue);
            effectInstance.Parameters["specularIntensity"].SetValue(
                specularIntensityValue);
            effectInstance.Parameters["materialColor"].SetValue(colorValue.ToVector4());
            effectInstance.Parameters["textureUReps"].SetValue(textureURepsValue);
            effectInstance.Parameters["textureVReps"].SetValue(textureVRepsValue);
        }
开发者ID:JamesPersaud,项目名称:GOOS,代码行数:46,代码来源:Material.cs

示例13: SkyRenderer

        public SkyRenderer(ContentManager contentManager, Camera camera)
            : base(contentManager)
        {
            this.camera = camera;
             skyDome = Content.Load<Model>("sky_dome");
             effect = Content.Load<Effect>("sky");
             skyDome.Meshes[0].MeshParts[0].Effect = effect.Clone(Device);
             projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Device.Viewport.AspectRatio,
            Config.Instance.Rendering.NearClippingDistance, Config.Instance.Rendering.FarClippingDistance);

             var pp = Device.PresentationParameters;
             cloudsRenderTarget = new RenderTarget2D(Device, pp.BackBufferWidth, pp.BackBufferHeight, 1, Device.DisplayMode.Format);
             cloudStaticMap = CreateStaticMap(32);

             fullScreenVertexDeclaration = new VertexDeclaration(Device, VertexPositionTexture.VertexElements);
             fullScreenVertices = SetUpFullscreenVertices();
        }
开发者ID:dennisyolkin,项目名称:gta_gameworld_renderer,代码行数:17,代码来源:Sky.cs

示例14: Water

        public Water(GraphicsDevice device, ContentManager content, Effect GBuffer)
        {
            this.GBuffer = GBuffer;
            this.device = device;
            int backbufferWidth = device.PresentationParameters.BackBufferWidth;
            int backbufferHeight = device.PresentationParameters.BackBufferHeight;

            refractionRenderTarget = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, device.DisplayMode.Format, DepthFormat.Depth24Stencil8, 1, RenderTargetUsage.DiscardContents);
            reflectionRenderTarget = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, device.DisplayMode.Format, DepthFormat.Depth24Stencil8, 1, RenderTargetUsage.DiscardContents);

            skyDome = content.Load<Model>("Models/SkyDome/dome");
            skyDome.Meshes[0].MeshParts[0].Effect = GBuffer.Clone();
            cloudMap = content.Load<Texture2D>("Models/SkyDome/cloudMap");
            waterEffect = content.Load<Effect>("Effects/Water");
            waterBump = content.Load<Texture2D>("waterbump");
            SetUpWaterVertices();
            waterVertexDeclaration = VertexPositionTexture.VertexDeclaration;
        }
开发者ID:patrykos91,项目名称:Laikos,代码行数:18,代码来源:Water.cs

示例15: SpatialHash4

        public SpatialHash4(GraphicsDevice device,
            Effect effect,
            int width, int height, int particleNumber,
            Vector2 spatialHashTextureSize,
            Vector3 buckets,
            Vector3 bucketSpacePosition, Vector3 bucketSpaceDimensions)
        {
            state1.DepthBufferEnable = true;
            state1.DepthBufferWriteEnable = true;
            state1.DepthBufferFunction = CompareFunction.Greater;

            state2.DepthBufferEnable = true;
            state2.DepthBufferFunction = CompareFunction.Less;
            state2.StencilEnable = true;
            state2.StencilFunction = CompareFunction.Greater;
            state2.ReferenceStencil = 1;
            state2.StencilPass = StencilOperation.Increment;

            this.effect = effect;
            this.effect2 = effect.Clone();
            Device = device;

            this.pwidth = width;
            this.pheight = height;

            Buckets = buckets;
            BucketSpacePosition = bucketSpacePosition;
            BucketSpaceDimensions = bucketSpaceDimensions;

            SpatialHashTextureSize = spatialHashTextureSize;

            createParticles();

            ParticleNumber = particleNumber;

            loadContent();
        }
开发者ID:vuce,项目名称:GpuCollisionDetection,代码行数:37,代码来源:SpatialHash4.cs


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