예제 #1
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var debugSheet = Asset.Load<SpriteSheet>("DebugSpriteSheet");

            // normal reference one
            var normal = CreateSpriteEntity(debugSheet, "Normal");
            normal.Transform.Position = new Vector3(75, 75, 0);
            normal.Transform.RotationEulerXYZ = new Vector3(0.8f, 1.2f, 0.3f);
            normal.Get<SpriteComponent>().CurrentSprite.Center = new Vector2(75);

            // billboard
            var billboard = CreateSpriteEntity(debugSheet, "Billboard");
            billboard.Transform.Position = new Vector3(150, 150, 0);
            billboard.Transform.RotationEulerXYZ = new Vector3(0.5f, 1f, 1.5f);
            billboard.Get<SpriteComponent>().SpriteType = SpriteType.Billboard;

            // ratio
            var child = CreateSpriteEntity(debugSheet, "Child", false);
            child.Transform.Position = new Vector3(100, 0, 0);
            ratio = CreateSpriteEntity(debugSheet, "OtherRatio");
            ratio.Transform.Position = new Vector3(350, 150, 0);
            ratio.AddChild(child);

            // depth test
            var onBack = CreateSpriteEntity(debugSheet, "OnBack");
            onBack.Transform.Position = new Vector3(75, 250, 0);
            onBack.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0);
            onBack.Get<SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            var onFront = CreateSpriteEntity(debugSheet, "OnFront");
            onFront.Transform.Position = new Vector3(75, 350, 0.1f);
            onFront.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0);
            onFront.Get<SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            var noDepth = CreateSpriteEntity(debugSheet, "NoDepth");
            noDepth.Transform.Position = new Vector3(75, 450, 0.2f);
            noDepth.Get<SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            noDepth.Get<SpriteComponent>().IgnoreDepth = true;

            // create the rotating sprites
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "Center"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "TopLeft"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "OutOfImage"));

            for (int i = 0; i < rotatingSprites.Count; i++)
                rotatingSprites[i].Transform.Position = new Vector3(ScreenWidth, ScreenHeight, 0) / 2;

            // add all the entities to the scene
            foreach (var entity in entities)
                SceneSystem.SceneInstance.Scene.Entities.Add(entity);

            cameraScript = new TestCamera();
            CameraComponent = cameraScript.Camera;
            Script.Add(cameraScript);

            cameraScript.Yaw = 0;
            cameraScript.Pitch = 0;
            cameraScript.Position = new Vector3(400, 300, 800);
        }
예제 #2
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Asset.Load<SpriteFont>("Font");

            wireframeState = RasterizerState.New(GraphicsDevice, new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe });

            materials.Add(Asset.Load<Material>("NoTessellation"));
            materials.Add(Asset.Load<Material>("FlatTessellation"));
            materials.Add(Asset.Load<Material>("PNTessellation"));
            materials.Add(Asset.Load<Material>("PNTessellationAE"));
            materials.Add(Asset.Load<Material>("FlatTessellationDispl"));
            materials.Add(Asset.Load<Material>("FlatTessellationDisplAE"));
            materials.Add(Asset.Load<Material>("PNTessellationDisplAE"));

            var cube = new Entity("Cube") { new ModelComponent(new ProceduralModelDescriptor(new CubeProceduralModel { Size = new Vector3(80), MaterialInstance = { Material = materials[0] } }).GenerateModel(Services)) };
            var sphere = new Entity("Sphere") { new ModelComponent(new ProceduralModelDescriptor(new SphereProceduralModel { Radius = 50, Tessellation = 5, MaterialInstance = { Material = materials[0] }} ).GenerateModel(Services)) };

            var megalodon = new Entity { new ModelComponent { Model = Asset.Load<Model>("megalodon Model") } };
            megalodon.Transform.Position= new Vector3(0, -30f, -10f);

            var knight = new Entity { new ModelComponent { Model = Asset.Load<Model>("knight Model") } };
            knight.Transform.RotationEulerXYZ = new Vector3(-MathUtil.Pi / 2, MathUtil.Pi / 4, 0);
            knight.Transform.Position = new Vector3(0, -50f, 20f);
            knight.Transform.Scale= new Vector3(0.6f);

            entities.Add(sphere);
            entities.Add(cube);
            entities.Add(megalodon);
            entities.Add(knight);

            camera = new TestCamera();
            CameraComponent = camera.Camera;
            Script.Add(camera);

            LightingKeys.EnableFixedAmbientLight(GraphicsDevice.Parameters, true);
            GraphicsDevice.Parameters.Set(EnvironmentLightKeys.GetParameterKey(LightSimpleAmbientKeys.AmbientLight, 0), (Color3)Color.White);

            ChangeModel(0);
            SetWireframe(true);

            camera.Position = new Vector3(25, 45, 80);
            camera.SetTarget(currentEntity, true);
        }
예제 #3
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Asset.Load <SpriteFont>("Font");

            wireframeState = RasterizerState.New(GraphicsDevice, new RasterizerStateDescription(CullMode.Back)
            {
                FillMode = FillMode.Wireframe
            });

            materials.Add(Asset.Load <Material>("NoTessellation"));
            materials.Add(Asset.Load <Material>("FlatTessellation"));
            materials.Add(Asset.Load <Material>("PNTessellation"));
            materials.Add(Asset.Load <Material>("PNTessellationAE"));
            materials.Add(Asset.Load <Material>("FlatTessellationDispl"));
            materials.Add(Asset.Load <Material>("FlatTessellationDisplAE"));
            materials.Add(Asset.Load <Material>("PNTessellationDisplAE"));

            var cube = new Entity("Cube")
            {
                new ModelComponent(new ProceduralModelDescriptor(new CubeProceduralModel {
                    Size = new Vector3(80), MaterialInstance = { Material = materials[0] }
                }).GenerateModel(Services))
            };
            var sphere = new Entity("Sphere")
            {
                new ModelComponent(new ProceduralModelDescriptor(new SphereProceduralModel {
                    Radius = 50, Tessellation = 5, MaterialInstance = { Material = materials[0] }
                }).GenerateModel(Services))
            };

            var megalodon = new Entity {
                new ModelComponent {
                    Model = Asset.Load <Model>("megalodon Model")
                }
            };

            megalodon.Transform.Position = new Vector3(0, -30f, -10f);

            var knight = new Entity {
                new ModelComponent {
                    Model = Asset.Load <Model>("knight Model")
                }
            };

            knight.Transform.RotationEulerXYZ = new Vector3(-MathUtil.Pi / 2, MathUtil.Pi / 4, 0);
            knight.Transform.Position         = new Vector3(0, -50f, 20f);
            knight.Transform.Scale            = new Vector3(0.6f);

            entities.Add(sphere);
            entities.Add(cube);
            entities.Add(megalodon);
            entities.Add(knight);

            camera          = new TestCamera();
            CameraComponent = camera.Camera;
            Script.Add(camera);

            LightingKeys.EnableFixedAmbientLight(GraphicsDevice.Parameters, true);
            GraphicsDevice.Parameters.Set(EnvironmentLightKeys.GetParameterKey(LightSimpleAmbientKeys.AmbientLight, 0), (Color3)Color.White);

            ChangeModel(0);
            SetWireframe(true);

            camera.Position = new Vector3(25, 45, 80);
            camera.SetTarget(currentEntity, true);
        }
예제 #4
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var debugSheet = Asset.Load <SpriteSheet>("DebugSpriteSheet");

            // normal reference one
            var normal = CreateSpriteEntity(debugSheet, "Normal");

            normal.Transform.Position         = new Vector3(75, 75, 0);
            normal.Transform.RotationEulerXYZ = new Vector3(0.8f, 1.2f, 0.3f);
            normal.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75);

            // billboard
            var billboard = CreateSpriteEntity(debugSheet, "Billboard");

            billboard.Transform.Position                 = new Vector3(150, 150, 0);
            billboard.Transform.RotationEulerXYZ         = new Vector3(0.5f, 1f, 1.5f);
            billboard.Get <SpriteComponent>().SpriteType = SpriteType.Billboard;

            // ratio
            var child = CreateSpriteEntity(debugSheet, "Child", false);

            child.Transform.Position = new Vector3(100, 0, 0);
            ratio = CreateSpriteEntity(debugSheet, "OtherRatio");
            ratio.Transform.Position = new Vector3(350, 150, 0);
            ratio.AddChild(child);

            // depth test
            var onBack = CreateSpriteEntity(debugSheet, "OnBack");

            onBack.Transform.Position         = new Vector3(75, 250, 0);
            onBack.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0);
            onBack.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            var onFront = CreateSpriteEntity(debugSheet, "OnFront");

            onFront.Transform.Position         = new Vector3(75, 350, 0.1f);
            onFront.Transform.RotationEulerXYZ = new Vector3(0, 1f, 0);
            onFront.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            var noDepth = CreateSpriteEntity(debugSheet, "NoDepth");

            noDepth.Transform.Position = new Vector3(75, 450, 0.2f);
            noDepth.Get <SpriteComponent>().CurrentSprite.Center = new Vector2(75);
            noDepth.Get <SpriteComponent>().IgnoreDepth          = true;

            // create the rotating sprites
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "Center"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "TopLeft"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "OutOfImage"));

            for (int i = 0; i < rotatingSprites.Count; i++)
            {
                rotatingSprites[i].Transform.Position = new Vector3(ScreenWidth, ScreenHeight, 0) / 2;
            }

            // add all the entities to the scene
            foreach (var entity in entities)
            {
                SceneSystem.SceneInstance.Scene.Entities.Add(entity);
            }

            cameraScript    = new TestCamera();
            CameraComponent = cameraScript.Camera;
            Script.Add(cameraScript);

            cameraScript.Yaw      = 0;
            cameraScript.Pitch    = 0;
            cameraScript.Position = new Vector3(400, 300, 800);
        }