public void Evaluate(int SpreadMax) { this.FOutFrustrum.SliceCount = SpreadMax; this.FOutPlanes.SliceCount = SpreadMax*6; int cnt = 0; for (int i = 0; i < SpreadMax; i++) { Frustrum f = new Frustrum(this.FInView[i], this.FInProjection[i]); this.FOutFrustrum[i] = f; for (int j = 0; j < 6; j++) { this.FOutPlanes[cnt] = new Vector4(f.planes[j].Normal.X, f.planes[j].Normal.Y, f.planes[j].Normal.Z, f.planes[j].D); cnt++; } } }
public void Dispose() { _player = null; _frameCounter = null; _camera = null; _frustrum = null; _skyPlane.ShurDown(); _skyPlane = null; _skyDome.ShutDown(); _skyDome = null; _quadTree?.Shutdown(); _quadTree = null; _foliage?.Dispose(); _foliage = null; _groundModel?.Dispose(); _groundModel = null; _terrain?.Dispose(); _terrain = null; _userInterface?.Dispose(); _userInterface = null; _shaderManager?.Dispose(); _shaderManager = null; _input?.Dispose(); _input = null; _directX?.Dispose(); _directX = null; }
public bool Initialise(Dimension size, IntPtr windowHandle) { var result = true; try { _directX = new DirectX(); result &= _directX.Initialise(size, windowHandle); _input = new Input(); result &= _input.Initialise(size, windowHandle); _shaderManager = new ShaderManager(); result &= _shaderManager.Initialise(_directX, windowHandle); _player = new Player { Position = new Coordinate3D <float>(31.0f, 18.0f, 7.0f), Rotation = new Coordinate3D <float>(11.0f, 23.0f, 0.0f) }; _camera = new Camera(); _camera.SetPosition(new Coordinate3D <float>(0, 0, -10)); _camera.Render(); _camera.RenderBaseViewMatrix(); _frameCounter = new FrameCounter(); _frameCounter.Initialise(); _userInterface = new UserInterface(); result &= _userInterface.Initialise(_directX, size); _terrain = new Terrain(); result &= _terrain.Initialise(_directX.Device, "heightmap01.bmp", "dirt03.bmp"); _groundModel = new Object(); result &= _groundModel.Initialise(_directX.Device, "plane01.txt", "rock015.bmp"); _quadTree = new QuadTree(); result &= _quadTree.Initialise(_terrain, _directX.Device); _foliage = new Foliage(); result &= _foliage.Initialise(_directX.Device, _quadTree, "grass01.bmp", 2500); _frustrum = new Frustrum(); _skyDome = new SkyDome(); result &= _skyDome.Initialise(_directX.Device); _skyPlane = new SkyPlane(); result &= _skyPlane.Initialze(_directX.Device, "cloud001.bmp", "perturb001.bmp"); return(result); } catch (Exception ex) { //Log.WriteToFile(ErrorLevel.Error, "Window.Initialise", ex, true); return(false); } }
private Frustrum FrustrumHitsDoor(Frustrum frustrum, NodeEdge nextDoor) { if (frustrum == null) { return(null); } float highAngle = Vector2.SignedAngle(Vector2.up, frustrum.highEnd - frustrum.highStart); float lowAngle = Vector2.SignedAngle(Vector2.up, frustrum.lowEnd - frustrum.lowStart); Vector2 lowEnd; Vector2 highEnd; var nextFrustrum = GetFrustrum(frustrum.highStart, frustrum.lowStart, nextDoor); if (nextFrustrum == null) { return(null); } if (Vector2.SignedAngle(Vector2.up, nextFrustrum.lowEnd - frustrum.lowEnd) > Vector2.SignedAngle(Vector2.up, nextFrustrum.highEnd - frustrum.highEnd)) { lowEnd = nextFrustrum.highEnd; highEnd = nextFrustrum.lowEnd; } else { highEnd = nextFrustrum.highEnd; lowEnd = nextFrustrum.lowEnd; } float highAngleNext = Vector2.SignedAngle(Vector2.up, highEnd - frustrum.highStart); float lowAngleNext = Vector2.SignedAngle(Vector2.up, lowEnd - frustrum.lowStart);; bool hits = (highAngleNext >= lowAngle && highAngleNext <= highAngle) || (lowAngleNext >= lowAngle && lowAngleNext <= highAngle) || (highAngleNext >= highAngle && lowAngleNext <= lowAngle); Vector2 lowEndNew = lowEnd; Vector2 highEndNew = highEnd; if (highAngleNext < lowAngle || lowAngleNext > highAngle) { return(null); } if (highAngleNext >= lowAngle && highAngleNext <= highAngle) { frustrum.highEnd = GetFrustrum(frustrum.highStart, frustrum.lowStart, nextDoor).highEnd; } else { frustrum.highEnd = highEnd; } if (lowAngleNext >= lowAngle && lowAngleNext <= highAngle) { frustrum.lowEnd = GetFrustrum(frustrum.highStart, frustrum.lowStart, nextDoor).lowEnd; } else { frustrum.lowEnd = lowEnd; } return(frustrum); }