當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。