protected override async Task LoadContent() { await base.LoadContent(); var knightModel = Content.Load<Model>("knight Model"); knight = new Entity { new ModelComponent { Model = knightModel } }; knight.Transform.Position = new Vector3(0, 0f, 0f); var animationComponent = knight.GetOrCreate<AnimationComponent>(); animationComponent.Animations.Add("Run", Content.Load<AnimationClip>("knight Run")); animationComponent.Animations.Add("Idle", Content.Load<AnimationClip>("knight Idle")); // We will test both non-optimized and optimized clips megalodonClip = CreateModelChangeAnimation(new ProceduralModelDescriptor(new CubeProceduralModel { Size = Vector3.One, MaterialInstance = { Material = knightModel.Materials[0].Material } }).GenerateModel(Services)); knightOptimizedClip = CreateModelChangeAnimation(Content.Load<Model>("knight Model")); knightOptimizedClip.Optimize(); animationComponent.Animations.Add("ChangeModel1", megalodonClip); animationComponent.Animations.Add("ChangeModel2", knightOptimizedClip); Scene.Entities.Add(knight); camera = new TestCamera(); CameraComponent = camera.Camera; Script.Add(camera); camera.Position = new Vector3(6.0f, 2.5f, 1.5f); camera.SetTarget(knight, true); }
protected override async Task LoadContent() { await base.LoadContent(); var knightModel = Asset.Load<Model>("knight Model"); knight = new Entity { new ModelComponent { Model = knightModel } }; knight.Transform.Position = new Vector3(0, 0f, 0f); var animationComponent = knight.GetOrCreate<AnimationComponent>(); animationComponent.Animations.Add("Run", Asset.Load<AnimationClip>("knight Run")); animationComponent.Animations.Add("Idle", Asset.Load<AnimationClip>("knight Idle")); // We will test both non-optimized and optimized clips megalodonClip = CreateModelChangeAnimation(new ProceduralModelDescriptor(new CubeProceduralModel { Size = Vector3.One, MaterialInstance = { Material = knightModel.Materials[0].Material } }).GenerateModel(Services)); knightOptimizedClip = CreateModelChangeAnimation(Asset.Load<Model>("knight Model")); knightOptimizedClip.Optimize(); animationComponent.Animations.Add("ChangeModel1", megalodonClip); animationComponent.Animations.Add("ChangeModel2", knightOptimizedClip); Scene.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); camera.Position = new Vector3(6.0f, 2.5f, 1.5f); camera.SetTarget(knight, true); }
protected override async Task LoadContent() { await base.LoadContent(); var knightModel = Asset.Load <Model>("knight Model"); knight = new Entity { new ModelComponent { Model = knightModel } }; knight.Transform.Position = new Vector3(0, 0f, 0f); var animationComponent = knight.GetOrCreate <AnimationComponent>(); animationComponent.Animations.Add("Run", Asset.Load <AnimationClip>("knight Run")); animationComponent.Animations.Add("Idle", Asset.Load <AnimationClip>("knight Idle")); // We will test both non-optimized and optimized clips megalodonClip = CreateModelChangeAnimation(new ProceduralModelDescriptor(new CubeProceduralModel { Size = Vector3.One, MaterialInstance = { Material = knightModel.Materials[0].Material } }).GenerateModel(Services)); knightOptimizedClip = CreateModelChangeAnimation(Asset.Load <Model>("knight Model")); knightOptimizedClip.Optimize(); animationComponent.Animations.Add("ChangeModel1", megalodonClip); animationComponent.Animations.Add("ChangeModel2", knightOptimizedClip); Scene.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); camera.Position = new Vector3(6.0f, 2.5f, 1.5f); camera.SetTarget(knight, true); }
protected override async Task LoadContent() { await base.LoadContent(); var knightModel = Content.Load <Model>("knight Model"); knight = new Entity { new ModelComponent { Model = knightModel } }; knight.Transform.Position = new Vector3(0, 0f, 0f); var animationComponent = knight.GetOrCreate <AnimationComponent>(); animationComponent.Animations.Add("Run", Content.Load <AnimationClip>("knight Run")); animationComponent.Animations.Add("Idle", Content.Load <AnimationClip>("knight Idle")); // We will test both non-optimized and optimized clips megalodonClip = CreateModelChangeAnimation(new ProceduralModelDescriptor(new CubeProceduralModel { Size = Vector3.One, MaterialInstance = { Material = knightModel.Materials[0].Material } }).GenerateModel(Services)); knightOptimizedClip = CreateModelChangeAnimation(Content.Load <Model>("knight Model")); knightOptimizedClip.Optimize(); animationComponent.Animations.Add("ChangeModel1", megalodonClip); animationComponent.Animations.Add("ChangeModel2", knightOptimizedClip); Scene.Entities.Add(knight); camera = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = camera.Camera; Script.Add(camera); camera.Position = new Vector3(6.0f, 2.5f, 1.5f); camera.SetTarget(knight, true); }
protected override async Task LoadContent() { await base.LoadContent(); var debugSheet = Content.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++) { // Add some z-offset, so non-deterministic sorting due to threading does not cause issues with blending and depth testing enabled rotatingSprites[i].Transform.Position = new Vector3(ScreenWidth, ScreenHeight, 0) / 2; } // add all the entities to the scene foreach (var entity in entities) { SceneSystem.SceneInstance.RootScene.Entities.Add(entity); } cameraScript = new TestCamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor); CameraComponent = cameraScript.Camera; Script.Add(cameraScript); cameraScript.Yaw = 0; cameraScript.Pitch = 0; cameraScript.Position = new Vector3(400, 300, 800); }
protected override async Task LoadContent() { await base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Font"); wireframeState = new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe }; materials.Add(Content.Load <Material>("NoTessellation")); materials.Add(Content.Load <Material>("FlatTessellation")); materials.Add(Content.Load <Material>("PNTessellation")); materials.Add(Content.Load <Material>("PNTessellationAE")); materials.Add(Content.Load <Material>("FlatTessellationDispl")); materials.Add(Content.Load <Material>("FlatTessellationDisplAE")); materials.Add(Content.Load <Material>("PNTessellationDisplAE")); RenderContext.GetShared(Services).RendererInitialized += RendererInitialized; 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 = Content.Load <Model>("megalodon Model") } }; megalodon.Transform.Position = new Vector3(0, -30f, -10f); var knight = new Entity { new ModelComponent { Model = Content.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); // TODO GRAPHICS REFACTOR ChangeModel(0); camera.Position = new Vector3(25, 45, 80); camera.SetTarget(currentEntity, true); }
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); }
protected override async Task LoadContent() { await base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("Font"); wireframeState = new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe }; materials.Add(Content.Load<Material>("NoTessellation")); materials.Add(Content.Load<Material>("FlatTessellation")); materials.Add(Content.Load<Material>("PNTessellation")); materials.Add(Content.Load<Material>("PNTessellationAE")); materials.Add(Content.Load<Material>("FlatTessellationDispl")); materials.Add(Content.Load<Material>("FlatTessellationDisplAE")); materials.Add(Content.Load<Material>("PNTessellationDisplAE")); RenderContext.GetShared(Services).RendererInitialized += RendererInitialized; 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 = Content.Load<Model>("megalodon Model") } }; megalodon.Transform.Position= new Vector3(0, -30f, -10f); var knight = new Entity { new ModelComponent { Model = Content.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); // TODO GRAPHICS REFACTOR ChangeModel(0); camera.Position = new Vector3(25, 45, 80); camera.SetTarget(currentEntity, true); }
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); }
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); }