public override void _Ready() { GD.Print(ConfigManager.BASE_CONFIG_FILE_DIRECTORY_PATH); GD.Print(ConfigManager.BASE_DIRECTORY); GD.Print(ConfigManager.BASE_CONFIG_FILE_PATH); VisualServer.SetDebugGenerateWireframes(true); gameController = (GameController)FindParent("GameController"); ray = (RayCast)gameController.FindNode("Picker"); camera = (Camera)FindNode("Camera"); fps = (Label)camera.FindNode("FPS"); position = (Label)camera.FindNode("Position"); chunks = (Label)camera.FindNode("Chunks"); vertices = (Label)camera.FindNode("Vertices"); memory = (Label)camera.FindNode("Memory"); speed = (Label)camera.FindNode("Movement Speed"); initialRotation = new Vector3(); picker = gameController.GetPicker(); Input.SetMouseMode(Input.MouseMode.Captured); TerraVector3 origin = Converter.ConvertVector(GlobalTransform.origin); TerraBasis basis = Converter.ConvertBasis(GlobalTransform.basis); marker = new LoadMarker(origin, basis); gameController.Prepare(camera, marker); }
public override void ChangePosition(TerraVector3 origin, TerraBasis basis) { this.origin = origin; this.basis = basis; foreman.Release(); }
public bool Equals(TerraVector3 origin, TerraBasis basis) { return(origin == this.origin && basis.matrix[0] == this.basis.matrix[0] && basis.matrix[1] == this.basis.matrix[1] && basis.matrix[2] == this.basis.matrix[2]); }
public static TerraBasis ConvertBasis(Basis godotBasis) { TerraBasis basis = TerraBasis.InitEmpty(); basis.matrix[0] = new TerraVector3(godotBasis[0].x, godotBasis[0].y, godotBasis[0].z); basis.matrix[1] = new TerraVector3(godotBasis[1].x, godotBasis[1].y, godotBasis[1].z); basis.matrix[2] = new TerraVector3(godotBasis[2].x, godotBasis[2].y, godotBasis[2].z); return(basis); }
public override void _Input(InputEvent @event) { if (Input.IsActionPressed("toggle_mouse_capture")) { Input.SetMouseMode(Input.GetMouseMode() == Input.MouseMode.Captured ? Input.MouseMode.Visible : Input.MouseMode.Captured); } else if (Input.IsActionPressed("toggle_wireframe_mode")) { if (wireframe) { GetViewport().DebugDraw = Viewport.DebugDrawEnum.Wireframe; } else { GetViewport().DebugDraw = Viewport.DebugDrawEnum.Disabled; } wireframe = !wireframe; } else if (Input.IsActionPressed("ui_cancel")) { gameController.Clear(); GetTree().Quit(); } else if (@event is InputEventMouseMotion eventKey) { if (Input.GetMouseMode() == Input.MouseMode.Captured) { Vector3 rotation = new Vector3( (float)Math.Max(Math.Min(Rotation.x - eventKey.Relative.y * MOUSE_SENSITIVITY, Math.PI / 2), -Math.PI / 2), Rotation.y - eventKey.Relative.x * MOUSE_SENSITIVITY, Rotation.z); TerraBasis basis = new TerraBasis(Converter.ConvertVector(rotation)); marker.basis = basis; Rotation = rotation; } } else if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed && eventMouseButton.ButtonIndex == 1) { Vector3 from = camera.ProjectRayOrigin(eventMouseButton.Position); Vector3 to = camera.ProjectRayNormal(eventMouseButton.Position) * RAY_LENGHT; GD.Print(to); ray.Translation = from; ray.CastTo = to; ray.Enabled = true; } }
public TerraBasis(TerraVector3 euler) { matrix = new TerraVector3[3]; float c, s; c = (float)Math.Cos(euler.x); s = (float)Math.Sin(euler.x); TerraBasis xmat = new TerraBasis(1.0f, 0.0f, 0.0f, 0.0f, c, -s, 0.0f, s, c); c = (float)Math.Cos(euler.y); s = (float)Math.Sin(euler.y); TerraBasis ymat = new TerraBasis(c, 0.0f, s, 0.0f, 1.0f, 0.0f, -s, 0.0f, c); c = (float)Math.Cos(euler.z); s = (float)Math.Sin(euler.z); TerraBasis zmat = new TerraBasis(c, -s, 0.0f, s, c, 0.0f, 0.0f, 0.0f, 1.0f); //optimizer will optimize away all this anyway this = ymat * xmat * zmat; }
public override void Rotate(TerraBasis basis) { this.basis = this.basis * basis; foreman.Release(); }
public LoadMarker() { this.origin = new TerraVector3(); this.basis = TerraBasis.InitEmpty(); }
public LoadMarker(int x, int y, int z) { this.origin = new TerraVector3(x, y, z); this.basis = TerraBasis.InitEmpty(); }
public LoadMarker(TerraVector3 origin) { this.origin = origin; this.basis = TerraBasis.InitEmpty(); }
public LoadMarker(TerraVector3 origin, TerraBasis basis) { this.origin = origin; this.basis = basis; }
public abstract void ChangePosition(TerraVector3 origin, TerraBasis basis);
public abstract void Rotate(TerraBasis change);