public UPSCoordinates(CoordinateType.Enum coordinateType, char hemisphere, double easting, double northing) { this.coordinateType = coordinateType; this.hemisphere = hemisphere; this.easting = easting; this.northing = northing; }
public UPSCoordinates(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; this.hemisphere = 'N'; this.easting = 0; this.northing = 0; }
public GeodeticCoordinates(CoordinateType.Enum coordinateType, double longitude, double latitude, double height) { this.coordinateType = coordinateType; this.longitude = longitude; this.latitude = latitude; this.height = height; }
public MGRSorUSNGCoordinates(CoordinateType.Enum coordinateType, string warningMessage, string MGRSString, Precision.Enum precision) { this.coordinateType = coordinateType; this.precision = precision; this.MGRSString = MGRSString; this.warningMessage = warningMessage; }
public MapProjectionCoordinates(CoordinateType.Enum coordinateType, string warningMessage, double easting, double northing) { this.coordinateType = coordinateType; this.easting = easting; this.northing = northing; this.warningMessage = warningMessage; }
public void ChangeCoordinateState(int x, int y, CoordinateType state) { if (x <= 0 || x > COLS || y <= 0 || y > ROWS) throw new ArgumentException ("Illegal coordinates"); Coordinate itm =Coordinate(x, y); itm.Type = state; }
/// <summary> /// ファイルからMMDモーションを読み込む /// </summary> /// <param name="filename">MMDモーションファイル</param> /// <param name="coordinate">変換先座標系</param> /// <returns>MMDモーションオブジェクト</returns> /// <param name="scale">スケーリング値</param> public static MMDMotion Read(string filename, CoordinateType coordinate, float scale=1.0f) { //フルパス取得 filename = Path.GetFullPath(filename); //ファイルチェック if (!File.Exists(filename)) throw new FileNotFoundException("MMDモーションファイル:" + filename + "が見つかりません"); //戻り値用変数 MMDMotion result = null; //ファイルリーダー using (FileStream fs = new FileStream(filename, FileMode.Open)) { BinaryReader reader = new BinaryReader(fs); //マジック文字列 string magic = MMDMotion2.GetString(reader.ReadBytes(30)); if (magic.Substring(0, 20) != "Vocaloid Motion Data") throw new FileLoadException("MMDモーションファイルではありません"); //バージョン int version = Convert.ToInt32(magic.Substring(21)); if (version == 2) result = new MMDMotion2(); else throw new FileLoadException("version=" + version.ToString() + "モデルは対応していません"); result.Read(reader, coordinate,scale); if (fs.Length != fs.Position) Console.WriteLine("警告:ファイル末尾以降に不明データ?"); fs.Close(); } return result; }
public List<Coordinate> GetValidPositions(CoordinateType player) { CoordinateType Opponent = player == CoordinateType.Black ? CoordinateType.White : CoordinateType.Black; List<Coordinate> retval = new List<Coordinate>(); List<Coordinate> PlayerPieces = PlayerMarkers(player); int CurrX; int CurrY; bool FoundOpponent = false; PlayerPieces.ForEach(item => { foreach(BoardDirection d in _directions) { CurrX = item.X + d.X; CurrY = item.Y + d.Y; FoundOpponent = false; while (GetCoordinateState(CurrX , CurrY ) == Opponent) { FoundOpponent = true; CurrX += d.X; CurrY += d.Y; } if (FoundOpponent && GetCoordinateState(CurrX , CurrY ) == CoordinateType.Empty) { retval.Add(Coordinate(CurrX, CurrY)); } } }); return retval; }
public GeodeticCoordinates(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; this.longitude = 0.0; this.latitude = 0.0; this.height = 0.0; }
public UPSCoordinates(CoordinateType.Enum coordinateType, string warningMessage, char hemisphere, double easting, double northing) { this.coordinateType = coordinateType; this.hemisphere = hemisphere; this.easting = easting; this.northing = northing; this.warningMessage = warningMessage; }
/// <summary> /// Generates a pan action. If one sets the coordinate type to world both, new and old d, have to be that type /// </summary> /// <param name="oldD"></param> /// <param name="d"></param> /// <param name="scale"></param> /// <param name="mapPanel"></param> /// <param name="coordinatType"></param> public PanAction(PointD oldD, PointD newD, double scale, MapPanel mapPanel, CoordinateType coordinatType) { this.cType = coordinatType; this.oldD = oldD; this.d = newD; this.scale = scale; this.mapPanel = mapPanel; }
public GeodeticCoordinates(CoordinateType.Enum coordinateType, string warningMessage, double longitude, double latitude, double height) { this.coordinateType = coordinateType; this.longitude = longitude; this.latitude = latitude; this.height = height; this.warningMessage = warningMessage; }
public PolarStereographicStandardParallelParameters(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; this.centralMeridian = 0; this.standardParallel = 0; this.falseEasting = 0; this.falseNorthing = 0; }
public PolarStereographicStandardParallelParameters(CoordinateType.Enum coordinateType, double centralMeridian, double standardParallel, double falseEasting, double falseNorthing) { this.coordinateType = coordinateType; this.centralMeridian = centralMeridian; this.standardParallel = standardParallel; this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; }
public MapProjection5Parameters(CoordinateType.Enum coordinateType, double centralMeridian, double originLatitude, double scaleFactor, double falseEasting, double falseNorthing) { this.coordinateType = coordinateType; this.centralMeridian = centralMeridian; this.originLatitude = originLatitude; this.scaleFactor = scaleFactor; this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; }
public PolarStereographicScaleFactorParameters(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; this.centralMeridian = 0; this.scaleFactor = 0; this.hemisphere = 'N'; this.falseEasting = 0; this.falseNorthing = 0; }
public PolarStereographicScaleFactorParameters(CoordinateType.Enum coordinateType, double centralMeridian, double scaleFactor, char hemisphere, double falseEasting, double falseNorthing) { this.coordinateType = coordinateType; this.centralMeridian = centralMeridian; this.scaleFactor = scaleFactor; this.hemisphere = hemisphere; this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; }
public MapProjection5Parameters(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; this.centralMeridian = 0; this.originLatitude = 0; this.scaleFactor = 1.0; this.falseEasting = 0; this.falseNorthing = 0; }
/// <summary> /// Convert a list of points to closed well known text polygon. /// </summary> /// <param name="zone"></param> /// <param name="type"></param> /// <returns></returns> public static string ConvertPointsToWkt(this List<System.Windows.Point> zone, CoordinateType type) { var sb = new StringBuilder("'POLYGON(("); foreach (var p in zone.Select(pt => CoordinateUtils.ConvertCoordinateFromXY(pt.ToPoint(), type))) { sb.AppendFormat(CultureInfo.InvariantCulture, "{0} {1},", p.X, p.Y); } var p0 = CoordinateUtils.ConvertCoordinateFromXY(zone[0].ToPoint(), type); sb.AppendFormat(CultureInfo.InvariantCulture, "{0} {1}))'", p0.X, p0.Y); // close the ring return sb.ToString(); }
public GeoTagCoordinate(CoordinateType type) { CoordType = type; if (CoordType == CoordinateType.LATITUDE) { direction = 'S'; } else { direction = 'N'; } Coord = null; Decimal = null; }
public CoordinateFormattingOptions(CoordinateType coordType, string formatOption) { InitializeComponent(); FormatSpecifier = formatOption; this.CoordinateType = coordType; if (formatOption.Equals(SupportService.COORD_FORMAT_DECIMAL_DEGREES)) { optDecDeg.IsChecked = true; } else if (formatOption.Equals(SupportService.COORD_FORMAT_DEGREES_DECIMAL_MINUTES)) { optDegDecM.IsChecked = true; } else { optDMS.IsChecked = true; } this.Title = string.Format("Format {0} options", coordType.ToString()); UpdatePreview(); }
/// <summary> /// Gets the coordinate label. /// </summary> /// <returns></returns> public static string GetCoordinateLabel (CoordinateType pCoordinateType, CoordinateUtils.CoordinateDirection pCoordinateDirection) { switch (pCoordinateType) { // Latitude-longitude. case CoordinateType.Degreeminutesecond: switch (pCoordinateDirection) { case CoordinateUtils.CoordinateDirection.NorthSouth: return CoordinateTypes.COORDINATE_LABEL_DEGREEMINUTESECOND_NS; case CoordinateUtils.CoordinateDirection.WestEast: return CoordinateTypes.COORDINATE_LABEL_DEGREEMINUTESECOND_WE; default: return CoordinateTypes.COORDINATE_LABEL_UNKNOWN; } case CoordinateType.Degrees: switch (pCoordinateDirection) { case CoordinateUtils.CoordinateDirection.NorthSouth: return CoordinateTypes.COORDINATE_LABEL_DEGREES_NS; case CoordinateUtils.CoordinateDirection.WestEast: return CoordinateTypes.COORDINATE_LABEL_DEGREES_WE; default: return CoordinateTypes.COORDINATE_LABEL_UNKNOWN; } case CoordinateType.Rd: switch (pCoordinateDirection) { case CoordinateUtils.CoordinateDirection.NorthSouth: return CoordinateTypes.COORDINATE_LABEL_RD_NS; case CoordinateUtils.CoordinateDirection.WestEast: return CoordinateTypes.COORDINATE_LABEL_RD_WE; default: return CoordinateTypes.COORDINATE_LABEL_UNKNOWN; } case CoordinateType.Xy: switch (pCoordinateDirection) { case CoordinateUtils.CoordinateDirection.NorthSouth: return CoordinateTypes.COORDINATE_LABEL_XY_NS; case CoordinateUtils.CoordinateDirection.WestEast: return CoordinateTypes.COORDINATE_LABEL_XY_WE; default: return CoordinateTypes.COORDINATE_LABEL_UNKNOWN; } default: return CoordinateTypes.COORDINATE_LABEL_UNKNOWN; } }
/// <summary> /// ファイルからMMDモデルを読み込む /// </summary> /// <param name="filename">MMDモデルファイル</param> /// <param name="coordinate">変換先座標系</param> /// <param name="scale">スケーリング値</param> /// <returns>MMDモデルオブジェクト</returns> /// <remarks>MMDの座標系は右手座標系です</remarks> public static MMDModel Read(string filename, CoordinateType coordinate, float scale=1f) { //フルパス取得 filename = Path.GetFullPath(filename); //ファイルチェック if (!File.Exists(filename)) throw new FileNotFoundException("MMDモデルファイル:" + filename + "が見つかりません"); //戻り値用変数 MMDModel result = null; //ファイルリーダー using (FileStream fs = new FileStream(filename, FileMode.Open)) { BinaryReader reader = new BinaryReader(fs); //マジック文字列 string magic = MMDModel1.encoder.GetString(reader.ReadBytes(3)); if (magic != "Pmd") throw new FileLoadException("MMDモデルファイルではありません"); //バージョン float version = BitConverter.ToSingle(reader.ReadBytes(4), 0); if (OriginalObjects.ContainsKey(version) && OriginalObjects[version].BaseType == typeof(MMDModel)) {//このバージョンで使用し、利用可能型 result = (MMDModel)OriginalObjects[version].InvokeMember(null, System.Reflection.BindingFlags.CreateInstance, null, null, null); } else { if (version == 1.0) result = new MMDModel1(); else throw new FileLoadException("version=" + version.ToString() + "モデルは対応していません"); } result.Read(reader, coordinate, scale); if (fs.Length != fs.Position) Console.WriteLine("警告:ファイル末尾以降に不明データ?"); fs.Close(); } return result; }
//methods... /// <summary> /// Read関数 /// </summary> /// <remarks>この関数はMotionManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が読まれた状態で渡される</remarks> /// <param name="reader">ヘッダ読み込み済みのBinaryReader</param> /// <param name="coordinate">変換先座標系</param> /// <param name="scale">スケーリング値</param> public void Read(BinaryReader reader, CoordinateType coordinate, float scale) { Coordinate = coordinate;//座標系セット //モデル名読み込み ModelName = GetString(reader.ReadBytes(20)); //ボーンモーションデータ読み込み DWORD motion_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); Motions = new MotionData[motion_count]; for (long i = 0; i < Motions.LongLength; i++) { Motions[i] = new MotionData(); Motions[i].Read(reader, CoordZ, scale); } //フェイスモーションデータ読み込み DWORD face_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); FaceMotions = new FaceMotionData[face_count]; for (long i = 0; i < FaceMotions.LongLength; i++) { FaceMotions[i] = new FaceMotionData(); FaceMotions[i].Read(reader); } //カメラモーション読み込み DWORD camera_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); CameraMotions = new CameraMotionData[camera_count]; for (long i = 0; i < CameraMotions.LongLength; i++) { CameraMotions[i] = new CameraMotionData(); CameraMotions[i].Read(reader, CoordZ); } //ライトモーション読み込み DWORD light_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); LightMotions = new LightMotionData[light_count]; for (long i = 0; i < LightMotions.LongLength; i++) { LightMotions[i] = new LightMotionData(); LightMotions[i].Read(reader, CoordZ); } }
/// <summary> /// Formats the coordinate according to current setting. /// </summary> /// <param name = "pCoordinateType">Type of the coordinate.</param> /// <param name = "pLatitude">The latitude in degrees.</param> /// <param name = "pLongitude">The longitude in degrees.</param> /// <param name = "pWestEastValue">The west east value in the specified format.</param> /// <param name = "pNorthSouthValue">The north south value in the specified format.</param> public static void CoordinateToString (CoordinateType pCoordinateType, double pLatitude, double pLongitude, out string pWestEastValue, out string pNorthSouthValue) { switch (pCoordinateType) { // Latitude-longitude. case CoordinateType.Degrees: pWestEastValue = string.Format("{0:0.00000}", pLongitude); pNorthSouthValue = string.Format("{0:0.00000}", pLatitude); break; case CoordinateType.Degreeminutesecond: pWestEastValue = DecimalDegreestoDegreeMinuteSecond(pLongitude, CoordinateDirection.WestEast); pNorthSouthValue = DecimalDegreestoDegreeMinuteSecond(pLatitude, CoordinateDirection.NorthSouth); break; case CoordinateType.Xy: var point = LatLonDegreesToXYPoint(pLatitude, pLongitude); pWestEastValue = string.Format("{0:0.00000}", point.X); pNorthSouthValue = string.Format("{0:0.00000}", point.Y); break; // Rijksdriehoek. case CoordinateType.Rd: double x; double y; LonLat2Rd(pLongitude, pLatitude, out x, out y); pWestEastValue = string.Format("{0:0}", x); pNorthSouthValue = string.Format("{0:0}", y); break; default: pWestEastValue = string.Format("{0:0.00000}", pLongitude); pNorthSouthValue = string.Format("{0:0.00000}", pLatitude); break; } }
private Tuple <double, double> GetMaxMinCoordForInfo(List <Point3D> obstacles, CoordinateType coordinateType) { Tuple <double, double> coords = new Tuple <double, double>(-1, -1); switch (coordinateType) { case CoordinateType.X: { double minX = GetMinCoord(obstacles.Select(coord => coord.X).ToList(), MaxMinType.Min); double maxX = GetMinCoord(obstacles.Select(coord => coord.X).ToList(), MaxMinType.Max); coords = new Tuple <double, double>(minX, maxX); break; } case CoordinateType.Y: { double minY = GetMinCoord(obstacles.Select(coord => coord.Y).ToList(), MaxMinType.Min); double maxY = GetMinCoord(obstacles.Select(coord => coord.Y).ToList(), MaxMinType.Max); coords = new Tuple <double, double>(minY, maxY); break; } case CoordinateType.Z: { double minZ = GetMinCoord(obstacles.Select(coord => coord.Z).ToList(), MaxMinType.Min); double maxZ = GetMinCoord(obstacles.Select(coord => coord.Z).ToList(), MaxMinType.Max); coords = new Tuple <double, double>(minZ, maxZ); break; } } return(coords); }
public void setCoordinateType(CoordinateType.Enum coordinateType) { this.coordinateType = coordinateType; }
public CoordinateTuple(CoordinateType.Enum coordinateType, string warningMessage) { this.coordinateType = coordinateType; this.errorMessage = ""; this.warningMessage = warningMessage; }
protected internal void Draw(object texture, Vector2 position, Vector2 size, Vector2 center, float rotationSine, float rotationCosine, Vector2 texCoords, Vector2 texCoordsSize, Color4 color, CoordinateType coordinateType) { if (texture == null) { return; } size.X = Math.Abs(size.X); size.Y = Math.Abs(size.Y); // Difference vectors from the center to the texture edges (in screen coordinates). Vector2 left, up, right, down; if (coordinateType == CoordinateType.UNorm) { left = new Vector2(0 - center.X * size.X, 0); up = new Vector2(0, 0 - center.Y * size.Y); right = new Vector2((1 - center.X) * size.X, 0); down = new Vector2(0, (1 - center.Y) * size.Y); } else if (coordinateType == CoordinateType.SNorm) { left = new Vector2((-1 - center.X) * size.X / 2, 0); up = new Vector2(0, (1 - center.Y) * size.Y / 2); right = new Vector2((1 - center.X) * size.X / 2, 0); down = new Vector2(0, (-1 - center.Y) * size.Y / 2); } else { left = new Vector2(-center.X, 0); up = new Vector2(0, -center.Y); right = new Vector2(size.X - center.X, 0); down = new Vector2(0, size.Y - center.Y); } if (rotationSine != 0 || rotationCosine != 0) { if (coordinateType != CoordinateType.Absolute && coordinateType != CoordinateType.Relative) { // Normalized coordinates tend to be skewed when applying rotation throw new ArgumentException("Rotation is only allowed for relative or absolute coordinates"); } left = Rotate(left, rotationSine, rotationCosine); right = Rotate(right, rotationSine, rotationCosine); up = Rotate(up, rotationSine, rotationCosine); down = Rotate(down, rotationSine, rotationCosine); } var data = new VerticeSpriteSpecific { TexCoord = texCoords, TexCoordSize = texCoordsSize, Color = color.ToArgb(), TopLeft = ConvertCoordinate(position + up + left, coordinateType), TopRight = ConvertCoordinate(position + up + right, coordinateType), BottomLeft = ConvertCoordinate(position + down + left, coordinateType), BottomRight = ConvertCoordinate(position + down + right, coordinateType) }; if (AllowReorder) { // Is there already a sprite for this texture? var addNew = false; lock (_textureSprites) { if (_textureSprites.ContainsKey(texture)) { // Add the sprite to the last segment for this texture var segment = _textureSprites[texture].Last(); AddIn(segment, data); } else { // Add a new segment for this texture addNew = true; } } if (addNew) { AddNew(texture, data); } } else { // Add a new segment for this texture AddNew(texture, data); } }
public bool BuildCor(short num, CoordinateType interpolationAxisType) { throw new NotImplementedException(); }
public StringMetrics DrawString(string text, Vector2 position, float angle, float realFontSize, Color4 color, CoordinateType coordinateType) { IterateStringEm(text, position, angle, true, realFontSize, color, coordinateType, out var sm); return(sm); }
public StringMetrics MeasureString(string text, float angle, float realFontSize, CoordinateType coordinateType) { IterateStringEm(text, Vector2.Zero, angle, false, realFontSize, new Color4(), coordinateType, out var sm); return(sm); }
/// <summary> /// Draws a complete texture on the screen. /// </summary> /// <param name="texture">The shader resource view of the texture to draw</param> /// <param name="position">Position of the top left corner of the texture in the chosen coordinate system</param> /// <param name="size">Size of the texture in the chosen coordinate system. The size is specified in the screen's coordinate system.</param> /// <param name="coordinateType">A custom coordinate system in which to draw the texture</param> protected internal void Draw(object texture, Vector2 position, Vector2 size, CoordinateType coordinateType) { Draw(texture, position, size, Vector2.Zero, 0, coordinateType); }
private void IterateStringEm(string text, Vector2 position, float angle, bool draw, float realFontSize, Color4 color, CoordinateType coordinateType, out StringMetrics metrics) { var scale = realFontSize / FontSize; IterateString(text, position, angle, draw, scale, color, coordinateType, out metrics); }
private void IterateString(string text, Vector2 position, float angle, bool draw, float scale, Color4 color, CoordinateType coordinateType, out StringMetrics metrics) { metrics = new StringMetrics(); float scalY = coordinateType == CoordinateType.SNorm ? -1 : 1; var visualText = NBidi.NBidi.LogicalToVisual(text); var codePoints = Helpers.ConvertToCodePointArray(visualText); float sine, cosine; if (angle != 0f) { sine = (float)Math.Sin(angle); cosine = (float)Math.Cos(angle); } else { sine = cosine = 0f; } var x = 0f; var y = Lazier.Create(() => Math.Abs(GetCharDescription('M').CharSize.Y *scale *scalY)); for (var i = 0; i < codePoints.Length; i++) { var c = codePoints[i]; var charDesc = GetCharDescription(c); var charMetrics = charDesc.ToStringMetrics(position, scale, scale * scalY); metrics.Merge(charMetrics); if (c != '\r' && c != '\n') { if (draw) { var h = charMetrics.FullRectSize.Y; if (h != 0 && charMetrics.FullRectSize.X != 0) { var fix = new Vector2(-charMetrics.OverhangLeft, -scalY * charMetrics.OverhangTop); if (angle != 0f) { fix = SpriteRenderer.Rotate(fix, sine, cosine); } Sprite.Draw(charDesc.TableDescription.Srv, position + fix, charMetrics.FullRectSize, Vector2.Zero, sine, cosine, charDesc.TexCoordsStart, charDesc.TexCoordsSize, color, coordinateType); } } } var delta = new Vector2(charMetrics.Size.X + KerningAdjustment, 0f); switch (c) { case '\n': delta.Y += y.Value; goto case '\r'; case '\r': delta.X = -x; x = 0f; break; default: x += delta.X; break; } if (angle != 0f) { delta = SpriteRenderer.Rotate(delta, sine, cosine); } position += delta; } }
public bool ArcMove(short num, short AxisX, short AxisY, short AxisZ, double dAcc, double dDec, double dSpeed, double posX, double posY, double dR, short iCCW, CoordinateType interpolationAxisType) { throw new NotImplementedException(); }
public override IEnumerable <DataObject> ProcessInternal(ClientBase client, ResponseContainer container) { HtmlDocument doc = container.ResponseHtml.Value; HtmlNode message = doc.DocumentNode.SelectSingleNode("//div[@class='detail_msg']"); if (message == null) { yield break; } OGameClient oClient = (OGameClient)client; // Message info int messageId = message.GetAttributeValue("data-msg-id", 0); MessageTabType tabType = MessageTabType.FleetsEspionage; string dateText = message.SelectSingleNode(".//span[contains(@class, 'msg_date')]").InnerText; DateTime date = DateTime.ParseExact(dateText, "dd.MM.yyyy HH:mm:ss", oClient.ServerCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime(); EspionageReport result = new EspionageReport { MessageId = messageId, TabType = tabType, Sent = new DateTimeOffset(date).Add(-oClient.Settings.ServerUtcOffset).ToOffset(oClient.Settings.ServerUtcOffset) }; // Establish location HtmlNode locationLink = message.SelectSingleNode(".//a[contains(@href, 'page=galaxy')]"); // This might happen for a destroyed planet if (locationLink == null) { yield break; } string locationType = locationLink.SelectSingleNode("./figure").GetCssClasses(s => s == "moon" || s == "planet").First(); CoordinateType coordinateType = locationType == "moon" ? CoordinateType.Moon : CoordinateType.Planet; result.Coordinate = Coordinate.Parse(locationLink.InnerText, coordinateType); // Activity string activityText = message.SelectSingleNode(".//div[@class='detail_txt']/div/font[@color='red']")?.InnerText; if (activityText != null) { result.Activity = int.Parse(activityText); } // Parts HtmlNodeCollection partsNodesList = message.SelectNodes(".//ul[@data-type and not(./li[@class='detail_list_fail'])]"); Dictionary <string, HtmlNode> partsNodes = partsNodesList.ToDictionary(s => s.GetAttributeValue("data-type", "")); // Parts - Resources HtmlNode details; if (partsNodes.TryGetValue("resources", out details)) { HtmlNodeCollection values = details.SelectNodes(".//span[@class='res_value']"); Debug.Assert(values.Count == 4); var oneThousandAdd = oClient.ServerCulture.NumberFormat.NumberGroupSeparator + "000"; string[] vals = values.Select(s => s.InnerText .Replace("Mn", oneThousandAdd) .Replace("Bn", oneThousandAdd + oneThousandAdd)).ToArray(); // When val = 9.82Mn, the string from above will result in 9.82.000, which will end up being parsed to 982000 // This ensures that the second group is always 3 characters long for (var i = 0; i < vals.Length; ++i) { var groups = vals[i].Split('.'); if (groups.Length == 3) { groups[1] = groups[1].PadRight(3, '0'); } vals[i] = string.Join(oClient.ServerCulture.NumberFormat.NumberGroupSeparator, groups); } Resources resources = new Resources { Metal = int.Parse(vals[0], NumberStyles.AllowThousands | NumberStyles.Integer, oClient.ServerCulture), Crystal = int.Parse(vals[1], NumberStyles.AllowThousands | NumberStyles.Integer, oClient.ServerCulture), Deuterium = int.Parse(vals[2], NumberStyles.AllowThousands | NumberStyles.Integer, oClient.ServerCulture), Energy = int.Parse(vals[3], NumberStyles.AllowThousands | NumberStyles.Integer, oClient.ServerCulture) }; result.Resources = resources; result.Details |= ReportDetails.Resources; } // Parts - Ships if (partsNodes.TryGetValue("ships", out details)) { result.DetectedShips = ParseList <ShipType>(oClient, details); result.Details |= ReportDetails.Ships; } // Parts - Defense if (partsNodes.TryGetValue("defense", out details)) { result.DetectedDefence = ParseList <DefenceType>(oClient, details); result.Details |= ReportDetails.Defense; } // Parts - Buildings if (partsNodes.TryGetValue("buildings", out details)) { result.DetectedBuildings = ParseList <BuildingType>(oClient, details); result.Details |= ReportDetails.Buildings; } // Parts - Research if (partsNodes.TryGetValue("research", out details)) { result.DetectedResearch = ParseList <ResearchType>(oClient, details); result.Details |= ReportDetails.Research; } // Return yield return(result); }
public static string GetFormattedCoord(CoordinateType cType, string coord, string format) { if (cType == CoordinateType.DD) { CoordinateDD dd; if (CoordinateDD.TryParse(coord, out dd)) { return(dd.ToString(format, new CoordinateDDFormatter())); } } if (cType == CoordinateType.DDM) { CoordinateDDM ddm; if (CoordinateDDM.TryParse(coord, out ddm)) { return(ddm.ToString(format, new CoordinateDDMFormatter())); } } if (cType == CoordinateType.DMS) { CoordinateDMS dms; if (CoordinateDMS.TryParse(coord, out dms)) { return(dms.ToString(format, new CoordinateDMSFormatter())); } } if (cType == CoordinateType.GARS) { CoordinateGARS gars; if (CoordinateGARS.TryParse(coord, out gars)) { return(gars.ToString(format, new CoordinateGARSFormatter())); } } if (cType == CoordinateType.MGRS) { CoordinateMGRS mgrs; if (CoordinateMGRS.TryParse(coord, out mgrs)) { return(mgrs.ToString(format, new CoordinateMGRSFormatter())); } } if (cType == CoordinateType.USNG) { CoordinateUSNG usng; if (CoordinateUSNG.TryParse(coord, out usng)) { return(usng.ToString(format, new CoordinateMGRSFormatter())); } } if (cType == CoordinateType.UTM) { CoordinateUTM utm; if (CoordinateUTM.TryParse(coord, out utm)) { return(utm.ToString(format, new CoordinateUTMFormatter())); } } return(null); }
/// <summary> /// Draws a complete texture on the screen. /// </summary> /// <param name="texture">The shader resource view of the texture to draw</param> /// <param name="position">Position of the top left corner of the texture in the chosen coordinate system</param> /// <param name="size">Size of the texture in the chosen coordinate system. The size is specified in the screen's coordinate system.</param> /// <param name="center">Specify the texture's center in the chosen coordinate system. The center is specified in the texture's local coordinate system. E.g. for <paramref name="coordinateType"/>=CoordinateType.SNorm, the texture's center is defined by (0, 0).</param> /// <param name="rotationAngle">The angle in radians to rotate the texture. Positive values mean counter-clockwise rotation. Rotations can only be applied for relative or absolute coordinates. Consider using the Degrees or Radians helper structs.</param> /// <param name="coordinateType">A custom coordinate system in which to draw the texture</param> /// <param name="color">The color with which to multiply the texture</param> protected internal void Draw(object texture, Vector2 position, Vector2 size, Vector2 center, double rotationAngle, Color4 color, CoordinateType coordinateType) { Draw(texture, position, size, center, rotationAngle, Vector2.Zero, new Vector2(1, 1), color, coordinateType); }
private void MouseMoveTarget( ModelPanel panel, MouseEventArgs e, float depth, ModelPanelViewport v, Matrix transformMatrix, Matrix invTransformMatrix, SelectionParams selection) { if (ControlType == TransformType.None) { return; } CoordinateType coord = _coordinateTypes[(int)ControlType]; //Get the location of the bone Vector3 center = transformMatrix.GetPoint(); //Standard radius scaling snippet. This is used for orb scaling depending on camera distance. float radius = CamDistance(center, v); bool snapFound = false; if (ControlType == TransformType.Rotation) { //Get point projected onto our orb. Vector3 point = v.ProjectCameraSphere(new Vector2(e.X, e.Y), center, radius, false); //Get the distance of the mouse point from the bone float distance = point.TrueDistance(center); if (Math.Abs(distance - radius) < radius * _selectOrbScale) //Point lies within orb radius { selection._hiSphere = true; //Determine axis snapping Vector3 angles = (invTransformMatrix * point).GetAngles() * Maths._rad2degf; angles._x = Math.Abs(angles._x); angles._y = Math.Abs(angles._y); angles._z = Math.Abs(angles._z); if (Math.Abs(angles._y - 90.0f) <= _axisSnapRange) { selection._hiX = true; } else if (angles._x >= 180.0f - _axisSnapRange || angles._x <= _axisSnapRange) { selection._hiY = true; } else if (angles._y >= 180.0f - _axisSnapRange || angles._y <= _axisSnapRange) { selection._hiZ = true; } } else if (Math.Abs(distance - radius * _circOrbScale) < radius * _selectOrbScale ) //Point lies on circ line { selection._hiCirc = true; } if (selection._hiX || selection._hiY || selection._hiZ || selection._hiCirc) { snapFound = true; } } else if (ControlType == TransformType.Translation || ControlType == TransformType.Scale) { //No more need to use depth!!! Just some nice math if (_coordinateTypes[(int)ControlType] == CoordinateType.World) { transformMatrix = Matrix.TranslationMatrix(center) * Matrix.ScaleMatrix(transformMatrix.GetScale()); } Vector3[] planePoints = new Vector3[3]; //xy, yz, xz v.ProjectCameraPlanes(new Vector2(e.X, e.Y), transformMatrix, out planePoints[0], out planePoints[1], out planePoints[2]); List <Vector3> testDiffs = new List <Vector3>(); foreach (Vector3 planePoint in planePoints) { Vector3 d = coord == CoordinateType.World ? (planePoint - center) / radius : coord == CoordinateType.Local ? invTransformMatrix * planePoint / radius : (panel.Camera._matrix * planePoint - panel.Camera._matrix * center) / radius; if (d._x > -_axisSelectRange && d._x < _axisLDist + 0.01f && d._y > -_axisSelectRange && d._y < _axisLDist + 0.01f && d._z > -_axisSelectRange && d._z < _axisLDist + 0.01f) { testDiffs.Add(d); } } //Check if point lies on a specific axis foreach (Vector3 diff in testDiffs) { float errorRange = _axisSelectRange; if (diff._x > _axisHalfLDist && Math.Abs(diff._y) < errorRange && Math.Abs(diff._z) < errorRange) { selection._hiX = true; } if (diff._y > _axisHalfLDist && Math.Abs(diff._x) < errorRange && Math.Abs(diff._z) < errorRange) { selection._hiY = true; } if (diff._z > _axisHalfLDist && Math.Abs(diff._x) < errorRange && Math.Abs(diff._y) < errorRange) { selection._hiZ = true; } if (snapFound = selection._hiX || selection._hiY || selection._hiZ) { break; } } if (!snapFound) { foreach (Vector3 diff in testDiffs) { if (ControlType == TransformType.Translation) { if (diff._x < _axisHalfLDist && diff._y < _axisHalfLDist && diff._z < _axisHalfLDist) { //Point lies inside the double drag areas if (diff._x > _axisSelectRange) { selection._hiX = true; } if (diff._y > _axisSelectRange) { selection._hiY = true; } if (diff._z > _axisSelectRange) { selection._hiZ = true; } selection._hiCirc = !selection._hiX && !selection._hiY && !selection._hiZ; snapFound = true; } } else if (ControlType == TransformType.Scale) { //Determine if the point is in the double or triple drag triangles float halfDist = _scaleHalf2LDist; float centerDist = _scaleHalf1LDist; if (diff.IsInTriangle(new Vector3(), new Vector3(halfDist, 0, 0), new Vector3(0, halfDist, 0))) { if (diff.IsInTriangle(new Vector3(), new Vector3(centerDist, 0, 0), new Vector3(0, centerDist, 0))) { selection._hiX = selection._hiY = selection._hiZ = true; } else { selection._hiX = selection._hiY = true; } } else if (diff.IsInTriangle(new Vector3(), new Vector3(halfDist, 0, 0), new Vector3(0, 0, halfDist))) { if (diff.IsInTriangle(new Vector3(), new Vector3(centerDist, 0, 0), new Vector3(0, 0, centerDist))) { selection._hiX = selection._hiY = selection._hiZ = true; } else { selection._hiX = selection._hiZ = true; } } else if (diff.IsInTriangle(new Vector3(), new Vector3(0, halfDist, 0), new Vector3(0, 0, halfDist))) { if (diff.IsInTriangle(new Vector3(), new Vector3(0, centerDist, 0), new Vector3(0, 0, centerDist))) { selection._hiX = selection._hiY = selection._hiZ = true; } else { selection._hiY = selection._hiZ = true; } } snapFound = selection._hiX || selection._hiY || selection._hiZ; } if (snapFound) { break; } } } } if (snapFound) { panel.Cursor = Cursors.Hand; panel.Invalidate(); } }
/// <summary> /// Without changing the feature type or anything else, simply update the local coordinates /// to include the new coordinates. All the new coordinates will be considered one part. /// Since point and multi-point shapes don't have parts, they will just be appended to the /// original part. /// </summary> public void AddPart(IEnumerable<Coordinate> coordinates, CoordinateType coordType) { bool hasM = (coordType == CoordinateType.M || coordType == CoordinateType.Z); bool hasZ = (coordType == CoordinateType.Z); List<double> vertices = new List<double>(); List<double> z = new List<double>(); List<double> m = new List<double>(); int numPoints = 0; int oldNumPoints = (_vertices != null) ? _vertices.Length / 2 : 0; foreach (Coordinate coordinate in coordinates) { if (_shapeRange.Extent == null) _shapeRange.Extent = new Extent(); _shapeRange.Extent.ExpandToInclude(coordinate.X, coordinate.Y); vertices.Add(coordinate.X); vertices.Add(coordinate.Y); if (hasM) m.Add(coordinate.M); if (hasZ) z.Add(coordinate.Z); numPoints++; } // Using public accessor also updates individual part references Vertices = (_vertices != null) ? _vertices.Concat(vertices).ToArray() : vertices.ToArray(); if (hasZ) _z = (_z != null) ? _z.Concat(z).ToArray() : z.ToArray(); if (hasM) _m = (_m != null) ? _m.Concat(m).ToArray() : m.ToArray(); if (_shapeRange.FeatureType == FeatureType.MultiPoint || _shapeRange.FeatureType == FeatureType.Point) { // Only one part exists _shapeRange.Parts[0].NumVertices += numPoints; } else { PartRange part = new PartRange(_vertices, _shapeRange.StartIndex, oldNumPoints, _shapeRange.FeatureType); part.NumVertices = numPoints; _shapeRange.Parts.Add(part); } }
private Vector3 GetLocalTransform( MouseEventArgs e, ModelPanelViewport viewport, Matrix localTransform, Matrix invLocalTransform, Matrix localParentTransform, SelectionParams selection, out Vector3?worldPoint) { worldPoint = null; if (GetTransformPoint(new Vector2(e.X, e.Y), out Vector3 point, viewport, localTransform, selection)) { Vector3 transform = new Vector3(), lPoint; CoordinateType coord = _coordinateTypes[(int)ControlType]; switch (ControlType) { case TransformType.Rotation: lPoint = invLocalTransform * point; if (selection._lastPointLocal == lPoint) { return(new Vector3()); } //Get matrix with new rotation applied Matrix m = localParentTransform * Matrix.AxisAngleMatrix(selection._lastPointLocal, lPoint); //Derive angles from matrices, get difference transform = (m.GetAngles() - localParentTransform.GetAngles()).RemappedToRange(-180.0f, 180.0f); break; case TransformType.Translation: case TransformType.Scale: if (ControlType == TransformType.Scale && selection._snapX && selection._snapY && selection._snapZ) { //Get scale factor //TODO: calculate with distance between screen points instead transform = new Vector3((point / selection._lastPointWorld)._y); break; } lPoint = invLocalTransform * point; if (selection._lastPointLocal == lPoint) { return(new Vector3()); } if (!(ControlType == TransformType.Translation && selection._snapCirc)) { switch (coord) { case CoordinateType.World: //Limit world point with snaps if (!selection._snapX) { point._x = selection._lastPointWorld._x; } if (!selection._snapY) { point._y = selection._lastPointWorld._y; } if (!selection._snapZ) { point._z = selection._lastPointWorld._z; } //Remake local point with edited world point lPoint = invLocalTransform * point; break; case CoordinateType.Local: //Limit local point with snaps if (!selection._snapX) { lPoint._x = selection._lastPointLocal._x; } if (!selection._snapY) { lPoint._y = selection._lastPointLocal._y; } if (!selection._snapZ) { lPoint._z = selection._lastPointLocal._z; } break; case CoordinateType.Screen: break; } } if (ControlType == TransformType.Scale) { transform = localParentTransform * lPoint / (localParentTransform * selection._lastPointLocal); } else { transform = localParentTransform * lPoint - localParentTransform * selection._lastPointLocal; } break; } worldPoint = point; selection._lastPointWorld = point; return(transform); } return(new Vector3()); }
public void set(CoordinateType.Enum coordinateType, string warningMessage, string errorMessage) { this.coordinateType = coordinateType; this.warningMessage = warningMessage; this.errorMessage = errorMessage; }
/// <summary> /// Draws a complete texture on the screen. /// </summary> /// <param name="texture">The shader resource view of the texture to draw</param> /// <param name="position">Position of the top left corner of the texture in the chosen coordinate system</param> /// <param name="size">Size of the texture in the chosen coordinate system. The size is specified in the screen's coordinate system.</param> /// <param name="coordinateType">A custom coordinate system in which to draw the texture</param> /// <param name="color">The color with which to multiply the texture</param> public void Draw(ShaderResourceView texture, Vector2 position, Vector2 size, Color4 color, CoordinateType coordinateType) { base.Draw(texture, position.ToSTRVector(), size.ToSTRVector(), color.ToSTRColor(), coordinateType); }
public static void Read(BinaryReader reader, CoordinateType coordinate) { _coordinate = coordinate; _header = new ModelHeader(); _header.Read(reader); //Read Vertices UInt32 num_vertex = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _vertices = new ModelVertex[num_vertex]; for (UInt32 i = 0; i < num_vertex; i++) { _vertices[i] = new ModelVertex(); _vertices[i].Read(reader, CoordZ); } //Read Primitives UInt32 face_vert_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _faceIndices = new UInt16[face_vert_count]; for (UInt32 i = 0; i < face_vert_count; i++) _faceIndices[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0); //Read Materials UInt32 material_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _materials = new ModelMaterial[material_count]; for (UInt32 i = 0; i < material_count; i++) { _materials[i] = new ModelMaterial(); _materials[i].Read(reader); } //Read Bones UInt16 bone_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0); _bones = new ModelBone[bone_count]; for (UInt16 i = 0; i < bone_count; i++) { _bones[i] = new ModelBone(); _bones[i].Read(reader, CoordZ); } //Read IK Bones UInt16 ik_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0); _IKs = new ModelIK[ik_count]; for (UInt16 i = 0; i < ik_count; i++) { _IKs[i] = new ModelIK(); _IKs[i].Read(reader); } //Read Face Morphs UInt16 skin_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0); _skins = new ModelSkin[skin_count]; for (UInt16 i = 0; i < skin_count; i++) { _skins[i] = new ModelSkin(); _skins[i].Read(reader, CoordZ); } //Read face morph indices byte skin_disp_count = reader.ReadByte(); _skinIndex = new UInt16[skin_disp_count]; for (byte i = 0; i < _skinIndex.Length; i++) _skinIndex[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0); //Read bone morph names byte bone_disp_name_count = reader.ReadByte(); _boneDispNames = new ModelBoneDispName[bone_disp_name_count]; for (byte i = 0; i < _boneDispNames.Length; i++) { _boneDispNames[i] = new ModelBoneDispName(); _boneDispNames[i].Read(reader); } //Read bone morphs UInt32 bone_disp_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _boneDisps = new ModelBoneDisp[bone_disp_count]; for (UInt32 i = 0; i < _boneDisps.Length; i++) { _boneDisps[i] = new ModelBoneDisp(); _boneDisps[i].Read(reader); } //Read English strings, if there are any. try { _expansion = (reader.ReadByte() != 0); if (_expansion) { _header.ReadExpansion(reader); for (UInt16 i = 0; i < bone_count; i++) { _bones[i].ReadExpansion(reader); } for (UInt16 i = 0; i < skin_count; i++) { if (_skins[i]._skinType != 0) _skins[i].ReadExpansion(reader); } for (byte i = 0; i < _boneDispNames.Length; i++) { _boneDispNames[i].ReadExpansion(reader); } if (reader.BaseStream.Position >= reader.BaseStream.Length) _toonExpansion = false; else { _toonExpansion = true; _toonFileNames = new string[_numToonFileName]; for (int i = 0; i < _toonFileNames.Length; i++) { _toonFileNames[i] = GetString(reader.ReadBytes(100)); } } if (reader.BaseStream.Position >= reader.BaseStream.Length) _physicsExpansion = false; else { _physicsExpansion = true; UInt32 rididbody_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _rigidBodies = new ModelRigidBody[rididbody_count]; for (UInt32 i = 0; i < rididbody_count; i++) { _rigidBodies[i] = new ModelRigidBody(); _rigidBodies[i].ReadExpansion(reader, CoordZ); } UInt32 joint_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0); _joints = new ModelJoint[joint_count]; for (UInt32 i = 0; i < joint_count; i++) { _joints[i] = new ModelJoint(); _joints[i].ReadExpansion(reader, CoordZ); } } } } catch { Console.WriteLine("This file does not contain English strings."); } }
/// <summary> /// Draws a complete texture on the screen. /// </summary> /// <param name="texture">The shader resource view of the texture to draw</param> /// <param name="position">Position of the top left corner of the texture in the chosen coordinate system</param> /// <param name="size">Size of the texture in the chosen coordinate system. The size is specified in the screen's coordinate system.</param> /// <param name="center">Specify the texture's center in the chosen coordinate system. The center is specified in the texture's local coordinate system. E.g. for <paramref name="coordinateType"/>=CoordinateType.SNorm, the texture's center is defined by (0, 0).</param> /// <param name="rotationAngle">The angle in radians to rotate the texture. Positive values mean counter-clockwise rotation. Rotations can only be applied for relative or absolute coordinates. Consider using the Degrees or Radians helper structs.</param> /// <param name="coordinateType">A custom coordinate system in which to draw the texture</param> public void Draw(ShaderResourceView texture, Vector2 position, Vector2 size, Vector2 center, double rotationAngle, CoordinateType coordinateType) { base.Draw(texture, position.ToSTRVector(), size.ToSTRVector(), center.ToSTRVector(), rotationAngle, coordinateType); }
/// <summary> /// Draws a region of a texture on the screen. /// </summary> /// <param name="texture">The shader resource view of the texture to draw</param> /// <param name="position">Position of the center of the texture in the chosen coordinate system</param> /// <param name="size">Size of the texture in the chosen coordinate system. The size is specified in the screen's coordinate system.</param> /// <param name="coordinateType">A custom coordinate system in which to draw the texture</param> /// <param name="color">The color with which to multiply the texture</param> /// <param name="texCoords">Texture coordinates for the top left corner</param> /// <param name="texCoordsSize">Size of the region in texture coordinates</param> public void Draw(ShaderResourceView texture, Vector2 position, Vector2 size, Vector2 texCoords, Vector2 texCoordsSize, Color4 color, CoordinateType coordinateType) { Draw(texture, position, size, Vector2.Zero, 0, texCoords, texCoordsSize, color, coordinateType); }
public static double ToCoordinates(this string inputString, string cardinalDirection, CoordinateType coordinateType) { if (string.IsNullOrEmpty(inputString)) { return(0.0d); } var degreeCharacters = coordinateType == CoordinateType.Latitude ? 2 : 3; var degree = inputString.Substring(0, degreeCharacters).ToDouble(); degree += inputString.Substring(degreeCharacters).ToDouble() / 60; if (!double.IsNaN(degree) && (cardinalDirection == "S" || cardinalDirection == "W")) { degree *= -1; } return(degree); }