本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.BasicEffect.CommitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# BasicEffect.CommitChanges方法的具体用法?C# BasicEffect.CommitChanges怎么用?C# BasicEffect.CommitChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.BasicEffect
的用法示例。
在下文中一共展示了BasicEffect.CommitChanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: Draw
public static void Draw(this Utilities.GridTransform transform, GraphicsDevice graphicsDevice, BasicEffect basicEffect)
{
VertexPositionColor[] ctrlVerticies = new VertexPositionColor[transform.mapPoints.Length];
VertexPositionColor[] mapVerticies = new VertexPositionColor[transform.mapPoints.Length];
List<int> listIndicies = new List<int>(transform.Edges.Count / 2);
foreach(int iStartPoint in transform.Edges.Keys)
{
List<int> edgeList = transform.Edges[iStartPoint];
foreach (int iEndPoint in edgeList)
{
//Skip if we would have added it earlier
if (iEndPoint < iStartPoint)
continue;
listIndicies.AddRange(new int[] { iStartPoint, iEndPoint});
}
}
int[] indicies = listIndicies.ToArray();
for (int i = 0; i < transform.mapPoints.Length; i++)
{
GridVector2 CtrlP = transform.mapPoints[i].ControlPoint;
GridVector2 MapP = transform.mapPoints[i].MappedPoint;
Vector3 ctrlPosition = new Vector3((Single)CtrlP.X, (Single)CtrlP.Y, 1);
Vector3 mapPosition = new Vector3((Single)MapP.X, (Single)MapP.Y, 1);
ctrlVerticies[i] = new VertexPositionColor(ctrlPosition, Microsoft.Xna.Framework.Graphics.Color.Gold);
mapVerticies[i] = new VertexPositionColor(mapPosition, Microsoft.Xna.Framework.Graphics.Color.Red);
}
graphicsDevice.RenderState.PointSize = 5.0f;
VertexDeclaration oldVertexDeclaration = graphicsDevice.VertexDeclaration;
if (DrawExtensions.VertexPositionColorDeclaration == null)
{
DrawExtensions.VertexPositionColorDeclaration = new VertexDeclaration(
graphicsDevice,
VertexPositionColor.VertexElements
);
}
graphicsDevice.VertexDeclaration = DrawExtensions.VertexPositionColorDeclaration;
basicEffect.Texture = null;
basicEffect.TextureEnabled = false;
basicEffect.VertexColorEnabled = true;
basicEffect.CommitChanges();
basicEffect.Begin();
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
// graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, mapVerticies, 0, mapVerticies.Length, indicies, 0, indicies.Length / 2);
if(ctrlVerticies != null && ctrlVerticies.Length > 0)
graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, ctrlVerticies, 0, ctrlVerticies.Length, indicies, 0, indicies.Length / 2);
pass.End();
}
basicEffect.End();
graphicsDevice.VertexDeclaration = oldVertexDeclaration;
}
示例4: 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();
}
示例5: 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();
}
}