本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture类的典型用法代码示例。如果您正苦于以下问题:C# VertexPositionColorTexture类的具体用法?C# VertexPositionColorTexture怎么用?C# VertexPositionColorTexture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexPositionColorTexture类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了VertexPositionColorTexture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawDottedCircle
public static void DrawDottedCircle(float radius, Vector2 center, int segments, float rotation, Renderer renderer,
Color col)
{
if (segments == 0)
return;
VertexPositionColorTexture[] arr = new VertexPositionColorTexture[segments];
int c = 0;
Vector2 off = center;
for (double i = 0; i <= Math.PI * 2 - 0.001d; i += Math.PI * 2 / segments)
{
arr[c] = new VertexPositionColorTexture(
new Vector3((float)Math.Cos(i + rotation) * radius + off.X, (float)Math.Sin(i + rotation) * radius + off.Y, 0),
col, new Vector2());
c++;
}
bool a = renderer.IsDrawing;
bool b = renderer.IsScaeld;
if (!renderer.IsDrawing)
renderer.BeginUnscaled();
Main.renderer.Draw(MicroWorld.Graphics.GraphicsEngine.pixel, new Rectangle(0, 0, 0, 0), Color.White);
renderer.End();
renderer.GraphicsDevice.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.LineList,
arr, 0, arr.Length / 2);
if (a) renderer.Begin(b);
}
示例2: Draw
public void Draw(Rectangle dstRectangle, Color color)
{
// ensure space for my vertices and indices.
this.EnsureSpace(6, 4);
// add the new indices
indices[indexCount++] = (short)(vertexCount + 0);
indices[indexCount++] = (short)(vertexCount + 1);
indices[indexCount++] = (short)(vertexCount + 3);
indices[indexCount++] = (short)(vertexCount + 1);
indices[indexCount++] = (short)(vertexCount + 2);
indices[indexCount++] = (short)(vertexCount + 3);
// add the new vertices
vertices[vertexCount++] = new VertexPositionColorTexture(
new Vector3(dstRectangle.Left, dstRectangle.Top, 0)
, color, new Vector2(1,1));
vertices[vertexCount++] = new VertexPositionColorTexture(
new Vector3(dstRectangle.Right, dstRectangle.Top, 0)
, color, new Vector2(0, 1));
vertices[vertexCount++] = new VertexPositionColorTexture(
new Vector3(dstRectangle.Right, dstRectangle.Bottom, 0)
, color, new Vector2(0, 0));
vertices[vertexCount++] = new VertexPositionColorTexture(
new Vector3(dstRectangle.Left, dstRectangle.Bottom, 0)
, color, new Vector2(1, 0));
// we premultiply all vertices times the world matrix.
// the world matrix changes alot and we don't want to have to flush
// every time it changes.
Matrix world = this.World;
for (int i = vertexCount - 4; i < vertexCount; i++)
Vector3.Transform(ref vertices[i].Position, ref world, out vertices[i].Position);
}
示例3: SelectableCurve
public SelectableCurve(Color color)
{
this.color = color;
screenPoints = new VertexPositionColorTexture[subdivisions * 2];
selectPoints = new VertexPositionColorTexture[subdivisions * 2];
indices = new int[3 * subdivisions];
cornerAlpha = new float[4] { 1, 1, 1, 1 };
// create left points array and initialize each vertex
leftPoints = new VertexPositionColorTexture[GetNumPointsAfterIterations(6, iterations)];
for (int i = 0; i < leftPoints.Length; i++)
{
leftPoints[i] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
}
intermediary = new Vector3[iterations + 1][];
for (int i = 0; i < iterations + 1; i++)
{
intermediary[i] = new Vector3[GetNumPointsAfterIterations(6, i)];
}
screenPoints[0] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
screenPoints[1] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
screenPoints[2] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
screenPoints[3] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
selectPoints[0] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
selectPoints[1] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
selectPoints[2] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
selectPoints[3] = new VertexPositionColorTexture(Vector3.Zero, color, Vector2.Zero);
ComputeIndices();
}
示例4: AddLazer
public void AddLazer(Vector3 startPos, Vector3 endPos, Color color)
{
VertexPositionColorTexture start = new VertexPositionColorTexture();
VertexPositionColorTexture end = new VertexPositionColorTexture();
start.Position = startPos;
start.Color = color;
start.TextureCoordinate = Vector2.UnitX * currentTime;
end.Position = endPos;
end.Color = color;
end.TextureCoordinate = Vector2.UnitX * currentTime;
vertices.Add(start); //1
vertices.Add(end); //2
start.Position.X += 1; end.Position.X += 1;
vertices.Add(start); //3
vertices.Add(end); //4
start.Position.X -= 2; end.Position.X -= 2;
vertices.Add(start); //5
vertices.Add(end); //6
start.Position.Y += 1; end.Position.Y += 1;
vertices.Add(start); //7
vertices.Add(end); //8
start.Position.Y -= 2; end.Position.Y -= 2;
vertices.Add(start); //9
vertices.Add(end); //10
}
示例5: SpriteBatchItem
public SpriteBatchItem()
{
this.vertexTL = new VertexPositionColorTexture();
this.vertexTR = new VertexPositionColorTexture();
this.vertexBL = new VertexPositionColorTexture();
this.vertexBR = new VertexPositionColorTexture();
}
示例6: Border
public Border(World world, ScreenManager screenManager, Camera2D camera)
{
_screenManager = screenManager;
_camera = camera;
float halfWidth = ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Width) / 2f - 0.75f;
float halfHeight = ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Height) / 2f - 0.75f;
Vertices borders = new Vertices(4);
borders.Add(new Vector2(-halfWidth, halfHeight));
borders.Add(new Vector2(halfWidth, halfHeight));
borders.Add(new Vector2(halfWidth, -halfHeight));
borders.Add(new Vector2(-halfWidth, -halfHeight));
_anchor = BodyFactory.CreateLoopShape(world, borders);
_anchor.CollisionCategories = Category.All;
_anchor.CollidesWith = Category.All;
_basicEffect = new BasicEffect(screenManager.GraphicsDevice);
_basicEffect.VertexColorEnabled = true;
_basicEffect.TextureEnabled = true;
_basicEffect.Texture = screenManager.Content.Load<Texture2D>("Materials/pavement");
VertexPositionColorTexture[] vertice = new VertexPositionColorTexture[8];
vertice[0] = new VertexPositionColorTexture(new Vector3(-halfWidth, -halfHeight, 0f), Color.LightGray, new Vector2(-halfWidth, -halfHeight) / 5.25f);
vertice[1] = new VertexPositionColorTexture(new Vector3(halfWidth, -halfHeight, 0f), Color.LightGray, new Vector2(halfWidth, -halfHeight) / 5.25f);
vertice[2] = new VertexPositionColorTexture(new Vector3(halfWidth, halfHeight, 0f), Color.LightGray, new Vector2(halfWidth, halfHeight) / 5.25f);
vertice[3] = new VertexPositionColorTexture(new Vector3(-halfWidth, halfHeight, 0f), Color.LightGray, new Vector2(-halfWidth, halfHeight) / 5.25f);
vertice[4] = new VertexPositionColorTexture(new Vector3(-halfWidth - 2f, -halfHeight - 2f, 0f), Color.LightGray, new Vector2(-halfWidth - 2f, -halfHeight - 2f) / 5.25f);
vertice[5] = new VertexPositionColorTexture(new Vector3(halfWidth + 2f, -halfHeight - 2f, 0f), Color.LightGray, new Vector2(halfWidth + 2f, -halfHeight - 2f) / 5.25f);
vertice[6] = new VertexPositionColorTexture(new Vector3(halfWidth + 2f, halfHeight + 2f, 0f), Color.LightGray, new Vector2(halfWidth + 2f, halfHeight + 2f) / 5.25f);
vertice[7] = new VertexPositionColorTexture(new Vector3(-halfWidth - 2f, halfHeight + 2f, 0f), Color.LightGray, new Vector2(-halfWidth - 2f, halfHeight + 2f) / 5.25f);
_borderVerts = new VertexPositionColorTexture[24];
_borderVerts[0] = vertice[0];
_borderVerts[1] = vertice[5];
_borderVerts[2] = vertice[4];
_borderVerts[3] = vertice[0];
_borderVerts[4] = vertice[1];
_borderVerts[5] = vertice[5];
_borderVerts[6] = vertice[1];
_borderVerts[7] = vertice[6];
_borderVerts[8] = vertice[5];
_borderVerts[9] = vertice[1];
_borderVerts[10] = vertice[2];
_borderVerts[11] = vertice[6];
_borderVerts[12] = vertice[2];
_borderVerts[13] = vertice[7];
_borderVerts[14] = vertice[6];
_borderVerts[15] = vertice[2];
_borderVerts[16] = vertice[3];
_borderVerts[17] = vertice[7];
_borderVerts[18] = vertice[3];
_borderVerts[19] = vertice[4];
_borderVerts[20] = vertice[7];
_borderVerts[21] = vertice[3];
_borderVerts[22] = vertice[0];
_borderVerts[23] = vertice[4];
}
示例7: SelectableLine
public SelectableLine(Vector3 start, Vector3 end, Color color, float thickness)
: base(color)
{
linePoints[0] = new VertexPositionColorTexture(start, color, Vector2.Zero);
linePoints[1] = new VertexPositionColorTexture(end, color, Vector2.Zero);
selectableThickness = thickness;
Recompute();
}
示例8: SelectableQuad
public SelectableQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Color color)
: base()
{
screenPoints[0] = new VertexPositionColorTexture(p1, color, Vector2.Zero);
screenPoints[1] = new VertexPositionColorTexture(p2, color, Vector2.UnitX);
screenPoints[2] = new VertexPositionColorTexture(p3, color, Vector2.One);
screenPoints[3] = new VertexPositionColorTexture(p4, color, Vector2.UnitY);
Synchronize();
}
示例9: Draw
public void Draw(Texture2D texture, Vector2 position, Color color)
{
_texture = texture; //Hack sorta
_vertexArray[_index++] = new VertexPositionColorTexture(new Vector3(position.X, position.Y, 0), color, Vector2.Zero);
_vertexArray[_index++] = new VertexPositionColorTexture(new Vector3(position.X + texture.Width, position.Y, 0), color, Vector2.UnitX);
_vertexArray[_index++] = new VertexPositionColorTexture(new Vector3(position.X, position.Y + texture.Height, 0), color, Vector2.UnitY);
_vertexArray[_index++] = new VertexPositionColorTexture(new Vector3(position.X + texture.Width, position.Y + texture.Height, 0), color, Vector2.One);
}
示例10: getVertices
public void getVertices(VertexPositionColorTexture[] vertices,int offset)
{
vertices[offset++] = verts[0];
vertices[offset++] = verts[1];
vertices[offset++] = verts[3];
vertices[offset++] = verts[1];
vertices[offset++] = verts[3];
vertices[offset++] = verts[2];
}
示例11: CreateTexturedVertexBuffer
private static VertexBuffer CreateTexturedVertexBuffer(ModelMeshData mesh)
{
var vertices = new VertexPositionColorTexture[mesh.Vertices.Count];
for (var i = 0; i != mesh.Vertices.Count; ++i)
vertices[i] = new VertexPositionColorTexture(mesh.Vertices[i], mesh.Colors[i], mesh.TextureCoords[i]);
VertexBuffer vertexBuffer = new VertexBuffer(GraphicsDeviceHolder.Device,
mesh.Vertices.Count * VertexPositionColorTexture.SizeInBytes, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices);
return vertexBuffer;
}
示例12: PolygonRect
public PolygonRect(float X, float Y, float Z, float Width, float Height, Texture2D tex)
{
vertices = new VertexPositionColorTexture[6];
vertices[0] = new VertexPositionColorTexture(new Vector3(X, Y, Z), Color.White, Vector2.Zero);
vertices[1] = new VertexPositionColorTexture(new Vector3(X + Width, Y, Z), Color.White, new Vector2(1,0));
vertices[2] = new VertexPositionColorTexture(new Vector3(X + Width, Y + Height, Z), Color.White, new Vector2(1,1));
vertices[3] = new VertexPositionColorTexture(new Vector3(X + Width, Y + Height, Z), Color.White, new Vector2(1, 1));
vertices[4] = new VertexPositionColorTexture(new Vector3(X, Y + Height, Z), Color.White, new Vector2(0, 1));
vertices[5] = new VertexPositionColorTexture(new Vector3(X, Y, Z), Color.White, Vector2.Zero);
}
示例13: CreateCube
public void CreateCube(Color color, out VertexPositionColorTexture[] vertexData, out int[] indexData)
{
vertexData = new VertexPositionColorTexture[]
{
// front
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, -0.5f), color, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, -0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, -0.5f), color, new Vector2(0, 1)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, -0.5f), color, new Vector2(1, 1)),
// top
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, -0.5f), color, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, -0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, 0.5f), color, new Vector2(0, 1)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, 0.5f), color, new Vector2(1, 1)),
// back
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, 0.5f), color, new Vector2(1, 1)),
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, 0.5f), color, new Vector2(0, 1)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, 0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, 0.5f), color, new Vector2(0, 0)),
// bottom
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, -0.5f), color, new Vector2(1, 1)),
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, -0.5f), color, new Vector2(0, 1)),
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, 0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, 0.5f), color, new Vector2(0, 0)),
// left
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, 0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, -0.5f), color, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, 0.5f), color, new Vector2(1, 1)),
new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, -0.5f), color, new Vector2(0, 1)),
// right
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, -0.5f), color, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, 0.5f), color, new Vector2(1, 0)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, -0.5f), color, new Vector2(0, 1)),
new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, 0.5f), color, new Vector2(1, 1)),
};
indexData = new int[] {
0, 1, 2, 3, 2, 1,
4, 5, 6, 7, 6, 5,
8, 9, 10, 11, 10, 9,
12, 13, 14, 15, 14, 13,
16, 17, 18, 19, 18, 17,
20, 21, 22, 23, 22, 21
};
}
示例14: TexturedPrimitiveObject
public TexturedPrimitiveObject(string id, ObjectType objectType,
Transform3D transform, VertexPositionColorTexture[] vertices,
BasicEffect effect, PrimitiveType primitiveType, int primitiveCount, Texture2D texture)
: base(id, objectType, transform)
{
this.vertices = vertices;
this.effect = effect;
this.primitiveType = primitiveType;
this.primitiveCount = primitiveCount;
this.texture = texture;
}
示例15: GetFaces
public List<TriangleData> GetFaces()
{
Matrix rootTransform = sceneModel.Root.Transform;
List<TriangleData> faceList = new List<TriangleData>();// new TriangleData[totalNumFaces];
foreach (ModelMesh mesh in sceneModel.Meshes)
{
foreach (ModelMeshPart meshPart in mesh.MeshParts)
{
VertexPositionColorTexture[] meshPartVertices = new VertexPositionColorTexture[meshPart.NumVertices];
meshPart.VertexBuffer.GetData<VertexPositionColorTexture>(meshPartVertices);
if (meshPart.IndexBuffer.IndexElementSize == IndexElementSize.SixteenBits)
{
short[] meshIndices = new short[meshPart.IndexBuffer.IndexCount];
meshPart.IndexBuffer.GetData<short>(meshIndices);
for (int cFaces = 0; cFaces < meshPart.PrimitiveCount; cFaces++)
{
Vector3[] vertices = new Vector3[3];
for (int cFaceVertice = 0; cFaceVertice < 3; cFaceVertice++)
{
vertices[cFaceVertice] = Vector3.Transform(meshPartVertices[meshIndices[meshPart.VertexOffset + (cFaces * 3) + cFaceVertice]].Position, rootTransform);
}
TriangleData triangleData = new TriangleData(ref vertices);
faceList.Add(triangleData);
}
}
else
{
int[] meshIndices = new int[meshPart.IndexBuffer.IndexCount];
meshPart.IndexBuffer.GetData<int>(meshIndices);
for (int cFaces = 0; cFaces < meshPart.PrimitiveCount; cFaces++)
{
Vector3[] vertices = new Vector3[3];
for (int cFaceVertice = 0; cFaceVertice < 3; cFaceVertice++)
{
vertices[cFaceVertice] = Vector3.Transform(meshPartVertices[meshIndices[meshPart.VertexOffset + (cFaces * 3) + cFaceVertice]].Position, rootTransform);
}
TriangleData triangleData = new TriangleData(ref vertices);
faceList.Add(triangleData);
}
}
}
}
return faceList;
}