public override void DrawModel(GameModel model, GameTime time)
        {
            //Overlay.Profiler ["DrawModel1"] += Knot3.Core.Game.Time (() => {
            string key = string.Join (";", (string)model.Info.Modelname, model.BaseColor.R, model.BaseColor.B,
                                      model.BaseColor.G, model.Alpha, model.HighlightColor.R, model.HighlightColor.B,
                                      model.HighlightColor.G, model.HighlightIntensity);
            if (!instanceHash.ContainsKey (key)) {
                instanceHash [key] = new ModelInstances {
                    Model = model,
                    WorldMatrices = new Matrix[200],
                    Count = 0
                };
                Console.WriteLine ("new ModelInstances(" + key + ")");
            }
            ModelInstances instances = instanceHash [key] as ModelInstances;
            if (instances.Count + 1 >= instances.WorldMatrices.Length) {
                Array.Resize (ref instances.WorldMatrices, instances.WorldMatrices.Length * 2);
                Console.WriteLine ("Resize: " + instances.WorldMatrices.Length);
            }
            instances.Model = model;
            instances.WorldMatrices [instances.Count++] = model.WorldMatrix;

            //}).TotalMilliseconds;
        }
        public override void DrawModel(GameModel model, GameTime time)
        {
            Camera camera = model.World.Camera;
            lightDirection = new Vector4 (-Vector3.Cross (Vector3.Normalize (camera.TargetDirection), camera.UpVector), 1);
            celShader.Parameters ["LightDirection"].SetValue (lightDirection);
            celShader.Parameters ["World"].SetValue (model.WorldMatrix * camera.WorldMatrix);
            celShader.Parameters ["InverseWorld"].SetValue (Matrix.Invert (model.WorldMatrix * camera.WorldMatrix));
            celShader.Parameters ["View"].SetValue (camera.ViewMatrix);
            celShader.Parameters ["Projection"].SetValue (camera.ProjectionMatrix);
            celShader.CurrentTechnique = celShader.Techniques ["ToonShader"];

            if (model.BaseColor != Color.Transparent) {
                if (model.HighlightIntensity != 0f) {
                    Color = model.BaseColor.Mix (model.HighlightColor, model.HighlightIntensity);
                }
                else {
                    Color = model.BaseColor;
                }
            }

            foreach (ModelMesh mesh in model.Model.Meshes) {
                mesh.Draw ();
            }
        }
 public ShadowGameModel(GameScreen screen, GameModel model)
     : base(screen, model)
 {
     Model = model;
 }
        protected void ModifyBasicEffect(BasicEffect effect, GameModel model)
        {
            // lighting
            if (Keys.L.IsHeldDown ()) {
                effect.LightingEnabled = false;
            }
            else {
                effect.EnableDefaultLighting ();  // Beleuchtung aktivieren
            }

            // matrices
            effect.World = model.WorldMatrix * model.World.Camera.WorldMatrix;
            effect.View = model.World.Camera.ViewMatrix;
            effect.Projection = model.World.Camera.ProjectionMatrix;

            // colors
            if (model.BaseColor != Color.Transparent) {
                if (model.HighlightIntensity != 0f) {
                    effect.DiffuseColor = model.BaseColor.Mix (model.HighlightColor, model.HighlightIntensity).ToVector3 ();
                }
                else {
                    effect.DiffuseColor = model.BaseColor.ToVector3 ();
                }
            }
            if (background == Color.Transparent) {
                effect.Alpha = model.Alpha;
            }
            else {
                effect.DiffuseColor = new Color (effect.DiffuseColor).Mix (background, 1f - model.Alpha).ToVector3 ();
            }
            effect.FogEnabled = false;
        }
        /// <summary>
        /// Zeichnet ein 3D-Modell mit diesem Rendereffekt.
        /// </summary>
        /// <param name='model'>
        /// Model.
        /// </param>
        /// <param name='time'>
        /// Game time.
        /// </param>
        public virtual void DrawModel(GameModel model, GameTime time)
        {
            foreach (ModelMesh mesh in model.Model.Meshes) {
                foreach (ModelMeshPart part in mesh.MeshParts) {
                    if (part.Effect is BasicEffect) {
                        ModifyBasicEffect (part.Effect as BasicEffect, model);
                    }
                }
            }

            foreach (ModelMesh mesh in model.Model.Meshes) {
                mesh.Draw ();
            }
        }