private void initMover() { tickTotal = 20; tickCount = 0; double centerX = starSystemCollection[targetSystem].x; double centerY = starSystemCollection[targetSystem].y; double centerZ = starSystemCollection[targetSystem].z; double oppositeX = (starSystemCollection[targetSystem].x - starSystemCollection[targetStar].x) * -1; double oppositeY = (starSystemCollection[targetSystem].y - starSystemCollection[targetStar].y) * -1; double oppositeZ = (starSystemCollection[targetSystem].z - starSystemCollection[targetStar].z) * -1; inputBox.Text = "XYZ:[" + oppositeX.ToString("F") + "," + oppositeY.ToString("F") + "," + oppositeZ.ToString("F") + "] "; foreach (var systemNames in starSystemCollection.OrderBy(p => p.Value.z)) { double distance = calculateDistance(targetSystem, systemNames.Key,new Point3D(oppositeX, oppositeY, oppositeZ)); if (distance == 0 || (distance >= minDist && distance <= maxDist)) { if (starCollection.FindIndex(p => p.starID == systemNames.Key) == -1) { Star star = new Star(); star.starID = systemNames.Key; star.SetName(systemNames.Value.name); star.X = (centerX - systemNames.Value.x)*zoom; star.Y = (centerY - systemNames.Value.y)*zoom; star.Z = (centerZ - systemNames.Value.z)*zoom; star.originX = systemNames.Value.x; star.originY = systemNames.Value.y; star.originZ = systemNames.Value.z; star.elevation = elevation; star.azimuth = azimuth; star.rotaX = 0; star.rotaY = 0; star.rotaZ = 0; star.moveX = 0; star.moveY = 0; star.moveZ = 0; star.centerX = ProjectionViewCanvas.Width/2; star.centerY = ProjectionViewCanvas.Height/2; star.distance = calculateDistance(star.starID, targetSystem); star.maxDistance = maxDist; star.rendered = false; star.size = 3; star.SetEllipseSize(); star.setColor(); star.SetLabel(); starCollection.Add(star); } } } }
private void wheel_Handler(object sender, MouseWheelEventArgs e) { double divider = currentDist/32; double scroll =divider ;//16/maxDist; delta = (e.Delta/(120*0.25)); currentDist = maxDist; maxDist -= delta; if (maxDist < 4) { maxDist = 4; delta = 0; } else if (maxDist > 80) { maxDist = 80; delta = 0; } if (maxDist >= 32) {minDist = maxDist - 32;} else if (maxDist >= 64) { minDist = maxDist - 16;} zoom = (64 / maxDist) * 7.5; double targetX = starSystemCollection[targetSystem].x; double targetY = starSystemCollection[targetSystem].y; double targetZ = starSystemCollection[targetSystem].z; if (currentDist > maxDist) { var find = starCollection.FindAll(p => p.distance > maxDist); foreach (var item in find) { int index = starCollection.FindIndex(p => p.distance == item.distance); parkCollection.Add(starCollection[index]); starCollection.RemoveAt(index); } foreach (var star in starCollection) { star.X = (targetX - star.originX) * zoom; star.Y = (targetY - star.originY) * zoom; star.Z = (targetZ - star.originZ) * zoom; star.maxDistance = maxDist; star.SetEllipseSize(); star.setColor(); star.SetLabel(); } } else if (currentDist < maxDist) { if (parkCollection.Count == 0) { int count = 0; foreach (var systemNames in starSystemCollection.OrderBy(p => p.Value.z)) { double distance = calculateDistance(targetSystem, systemNames.Key); if (distance >= currentDist && distance <= maxDist) { count += 1; Star star = new Star(); star.starID = systemNames.Key; star.SetName(systemNames.Value.name); star.X = (targetX - systemNames.Value.x) * zoom; star.Y = (targetY - systemNames.Value.y) * zoom; star.Z = (targetZ - systemNames.Value.z) * zoom; star.originX = systemNames.Value.x; star.originY = systemNames.Value.y; star.originZ = systemNames.Value.z; star.rotaX = 0; star.rotaY = 0; star.rotaZ = 0; star.centerX = ProjectionViewCanvas.Width / 2; star.centerY = ProjectionViewCanvas.Height / 2; star.distance = distance; star.maxDistance = maxDist; star.rendered = false; star.size = 12; star.SetEllipseSize(); parkCollection.Add(star); } } } var find = parkCollection.FindAll(p => p.distance > minDist && p.distance < maxDist); foreach (var item in find) { int index = parkCollection.FindIndex(p => p.distance == item.distance); starCollection.Add(parkCollection[index]); parkCollection.RemoveAt(index); } foreach (var star in starCollection) { star.X = (targetX - star.originX) * zoom; star.Y = (targetY - star.originY) * zoom; star.Z = (targetZ - star.originZ) * zoom; star.maxDistance = maxDist; star.SetEllipseSize(); star.setColor(); star.SetLabel(); } } tb.Text = "[" + targetSystem + "] " + starSystemCollection[targetSystem].name + " : (" + targetX.ToString("F") + "," + targetY.ToString("F") + "," + targetZ.ToString("F") + ") " + " zoom: " + maxDist.ToString("F") + "LY" + "\ttotal:" + starCollection.Count+" - "+parkCollection.Count; }
private void findTargetSystem(int target,double maxDist=-1) { targetSystem = target; starCollection.Clear(); parkCollection.Clear(); double targetX = starSystemCollection[target].x; double targetY = starSystemCollection[target].y; double targetZ = starSystemCollection[target].z; int counter = 0; currentDist = 64; minDist = 0; if (maxDist < 0) { maxDist = 64; } zoom = (64 / maxDist) * 7.5; foreach (var systemNames in starSystemCollection.OrderBy(p => p.Value.z)) { double distance = calculateDistance(target, systemNames.Key); if (distance == 0 || (distance>=minDist && distance <= maxDist)) { Star star = new Star(); star.starID = systemNames.Key; star.SetName(systemNames.Value.name); star.X = (targetX - systemNames.Value.x) * zoom; star.Y = (targetY - systemNames.Value.y) * zoom; star.Z = (targetZ - systemNames.Value.z) * zoom; star.originX = systemNames.Value.x; star.originY = systemNames.Value.y; star.originZ = systemNames.Value.z; star.rotaX = 0; star.rotaY = 0; star.rotaZ = 0; star.moveX = 0; star.moveY = 0; star.moveZ = 0; star.centerX = ProjectionViewCanvas.Width/2; star.centerY = ProjectionViewCanvas.Height/2; star.distance = distance; star.maxDistance = maxDist; star.rendered = false; star.size = 12; star.SetEllipseSize(); starCollection.Add(star); counter += 1; } } tb.Text = "[" + target + "] " + starSystemCollection[target].name + " : (" + targetX.ToString("F") + "," + targetY.ToString("F") + "," + targetZ.ToString("F") + ") " + " zoom: " + maxDist + "LY" + "\ttotal:" + counter; timer.Interval = TimeSpan.FromMilliseconds(50); mover.Interval = TimeSpan.FromMilliseconds(50); timer.Start(); xFactor = 0.0; yFactor = 0.0; zFactor = 0.25; }