本文整理汇总了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);
}
示例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();
}
示例3: LD
public LD(GraphicsDevice gd)
{
effect = new BasicEffect(gd);
effect.VertexColorEnabled = true;
vertices = new VertexPositionColor[ushort.MaxValue];
vertexCount = 0;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例9: Renderer
public Renderer(GraphicsDevice device, RenderState renderState)
{
RenderState = renderState;
Device = device;
_effect = new BasicEffect(Device);
_bufferedInstructions = new List<IEnumerable<RenderInstruction>>();
}
示例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);
}
示例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();
}
示例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];
}
示例13: SimpleTree
public SimpleTree(GraphicsDevice device, TreeSkeleton skeleton)
{
this.device = device;
this.skeleton = skeleton;
BoneEffect = new BasicEffect(device, new EffectPool());
UpdateSkeleton();
}
示例14: ImmediateModeDebug
public ImmediateModeDebug(GraphicsDevice GraphicsDevice)
{
this.GraphicsDevice = GraphicsDevice;
this.Effect = new BasicEffect(GraphicsDevice);
Effect.TextureEnabled = false;
Effect.VertexColorEnabled = true;
}
示例15: CoordCross
public CoordCross(GraphicsDevice device)
{
this.device = device;
basicEffect = new BasicEffect(device);
InitVertices();
}