本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.BasicEffect.End方法的典型用法代码示例。如果您正苦于以下问题:C# BasicEffect.End方法的具体用法?C# BasicEffect.End怎么用?C# BasicEffect.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.BasicEffect
的用法示例。
在下文中一共展示了BasicEffect.End方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw()
{
Engine.Device.RenderState.CullMode = CullMode.CullClockwiseFace;
Matrix worldMatrix = Matrix.CreateTranslation(0, 0, -TILES_Z+1);
worldMatrix *= Matrix.CreateScale(10, 1, 10);
BasicEffect effect = new BasicEffect(Engine.Device, null);
effect.World = worldMatrix;
effect.View = Engine.Camera.View;
effect.Projection = Engine.Camera.Projection;
effect.Texture = Engine.ContentManager.Load<Texture2D>("Content\\Textures\\grass");
effect.TextureEnabled = true;
Engine.Device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
Engine.Device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
Engine.Device.Vertices[0].SetSource(vb, 0, VertexPositionNormalTexture.SizeInBytes);
Engine.Device.Indices = ib;
Engine.Device.VertexDeclaration = new VertexDeclaration(Engine.Device, VertexPositionNormalTexture.VertexElements);
Engine.Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, TILES_X * TILES_Z, 0, (TILES_X - 1) * (TILES_Z - 1) * 2);
}
effect.End();
}
示例2: DrawLine
public void DrawLine(Vector3 or, Vector3 end, Color c)
{
#if DEBUG
BasicEffect effect;
GraphicsDeviceManager gdm = ResourcesManager.GetInstance().GetGraphicsDeviceManager();
VertexPositionColor[] v = new VertexPositionColor[2];
v[0] = new VertexPositionColor(or, c);
v[1] = new VertexPositionColor(end, c);
effect = new BasicEffect(gdm.GraphicsDevice, null);
Camera cam = CameraManager.GetInstance().GetActiveCamera();
effect.View = cam.GetViewMatrix();
effect.Projection = cam.GetProjectionMatrix();
effect.VertexColorEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
gdm.GraphicsDevice.VertexDeclaration = new VertexDeclaration(gdm.GraphicsDevice, VertexPositionColor.VertexElements);
gdm.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, v, 0, 1);
pass.End();
}
effect.End();
#endif
}
示例3: DrawBoundingBox
public static void DrawBoundingBox(BoundingBox bBox, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
{
Vector3 v1 = bBox.Min;
Vector3 v2 = bBox.Max;
VertexPositionColor[] cubeLineVertices = new VertexPositionColor[8];
cubeLineVertices[0] = new VertexPositionColor(v1, Color.White);
cubeLineVertices[1] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v1.Z), Color.Red);
cubeLineVertices[2] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v2.Z), Color.Green);
cubeLineVertices[3] = new VertexPositionColor(new Vector3(v1.X, v1.Y, v2.Z), Color.Blue);
cubeLineVertices[4] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v1.Z), Color.White);
cubeLineVertices[5] = new VertexPositionColor(new Vector3(v2.X, v2.Y, v1.Z), Color.Red);
cubeLineVertices[6] = new VertexPositionColor(v2, Color.Green);
cubeLineVertices[7] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v2.Z), Color.Blue);
short[] cubeLineIndices = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projectionMatrix;
basicEffect.VertexColorEnabled = true;
device.RenderState.FillMode = FillMode.Solid;
basicEffect.Begin();
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, cubeLineVertices, 0, 8, cubeLineIndices, 0, 12);
pass.End();
}
basicEffect.End();
}
示例4: Draw
public void Draw(GraphicsDevice gd, Camera camera)
{
effect = new BasicEffect(gd, null);
effect.Begin();
effect.World = Matrix.Identity;
foreach (EffectPass pass in effect.CurrentTechnique.Passes) {
pass.Begin();
effect.Texture = texture;
RenderFloor(gd, camera);
pass.End();
}
effect.End();
}
示例5: Draw
public override void Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice device)
{
if (Mesh == null) { return; }
var effect = new BasicEffect(device, null);
effect.World = World;
effect.View = View;
effect.Projection = Projection;
effect.Begin();
if (Texture != null)
{
effect.TextureEnabled = true;
effect.Texture = Texture;
}
foreach (var pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
Mesh.Draw(device);
pass.End();
}
effect.End();
}
示例6: Render
public void Render(GraphicsDevice device, BasicEffect basicEffect, ObjectShip ship, LevelBackgroundGF levelBackground)
{
basicEffect.World = Matrix.Identity;
basicEffect.LightingEnabled = false;
device.RenderState.DepthBufferEnable = false;
device.RenderState.CullMode = CullMode.None;
device.RenderState.PointSpriteEnable = true;
//device.RenderState.PointScaleEnable = true ;
device.RenderState.PointSize = 10.0f;
device.RenderState.PointSizeMin = 0.00f;
device.RenderState.PointSizeMax = 100.00f;
//device.RenderState.PointScaleA = 0.00f;
//device.RenderState.PointScaleB = 0.00f;
//device.RenderState.PointScaleC = 1.00f;
device.RenderState.AlphaBlendEnable = true;
device.RenderState.SourceBlend = Blend.One;
device.RenderState.DestinationBlend = Blend.One;
basicEffect.Texture = texture;
basicEffect.TextureEnabled = true;
int count = 0;
bool hackColliding = false;
for(int i = 0; i < 6; i++)
{
Vector3 v = ship.colisionPoints[i];
//v = Vector3.TransformCoordinate(v, ship.renderMatrix);
v = Vector3.Transform(v, ship.renderMatrix);
//// Vector3 v = ship.Position;
//// v.Y = v.Y + (float)(ship.boundingBoxMax.Y * ship.scale * Math.Cos(ship.Rotation.Z));
//// v.X = v.X - (float)(ship.boundingBoxMax.Y * ship.scale * Math.Sin(ship.Rotation.Z));
bool collide = levelBackground.CheckCollision(v);
VertexPositionColor pv;
pv.Position = v;
pv.Color = collide ? Color.Yellow : Color.White;
if(collide)
{
vertices[count] = pv;
count++;
}
hackColliding |= collide;
}
if(!ship.hackColliding && hackColliding)
{
ship.Position = ship.OldPosition;
ship.Speed = -ship.Speed * 0.3f;
SoundHandler.Checkpoint();
}
ship.hackColliding = hackColliding;
device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
//// Unlock the vertex buffer
//vertexBuffer.Unlock();
//// Render any remaining particles
if (count > 0)
{
basicEffect.Begin();
foreach(EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
device.DrawUserPrimitives(PrimitiveType.PointList, vertices, 0, count);
pass.End();
}
basicEffect.End();
}
//// Reset render states
//device.RenderState.PointSpriteEnable = false;
//device.RenderState.PointScaleEnable = false;
//device.RenderState.PointSpriteEnable = true;
//device.RenderState.PointScaleEnable = true ;
//device.RenderState.AlphaBlendEnable = false;
device.RenderState.PointSpriteEnable = false;
device.RenderState.DepthBufferWriteEnable = true;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
}
示例7: Draw
public void Draw(GraphicsDevice graphics, BasicEffect effect)
{
effect.LightingEnabled = true;
effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
effect.Texture = this.texture;
effect.TextureEnabled = true;
effect.Alpha = this.Materiel.alpha;
effect.Begin();
graphics.RenderState.AlphaBlendEnable = Convert.ToBoolean(this.Materiel.alpha_enabled);
if (Convert.ToBoolean(this.Materiel.alpha_enabled))
{
graphics.RenderState.AlphaTestEnable = Convert.ToBoolean(this.Materiel.alpha_test_enabled);
if (this.Materiel.blending_mode == 1)
{
graphics.RenderState.SourceBlend = Blend.One;
}
else
{
graphics.RenderState.SourceBlend = Blend.SourceAlpha;
}
if (this.Materiel.blending_mode == 1)
{
graphics.RenderState.DestinationBlend = Blend.One;
}
else
{
graphics.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
}
graphics.RenderState.ReferenceAlpha = (int)this.Materiel.alpha_ref_enabled;
graphics.RenderState.AlphaFunction = CompareFunction.GreaterEqual;
graphics.RenderState.BlendFunction = BlendFunction.Add;
}
else
{
graphics.RenderState.AlphaTestEnable = false;
graphics.RenderState.SourceBlend = Blend.One;
graphics.RenderState.DestinationBlend = Blend.Zero;
graphics.RenderState.ReferenceAlpha = 0;
graphics.RenderState.AlphaFunction = CompareFunction.Always;
graphics.RenderState.BlendFunction = BlendFunction.Add;
}
for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++)
{
effect.CurrentTechnique.Passes[i].Begin();
graphics.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.vertex, 0, this.vertex.Length, this.Indices, 0, this.Indices.Length / 3);
effect.CurrentTechnique.Passes[i].End();
}
effect.End();
}
示例8: Draw
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionNormalTexture.VertexElements);
effect = new BasicEffect(GraphicsDevice, null);
effect.World = worldRotation * worldTranslation;
effect.View = camera.view;
effect.Projection = camera.project;
effect.Texture = tex[0];
effect.TextureEnabled = true;
//loads a side, changes texture, loads next side, repeat
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.ffront, 0, 2);
pass.End();
effect.Texture = tex[1];
effect.TextureEnabled = true;
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.bback, 0, 2);
pass.End();
effect.Texture = tex[2];
effect.TextureEnabled = true;
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.lleft, 0, 2);
pass.End();
effect.Texture = tex[3];
effect.TextureEnabled = true;
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.rright, 0, 2);
pass.End();
effect.Texture = tex[4];
effect.TextureEnabled = true;
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.ttop, 0, 2);
pass.End();
effect.Texture = tex[5];
effect.TextureEnabled = true;
pass.Begin();
GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, cube.bbot, 0, 2);
pass.End();
}
effect.End();
base.Draw(gameTime);
}
示例9: DrawBones
private void DrawBones(Skelenton skel)
{
var device = GraphicsDevice;
device.RenderState.PointSize = 10.0f;
device.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements);
device.RenderState.CullMode = CullMode.None;
var effect = new BasicEffect(GraphicsDevice, null);
//effect.Texture = TextureUtils.TextureFromColor(device, color);
//effect.TextureEnabled = true;
effect.World = World;
effect.View = View;
effect.Projection = Projection;
effect.VertexColorEnabled = true;
effect.EnableDefaultLighting();
effect.CommitChanges();
effect.Begin();
foreach (var pass in effect.Techniques[0].Passes)
{
pass.Begin();
foreach(var bone in skel.Bones){
var color = Color.Green;
if (bone.Name == "ROOT")
{
color = Color.Red;
}
else if (bone.Name == "HEAD")
{
color = Color.Yellow;
}
var vertex = new VertexPositionColor(bone.AbsolutePosition, color);
var vertexList = new VertexPositionColor[1]{vertex};
device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);
}
pass.End();
}
effect.End();
}
示例10: DrawMesh
private void DrawMesh(Mesh mesh, Texture2D texture)
{
//glTranslatef(Character.Translation.x, Character.Translation.y, zoom + Character.Translation.z);
//glRotatef(Character.Rotation.x, 1.0f, 0.0f, 0.0f);
//glRotatef(Character.Rotation.y, 0.0f, 1.0f, 0.0f);
//glRotatef(Character.Rotation.z, 0.0f, 0.0f, 1.0f);
var device = GraphicsDevice;
device.VertexDeclaration = new VertexDeclaration(GraphicsDevice, MeshVertex.VertexElements);
device.RenderState.CullMode = CullMode.None;
var effect = new BasicEffect(GraphicsDevice, null);
effect.Texture = texture;
effect.TextureEnabled = true;
effect.VertexColorEnabled = false;
effect.World = World;
effect.View = View;
effect.Projection = Projection;
effect.CommitChanges();
effect.Begin();
foreach (var pass in effect.Techniques[0].Passes)
{
pass.Begin();
foreach (var face in mesh.FaceData)
{
var vertexA = mesh.TransformedVertex[face.VertexA];
var vertexB = mesh.TransformedVertex[face.VertexB];
var vertexC = mesh.TransformedVertex[face.VertexC];
var vertexList = new MeshVertex[3] { vertexA.Vertex, vertexB.Vertex, vertexC.Vertex };
device.DrawUserPrimitives(PrimitiveType.TriangleList, vertexList, 0, 1);
}
//device.DrawUserPrimitives(PrimitiveType.TriangleList, mesh.TransformedVertexData, 0, mesh.TransformedVertexData.Length / 3);
pass.End();
}
effect.End();
}
示例11: RenderSpriteList
private void RenderSpriteList(List<_3DSprite> sprites, BasicEffect effect, EffectTechnique technique)
{
ApplyCamera(effect);
effect.TextureEnabled = true;
var byTexture = sprites.GroupBy(x => x.Texture);
foreach (var group in byTexture){
effect.Texture = group.Key;
effect.CommitChanges();
effect.Begin();
foreach (var pass in technique.Passes)
{
pass.Begin();
foreach (var geom in group){
effect.World = geom.World;
effect.CommitChanges();
geom.Geometry.DrawGeometry(this.Device);
}
pass.End();
}
effect.End();
}
}
示例12: Draw
public void Draw(GraphicsDevice device)
{
device.RenderState.PointSize = 30.0f;
device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
//device.RenderState.CullMode = CullMode.None;
var effect = new BasicEffect(device, null);
//effect.Texture = TextureUtils.TextureFromColor(device, color);
//effect.TextureEnabled = true;
effect.World = Matrix.Identity;
effect.View = View;
effect.Projection = Projection;
effect.VertexColorEnabled = true;
//effect.EnableDefaultLighting();
effect.CommitChanges();
effect.Begin();
foreach (var pass in effect.Techniques[0].Passes)
{
pass.Begin();
var vertex = new VertexPositionColor(Position, Color.Green);
var vertexList = new VertexPositionColor[1] { vertex };
device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);
vertex.Color = Color.Red;
vertex.Position = Target;
device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);
pass.End();
}
effect.End();
}
示例13: DrawPhysXDebug
/// <summary>
/// This method gets the debug geometry from the PhysX scene, and draws it to the screen. This is useful for
/// making sure that models are being correctly placed within their PhysX bounding boxes, and for checking to
/// see if things are physically working without actually drawing them.
/// </summary>
/// <param name="scene">The PhysX scene that we want to draw debug geometry for.</param>
public void DrawPhysXDebug(StillDesign.PhysX.Scene scene)
{
Camera cam = (Camera)this.Game.Services.GetService(typeof(ICameraService));
_graphics.VertexDeclaration = new VertexDeclaration(_graphics, VertexPositionColor.VertexElements);
BasicEffect debugEffect = new BasicEffect(_graphics, null);
debugEffect.World = Matrix.Identity;
debugEffect.View = cam.View;
debugEffect.Projection = cam.Projection;
DebugRenderable data = scene.GetDebugRenderable();
debugEffect.Begin();
foreach (EffectPass pass in debugEffect.CurrentTechnique.Passes)
{
pass.Begin();
if (data.PointCount > 0)
{
DebugPoint[] points = data.GetDebugPoints();
_graphics.DrawUserPrimitives<DebugPoint>(PrimitiveType.PointList, points, 0, points.Length);
}
if (data.LineCount > 0)
{
DebugLine[] lines = data.GetDebugLines();
VertexPositionColor[] vertices = new VertexPositionColor[data.LineCount * 2];
for (int x = 0; x < data.LineCount; x++)
{
DebugLine line = lines[x];
vertices[x * 2 + 0] = new VertexPositionColor(line.Point0, Int32ToColor(line.Color));
vertices[x * 2 + 1] = new VertexPositionColor(line.Point1, Int32ToColor(line.Color));
}
_graphics.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, lines.Length);
}
if (data.TriangleCount > 0)
{
DebugTriangle[] triangles = data.GetDebugTriangles();
VertexPositionColor[] vertices = new VertexPositionColor[data.TriangleCount * 3];
for (int x = 0; x < data.TriangleCount; x++)
{
DebugTriangle triangle = triangles[x];
vertices[x * 3 + 0] = new VertexPositionColor(triangle.Point0, Int32ToColor(triangle.Color));
vertices[x * 3 + 1] = new VertexPositionColor(triangle.Point1, Int32ToColor(triangle.Color));
vertices[x * 3 + 2] = new VertexPositionColor(triangle.Point2, Int32ToColor(triangle.Color));
}
_graphics.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, triangles.Length);
}
pass.End();
}
debugEffect.End();
}
示例14: Render
public void Render(GraphicsDevice device, BasicEffect be)
{
//san
#if false
be.World = Matrix.Identity;
//device.RenderState.DepthBufferEnable = false; // dx: device.RenderState.ZBufferEnable = false;
be.LightingEnabled = false; //dx: device.RenderState.Lighting = false;
device.RenderState.CullMode = CullMode.None;
be.Texture = texture;
be.TextureEnabled = true;
// dx: device.SetTexture(0, texture);
//device.SamplerState[0].MagFilter = TextureFilter.Linear;
//device.TextureState[0].ColorOperation = TextureOperation.Modulate;
//device.TextureState[0].ColorArgument1 = TextureArgument.Texture;
//device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
//device.TextureState[0].AlphaOperation = TextureOperation.Disable;
//device.SetStreamSource(0, vertexes, 0);
//device.VertexFormat = Direct3D.CustomVertex.PositionTextured.Format;
//device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
//VertexBuffer vb = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.None);
//vb.SetData(vertexes);
//device.Vertices[0].SetSource(vb, 0, VertexPositionTexture.SizeInBytes);
be.Begin();
device.VertexDeclaration = declaration;
//foreach(EffectPass pass in be.CurrentTechnique.Passes)
{
//pass.Begin();
be.CurrentTechnique.Passes[0].Begin();
device.DrawUserPrimitives(PrimitiveType.TriangleFan, vertexes, 0, 2);
be.CurrentTechnique.Passes[0].End();
//pass.End();
}
be.End();
#else
SpriteBatch sb = new SpriteBatch(device);
sb.Begin();
sb.Draw(texture, new Vector2(0,0), Color.White);
sb.End();
#endif
}
示例15: DrawSphere
public void DrawSphere(Vector3 c, float rad, Color color)
{
#if DEBUG
Matrix sphereMatrix = Matrix.CreateScale(rad) * Matrix.CreateTranslation(c);
int iCountVerts = 0;
//create the loop on the XY plane first
for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
{
Vector3 position =
new Vector3((float)Math.Cos(a), (float)Math.Sin(a), 0f);
position = Vector3.Transform(position, sphereMatrix);
BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
}
//next on the XZ plane
for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
{
Vector3 position =
new Vector3((float)Math.Cos(a), 0f, (float)Math.Sin(a));
position = Vector3.Transform(position, sphereMatrix);
BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
}
//finally on the YZ plane
for (float a = 0f; a <= MathHelper.TwoPi; a += BSPHERE_STEP)
{
Vector3 position =
new Vector3(0f, (float)Math.Cos(a), (float)Math.Sin(a));
position = Vector3.Transform(position, sphereMatrix);
BSphereVerts[iCountVerts++] = new VertexPositionColor(position, color);
}
BasicEffect effect;
GraphicsDeviceManager gdm = ResourcesManager.GetInstance().GetGraphicsDeviceManager();
effect = new BasicEffect(gdm.GraphicsDevice, null);
Camera cam = CameraManager.GetInstance().GetActiveCamera();
effect.View = cam.GetViewMatrix();
effect.Projection = cam.GetProjectionMatrix();
effect.VertexColorEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
gdm.GraphicsDevice.VertexDeclaration = new VertexDeclaration(gdm.GraphicsDevice, VertexPositionColor.VertexElements);
gdm.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, BSphereVerts, 0, iCountVerts / 2);
pass.End();
}
effect.End();
#endif
}