public override void OnEnter() { base.OnEnter(); oldInputHandler = view.StateInputHandler; editor1 = new Graphics.Editors.GroundTextureEditor { Camera = view.Scene.Camera, GroundIntersect = view.GroundProbe, SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>[] { new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>( TextureUtil.ReadTexture <Graphics.Software.Texel.A8R8G8B8>(MainWindow.Instance.CurrentMap.Ground.SplatMap1.Resource9, 0)), new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>( TextureUtil.ReadTexture <Graphics.Software.Texel.A8R8G8B8>(MainWindow.Instance.CurrentMap.Ground.SplatMap2.Resource9, 0)), }, Texture9 = new SlimDX.Direct3D9.Texture[] { MainWindow.Instance.CurrentMap.Ground.SplatMap1.Resource9, MainWindow.Instance.CurrentMap.Ground.SplatMap2.Resource9 }, Position = MainWindow.Instance.CurrentMap.Ground.Translation, Size = MainWindow.Instance.CurrentMap.Ground.Size, Viewport = view.Viewport }; editor1.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler(editor_TextureValuesChanged); editorRenderer = new Graphics.Editors.GroundTextureEditorRenderer(editor1); editor1.Pencil = settings.Pencil1; view.StateInputHandler = editor1; }
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 static Map.Map ChallengeInaccessibleCleric(SlimDX.Direct3D9.Device device) { var m = Medium(device); Graphics.Editors.GroundTextureEditor e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture <Graphics.Software.Texel.R32F>(m.Ground.Heightmap) }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; e.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler( (o, args) => m.Ground.UpdatePieceMeshes(args.ChangedRegion)); e.Draw(new Vector2(22, 22), new Graphics.Editors.GroundTexturePencil { Radius = 7, Color = new Vector4(-1, 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }); e.Draw(new Vector2(22, 22), new Graphics.Editors.GroundTexturePencil { Radius = 5, Color = new Vector4(1, 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }); for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = new SlimDX.Vector3(25 + x * 2, 25 + y * 2, 0), State = Map.UnitState.Alive }); } } m.DynamicsRoot.AddChild(new Map.Units.Cleric { Translation = new SlimDX.Vector3(20, 20, 0) }); foreach (var u in m.DynamicsRoot.Offspring) { if (u is Map.Unit) { u.Translation = m.Ground.GetHeight(u.Translation) + Vector3.UnitZ * 0.1f; } } return(m); }
public override void OnEnter() { base.OnEnter(); oldInputHandler = view.StateInputHandler; editor = new Graphics.Editors.GroundTextureEditor { Camera = view.Scene.Camera, GroundIntersect = view.GroundProbe, SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture <Graphics.Software.Texel.R32F>( MainWindow.Instance.CurrentMap.Ground.Heightmap) }, Position = MainWindow.Instance.CurrentMap.Ground.Translation, Size = MainWindow.Instance.CurrentMap.Ground.Size, Viewport = view.Viewport }; editor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler(editor_TextureValuesChanged); editorRenderer = new Graphics.Editors.GroundTextureEditorRenderer(editor); InputHandler = editor; view.StateInputHandler = this; editor.Pencil = pencil; }
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; 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(); }
static Map.Map Random(SlimDX.Direct3D9.Device device, System.Drawing.SizeF size, int nHeightIncs, int nSplatDraws, int nProps) { var m = Map.Map.New(new Client.Game.Map.MapSettings { Size = size }, device); m.MainCharacter.Position = new SlimDX.Vector3(m.Settings.Size.Width/2f, m.Settings.Size.Height/2f, 0); Random r = new Random(); // Heightmap Graphics.Editors.GroundTextureEditor e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture<Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture<Graphics.Software.Texel.R32F>(m.Ground.Heightmap) }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; e.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler( (o, args) => m.Ground.UpdatePieceMeshes(args.ChangedRegion)); for (int i = 0; i < nHeightIncs; i++) { var p = new Graphics.Editors.GroundTexturePencil { Radius = 1 + (float)(r.NextDouble()*10), Color = new SlimDX.Vector4((float)(r.NextDouble() * 2 - 1), 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }; e.Draw( new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height)), p); } // Splatmap e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>[] { new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>( Graphics.TextureUtil.ReadTexture<Graphics.Software.Texel.A8R8G8B8>(m.Ground.SplatMap1.Resource9, 0)) }, Texture9 = new SlimDX.Direct3D9.Texture[] { m.Ground.SplatMap1.Resource9 }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; for (int i = 0; i < nSplatDraws; i++) { SlimDX.Vector4 v = Vector4.Zero; float d = (float)r.NextDouble(); switch (r.Next(5)) { case 0: v = new Vector4(d, -d, -d, -d); break; case 1: v = new Vector4(-d, d, -d, -d); break; case 2: v = new Vector4(-d, -d, d, -d); break; case 3: v = new Vector4(-d, -d, -d, d); break; case 4: v = new Vector4(-d, -d, -d, -d); break; } var p = new Graphics.Editors.GroundTexturePencil { Radius = 1 + (float)(r.NextDouble() * 10), Color = v, Type = Graphics.Editors.GroundTexturePencilType.AddSaturate }; e.Draw( new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height)), p); } // Props List<Type> propTypes = new List<Type>(); foreach (var v in typeof(Map.Props.Prop).Assembly.GetTypes()) if (typeof(Map.Props.Prop).IsAssignableFrom(v)) propTypes.Add(v); propTypes.Remove(typeof(Map.Props.Prop)); for (int i = 0; i < nProps; i++) { var p = (Map.Props.Prop)Activator.CreateInstance(propTypes[r.Next(propTypes.Count)]); p.Position = new SlimDX.Vector3( (float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height), 0); float rotation = (float)(2 * Math.PI * r.NextDouble()); p.Rotation = Quaternion.RotationAxis(Vector3.UnitZ, rotation); p.Position = m.Ground.GetHeight(p.Position); m.DynamicsRoot.AddChild(p); } m.MainCharacter.Position = m.Ground.GetHeight(m.MainCharacter.Position); return m; }
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 OnEnter() { base.OnEnter(); oldInputHandler = view.StateInputHandler; editor1 = new Graphics.Editors.GroundTextureEditor { Camera = view.Scene.Camera, GroundIntersect = view.GroundProbe, SoftwareTexture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>[] { new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>( TextureUtil.ReadTexture<Graphics.Software.Texel.A8R8G8B8>(MainWindow.Instance.CurrentMap.Ground.SplatMap1.Resource9, 0)), new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>( TextureUtil.ReadTexture<Graphics.Software.Texel.A8R8G8B8>(MainWindow.Instance.CurrentMap.Ground.SplatMap2.Resource9, 0)), }, Texture9 = new SlimDX.Direct3D9.Texture[] { MainWindow.Instance.CurrentMap.Ground.SplatMap1.Resource9, MainWindow.Instance.CurrentMap.Ground.SplatMap2.Resource9 }, Position = MainWindow.Instance.CurrentMap.Ground.Translation, Size = MainWindow.Instance.CurrentMap.Ground.Size, Viewport = view.Viewport }; editor1.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler(editor_TextureValuesChanged); editorRenderer = new Graphics.Editors.GroundTextureEditorRenderer(editor1); editor1.Pencil = settings.Pencil1; view.StateInputHandler = editor1; }
public override void OnEnter() { base.OnEnter(); oldInputHandler = view.StateInputHandler; editor = new Graphics.Editors.GroundTextureEditor { Camera = view.Scene.Camera, GroundIntersect = view.GroundProbe, SoftwareTexture = new Graphics.Software.Texture<Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture<Graphics.Software.Texel.R32F>( MainWindow.Instance.CurrentMap.Ground.Heightmap) }, Position = MainWindow.Instance.CurrentMap.Ground.Translation, Size = MainWindow.Instance.CurrentMap.Ground.Size, Viewport = view.Viewport }; editor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler(editor_TextureValuesChanged); editorRenderer = new Graphics.Editors.GroundTextureEditorRenderer(editor); InputHandler = editor; view.StateInputHandler = this; editor.Pencil = pencil; }
static Map.Map Random(SlimDX.Direct3D9.Device device, System.Drawing.SizeF size, int nHeightIncs, int nSplatDraws, int nProps) { var m = Map.Map.New(new Client.Game.Map.MapSettings { Size = size }, device); m.MainCharacter.Position = new SlimDX.Vector3(m.Settings.Size.Width / 2f, m.Settings.Size.Height / 2f, 0); Random r = new Random(); // Heightmap Graphics.Editors.GroundTextureEditor e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture <Graphics.Software.Texel.R32F>(m.Ground.Heightmap) }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; e.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler( (o, args) => m.Ground.UpdatePieceMeshes(args.ChangedRegion)); for (int i = 0; i < nHeightIncs; i++) { var p = new Graphics.Editors.GroundTexturePencil { Radius = 1 + (float)(r.NextDouble() * 10), Color = new SlimDX.Vector4((float)(r.NextDouble() * 2 - 1), 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }; e.Draw( new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height)), p); } // Splatmap e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>[] { new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>( Graphics.TextureUtil.ReadTexture <Graphics.Software.Texel.A8R8G8B8>(m.Ground.SplatMap1.Resource9, 0)) }, Texture9 = new SlimDX.Direct3D9.Texture[] { m.Ground.SplatMap1.Resource9 }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; for (int i = 0; i < nSplatDraws; i++) { SlimDX.Vector4 v = Vector4.Zero; float d = (float)r.NextDouble(); switch (r.Next(5)) { case 0: v = new Vector4(d, -d, -d, -d); break; case 1: v = new Vector4(-d, d, -d, -d); break; case 2: v = new Vector4(-d, -d, d, -d); break; case 3: v = new Vector4(-d, -d, -d, d); break; case 4: v = new Vector4(-d, -d, -d, -d); break; } var p = new Graphics.Editors.GroundTexturePencil { Radius = 1 + (float)(r.NextDouble() * 10), Color = v, Type = Graphics.Editors.GroundTexturePencilType.AddSaturate }; e.Draw( new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height)), p); } // Props List <Type> propTypes = new List <Type>(); foreach (var v in typeof(Map.Props.Prop).Assembly.GetTypes()) { if (typeof(Map.Props.Prop).IsAssignableFrom(v)) { propTypes.Add(v); } } propTypes.Remove(typeof(Map.Props.Prop)); for (int i = 0; i < nProps; i++) { var p = (Map.Props.Prop)Activator.CreateInstance(propTypes[r.Next(propTypes.Count)]); p.Position = new SlimDX.Vector3( (float)(r.NextDouble() * m.Settings.Size.Width), (float)(r.NextDouble() * m.Settings.Size.Height), 0); float rotation = (float)(2 * Math.PI * r.NextDouble()); p.Rotation = Quaternion.RotationAxis(Vector3.UnitZ, rotation); p.Position = m.Ground.GetHeight(p.Position); m.DynamicsRoot.AddChild(p); } m.MainCharacter.Position = m.Ground.GetHeight(m.MainCharacter.Position); return(m); }
public static Map.Map ChallengeInaccessibleCleric(SlimDX.Direct3D9.Device device) { var m = Medium(device); Graphics.Editors.GroundTextureEditor e = new Graphics.Editors.GroundTextureEditor { Size = m.Settings.Size, SoftwareTexture = new Graphics.Software.Texture<Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture<Graphics.Software.Texel.R32F>(m.Ground.Heightmap) }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new SlimDX.Vector4(1, 0, 0, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.Add } }; e.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler( (o, args) => m.Ground.UpdatePieceMeshes(args.ChangedRegion)); e.Draw(new Vector2(22, 22), new Graphics.Editors.GroundTexturePencil { Radius = 7, Color = new Vector4(-1, 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }); e.Draw(new Vector2(22, 22), new Graphics.Editors.GroundTexturePencil { Radius = 5, Color = new Vector4(1, 0, 0, 0), Type = Graphics.Editors.GroundTexturePencilType.Add }); for (int y = 0; y < 5; y++) for (int x = 0; x < 5; x++) m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = new SlimDX.Vector3(25 + x * 2, 25 + y * 2, 0), State = Map.UnitState.Alive }); m.DynamicsRoot.AddChild(new Map.Units.Cleric { Translation = new SlimDX.Vector3(20, 20, 0) }); foreach (var u in m.DynamicsRoot.Offspring) if (u is Map.Unit) u.Translation = m.Ground.GetHeight(u.Translation) + Vector3.UnitZ * 0.1f; return m; }
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; 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(); }