Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Microsoft XNA Game Studio Creator’s Guide- P9:The release of the XNA platform and specifically the ability for anyone to write Xbox 360 console games was truly a major progression in the game-programming world. Before XNA, it was simply too complicated and costly for a student, software hobbyist, or independent game developer to gain access to a decent development kit for a major console platform. | 218 MICROSOFT XNA GAME STUDIO CREATOR S GUIDE translation so you may need to check this if your models are not animating properly. The product of the bone matrix and the World matrix is passed to the World matrix variable inXNA s BasicEffect shader. At the same time you also need to store the View and Projection matrices from your game class in the BasicEffect s variables. The shader needs this information to position your models so they can be seen properly by the camera. Lighting is also enabled in step 4 using the EnableDefaultLighting method. Refer to Chapter 22 for more information on how to use the different lighting options that come with the BasicEffect class. Finally the model can be drawn using the ModelMesh object s Draw method. Add DrawWindmill to your game class to transform and render your fan and windmill void DrawWindmill Model model int modelNum GameTime gameTime graphics.GraphicsDevice.RenderState.CullMode don t draw backface CullMode.CullClockwiseFace when many vertices foreach ModelMesh mesh in model.Meshes 1 declare matrices Matrix world scale rotationZ translation 2 initialize matrices scale Matrix.CreateScale 0.1f 0.1f 0.1f translation Matrix.CreateTranslation 0.0f 0.9f -4.0f rotationZ Matrix.CreateRotationZ 0.0f if modelNum WINDMILL_FAN calculate time between frames for system independent speed fanRotation gameTime.ElapsedRealTime.Ticks 6000000.0f prevent var overflow - store remainder fanRotation fanRotation 2.0f float Math.PI rotationZ Matrix.CreateRotationZ fanRotation 3 build cumulative world matrix using I.S.R.O.T. sequence identity scale rotate orbit translate rotate translate world scale rotationZ translation 4 set shader parameters foreach BasicEffect effect in mesh.Effects if modelNum WINDMILL_BASE effect.World baseMatrix mesh.ParentBone.Index world chapter 14 219 if modelNum WINDMILL_FAN effect.World fanMatrix mesh.ParentBone.Index world effect.View cam.viewMatrix effect.Projection cam.projectionMatrix effect.EnableDefaultLighting