상속: GameObject
예제 #1
0
        protected void ModifyBasicEffect(BasicEffect effect, GamePrimitive primitive)
        {
            ModifyBasicEffect (effect: effect, obj: primitive as IGameObject);

            effect.TextureEnabled = true;
            effect.Texture = GetTexture (primitive);
        }
 public override void DrawPrimitive(GamePrimitive primitive, GameTime time)
 {
     string key = primitive.GameObjectCategory;
     InstancedPrimitive instancedPrimitive;
     if (!cacheInstancedPrimitives.ContainsKey (key)) {
         cacheInstancedPrimitives [key] = instancedPrimitive = new InstancedPrimitive () {
             Primitive = primitive.Primitive,
             World = primitive.World,
             Texture = GetTexture (primitive),
             Instances = new InstanceInfo [100],
             InstanceCount = 0,
             InstanceUniqueHash = 0,
             IsSkyObject = primitive.IsSkyObject
         };
     }
     else {
         instancedPrimitive = cacheInstancedPrimitives [key];
     }
     if (instancedPrimitive.InstanceCount + 1 >= instancedPrimitive.Instances.Length) {
         Array.Resize (ref instancedPrimitive.Instances, instancedPrimitive.Instances.Length + 200);
     }
     InstanceInfo instanceInfo = new InstanceInfo {
         WorldMatrix = primitive.WorldMatrix * primitive.World.Camera.WorldMatrix,
         TransposeInverseWorldMatrix = primitive.WorldMatrixInverseTranspose * primitive.World.Camera.WorldMatrix,
         Alpha = primitive.Coloring.Alpha,
         IsLightingEnabled = primitive.IsLightingEnabled ? 1 : 0,
         SingleColor = primitive.IsSingleColored ? primitive.Coloring.MixedColor.ToVector4 () : Vector4.Zero
     };
     instancedPrimitive.Instances [instancedPrimitive.InstanceCount++] = instanceInfo;
     instancedPrimitive.InstanceUniqueHash += primitive.Position.LengthSquared ();
 }
예제 #3
0
        public override void DrawPrimitive(GamePrimitive primitive, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = Screen.Viewport;
            Screen.Viewport = primitive.World.Viewport;

            SetShaderParameters (obj: primitive, time: time);
            primitive.Primitive.Draw (effect: effect);

            // Setze den Viewport wieder auf den ganzen Screen
            Screen.Viewport = original;
        }
예제 #4
0
        /// <summary>
        /// Zeichnet das Spielmodell model mit diesem Rendereffekt.
        /// </summary>
        public virtual void DrawPrimitive(GamePrimitive primitive, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = Screen.Viewport;
            Screen.Viewport = primitive.World.Viewport;

            if (basicEffectForPrimitives == null) {
                basicEffectForPrimitives = new BasicEffect (Screen.GraphicsDevice);
                RegisterEffect (basicEffectForPrimitives);
            }

            ModifyBasicEffect (effect: basicEffectForPrimitives, primitive: primitive);
            primitive.Primitive.Draw (effect: basicEffectForPrimitives);

            // Setze den Viewport wieder auf den ganzen Screen
            Screen.Viewport = original;
        }
예제 #5
0
        public override void DrawPrimitive(GamePrimitive model, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = Screen.Viewport;
            Screen.Viewport = model.World.Viewport;

            Camera camera = model.World.Camera;

            //lightDirection = new Vector4 (-Vector3.Cross (Vector3.Normalize (camera.TargetDirection), camera.UpVector), 1);
            pascalEffect.Parameters ["World"].SetValue (model.WorldMatrix * camera.WorldMatrix);
            pascalEffect.Parameters ["View"].SetValue (camera.ViewMatrix);
            pascalEffect.Parameters ["Projection"].SetValue (camera.ProjectionMatrix);

            pascalEffect.Parameters ["color1"].SetValue (Color.Yellow.ToVector4 ());
            pascalEffect.Parameters ["color2"].SetValue (Color.Red.ToVector4 ());

            pascalEffect.CurrentTechnique = pascalEffect.Techniques ["Technique1"];

            model.Primitive.Draw (pascalEffect);

            // Setze den Viewport wieder auf den ganzen Screen
            Screen.Viewport = original;
        }
예제 #6
0
        /// <summary>
        /// Zeichnet das Spielprimitiv primitive mit diesem Rendereffekt.
        /// </summary>
        public virtual void DrawPrimitive(GamePrimitive primitive, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = screen.Viewport;
            screen.Viewport = primitive.World.Viewport;

            // hier würde das Modell gezeichnet werden

            // Setze den Viewport wieder auf den ganzen Screen
            screen.Viewport = original;
        }
예제 #7
0
 public override void DrawPrimitive(GamePrimitive primitive, GameTime time)
 {
     string key = primitive.GameObjectCategory;
     InstancedPrimitive instancedPrimitive;
     if (!cacheInstancedPrimitives.ContainsKey (key)) {
         cacheInstancedPrimitives [key] = instancedPrimitive = new InstancedPrimitive () {
             Primitive = primitive.Primitive,
             World = primitive.World,
             Texture = GetTexture (primitive),
             Instances = new InstanceInfo [100],
             InstanceCount = 0,
             InstanceUniqueHash = 0
         };
     }
     else {
         instancedPrimitive = cacheInstancedPrimitives [key];
     }
     if (instancedPrimitive.InstanceCount + 1 >= instancedPrimitive.Instances.Length) {
         Array.Resize (ref instancedPrimitive.Instances, instancedPrimitive.Instances.Length + 200);
     }
     InstanceInfo instanceInfo = new InstanceInfo {
         WorldMatrix = primitive.WorldMatrix * primitive.World.Camera.WorldMatrix,
         TransposeInverseWorldMatrix = primitive.WorldMatrixInverseTranspose * primitive.World.Camera.WorldMatrix
     };
     instancedPrimitive.Instances [instancedPrimitive.InstanceCount++] = instanceInfo;
     instancedPrimitive.InstanceUniqueHash += primitive.Position.LengthSquared ();
 }
예제 #8
0
        public override void DrawPrimitive(GamePrimitive model, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = Screen.Viewport;
            Screen.Viewport = model.World.Viewport;

            Camera camera = model.World.Camera;

            zNebulaEffect.Parameters ["World"].SetValue (model.WorldMatrix * camera.WorldMatrix);
            zNebulaEffect.Parameters ["View"].SetValue (camera.ViewMatrix);
            zNebulaEffect.Parameters ["Projection"].SetValue (camera.ProjectionMatrix);

            zNebulaEffect.CurrentTechnique = zNebulaEffect.Techniques ["Simplest"];

            model.Primitive.Draw (zNebulaEffect);

            // Setze den Viewport wieder auf den ganzen Screen
            Screen.Viewport = original;
        }
예제 #9
0
        /// <summary>
        /// Zeichnet das Spielmodell model mit dem Cel-Shading-Effekt.
        /// Eine Anwendung des NVIDIA-Toon-Shaders.
        /// </summary>
        public override void DrawPrimitive(GamePrimitive model, GameTime time)
        {
            // Setze den Viewport auf den der aktuellen Spielwelt
            Viewport original = Screen.Viewport;
            Screen.Viewport = model.World.Viewport;

            Camera camera = model.World.Camera;
            lightDirection = new Vector4 (-Vector3.Cross (Vector3.Normalize (camera.PositionToTargetDirection), 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.Coloring.IsTransparent) {
                Color = model.Coloring.MixedColor;
            }

            model.Primitive.Draw (effect: celShader);

            // Setze den Viewport wieder auf den ganzen Screen
            Screen.Viewport = original;
        }