本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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);
}
示例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"];
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}