private int findLeaf() { ICameraComponent camera = (ICameraComponent)Game.Services.GetService(typeof(ICameraComponent)); int index = 0; while (index >= 0) { node node = file.Nodes[index]; plane plane = file.Planes[node.Plane]; //dist double distance = Vector3.Dot(V3FromFloatArray(plane.Normal), Swizzle(camera.Position)) - plane.Dist; if (distance >= 0) { index = node.Children[0]; } else { index = node.Children[node.Children.Count() - 1]; } } return(-index - 1); }
/// <inheritdoc /> public ICameraComponent?GetComponent(string name) { for (int c = 0; c < _components.Count; c++) { ICameraComponent controller = _components[c]; if (controller.Name == name) { return(controller); } } return(null); }
public void Enable(MovingType type) { _currentMoving?.Disable(); switch (type) { case MovingType.Charmode: _charmodeMoving.Enable(); _currentMoving = _charmodeMoving; break; case MovingType.Panorama: _panoramaMoving.Enable(); _currentMoving = _panoramaMoving; break; case MovingType.Orbital: _orbitalMoving.Enable(); _currentMoving = _orbitalMoving; break; } }
/// <inheritdoc /> public bool AddComponent(ICameraComponent component) { if (!_components.Contains(component)) { if (_isInitialized) { // ReSharper disable once SuspiciousTypeConversion.Global if (component is IInitializableCameraComponent c) { c.Initialize(_registry !, this); } } _components.Add(component); if (component is IUpdateableCameraComponent updateableCameraComponent) { _updateableCameraComponents.Add(updateableCameraComponent); } return(true); } return(false); }
public override void Draw(GameTime gameTime) { GraphicsDevice device = Game.GraphicsDevice; RasterizerState rs = new RasterizerState(); rs.CullMode = CullMode.CullCounterClockwiseFace; if (!WireFrame) { rs.FillMode = FillMode.Solid; effect.EnableDefaultLighting(); } else { rs.FillMode = FillMode.WireFrame; effect.LightingEnabled = false; } device.RasterizerState = rs; ICameraComponent camera = (ICameraComponent)Game.Services.GetService(typeof(ICameraComponent)); effect.World = Matrix.Identity; effect.View = camera.ViewMatrix; effect.Projection = camera.ProjectionMatrix; effect.TextureEnabled = true; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { GraphicsDevice.SetVertexBuffer(VBuffer); int lastOffset = 0; for (int i = 0; i < textureLengths.Count(); i++) { if ((textureLengths[i] - lastOffset) > 0) { string textureName = "textures/Quake3/" + file.Textures[i].Name.Substring(9); if (_textures.ContainsKey(textureName)) { effect.Texture = _textures[textureName]; } else { effect.Texture = Game.Content.Load <Texture2D>("textures/devgrid"); } pass.Apply(); device.Indices = IBuffer; device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, IBuffer.IndexCount, lastOffset, (textureLengths[i] - lastOffset) / 3); lastOffset = textureLengths[i]; } } GraphicsDevice.SetVertexBuffer(BeziersVertices); if (BeziersVertices != null) { lastOffset = 0; for (int i = 0; i < BezierstextureLengths.Count(); i++) { if ((BezierstextureLengths[i] - lastOffset) > 0) { string textureName = "textures/Quake3/" + file.Textures[i].Name.Substring(9); if (_textures.ContainsKey(textureName)) { effect.Texture = _textures[textureName]; } else { effect.Texture = Game.Content.Load <Texture2D>("textures/devgrid"); } pass.Apply(); device.Indices = BeziersIndex; device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, BeziersIndex.IndexCount, lastOffset, (BezierstextureLengths[i] - lastOffset) / 3); lastOffset = BezierstextureLengths[i]; } } } } base.Draw(gameTime); }