![]() |
![]() |
| #region __CODE_ADDED__
EffectPool effectPool; // for transformation and shading BasicEffect basicEffect; // traditional pipeline and fixed 3-stage transform float dy, dx; // movements of the thumbstick #endregion |
|
#region __CODE_ADDED__
// Initialize the graphics rendering state
graphics.GraphicsDevice.RenderState.DepthBufferEnable = false; graphics.GraphicsDevice.RenderState.MultiSampleAntiAlias = true; graphics.GraphicsDevice.RenderState.CullMode = CullMode.None; graphics.GraphicsDevice.RenderState.FillMode = FillMode.Solid; graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true; ... // Create default shading procedure effectPool = new EffectPool(); basicEffect = new BasicEffect(graphics.GraphicsDevice, effectPool); ... // Initialize thumbstick position dy = 0.0f; dx = 0.0f; #endregion |
| #region __CODE_ADDED__
Vector2 p = GamePad.GetState(PlayerIndex.One).ThumbSticks.Right; dx = p.X; // Thumbstick x-movement dy = p.Y; // Thumbstick y-movement #endregion |
| #region __CODE_ADDED__
// Begin drawing ... ... // Triangle vertex position based on thumbstick position (dx, dy) Vector3 p = new Vector3(dx, dy, 0); VertexPositionColor[] vertices = new VertexPositionColor[3]; for (int i=0; i<3; i++) vertices[i].Position = p; // Center of triangle ... // color of the triangle vertices vertices[0].Position.X -= 0.1f; // left vertex of triangle vertices[1].Position.X += 0.1f; // right vertex of triangle vertices[2].Position.Y += 0.2f; // top vertex of triangle // draw the triangle graphics...DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1); ... #endregion |
![]() |
| Kelvin Sung Computing and Software Systems University of Washington, Bothell ksung@u.washington.edu |