public override Result Init(int width, int height, bool windowed) { CreateWindow(width, height); Device = CreateDevice(width, height, windowed); if (Device == null) return ResultCode.Failure; Font = new Font(Device, 18, 0, FontWeight.Bold, 1, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.Default | PitchAndFamily.DontCare, "Arial"); _heightmap = new HeightMap(Device, new Point(100, 100), 15.0f); if (_heightmap.LoadFromFile("images/abe.jpg").IsFailure) { Debug.Print("failed to load from file"); Quit(); } _hmRenderer = new HeightMapRenderer(_heightmap, Device); if (_hmRenderer.CreateParticles().IsFailure) { Debug.Print("Failed to create particles"); Quit(); } IsRunning = true; return ResultCode.Success; }
public override Result Init(int width, int height, bool windowed) { CreateWindow(width, height); Device = CreateDevice(width, height, windowed); if (Device == null) return ResultCode.Failure; Font = new Font(Device, 18, 0, FontWeight.Bold, 1, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.Default | PitchAndFamily.DontCare, "Arial"); _heightmap = new HeightMap(Device, new Point(50, 50), 15.0f); _hmRenderer = new HeightMapRenderer(_heightmap, Device) { ShowSelection = true }; _heightmap.Renderer = _hmRenderer; _editor = new HeightMapEditorSelection(_heightmap, _hmRenderer); _hmRenderer.Editor = _editor; if (_hmRenderer.CreateParticles().IsFailure) { Debug.Print("Failed to create particles"); Quit(); } IsRunning = true; return ResultCode.Success; }
public HeightMapExample2() { _heightmap = null; _angle = 0.0f; _size = 10; _amplitude = 5; }
public HeightMapRenderer(HeightMap hm, Device device) { _device = device; _hm = hm; _vb = null; _sprite = new Sprite(device); }
public override Result Init(int width, int height, bool windowed) { CreateWindow(width, height); Device = CreateDevice(width, height, windowed); if (Device == null) return ResultCode.Failure; Font = new Font(Device, 18, 0, FontWeight.Bold, 1, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.Default | PitchAndFamily.DontCare, "Arial"); _heightmap = new HeightMap(Device, new Point(100, 100), 15.0f); if (_heightmap.CreateRandomHeightMap(MathF.Rand(2000), _size / 10.0f, _amplitude / 10.0f, 9).IsFailure) { Debug.Print("Failed to create random heightmap"); Quit(); } _hmRenderer = new HeightMapRenderer(_heightmap, Device); if (_hmRenderer.CreateParticles().IsFailure) { Debug.Print("Failed to create particles"); Quit(); } IsRunning = true; return ResultCode.Success; }
public static HeightMap operator *(HeightMap left, HeightMap right) { var ret = new HeightMap(left._device, left.Size, left.MaxHeight); for (int y = 0; y < left.Size.Y; y++) { for (int x = 0; x < left.Size.X; x++) { var a = left[x + y*left.Size.X]/left.MaxHeight; var b = 1.0f; if (x <= right.Size.X && y <= right.Size.Y) { b = right[x + y*left.Size.X]/right.MaxHeight; } ret[x + y*ret.Size.X] = a*b*left.MaxHeight; } } return ret; }
public HeightMapEditorSelection(HeightMap hm, HeightMapRenderer r) { _selectRect = new Rectangle(hm.Size.X / 2 - 5, hm.Size.Y / 2 - 5, 10, 10); _renderer = r; }