[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; public class MyGame : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; BasicEffect effect; VertexPositionColor[] vertices = new VertexPositionColor[6]; public MyGame() { graphics = new GraphicsDeviceManager(this); vertices[0] = new VertexPositionColor(new Vector3(0, 1, 0), Color.White); vertices[1] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Red); vertices[2] = new VertexPositionColor(new Vector3(-1, 0, 0), Color.Navy); vertices[3] = new VertexPositionColor(new Vector3(0, 1, -1), Color.White); vertices[4] = new VertexPositionColor(new Vector3(1, 0, -1), Color.Red); vertices[5] = new VertexPositionColor(new Vector3(-1, 0, -1), Color.Navy); } protected override void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { effect = new BasicEffect(graphics.GraphicsDevice, null); effect.Projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45), Window.ClientBounds.Width / (float)Window.ClientBounds.Height, 1, 100 ); effect.View = Matrix.CreateLookAt( new Vector3(0, 0, 3), new Vector3(0, 0, 0), new Vector3(0, 1, 0) ); effect.VertexColorEnabled = true; } } protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaration( graphics.GraphicsDevice, VertexPositionColor.VertexElements ); graphics.GraphicsDevice.RenderState.FillMode = FillMode.WireFrame; effect.Begin(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>( PrimitiveType.TriangleList, vertices, 0, 2 ); pass.End(); } effect.End(); } }