public Armature(int anchor, CapType cap, double botRot, double topRot) { Anchor = anchor; CapType = cap; BottomRotation = botRot; TopRotation = topRot; }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 50, Configuration.FieldSeparator), Id, ExternalAccessionIdentifier?.ToDelimitedString(), AccessionIdentifier?.ToDelimitedString(), ContainerIdentifier?.ToDelimitedString(), PrimaryParentContainerIdentifier?.ToDelimitedString(), EquipmentContainerIdentifier?.ToDelimitedString(), SpecimenSource, RegistrationDateTime.HasValue ? RegistrationDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ContainerStatus?.ToDelimitedString(), CarrierType?.ToDelimitedString(), CarrierIdentifier?.ToDelimitedString(), PositionInCarrier?.ToDelimitedString(), TrayTypeSac?.ToDelimitedString(), TrayIdentifier?.ToDelimitedString(), PositionInTray?.ToDelimitedString(), Location != null ? string.Join(Configuration.FieldRepeatSeparator, Location.Select(x => x.ToDelimitedString())) : null, ContainerHeight.HasValue ? ContainerHeight.Value.ToString(Consts.NumericFormat, culture) : null, ContainerDiameter.HasValue ? ContainerDiameter.Value.ToString(Consts.NumericFormat, culture) : null, BarrierDelta.HasValue ? BarrierDelta.Value.ToString(Consts.NumericFormat, culture) : null, BottomDelta.HasValue ? BottomDelta.Value.ToString(Consts.NumericFormat, culture) : null, ContainerHeightDiameterDeltaUnits?.ToDelimitedString(), ContainerVolume.HasValue ? ContainerVolume.Value.ToString(Consts.NumericFormat, culture) : null, AvailableSpecimenVolume.HasValue ? AvailableSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null, InitialSpecimenVolume.HasValue ? InitialSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null, VolumeUnits?.ToDelimitedString(), SeparatorType?.ToDelimitedString(), CapType?.ToDelimitedString(), Additive != null ? string.Join(Configuration.FieldRepeatSeparator, Additive.Select(x => x.ToDelimitedString())) : null, SpecimenComponent?.ToDelimitedString(), DilutionFactor?.ToDelimitedString(), Treatment?.ToDelimitedString(), Temperature?.ToDelimitedString(), HemolysisIndex.HasValue ? HemolysisIndex.Value.ToString(Consts.NumericFormat, culture) : null, HemolysisIndexUnits?.ToDelimitedString(), LipemiaIndex.HasValue ? LipemiaIndex.Value.ToString(Consts.NumericFormat, culture) : null, LipemiaIndexUnits?.ToDelimitedString(), IcterusIndex.HasValue ? IcterusIndex.Value.ToString(Consts.NumericFormat, culture) : null, IcterusIndexUnits?.ToDelimitedString(), FibrinIndex.HasValue ? FibrinIndex.Value.ToString(Consts.NumericFormat, culture) : null, FibrinIndexUnits?.ToDelimitedString(), SystemInducedContaminants != null ? string.Join(Configuration.FieldRepeatSeparator, SystemInducedContaminants.Select(x => x.ToDelimitedString())) : null, DrugInterference != null ? string.Join(Configuration.FieldRepeatSeparator, DrugInterference.Select(x => x.ToDelimitedString())) : null, ArtificialBlood?.ToDelimitedString(), SpecialHandlingCode != null ? string.Join(Configuration.FieldRepeatSeparator, SpecialHandlingCode.Select(x => x.ToDelimitedString())) : null, OtherEnvironmentalFactors != null ? string.Join(Configuration.FieldRepeatSeparator, OtherEnvironmentalFactors.Select(x => x.ToDelimitedString())) : null, ContainerLength?.ToDelimitedString(), ContainerWidth?.ToDelimitedString(), ContainerForm?.ToDelimitedString(), ContainerMaterial?.ToDelimitedString(), ContainerCommonName?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
private void LoadPreset() { if (!File.Exists(mainPath + "preset.json")) { return; } preset = JsonUtility.FromJson <Preset>(File.ReadAllText(mainPath + "preset.json")); Texture2D loadedTexture, loadedNormal, loadedRgMtAo; if (preset.hatPath != "" && File.Exists(preset.hatPath)) { LoadTextures(preset.hatPath, out loadedTexture, out loadedNormal, out loadedRgMtAo); switch (preset.cap) { case CapType.defaultCap: selectedWindow = SkinEditorWindowShow.Hat; break; case CapType.beanie: selectedWindow = SkinEditorWindowShow.Beanie; break; case CapType.forwardSnapback: selectedWindow = SkinEditorWindowShow.Snapback; break; case CapType.backwardSnapback: selectedWindow = SkinEditorWindowShow.Snapback; break; } updateTexture("Hat", loadedTexture, loadedNormal, loadedRgMtAo); currentCap = preset.cap; ApplyNewHat(); } if (preset.shirtPath != "" && File.Exists(preset.shirtPath)) { LoadTextures(preset.shirtPath, out loadedTexture, out loadedNormal, out loadedRgMtAo); updateTexture(preset.usingHoodie ? "Hoodie" : "Shirt", loadedTexture, loadedNormal, loadedRgMtAo); } if (preset.pantsPath != "" && File.Exists(preset.pantsPath)) { selectedWindow = SkinEditorWindowShow.Pants; LoadTextures(preset.pantsPath, out loadedTexture, out loadedNormal, out loadedRgMtAo); updateTexture("Pants", loadedTexture, loadedNormal, loadedRgMtAo); } if (preset.shoesPath != "" && File.Exists(preset.shoesPath)) { LoadTextures(preset.shoesPath, out loadedTexture, out loadedNormal, out loadedRgMtAo); updateTexture("Shoes", loadedTexture, loadedNormal, loadedRgMtAo); } if (preset.boardPath != "" && File.Exists(preset.boardPath)) { LoadTextures(preset.boardPath, out loadedTexture, out loadedNormal, out loadedRgMtAo); updateTexture("Skateboard", loadedTexture, loadedNormal, loadedRgMtAo); } selectedWindow = SkinEditorWindowShow.MainSelector; }
private void btnTestCap_Click(object sender, EventArgs e) { if (tbIp.Text.Trim() == "") { WinInfoHelper.ShowInfoWindow(this, "IP不能为空!"); return; } if (picBox.Image != null) { picBox.Image.Dispose(); picBox.Image = null; } IPCamera ipcamera = new IPCamera(); ipcamera.IP = tbIp.Text.Trim(); ipcamera.Port = iiPort.Value; ipcamera.User = tbUser.Text.Trim(); ipcamera.Password = tbPwd.Text; CameraModel model = CameraModel.None; Enum.TryParse <CameraModel>((string)cbModel.SelectedItem, out model); ipcamera.Model = model; ipcamera.CapturePort = iiCapPort.Value; CapType captype = CapType.Onvif; Enum.TryParse <CapType>((string)cbCapType.SelectedItem, out captype); ipcamera.CapType = captype; IIPCamera engine = ipcamera.GetEngine(); if (engine != null) { CtrlWaiting waiting = new CtrlWaiting(() => { try { Image image = engine.CaptureImage(); if (image == null) { WinInfoHelper.ShowInfoWindow(this, "截图失败!"); return; } this.Invoke(new Action(() => { picBox.Image = image; })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "截图失败!" + ex.Message); log.Error("截图失败:", ex); } }); waiting.Show(this); } }
public override void WriteXml(XmlWriter writer) { base.WriteXml(writer); writer.WriteAttributeString("LineType", LineType.ToString()); writer.WriteAttributeString("DashType", DashType.ToString()); writer.WriteAttributeString("Type", CapType.ToString()); writer.WriteAttributeDouble("StrokeThickness", StrokeThickness); writer.WriteAttributeString("R", StrokeColor.R.ToString()); writer.WriteAttributeString("G", StrokeColor.G.ToString()); writer.WriteAttributeString("B", StrokeColor.B.ToString()); }
private IEnumerable <Coordinates> GetCapCoordinates(CapType cap, Coordinates position, int thickness) { switch (cap) { case CapType.Round: { return(GetRoundCap(position, thickness)); // Round cap is not working very well, circle tool must be improved } default: return(GetThickShape(new[] { position }, thickness)); } }
public Coordinates[] CreateLine(Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap) { return(CreateLine(new[] { end, start }, thickness, startCap, endCap)); }
internal void CommitConnectionTargetCapType(CapType? oldTargetCapType, CapType? newTargetCapType) { if (this.owner == null) { return; } var compositeCommand = new CompositeCommand("Change Connections Target Cap Type"); foreach (var conn in this.SelectedConnections) { var ensureDifferentConnection = conn; var command = new UndoableDelegateCommand("Change Connection Target Cap Type", p => ensureDifferentConnection.TargetCapType = newTargetCapType.HasValue ? newTargetCapType.Value : CapType.None, p => ensureDifferentConnection.TargetCapType = oldTargetCapType.HasValue ? oldTargetCapType.Value : CapType.None); compositeCommand.AddCommand(command); } this.owner.UndoRedoService.ExecuteCommand(compositeCommand); }
private IEnumerable <Coordinates> CreateLine(Coordinates[] coordinates, int thickness, CapType startCap, CapType endCap) { Coordinates startingCoordinates = coordinates[^ 1];
private static IEnumerable <UIVertex[]> CreateUiVertexsGroup(IList <Vector2> points, float width, Color color, CapType cap, CornerType corner) { var vertex = new UIVertex { color = color }; var queVertexs = new List <UIVertex[]>(); for (var i = 0; i < points.Count - 1; i++) { var vertexs = new List <UIVertex>(); // Pointを定義 Vector2?point0; var point1 = points[i + 0]; var point2 = points[i + 1]; Vector2?point3; if (i - 1 < 0) { point0 = null; } else { point0 = points[i - 1]; } if (i + 2 > points.Count - 1) { point3 = null; } else { point3 = points[i + 2]; } var defaultNormal = (point1 - point2).normalized; var defaultCalcNormal = new Vector2(-defaultNormal.y, defaultNormal.x); { var normal2 = CalcNormal(point1, point2, point3); var normal1 = CalcNormal(point0, point1, point2); var innerProduct1 = Vector2.Dot(defaultCalcNormal, normal1); var innerProduct2 = Vector2.Dot(defaultCalcNormal, normal2); var upPosition1 = defaultNormal - (normal1 + defaultCalcNormal).normalized; var downPosition1 = defaultNormal + (normal1 + defaultCalcNormal).normalized; var upPosition2 = defaultNormal - (normal2 + defaultCalcNormal).normalized; var downPosition2 = defaultNormal + (normal2 + defaultCalcNormal).normalized; var isUp1 = upPosition1.magnitude >= downPosition1.magnitude; var isUp2 = upPosition2.magnitude >= downPosition2.magnitude; var width1 = width / innerProduct1; var width2 = width / innerProduct2; if (!point0.HasValue) { AddCap(point1, point2, defaultNormal, defaultCalcNormal, width, false, cap, vertex, queVertexs); } else { var upPosition = -defaultNormal - (normal1 + defaultCalcNormal).normalized; var downPosition = -defaultNormal + (normal1 + defaultCalcNormal).normalized; var clockwise = upPosition.magnitude >= downPosition.magnitude; AddCorner(point1, point2, defaultNormal, defaultCalcNormal, normal1, width, false, clockwise, corner, vertex, queVertexs); } switch (corner) { case CornerType.Miter: { vertex.position = point1 - normal1 * width1; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point2 - normal2 * width2; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point2 + normal2 * width2; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point1 + normal1 * width1; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); break; } case CornerType.Round: case CornerType.Bevel: { vertex.position = isUp1 ? point1 - defaultCalcNormal * width : point1 - normal1 * width1; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = isUp2 ? point2 - normal2 * width2 : point2 - defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = isUp2 ? point2 + defaultCalcNormal * width : point2 + normal2 * width2; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = isUp1 ? point1 + normal1 * width1 : point1 + defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); break; } default: throw new ArgumentOutOfRangeException(corner.GetType().Name, corner, null); } if (!point3.HasValue) { AddCap(point1, point2, defaultNormal, defaultCalcNormal, width, true, cap, vertex, queVertexs); } else { var upPosition = -defaultNormal - (normal2 + defaultCalcNormal).normalized; var downPosition = -defaultNormal + (normal2 + defaultCalcNormal).normalized; var clockwise = upPosition.magnitude >= downPosition.magnitude; AddCorner(point1, point2, defaultNormal, defaultCalcNormal, normal2, width, true, clockwise, corner, vertex, queVertexs); } } } return(queVertexs.ToArray()); }
/// <summary> /// 端に追加する /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="defaultNormal"></param> /// <param name="defaultCalcNormal"></param> /// <param name="width"></param> /// <param name="isEnd"></param> /// <param name="cap"></param> /// <param name="vertex"></param> /// <param name="queVertexs"></param> private static void AddCap(Vector2 point1, Vector2 point2, Vector2 defaultNormal, Vector2 defaultCalcNormal, float width, bool isEnd, CapType cap, UIVertex vertex, ICollection <UIVertex[]> queVertexs) { var vertexs = new List <UIVertex>(); if (!isEnd) { switch (cap) { case CapType.Butt: break; case CapType.Round: { var upCorner = RotationVector2(defaultNormal, -Mathf.PI / 4); var downCorner = RotationVector2(defaultNormal, Mathf.PI / 4); { vertex.position = point1 + downCorner * width; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point1 + defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point1; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point1 + defaultNormal * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); } { vertex.position = point1 + defaultNormal * width; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point1; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point1 - defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point1 + upCorner * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); } break; } case CapType.Square: { vertex.position = point1 + defaultNormal * width + defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point1 + defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point1 - defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point1 + defaultNormal * width - defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); break; } default: throw new ArgumentOutOfRangeException(cap.GetType().Name, cap, null); } } else { switch (cap) { case CapType.Butt: break; case CapType.Round: { var upCorner = RotationVector2(-defaultNormal, Mathf.PI / 4); var downCorner = RotationVector2(-defaultNormal, -Mathf.PI / 4); { vertex.position = point2 + defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point2 + downCorner * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point2 - defaultNormal * width; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point2; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); } { vertex.position = point2; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point2 - defaultNormal * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point2 + upCorner * width; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point2 - defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); } break; } case CapType.Square: { vertex.position = point2 + defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 0); vertexs.Add(vertex); vertex.position = point2 - defaultNormal * width + defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 0); vertexs.Add(vertex); vertex.position = point2 - defaultNormal * width - defaultCalcNormal * width; vertex.uv0 = new Vector2(1, 1); vertexs.Add(vertex); vertex.position = point2 - defaultCalcNormal * width; vertex.uv0 = new Vector2(0, 1); vertexs.Add(vertex); queVertexs.Add(vertexs.ToArray()); vertexs.Clear(); break; } default: throw new ArgumentOutOfRangeException(cap.GetType().Name, cap, null); } } }
private void DrawStem(Spline spline, float maxThickness, float minThickness, float startTime = 0f, float endTime = 1f, CapType capType = CapType.round) { const int vertexCount = 8; List <Vector3> meshVertices = new List <Vector3>(); List <int> meshTriangles = new List <int>(); //Init mesh to ReDraw Mesh mesh; try { mesh = spline.gameObject.GetComponent <MeshFilter>().mesh; mesh.Clear(); } catch (MissingComponentException e) { throw new MissingComponentException("Mesh Related Component is Missing", e); } int vertexRingCount = (int)Math.Round(spline.Length * (endTime - startTime) / MAX_VERTEXT_DISTANCE); if (vertexRingCount < 2) { vertexRingCount = 2; } float vertexInterval = (endTime - startTime) / vertexRingCount; float thicknessInterval = (maxThickness - minThickness) / vertexRingCount; //for each Vertex Path Generate 8 vertices for a circle for (int i = 0; i <= vertexRingCount; i++) { CurveSample centerSamplePoint = Util.GetSampleAt(spline, startTime + (vertexInterval * i)); float currentThickness = maxThickness - thicknessInterval * i; Vector3[] tempList = GenerateCircleVertices(centerSamplePoint, vertexCount, currentThickness); meshVertices.AddRange(tempList); } //Generate triangles for Quads for (int i = 0; i < vertexRingCount; i++) { int initialPoint = i * vertexCount; int[] tempList = GenerateCircleTriangles(initialPoint, vertexCount); meshTriangles.AddRange(tempList); } //GenerateCap switch (capType) { case CapType.flat: break; case CapType.sharp: break; case CapType.round: //Add Cap Vertices CurveSample endPoint = Util.GetSampleAt(spline, endTime); Vector3 radiusDistanceFromEndPoint = endPoint.tangent * minThickness / 2; Vector3 centerPoint = endPoint.location + radiusDistanceFromEndPoint / 2; float currentThickness = minThickness * (float)Math.Sqrt(3) / 2; Vector3[] tempPointList = GenerateCircleVertices(centerPoint, endPoint.tangent, vertexCount, currentThickness); meshVertices.AddRange(tempPointList); Vector3 lastPoint = endPoint.location + radiusDistanceFromEndPoint; meshVertices.Add(lastPoint); //Add Triangles int initialPoint = (vertexRingCount) * vertexCount; int[] tempTriangleList = GenerateCircleTriangles(initialPoint, vertexCount); meshTriangles.AddRange(tempTriangleList); int[] capTrinangleList = GenerateCapTriangles(meshVertices.Count - 3 - vertexCount, meshVertices.Count - 2, meshVertices.Count - 1); meshTriangles.AddRange(capTrinangleList); break; default: break; } mesh.SetVertices(meshVertices); mesh.SetTriangles(meshTriangles, 0); mesh.RecalculateNormals(); mesh.RecalculateBounds(); }
private void updateTexture(string GearItem, Texture2D texture, Texture2D normal, Texture2D rgmtao) { if (!GearItem.Equals("Skateboard")) { if (!GearItem.Equals("Shirt") && !GearItem.Equals("Hoodie")) { foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals(GearItem)) { if (GearItem == "Shoes") { RemoveTupleFromGear(t); CharacterGear newGear = CreateGear("PAX_1", "Black White Sole", "CharacterCustomization/shoes/PAX_1", GearItem); GameObject newObject = CustomLoadPrefab(Resources.Load <GameObject>(newGear.path), skaterMeshesObject.transform); AddGear(newGear, newObject); GameObject Shoe_L = newObject.transform.Find("Shoe_L").gameObject; GameObject Shoe_R = newObject.transform.Find("Shoe_R").gameObject; if (normal == null) { normal = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shoe_Normal.png"); } if (rgmtao == null) { rgmtao = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shoe_RgMtAo.png"); } SetNewTextures(Shoe_L, texture, normal, rgmtao); SetNewTextures(Shoe_R, texture, normal, rgmtao); break; } else { RemoveTupleFromGear(t); string name = ""; string path = ""; CharacterGear newGear = null; switch (GearItem) { case "Hat": name = "Black"; path = "CharacterCustomization/Hat/PAX_1"; newGear = CreateGear("PAX_1", name, path, GearItem); break; case "Pants": name = "Black"; path = "CharacterCustomization/pants/PAX_1"; newGear = CreateGear("PAX_1", name, path, GearItem); break; } GameObject prefab = Resources.Load <GameObject>(newGear.path); GameObject newObject = CustomLoadPrefab(prefab, skaterMeshesObject.transform); Tuple <Mesh, Texture2D[]> hat = null; if (selectedWindow == SkinEditorWindowShow.Hat) { if (currentCap != CapType.defaultCap) { currentCap = CapType.defaultCap; } hat = GetHatMesh(); } else if (selectedWindow == SkinEditorWindowShow.Beanie) { currentCap = CapType.beanie; hat = GetHatMesh(); } else if (selectedWindow == SkinEditorWindowShow.Snapback) { if (currentCap != CapType.backwardSnapback || currentCap != CapType.forwardSnapback) { currentCap = CapType.forwardSnapback; } hat = GetHatMesh(); } if (hat != null) { newObject.GetComponent <SkinnedMeshRenderer>().sharedMesh = hat.Item1; if (normal == null) { normal = hat.Item2[0]; } if (rgmtao == null) { rgmtao = hat.Item2[1]; } UpdateReplayhat(); } else { if (normal == null) { normal = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Pants_Normal.png"); } if (rgmtao == null) { rgmtao = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Pants_RgMtAo.png"); } } AddGear(newGear, newObject); SetNewTextures(newObject, texture, normal, rgmtao); break; } } } } else { foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals("Hoodie") || t.Item1.categoryName.Equals("Shirt")) { RemoveTupleFromGear(t); string name = GearItem.Equals("Hoodie") ? "Black" : "Black"; string path = GearItem.Equals("Hoodie") ? "CharacterCustomization/Hoodie/PAX_1" : "CharacterCustomization/Shirt/PAX_1"; normal = normal != null ? normal : GearItem.Equals("Hoodie") ? assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Hoodie_Normal.png") : assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shirt_Normal.png"); rgmtao = rgmtao != null ? rgmtao : GearItem.Equals("Hoodie") ? assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Hoodie_RgMtAo.png") : assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shirt_RgMtAo.png"); CharacterGear newGear = CreateGear("PAX_1", name, path, GearItem); GameObject newObject = CustomLoadPrefab(Resources.Load <GameObject>(newGear.path), skaterMeshesObject.transform); AddGear(newGear, newObject); SetNewTextures(newObject, texture, normal, rgmtao); Traverse.Create(characterCustomizer).Method("UpdateBodyMesh").GetValue(); break; } } } } else { foreach (Transform t in board.GetComponentsInChildren <Transform>()) { if (SkateboardMaterials.Contains(t.name)) { Renderer r = t.GetComponent <Renderer>(); if (r != null) { if (t.name.Equals(SkateboardMaterials[0])) { UnityEngine.Object.Destroy(r.sharedMaterial.GetTexture(MainDeckTextureName)); } r.sharedMaterial.SetTexture(MainDeckTextureName, texture); if (normal != null) { r.sharedMaterial.SetTexture(NormalDeckTextureName, normal); } if (rgmtao != null) { r.sharedMaterial.SetTexture(rgmtaoDeckTextureName, rgmtao); } } } } } }
private void SkinEditorWindow(int windowID) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); switch (selectedWindow) { case SkinEditorWindowShow.MainSelector: GUI.Label(new Rect(50, 20, 500, 30), "Select type"); if (GUI.Button(new Rect(15, 40, 150, 25), "Skateboard")) { selectedWindow = SkinEditorWindowShow.Skateboard; } if (GUI.Button(new Rect(15, 70, 150, 25), "TeeShirt")) { selectedWindow = SkinEditorWindowShow.TeeShirt; } if (GUI.Button(new Rect(15, 100, 150, 25), "Hoodie")) { selectedWindow = SkinEditorWindowShow.Hoodie; } if (GUI.Button(new Rect(15, 130, 150, 25), "Pants")) { selectedWindow = SkinEditorWindowShow.Pants; } if (GUI.Button(new Rect(15, 160, 150, 25), "Shoes")) { selectedWindow = SkinEditorWindowShow.Shoes; } if (GUI.Button(new Rect(15, 190, 150, 25), "Hat")) { selectedWindow = SkinEditorWindowShow.Hat; } if (GUI.Button(new Rect(15, 220, 150, 25), "Beanie")) { selectedWindow = SkinEditorWindowShow.Beanie; } if (GUI.Button(new Rect(15, 250, 150, 25), "Snapback")) { selectedWindow = SkinEditorWindowShow.Snapback; } if (GUI.Button(new Rect(15, 280, 150, 25), "Select Hat Type")) { selectedWindow = SkinEditorWindowShow.SelectHatType; } GUI.backgroundColor = Color.cyan; if (GUI.Button(new Rect(15, 310, 150, 25), "F**k hats!")) { foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals("Hat")) { RemoveTupleFromGear(t); break; } } } if (GUI.Button(new Rect(15, 340, 150, 25), "F**k Clothes!")) { List <Tuple <CharacterGear, GameObject> > newList = new List <Tuple <CharacterGear, GameObject> >(); foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals("Hoodie") || t.Item1.categoryName.Equals("Shirt") || t.Item1.categoryName.Equals("Pants") || t.Item1.categoryName.Equals("Shoes")) { newList.Add(t); } } foreach (Tuple <CharacterGear, GameObject> t in newList) { RemoveTupleFromGear(t); } Traverse.Create(characterCustomizer).Method("UpdateBodyMesh").GetValue(); } GUI.backgroundColor = Color.red; if (GUI.Button(new Rect(15, 370, 150, 25), "Exit")) { show = false; ModMenu.Instance.HideCursor(Main.modId); } SkinEditorWindowRect.height = 400; break; case SkinEditorWindowShow.SelectHatType: GUI.Label(new Rect(50, 20, 500, 30), "Select hat type"); if (GUI.Button(new Rect(15, 40, 150, 25), "Default Hat")) { currentCap = CapType.defaultCap; ApplyNewHat(); } if (GUI.Button(new Rect(15, 70, 150, 25), "Forward Snapback")) { currentCap = CapType.forwardSnapback; ApplyNewHat(); } if (GUI.Button(new Rect(15, 100, 150, 25), "Backward Snapback")) { currentCap = CapType.backwardSnapback; ApplyNewHat(); } if (GUI.Button(new Rect(15, 130, 150, 25), "Beanie")) { currentCap = CapType.beanie; ApplyNewHat(); } GUI.backgroundColor = Color.red; if (GUI.Button(new Rect(10, 280, 150, 25), "Exit")) { selectedWindow = SkinEditorWindowShow.MainSelector; } SkinEditorWindowRect.height = 315; break; default: DrawSelectSkin(); break; } }
private IEnumerable <Coordinates> GetLinePoints(Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap) { IEnumerable <Coordinates> startingCap = GetCapCoordinates(startCap, start, thickness); if (start == end) { return(startingCap); } IEnumerable <Coordinates> line = BresenhamLine(start.X, start.Y, end.X, end.Y); List <Coordinates> output = new List <Coordinates>(startingCap); output.AddRange(GetCapCoordinates(endCap, end, thickness)); if (line.Count() > 2) { output.AddRange(GetThickShape(line.Except(new[] { start, end }), thickness)); } return(output.Distinct()); }
private IEnumerable <Coordinates> CreateLine(IEnumerable <Coordinates> coordinates, int thickness, CapType startCap, CapType endCap) { Coordinates startingCoordinates = coordinates.Last(); Coordinates latestCoordinates = coordinates.First(); if (thickness == 1) { return(BresenhamLine(startingCoordinates.X, startingCoordinates.Y, latestCoordinates.X, latestCoordinates.Y)); } return(GetLinePoints(startingCoordinates, latestCoordinates, thickness, startCap, endCap)); }
public IEnumerable <Coordinates> CreateLine(Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap) { return(CreateLine(new List <Coordinates>() { end, start }, thickness, startCap, endCap)); }
private Coordinates[] CreateLine(Coordinates[] coordinates, int thickness, CapType startCap, CapType endCap) { Coordinates startingCoordinates = coordinates[^ 1];
public static void AddKey(CapType type) { Thread.Sleep(100); ThreadPool.QueueUserWorkItem(new WaitCallback(AddKeyThread), new object[] { type, new Random().Next() }); }
private void DoLoadCtrlr() { try { log.Info("加载抓拍配置..."); string sql = "SELECT SDC.*,SDI.CTRL_ID,SDI.CTRL_DOOR_INDEX,SCI.*,SCIF.* FROM SMT_DOOR_CAMERA SDC INNER JOIN SMT_DOOR_INFO SDI ON SDC.DOOR_ID=SDI.ID INNER JOIN SMT_CAMERA_INFO SCI ON SDC.CAMERA_ID=SCI.ID INNER JOIN SMT_CONTROLLER_INFO SCIF ON SDI.CTRL_ID=SCIF.ID WHERE SDC.ENABLE_CAP=1"; DataTable dt = Maticsoft.DBUtility.DbHelperSQL.Query(sql).Tables[0]; doorCameraObjects.Clear(); foreach (DataRow dr in dt.Rows) { try { DoorCameraObject dco = new DoorCameraObject(); Controller ctrlr = new Controller(); ControllerDoorType type = ControllerDoorType.TwoDoorsTwoDirections; Enum.TryParse <ControllerDoorType>(Convert.ToString(dr["CTRLR_TYPE"]), out type); ctrlr.doorType = type; ctrlr.driverReleaseTime = dr["DRIVER_DATE"] == null ? DateTime.MinValue : (DateTime)dr["DRIVER_DATE"]; ctrlr.driverVersion = Convert.ToString(dr["DRIVER_VERSION"]); ctrlr.gateway = Convert.ToString(dr["GATEWAY"]); ctrlr.id = dr["CTRL_ID"] == null ? -1 : (decimal)dr["CTRL_ID"]; ctrlr.ip = Convert.ToString(dr["IP"]); ctrlr.mac = Convert.ToString(dr["MAC"]); ctrlr.mask = Convert.ToString(dr["MASK"]); ctrlr.model = Convert.ToString(dr["CTRLR_MODEL"]); ctrlr.port = dr["PORT"] == null ? 60000 : (int)dr["PORT"]; ctrlr.sn = Convert.ToString(dr["SN_NO"]); dco.controller = ctrlr; IPCamera camera = new IPCamera(); camera.CapturePort = dr["CAMERA_CAP_PORT"] == null ? 80 : (int)dr["CAMERA_CAP_PORT"]; CapType ct = CapType.Onvif; Enum.TryParse <CapType>(Convert.ToString(dr["CAMERA_CAP_TYPE"]), out ct); camera.CapType = ct; camera.IP = Convert.ToString(dr["CAMERA_IP"]); CameraModel model = CameraModel.None; Enum.TryParse <CameraModel>(Convert.ToString(dr["CAMERA_MODEL"]), out model); camera.Model = model; camera.Password = Convert.ToString(dr["CAMERA_PWD"]); camera.Port = dr["CAMERA_PORT"] == null ? 80 : (int)dr["CAMERA_PORT"]; camera.User = Convert.ToString(dr["CAMERA_USER"]); dco.camera = camera; dco.ctrl_door_index = dr["CTRL_DOOR_INDEX"] == null ? 1 : (byte)dr["CTRL_DOOR_INDEX"]; doorCameraObjects.Add(dco); } catch (Exception ex) { log.Error("加载抓拍配置异常:DOOR_ID=" + dr["DOOR_ID"] + ",CAMERA_IP=" + dr["CAMERA_IP"], ex); } } List <string> sns = new List <string>(); var curSNs = watchService.GetControllerSNs(); foreach (var item in doorCameraObjects) { if (!curSNs.Contains(item.controller.sn)) { sns.Add(item.controller.sn); } } foreach (var item in curSNs) { if (!sns.Contains(item)) { watchService.RemoveController(item); } } foreach (var item in doorCameraObjects) { watchService.AddController(item.controller, ControllerStateCallBack, "test"); } } catch (Exception ex) { log.Error("读取抓拍配置异常:", ex); } }