本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexPositionTexture类的典型用法代码示例。如果您正苦于以下问题:C# VertexPositionTexture类的具体用法?C# VertexPositionTexture怎么用?C# VertexPositionTexture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexPositionTexture类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了VertexPositionTexture类的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: BoardTexture
// To get the texture you want to draw
public BoardTexture()
{
// Initialization of each value
this.pos = Vector3.Zero;
this.scale = Vector3.One;
this.rotation = Vector3.Zero;
this.alpha = 1.0f;
// Effects creation
this.basicEffect = Game1.basicEffect;
// I authorize the use of texture
this.basicEffect.TextureEnabled = true;
// Create a vertex buffer
this.vertexBuffer = new VertexBuffer(
Game1.graphics.GraphicsDevice,
typeof(VertexPositionTexture),
4,
BufferUsage.None);
// I want to create the vertex data
VertexPositionTexture[] vertices = new VertexPositionTexture[4];
// I want to set the value of each vertex
vertices[0] = new VertexPositionTexture(new Vector3(-1.0f, 1.0f, 1.0f),
new Vector2(0.0f, 0.0f));
vertices[1] = new VertexPositionTexture(new Vector3(1.0f, 1.0f, 1.0f),
new Vector2(1.0f, 0.0f));
vertices[2] = new VertexPositionTexture(new Vector3(-1.0f, -1.0f, 1.0f),
new Vector2(0.0f, 1.0f));
vertices[3] = new VertexPositionTexture(new Vector3(1.0f, -1.0f, 1.0f),
new Vector2(1.0f, 1.0f));
// I write in the vertex buffer vertex data
this.vertexBuffer.SetData(vertices);
}
示例3: Render
public static void Render(GraphicsDevice device, Color color)
{
BasicEffect _effect = new BasicEffect(device);
_effect.Texture = new Texture2D(device, 1, 1);
_effect.Texture.SetData<Color>(new Microsoft.Xna.Framework.Color[] { color });
_effect.TextureEnabled = true;
//_effect.VertexColorEnabled = true;
VertexPositionTexture[] _vertices = new VertexPositionTexture[3];
_vertices[0].Position = new Vector3(.5f,.5f,0);
_vertices[1].Position = new Vector3(-.5f, -.5f, 0);
_vertices[2].Position = new Vector3(.5f, 0f, 0);
foreach (var pass in _effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawUserIndexedPrimitives<VertexPositionTexture>
(
PrimitiveType.TriangleStrip, // same result with TriangleList
_vertices,
0,
_vertices.Length,
new int[] { 0, 1, 2 },
0,
1
);
}
}
示例4: InitializeParticleVertices
private void InitializeParticleVertices()
{
verts = new VertexPositionTexture[maxParticles * 4];
vertexColorArray = new Color[maxParticles];
Color[] colors = new Color[particleColorsTexture.Width * particleColorsTexture.Height];
particleColorsTexture.GetData(colors);
for (int i = 0; i < maxParticles; ++i)
{
float size = (float)rand.NextDouble() * particleSettings.maxSize;
Vector3 position = new Vector3(rand.Next(-(int)maxPosition.X,(int)maxPosition.X),rand.Next(-(int)maxPosition.Y,(int)maxPosition.Y),maxPosition.Z);
verts[i * 4] = new VertexPositionTexture(position,new Vector2(0,0));
verts[(i * 4) + 1] = new VertexPositionTexture(new Vector3(position.X, position.Y + size, position.Z), new Vector2(0,1));
verts[(i * 4) + 2] = new VertexPositionTexture(new Vector3(position.X + size, position.Y, position.Z), new Vector2(1, 0));
verts[(i * 4) + 3] = new VertexPositionTexture(new Vector3(position.X + size, position.Y + size, position.Z), new Vector2(1, 1));
vertexColorArray[i] = colors[(rand.Next(0,particleColorsTexture.Height) * particleColorsTexture.Width) + rand.Next(0,particleColorsTexture.Width)];
}
particleVertexBuffer = new VertexBuffer(graphicDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None);
}
示例5: Draw
public void Draw(GraphicsDevice device, BasicEffect effect)
{
if (buf == null)
{
buf = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.None);
var vpt = new VertexPositionTexture[4]{
new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0,0)),
new VertexPositionTexture(new Vector3(SIZE, 0, 0), new Vector2(1,0)),
new VertexPositionTexture(new Vector3(0, 0, SIZE), new Vector2(0,1)),
new VertexPositionTexture(new Vector3(SIZE, 0, SIZE), new Vector2(1,1))
};
buf.SetData(vpt);
}
device.SetVertexBuffer(buf);
effect.TextureEnabled = true;
effect.Texture = texture;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}
示例6: initialize
public static void initialize()
{
vertex = new VertexPositionTexture[4];
vertex[0].Position = new Vector3(-0.5f,-0.5f, 0.0f);
vertex[0].TextureCoordinate = new Vector2(0.0f, 1.0f);
//vertex[0].Color = new Color(1, 1, 1, 1);
vertex[1].Position = new Vector3(-0.5f, 0.5f, 0.0f);
vertex[1].TextureCoordinate = new Vector2(0.0f, 0.0f);
//vertex[1].Color = new Color(1, 1, 1, 1);
vertex[2].Position = new Vector3(0.5f, -0.5f, 0.0f);
vertex[2].TextureCoordinate = new Vector2(1.0f, 1.0f);
//vertex[2].Color = new Color(1, 1, 1, 1);
vertex[3].Position = new Vector3(0.5f, 0.5f, 0.0f);
vertex[3].TextureCoordinate = new Vector2(1.0f, 0.0f);
//vertex[3].Color = new Color(1, 1, 1, 1);
vertexUVs = new VertexPositionTexture[4];
vertexUVs[0].Position = new Vector3(-0.5f, -0.5f, 0.0f);
//vertexUVs[0].Color = new Color(1, 1, 1, 1);
vertexUVs[1].Position = new Vector3(-0.5f, 0.5f, 0.0f);
//vertexUVs[1].Color = new Color(1, 1, 1, 1);
vertexUVs[2].Position = new Vector3(0.5f, -0.5f, 0.0f);
//vertexUVs[2].Color = new Color(1, 1, 1, 1);
vertexUVs[3].Position = new Vector3(0.5f, 0.5f, 0.0f);
//vertexUVs[3].Color = new Color(1, 1, 1, 1);
}
示例7:
void CréerTableauSommets()
{
PtsTexture = new Vector2[NbColonnes + 1, NbRangées + 1];
PtsSommets = new Vector3[NbColonnes + 1, NbRangées - 1]; //-1, texture occupe le haut et le bas, donc 2 rangées de moins dans les ptsSommets
Sommets = new VertexPositionTexture[NbSommets];
CréerTableauPointsTexture();
}
示例8: SkyplaneEngine
public SkyplaneEngine(InfiniminerGame gameInstance)
{
this.gameInstance = gameInstance;
// Generate a noise texture.
randGen = new Random();
texNoise = new Texture2D(gameInstance.GraphicsDevice, 64, 64);
uint[] noiseData = new uint[64*64];
for (int i = 0; i < 64 * 64; i++)
if (randGen.Next(32) == 0)
noiseData[i] = Color.White.PackedValue;
else
noiseData[i] = Color.Black.PackedValue;
texNoise.SetData(noiseData);
// Load the effect file.
effect = gameInstance.Content.Load<Effect>("effect_skyplane");
// Create our vertices.
vertexDeclaration = new VertexDeclaration(gameInstance.GraphicsDevice, VertexPositionTexture.VertexElements);
vertices = new VertexPositionTexture[6];
vertices[0] = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
vertices[1] = new VertexPositionTexture(new Vector3(274, 100, -210), new Vector2(1, 0));
vertices[2] = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
vertices[3] = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
vertices[4] = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
vertices[5] = new VertexPositionTexture(new Vector3(-210, 100, 274), new Vector2(0, 1));
}
示例9: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// Initialize vertices
verts = new VertexPositionTexture[4];
verts[0] = new VertexPositionTexture(
new Vector3(-1, 1, 0), new Vector2(0, 0));
verts[1] = new VertexPositionTexture(
new Vector3(1, 1, 0), new Vector2(1, 0));
verts[2] = new VertexPositionTexture(
new Vector3(-1, -1, 0), new Vector2(0, 1));
verts[3] = new VertexPositionTexture(
new Vector3(1, -1, 0), new Vector2(1, 1));
// Set vertex data in VertexBuffer
vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None);
vertexBuffer.SetData(verts);
// Initialize the BasicEffect
effect = new BasicEffect(GraphicsDevice);
// Load texture
texture = Content.Load<Texture2D>(@"Textures\trees");
}
示例10: SetUpVertices
private void SetUpVertices()
{
// Fill in texture coordinates to display full texture
// on quad
Vector2 textureUpperLeft = new Vector2(0.0f, 0.0f);
Vector2 textureUpperRight = new Vector2(1.0f, 0.0f);
Vector2 textureLowerLeft = new Vector2(0.0f, 1.0f);
Vector2 textureLowerRight = new Vector2(1.0f, 1.0f);
// Create 4 vertices
vertices[0] = new VertexPositionTexture(LowerLeft, textureLowerLeft);
vertices[1] = new VertexPositionTexture(UpperLeft, textureUpperLeft);
vertices[2] = new VertexPositionTexture(LowerRight, textureLowerRight);
vertices[3] = new VertexPositionTexture(UpperRight, textureUpperRight);
// Set the index buffer for each vertex, using
// clockwise winding
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 2;
indices[4] = 1;
indices[5] = 3;
// Initialize the VertexBuffer, and insert the data
this.vertexBuffer = new VertexBuffer(Device, typeof(VertexPositionTexture), vertices.Length, BufferUsage.WriteOnly);
this.vertexBuffer.SetData(vertices);
// Initialize the IndexBuffer, and insert the data
indexBuffer = new IndexBuffer(Device, typeof(short), indices.Length, BufferUsage.WriteOnly);
indexBuffer.SetData(indices);
}
示例11: draw
public void draw()
{
if (show)
{
//Lägg spriten på en triangel
VertexPositionTexture[] vertices = new VertexPositionTexture[6];
//vertices[0] = new VertexPositionTexture(position, new Vector2(1, 1));
vertices[0] = new VertexPositionTexture(position, new Vector2(1, 1));
vertices[1] = new VertexPositionTexture(position, new Vector2(0, 0));
vertices[2] = new VertexPositionTexture(position, new Vector2(1, 0));
vertices[3] = new VertexPositionTexture(position, new Vector2(1, 1));
vertices[4] = new VertexPositionTexture(position, new Vector2(0, 1));
vertices[5] = new VertexPositionTexture(position, new Vector2(0, 0));
Globals.effect.CurrentTechnique = Globals.effect.Techniques["PointSprites"];
Globals.effect.Parameters["xWorld"].SetValue(Matrix.Identity);
Globals.effect.Parameters["xProjection"].SetValue(Globals.player.camera.projection);
Globals.effect.Parameters["xView"].SetValue(Globals.player.camera.view);
Globals.effect.Parameters["xCamPos"].SetValue(Globals.player.camera.position);
Globals.effect.Parameters["xTexture"].SetValue(sprite[frame]);
Globals.effect.Parameters["xCamUp"].SetValue(Globals.player.camera.up);
Globals.effect.Parameters["xPointSpriteSize"].SetValue(100f);
if (frame >= sprite.Length - 40) Globals.device.BlendState = BlendState.Additive;
foreach (EffectPass pass in Globals.effect.CurrentTechnique.Passes)
{
pass.Apply();
Globals.device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2);
}
if (frame >= sprite.Length - 40) Globals.device.BlendState = BlendState.Opaque;
}
}
示例12: DrawPolygons
public void DrawPolygons(Vector2 position, float angle, float scale,
Texture2D texture, VertexPositionTexture[] vertices, BlendState blendMode)
{
effect.World = Matrix.CreateRotationZ(angle) *
Matrix.CreateScale(scale) *
Matrix.CreateTranslation(new Vector3(position, 0));
effect.Texture = texture;
GraphicsDevice device = GameEngine.Instance.GraphicsDevice;
if (blendMode == BlendState.AlphaBlend)
{
device.BlendState = BlendState.AlphaBlend;
}
else if (blendMode == BlendState.Additive)
{
device.BlendState = BlendState.Additive;
}
SamplerState s = new SamplerState();
s.AddressU = TextureAddressMode.Wrap;
s.AddressV = TextureAddressMode.Wrap;
device.SamplerStates[0] = s;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
//pass.Apply();
}
}
示例13: Tile
public Tile(Texture2D texture2D, GraphicsDeviceManager graphicsDeviceManager, Vector3 position, Vector3 dimension)
{
texture = texture2D;
tile = new VertexPositionTexture[14];
tile[0] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(0, 0));
tile[1] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(1, 0));
tile[2] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
tile[3] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z), new Vector2(1, 1));
tile[4] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
tile[5] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(0, 1));
tile[6] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(0, 0));
tile[7] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(1, 1));
tile[8] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(1, 0));
tile[9] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
tile[10] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(0, 0));
tile[11] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
tile[12] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(0, 1));
tile[13] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(1, 1));
// Set vertex data in VertexBuffer
vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), tile.Length, BufferUsage.None);
vertexBuffer.SetData(tile);
// Initialize the BasicEffect
effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
}
示例14: Billboard
public Billboard(GraphicsDevice graphicsDevice, Effect effect)
{
this.graphicsDevice = graphicsDevice;
this.effect = effect;
LifeTime = 1f;
Scale = 1f;
Alpha = 1f;
Angle = 0f;
Diffuse = Color.White;
Age = 0f;
PositionFunc = x => Position;
AlphaFunc = x => Alpha;
ScaleFunc = x => Scale;
AngleFunc = x => Angle;
DiffuseFunc = x => Diffuse;
vertices[0] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 0));
vertices[1] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 0));
vertices[2] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 1));
vertices[3] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 0));
vertices[4] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 1));
vertices[5] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 1));
}
示例15: Draw
public override void Draw(GameTime gameTime)
{
VertexPositionTexture[] bulletVertices = new VertexPositionTexture[6];
int i = 0;
Vector3 center = Position + (Vector3.Up * 0.75f);
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 1));
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 0));
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 0));
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(1, 1));
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 1));
bulletVertices[i++] = new VertexPositionTexture(center, new Vector2(0, 0));
effects.CurrentTechnique = effects.Techniques["PointSprites"];
effects.Parameters["xWorld"].SetValue(Matrix.Identity);
effects.Parameters["xProjection"].SetValue(camera.projectionMatrix);
effects.Parameters["xView"].SetValue(camera.viewMatrix);
effects.Parameters["xTexture"].SetValue(Texture);
effects.Parameters["xCamPos"].SetValue(camera.cameraPos);
effects.Parameters["xCamUp"].SetValue(Vector3.Up);
effects.Parameters["xPointSpriteSize"].SetValue(0.5f);
graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;
foreach (EffectPass pass in effects.CurrentTechnique.Passes)
{
pass.Apply();
graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, bulletVertices, 0, 2);
}
graphics.GraphicsDevice.BlendState = BlendState.Opaque;
base.Draw(gameTime);
}