tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P9

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 don t draw backface when many vertices foreach ModelMesh mesh in 1 declare matrices Matrix world scale rotationZ translation 2 initialize matrices scale translation rotationZ if modelNum WINDMILL_FAN calculate time between frames for system independent speed fanRotation prevent var overflow - store remainder fanRotation fanRotation float rotationZ fanRotation 3 build cumulative world matrix using . sequence identity scale rotate orbit translate rotate translate world scale rotationZ translation 4 set shader parameters foreach BasicEffect effect in if modelNum WINDMILL_BASE baseMatrix world chapter 14 219 if modelNum WINDMILL_FAN fanMatrix world