tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P13
Microsoft XNA Game Studio Creator’s Guide- P13: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. | 38 MICROSOFT X N A GAME STUDIO CREATOR S GUIDE 0 .Passes 0 .End The code required to draw the particle using point sprites is very similar to code that draws any textured primitive surface. Scaling for the entire group of particles is triggered once based on the distance between the camera and the group of particles. Each fire particle is rendered individually. The group of particles is moved into position and then each individual particle is translated from the fire base to its own position in the roaring fire. The particle s life level which ranges between 0 for dead and 1 for full life is passed to the shader so it can be used to fade the color of the flame and shrink the size as each particle rises away from the core of the fire private void DrawParticles 1 declare matrices Matrix world translateParticle translateGroup scale the point sprite by cam distance to the group of particles Vector3 particlesPosition new Vector3 2 initialize matrices translateGroup particlesPosition for int i 0 i NUM_PARTICLES i translate each individual particle translateParticle particle i .position 3 build cumulative world matrix using . sequence identity scale rotate orbit translate rotate translate world translateGroup translateParticle 4 set shader variables world particleTexture particle i .life 5 draw object-select vertex type primitive type primitives ParticleShader vertexBuffer 39 CHAPTER 20 I Inside the Draw method a call can be made to draw the fire DrawParticles Finally as one last touch to make the example a little more interesting we ll add a model torch. For this to work the file must .
đang nạp các trang xem trước