123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.Graphics;
- using nkast.Aether.Shaders;
- namespace Samples.Deferred
- {
- public class Spaceship
- {
- Model model;
-
- public void Load(ContentManager content)
- {
- model = content.Load<Model>("spaceship");
- }
-
- public void Draw(Matrix world, Matrix view, Matrix projection)
- {
- foreach (ModelMesh mesh in model.Meshes)
- {
- foreach (BasicEffect effect in mesh.Effects)
- {
- effect.World = world;
- effect.View = view;
- effect.Projection = projection;
- effect.EnableDefaultLighting();
- effect.DiffuseColor = new Vector3(0.6f);
- effect.EmissiveColor = new Vector3(0.6f);
- }
- mesh.Draw();
- }
- }
- internal void DrawDeferred(GraphicsDevice device, DeferredBasicEffect deferredBasicEffect, Matrix world, Matrix view, Matrix projection)
- {
- deferredBasicEffect.World = world;
- deferredBasicEffect.View = view;
- deferredBasicEffect.Projection = projection;
- foreach (var mesh in model.Meshes)
- {
- foreach (var part in mesh.MeshParts)
- {
- deferredBasicEffect.CurrentTechnique.Passes[0].Apply();
- device.Textures[0] = ((BasicEffect)part.Effect).Texture;
- device.SetVertexBuffer(part.VertexBuffer);
- device.Indices = part.IndexBuffer;
- device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
- part.VertexOffset, 0, part.NumVertices,
- part.StartIndex, part.PrimitiveCount);
- }
- }
- }
- }
- }
|