public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Lookat = new Vector3(0, 0, 0), Position = new Vector3(0, 0, 10), FOV = 0.5f, ZFar = 100, AspectRatio = AspectRatio }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = new InteractiveSceneManager { Scene = scene }, }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9) }; renderer.Initialize(this); motionSimulation = new Common.Motion.Simulation(); scene.EntityRemoved += new Action<Entity>(scene_EntityRemoved); scene.EntityAdded += new Action<Entity>(scene_EntityAdded); scene.Add(CreateBlock(-Vector3.UnitZ, new Vector3(size.Width, size.Height, 1), "grass1.png")); InitiateUnits(); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100 }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); heightmap = new Graphics.Software.Texel.R32F[250, 250]; texture = new Graphics.Software.Texture<Graphics.Software.Texel.R32F>(heightmap); scene.Add(ground = new TestGround { Size = new SizeF(100, 100), Heightmap = heightmap, NPieces = new Size(20, 20), Height = 1 }); ground.ConstructPieces(); heightmapEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new[] {texture}, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() } }; heightmapEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { ground.UpdatePatches(e.ChangedRegion); }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera) scene.Camera, InputHandler = heightmapEditor }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); }
public override void Init() { Content.ContentPath = "Data"; Scene = new Scene(); Scene.View = this; Scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; sceneQuadtree = new Common.Quadtree<Entity>(10); sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree); StateManager = new Device9StateManager(Device9); Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.NoShadows } }; Renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = Scene, Renderer = Renderer }; sceneRendererConnector.Initialize(); Scene.Add(exquemelin = new Entity { MainGraphic = new Graphics.Content.MetaModel { SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/Zombie1.x"), Texture = new Graphics.Content.TextureFromFile("Models/Units/Zombie1.png"), World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.5f, 0.5f, 0.5f), HasAlpha = false, }, VisibilityLocalBounding = new Common.Bounding.NonfittableBounding(Vector3.Zero, false, true) }); Graphics.Renderer.Renderer.EntityAnimation ea = Scene.View.Content.Peek<Graphics.Renderer.Renderer.EntityAnimation>(exquemelin.MetaEntityAnimation); ea.PlayAnimation(new AnimationPlayParameters("Idle1", true)); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)Scene.Camera, }; }
public override void Init() { Content.ContentPath = "Data"; Instance = this; scene = new Scene(); scene.DesignMode = true; scene.View = this; scene.Camera = new LookatCartesianCamera() { ZFar = 100, AspectRatio = AspectRatio }; ((LookatCamera)scene.Camera).Lookat = new Vector3(SceneSize.Width / 2f, SceneSize.Height / 2f, 0); ((LookatCamera)scene.Camera).Position = ((LookatCamera)scene.Camera).Lookat + new Vector3(10, 10, 10); scene.EntityAdded += new Action<Entity>(scene_EntityAdded); scene.EntityRemoved += new Action<Entity>(scene_EntityRemoved); sceneQuadtree = new Common.Quadtree<Entity>(0, 0, SceneSize.Width, SceneSize.Height, 10); sbau = new SceneBVHAutoSyncer(scene, sceneQuadtree); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = new Graphics.InteractiveSceneManager { Scene = scene }, }; timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1; timer.Enabled = true; RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Starting to add initial objects"); for (int i = 0; i < nInitialEntities; i++) CreateRandomTestEntity(); RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Starting CRUSHING!"); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; Scene = new Scene(); Scene.View = this; Scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; sceneQuadtree = new Common.Quadtree<Entity>(-1, -1, 100, 100, 10); sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree); StateManager = new Device9StateManager(Device9); rand = new Random(); nBillboards = 2000; billboards = new Entity[nBillboards]; directions = new Vector3[nBillboards]; for (int i = 0; i < nBillboards; i++) directions[i] = new Vector3((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)Scene.Camera }; Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 500 } }; Renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = Renderer, Scene = Scene }; sceneRendererConnector.Initialize(); for (int i = 0; i < nBillboards; i++) { Scene.Add(billboards[i] = new Entity { MainGraphic = new MetaModel { AlphaRef = 0, BaseTexture = null, CastShadows = Priority.Never, HasAlpha = true, IsBillboard = true, IsWater = false, MaterialTexture = null, Mesh = null, ReceivesAmbientLight = Priority.Never, ReceivesDiffuseLight = Priority.Never, ReceivesShadows = Priority.Never, SkinnedMesh = null, SplatMapped = false, SplatTexutre = null, Texture = new TextureFromFile("checker.png"), Visible = Priority.High, World = Matrix.Identity, XMesh = new MeshConcretize { MeshDescription = new Meshes.IndexedPlane { Facings = Facings.Backside | Facings.Frontside, Position = Vector3.Zero, Size = new Vector2(5, 5), UVMin = Vector2.Zero, UVMax = new Vector2(1, 1) }, Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance } }, VisibilityLocalBounding = Vector3.Zero, WorldMatrix = Matrix.Identity }); } }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera { Position = new Vector3(-5, 5, 5), }; foreach (var v in scene.AllEntities) v.VisibilityLocalBounding = Content.Acquire<Graphics.Content.StructBoxer<BoundingBox>>(v.MainGraphic).Value; var stateManager = new Device9StateManager(Device9); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = stateManager }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); editor = new Graphics.Editors.SceneEditor { Scene = scene }; editorRenderer = new Graphics.Editors.SceneEditor.Renderer9(editor) { BoundingVolumesRenderer = new BoundingVolumesRenderer { StateManager = stateManager, View = this } }; InputHandler = editor; Entity e; scene.Add(e = new Entity { MainGraphic = new MetaModel { XMesh = new MeshFromFile("Models/Props/Barrel1.x"), Texture = new TextureFromFile("Models/Props/Barrel1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(1, 0, 0) }, }); e.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)e.MainGraphic); e.PickingLocalBounding = CreateBoundingMeshFromModel(e, (MetaModel)e.MainGraphic); scene.Add(e = new Entity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"), Texture = new TextureFromFile("Models/Props/Bridge1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(3, 0, 0) }, }); e.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)e.MainGraphic); e.PickingLocalBounding = CreateBoundingMeshFromModel(e, (MetaModel)e.MainGraphic); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); texture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>(new Graphics.Software.Texel.A8R8G8B8[250, 250]); scene.Add(ground = new TestGround { Size = new SizeF(100, 100), //Texture = new SingleColorTexture(Color.Orange), NPieces = new Size(20, 20), }); ground.ConstructPieces(); dxTexture = texture.ToTexture9(Device9); ground.Texture = new UnmanagedResource<SlimDX.Direct3D9.Texture, SlimDX.Direct3D10.Texture2D> { Resource9 = dxTexture }; groundTextureEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new[] {texture}, Texture9 = new[] {dxTexture}, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new Vector4(0, 0, 1, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.AddSaturate } }; groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = groundTextureEditor, }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; Scene = new Scene(); Scene.View = this; Scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 10000, AspectRatio = AspectRatio }; sceneQuadtree = new Common.Quadtree<Entity>(-1, -1, 100, 100, 10); sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree); StateManager = new Device9StateManager(Device9); arrow = new MetaModel { HasAlpha = true, IsAxialBillboard = true, AxialDirection = new Vector3(0.5f, 0.5f, 0), XMesh = new Graphics.Content.MeshFromFile("Arrow.x"), Texture = new TextureFromFile("green.png"), Visible = Priority.High, World = Matrix.Identity, }; direction = new Vector3(1, 0, 0); axialBillboard = new MetaModel { HasAlpha = true, IsAxialBillboard = true, AxialDirection = direction, XMesh = new MeshConcretize { MeshDescription = new Graphics.Software.Meshes.IndexedPlane { Facings = Facings.Frontside | Facings.Backside, Position = new Vector3(-0.5f, -0.5f, 0), Size = new Vector2(1, 1), UVMin = Vector2.Zero, UVMax = new Vector2(1, 1) }, Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile("Models/Effects/MuzzleFlash1.png"), World = Matrix.RotationX((float) Math.PI /2.0f) * Matrix.RotationY((float)Math.PI / 2.0f) * Matrix.Translation(direction * 0.5f) }; rand = new Random(); //axialBillboard.World.Invert(); nBillboards = 1; billboards = new Entity[nBillboards]; directions = new Vector3[nBillboards]; for (int i = 0; i < nBillboards; i++) directions[i] = new Vector3((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)Scene.Camera }; Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 50000, WaterLevel = 0 } }; Renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = Renderer, Scene = Scene }; sceneRendererConnector.Initialize(); for (int i = 0; i < nBillboards; i++) { Scene.Add(billboards[i] = new Entity { MainGraphic = axialBillboard, VisibilityLocalBounding = Vector3.Zero, WorldMatrix = Matrix.Identity }); } }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(-5, 5, 5), AspectRatio = AspectRatio }; foreach (var v in scene.AllEntities) v.VisibilityLocalBounding = Vector3.Zero; Device9StateManager sm = new Device9StateManager(Device9); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = sm }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); bvr = new BoundingVolumesRenderer { View = this, StateManager = sm }; BVEntity t; scene.Add(t = new BVEntity { MainGraphic = new MetaModel { XMesh = new MeshFromFile("Models/Props/Barrel1.x"), Texture = new TextureFromFile("Models/Props/Barrel1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya, }, WorldMatrix = Matrix.Translation(1, 0, 0) }); t.BoundingVolume = Graphics.Boundings.Transform(new Graphics.MetaBoundingBox { Mesh = ((MetaModel)t.MainGraphic).XMesh }, ((MetaModel)t.MainGraphic).World); scene.Add(t = new BVEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"), Texture = new TextureFromFile("Models/Props/Bridge1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya }, WorldMatrix = Matrix.Translation(3, 0, 0) }); scene.Add(t = new BVEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"), Texture = new TextureFromFile("Models/Props/Bridge1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya }, WorldMatrix = Matrix.Translation(-3, -3, 0) }); t.BoundingVolume = Vector3.Zero; }
public override void Init() { Content.ContentPath = "Data"; Instance = this; Scene = new Scene(); Scene.View = this; Scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 10000, AspectRatio = AspectRatio }; sceneQuadtree = new Common.Quadtree<Entity>(0, 0, 100, 100, 10); sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree); StateManager = new Device9StateManager(Device9); int nVertices = 10; int nFaces = nVertices*2 - 4; int nIndices = nFaces * 3; List<int> indices = new List<int>(); List<Graphics.Software.Vertex.Position3Normal3Texcoord3> vertices = new List<Graphics.Software.Vertex.Position3Normal3Texcoord3>(); for (int i = 0; i < (nVertices / 2) - 1; i++) { indices.Add(i * 2); indices.Add(i * 2 + 2); indices.Add(i * 2 + 1); indices.Add(i * 2 + 1); indices.Add(i * 2 + 2); indices.Add(i * 2 + 3); indices.Add(i * 2 + 0); indices.Add(i * 2 + 1); indices.Add(i * 2 + 3); indices.Add(i * 2 + 0); indices.Add(i * 2 + 3); indices.Add(i * 2 + 2); } for (int i = 0; i < nVertices / 2; i++) { float texturecoord = 1 - ((float)i / (float)nVertices); if (texturecoord > 0.99f) texturecoord = 0.99f; vertices.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(Vector3.UnitX * i, Vector3.Zero, new Vector3(texturecoord, 1, 0))); vertices.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(Vector3.UnitX * i + Vector3.UnitY*4.0f, Vector3.Zero, new Vector3(texturecoord, 0, 0))); } arrow = new MetaModel { HasAlpha = true, Opacity = 0.4f, XMesh = new MeshConcretize { Mesh = new Graphics.Software.Mesh { IndexBuffer = new Graphics.Software.IndexBuffer(indices.ToArray()), VertexBuffer = new VertexBuffer<Graphics.Software.Vertex.Position3Normal3Texcoord3>(vertices.ToArray()), NVertices = nVertices, NFaces = nFaces, VertexStreamLayout = global::Graphics.Software.Vertex.Position3Normal3Texcoord3.Instance, }, Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile("green.png"), }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)Scene.Camera }; Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 50000, WaterLevel = 0 } }; Renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = Renderer, Scene = Scene }; sceneRendererConnector.Initialize(); Scene.Add(new Entity { MainGraphic = arrow, VisibilityLocalBounding = Vector3.Zero, }); }
public override void Init() { if (DesignMode) return; Content.ContentPath = "Data(.kel)"; Client.Game.Map.GameEntity.ContentPool = Content; Scene.View = this; Scene.Camera = new LookatSphericalCamera() { FOV = 0.5f, ZFar = 50, SphericalCoordinates = Program.ClientDefaultSettings.CameraSphericalCoordinates, AspectRatio = this.AspectRatio }; Controller = new InteractiveSceneManager { Scene = Scene }; StateManager = new DummyDevice9StateManager(Device9); InputHandler = inputHandlersRoot; cameraInputHandler = new CameraInputHandler { Camera = (LookatSphericalCamera)Scene.Camera, View = this, }; Scene.Camera.ZFar = 50; inputHandlersRoot.InputHandlers.Add(cameraInputHandler); cameraInputHandler.InputHandler = Controller; if (Program.Settings.UseDummyRenderer) { throw new NotSupportedException("Dummy renderer is no longer supported."); //Renderer = new Graphics.DummyRenderer.Renderer { Scene = Scene, StateManager = StateManager }; } else { Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.Medium, LightingQuality = Graphics.Renderer.Settings.LightingQualities.High } }; SceneRendererConnector = new SortedTestSceneRendererConnector { Scene = Scene, Renderer = Renderer }; } Renderer.Settings.TerrainQuality = Graphics.Renderer.Settings.TerrainQualities.High; Renderer.Settings.LightingQuality = Graphics.Renderer.Settings.LightingQualities.High; Renderer.Settings.ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.Low; SceneRendererConnector.Initialize(); Renderer.Initialize(Scene.View); if (Program.Settings.DeveloperSettings) { p1 = new System.Windows.Forms.PropertyGrid { SelectedObject = Renderer.Settings, Dock = System.Windows.Forms.DockStyle.Fill }; form1.Controls.Add(p1); form1.Show(); } bvRenderer = new BoundingVolumesRenderer { StateManager = StateManager, View = this }; tooltip = new System.Windows.Forms.ToolTip(); StartDefaultMode(); }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); texture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>( new Graphics.Software.Texel.A8R8G8B8[250, 250]); var r = new Random(); for(int y=0; y < texture.Size.Height; y++) for(int x=0; x < texture.Size.Width; x++) texture[y, x] = new Graphics.Software.Texel.A8R8G8B8 { //R = 1f,//(float)r.NextDouble(), //G = (float)r.NextDouble(), //B = (float)r.NextDouble(), A = 1f, }; scene.Add(ground = new TestGround { Size = new SizeF(100, 100), //Texture = new SingleColorTexture(Color.Orange), NPieces = new Size(20, 20), }); ground.ConstructPieces(); dxTexture = texture.ToTexture9(Device9); UpdateTexture(); groundTextureEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new ITexture[] { texture }, Texture9 = new[] {dxTexture}, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new Vector4(1, 0, 0, 0), Radius = 30, Type = Graphics.Editors.GroundTexturePencilType.Add } }; groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { UpdateTexture(); foreach (var v in ground.Children) v.Invalidate(); }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = groundTextureEditor }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; nParticles = 0; scene = new Scene { View = this, Camera = new LookatCartesianCamera { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 600, AspectRatio = AspectRatio } }; sceneQuadtree = new Common.Quadtree<Entity>(10); new SceneBVHAutoSyncer(scene, sceneQuadtree); stateManager = new DummyDevice9StateManager(Device9); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = stateManager, Settings = new Graphics.Renderer.Settings { CullMode = Cull.Counterclockwise, FogDistance = 1500, } }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = new InteractiveSceneManager { Scene = scene }, }; ground = new MetaModel { AlphaRef = 0, HasAlpha = false, Texture = new TextureFromFile("Models/GroundTextures/Grass1.png"), XMesh = new MeshConcretize { MeshDescription = new Graphics.Software.Meshes.IndexedPlane { Position = new Vector3(-5f, -5f, -1), Size = new Vector2(10, 10), UVMin = Vector2.Zero, UVMax = new Vector2(1, 1), Facings = Facings.Frontside }, Layout = Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, }; scene.Add(new Entity { MainGraphic = ground, VisibilityLocalBounding = new Common.Bounding.NonfittableBounding(Vector3.Zero, false, true), Translation = Vector3.UnitZ }); }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Lookat = new Vector3(size.Width / 2f, size.Height / 2f, 0), Position = new Vector3(10, 10, 10), FOV = 0.5f, ZFar = 100, AspectRatio = AspectRatio }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9), Settings = new Graphics.Renderer.Settings { WaterEnable = false } }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); motionSimulation = new Common.Motion.Simulation(); scene.EntityAdded += new Action<Entity>(scene_EntityAdded); CreateGround(); scene.EntityAdded -= new Action<Entity>(scene_EntityAdded); }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Lookat = new Vector3(size.Width / 2f, size.Height / 2f, 0), Position = new Vector3(10, 10, 10), FOV = 0.5f, ZFar = 100, AspectRatio = AspectRatio }; viewport = new Graphics.GraphicsDevice.Viewport(Device9.Viewport); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = new InteractiveSceneManager { Scene = scene }, }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9), Settings = new Graphics.Renderer.Settings { WaterEnable = false } }; //renderer = new Graphics.DummyRenderer.Renderer { Scene = scene, StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9), Settings = new Graphics.Renderer.Settings { WaterEnable = false } }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); motionSimulation = new Common.Motion.Simulation(); scene.EntityAdded += new Action<Entity>(scene_EntityAdded); scene.EntityRemoved += new Action<Entity>(scene_EntityRemoved); var sim = (Common.Motion.Simulation)motionSimulation; npcs = new List<Common.IMotion.INPC>(); Vector2 startingPosition = new Vector2(size.Width / 2f, size.Height / 2f); CreateGround(true); scene.Add(controlledUnit = CreateUnit(startingPosition)); scene.Add(CreateBlock(Common.Math.ToVector3(startingPosition + new Vector2(2, -2)), new Vector3(1, 1, 1.5f))); scene.Add(CreateBlock(Common.Math.ToVector3(startingPosition + new Vector2(-4, 2)), new Vector3(1, 1, 1.5f))); scene.Add(CreateBlock(Common.Math.ToVector3(startingPosition + new Vector2(4, -2)), new Vector3(1, 1, 1.5f))); scene.Add(CreateBlock(Common.Math.ToVector3(startingPosition + new Vector2(7, -1)), new Vector3(1, 1, 1.5f))); //scene.Add(CreateNPC(startingPosition + new Vector2(3, 3))); scene.Add(CreateNPC(startingPosition + new Vector2(3, -1))); scene.Add(CreateNPC(startingPosition + new Vector2(-5, 3))); scene.Add(CreateNPC(startingPosition + new Vector2(-2, 1))); Vector2 unitGroupStartingPosition = startingPosition + new Vector2(3, 3); for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { scene.Add(CreateNPC(unitGroupStartingPosition + new Vector2(x, y))); } } BulletCreation = (() => { scene.Add(CreateBullet(controlledUnit.Translation + Vector3.UnitZ, bulletSpeed, controlledUnit.MotionObject.Rotation.Angle, bulletAcceleration)); }); foreach (var npc in npcs) npc.Pursue(controlledUnit.MotionObject, 1f); }
public override void Init() { Content.ContentPath = "Data"; StateManager = new Device9StateManager(Device9); Scene.View = this; Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager }; Renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = Renderer, Scene = Scene }; sceneRendererConnector.Initialize(); Scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, AspectRatio = AspectRatio }; Scene.Add(donutEntity = new Entity { MainGraphic = new Graphics.Content.MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Palmtree1.x"), Texture = new TextureFromFile("Models/Props/Palmtree1.png"), World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya } }); Scene.Add(goblinEntity = new Entity { MainGraphic = new Graphics.Content.MetaModel { SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/Brute1.x"), Texture = new Graphics.Content.TextureFromFile("Models/Units/Brute1.png"), World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(4, 4, 0), } }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)Scene.Camera, }; //donutEntity.PlayAnimation("idle1", 1, true, 0); Renderer.Initialize(this); System.Windows.Forms.PropertyGrid p1; System.Windows.Forms.PropertyGrid p2; System.Windows.Forms.Form form1 = new System.Windows.Forms.Form(); System.Windows.Forms.Form form2 = new System.Windows.Forms.Form(); form1.Controls.Add(p1 = new System.Windows.Forms.PropertyGrid { SelectedObject = Renderer.Settings, Dock = System.Windows.Forms.DockStyle.Fill }); form2.Controls.Add(p2 = new System.Windows.Forms.PropertyGrid { SelectedObject = GraphicsDevice.Settings, Dock = System.Windows.Forms.DockStyle.Fill }); form1.Show(); form2.Show(); }
public override void Init() { Content.ContentPath = "Data"; Instance = this; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; sceneQuadtree = new Common.Quadtree<Entity>(0, 0, 100, 100, 10); sbau = new SceneBVHAutoSyncer(scene, sceneQuadtree); //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); heightmap = new Graphics.Software.Texel.R32F[250, 250]; texture = new Graphics.Software.Texture<Graphics.Software.Texel.R32F>(heightmap); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Settings.ShadowQuality = Settings.ShadowQualities.NoShadows; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); scene.Add(ground = new TestGround { Size = new SizeF(100, 100), Heightmap = heightmap, NPieces = new Size(20, 20), Height = 1 }); ground.ConstructPieces(); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera }; }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); Random r = new Random(); heightmap = new Graphics.Software.Texel.R32F[64, 64]; for (int y = 0; y < 64; y++) for (int x = 0; x < 64; x++) heightmap[y, x] = new Graphics.Software.Texel.R32F((float)r.NextDouble()); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); SizeF patches = new SizeF(20, 20); SizeF patchSize = new SizeF(1f / 20f, 1f / 20f); SizeF groundSize = new SizeF(100, 100); for(int y=0; y < patches.Height; y++) for (int x = 0; x < patches.Width; x++) scene.Add(e = new Entity { MainGraphic = new MetaModel { XMesh = new MeshConcretize { MeshDescription = new Graphics.Software.Meshes.MeshFromHeightmap { Grid = new Graphics.Software.Meshes.Grid { Position = Vector3.Zero, MeshType = MeshType.Indexed, Size = new Vector2(patchSize.Width * groundSize.Width, patchSize.Height * groundSize.Height), NWidth = (int)((heightmap.GetLength(1) - 1) * patchSize.Width), NHeight = (int)((heightmap.GetLength(0) - 1) * patchSize.Height), UVMin = new Vector2(0, 0), UVMax = new Vector2(1, 1) }, Height = 5, Heightmap = heightmap, Rectangle = new RectangleF(x * patchSize.Width, y * patchSize.Height, patchSize.Width, patchSize.Height), PointSample = true }, Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile("Models/GroundTextures/Grass1.png") }, Translation = new Vector3(x * groundSize.Width/patches.Width, y*groundSize.Height/patches.Height, 0), VisibilityLocalBounding = Vector3.Zero }); }