public void AreNotEqual() { var color1 = new L16(12345); var color2 = new L16(54321); Assert.NotEqual(color1, color2); }
public void AreEqual() { var color1 = new L16(3000); var color2 = new L16(3000); Assert.Equal(color1, color2); }
public static TPixel ColorFromL16 <TPixel>(L16 l16, ushort intensity, TPixel color) where TPixel : unmanaged, IPixel <TPixel> { l16.PackedValue = intensity; color.FromL16(l16); return(color); }
public void WriteImagePixels_SingleImage() { using var image = new Image <L16>(256, 256); this.ProcessPixelRowsImpl(image, accessor => { for (int y = 0; y < accessor.Height; y++) { Span <L16> row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { row[x] = new L16((ushort)(x * y)); } } }); Buffer2D <L16> buffer = image.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span <L16> row = buffer.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { int actual = row[x].PackedValue; Assert.Equal(x * y, actual); } } }
public void L16_FromVector4() { // Arrange L16 gray = default; const ushort expected = 32767; var vector = new L16(expected).ToVector4(); // Act gray.FromVector4(vector); ushort actual = gray.PackedValue; // Assert Assert.Equal(expected, actual); }
public void L16_FromRgba32() { // Arrange L16 gray = default; const byte rgb = 128; ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb); ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); ushort actual = gray.PackedValue; // Assert Assert.Equal(expected, actual); }
public void L16_ToVector4(ushort input) { // Arrange var gray = new L16(input); // Act var actual = gray.ToVector4(); // Assert float vectorInput = input / 65535F; Assert.Equal(vectorInput, actual.X); Assert.Equal(vectorInput, actual.Y); Assert.Equal(vectorInput, actual.Z); Assert.Equal(1F, actual.W); }
public void L16_ToRgba32(ushort input) { // Arrange ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input); var gray = new L16(input); // Act Rgba32 actual = default; gray.ToRgba32(ref actual); // Assert Assert.Equal(expected, actual.R); Assert.Equal(expected, actual.G); Assert.Equal(expected, actual.B); Assert.Equal(byte.MaxValue, actual.A); }
public void WriteImagePixels_MultiImage3() { using var img1 = new Image <L16>(256, 256); Buffer2D <L16> buffer2 = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span <L16> row = buffer2.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { row[x] = new L16((ushort)(x * y)); } } using var img2 = new Image <L16>(256, 256); using var img3 = new Image <L16>(256, 256); this.ProcessPixelRowsImpl(img1, img2, img3, (accessor1, accessor2, accessor3) => { for (int y = 0; y < accessor1.Height; y++) { Span <L16> row1 = accessor1.GetRowSpan(y); Span <L16> row2 = accessor2.GetRowSpan(accessor2.Height - y - 1); Span <L16> row3 = accessor3.GetRowSpan(y); row1.CopyTo(row2); row1.CopyTo(row3); } }); buffer2 = img2.Frames.RootFrame.PixelBuffer; Buffer2D <L16> buffer3 = img3.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span <L16> row2 = buffer2.DangerousGetRowSpan(y); Span <L16> row3 = buffer3.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { int actual2 = row2[x].PackedValue; int actual3 = row3[x].PackedValue; Assert.Equal(x * (256 - y - 1), actual2); Assert.Equal(x * y, actual3); } } }
/// <inheritdoc/> public override void Decode(ReadOnlySpan <byte> data, Buffer2D <TPixel> pixels, int left, int top, int width, int height) { // Note: due to an issue with netcore 2.1 and default values and unpredictable behavior with those, // we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623 L16 l16 = TiffUtils.L16Default; var color = default(TPixel); color.FromVector4(TiffUtils.Vector4Default); int offset = 0; for (int y = top; y < top + height; y++) { Span <TPixel> pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); if (this.isBigEndian) { for (int x = 0; x < pixelRow.Length; x++) { ushort intensity = TiffUtils.ConvertToUShortBigEndian(data.Slice(offset, 2)); offset += 2; pixelRow[x] = TiffUtils.ColorFromL16(l16, intensity, color); } } else { int byteCount = pixelRow.Length * 2; PixelOperations <TPixel> .Instance.FromL16Bytes( this.configuration, data.Slice(offset, byteCount), pixelRow, pixelRow.Length); offset += byteCount; } } }
public void FromL16(L16 source) { }
static void Main(string[] args) { string basePath = "NoiseTextures"; Directory.CreateDirectory(basePath); int seed = 1234; float offsetX = 0; if (true) { WriteAll(basePath, 1024, 1024, seed, offsetX); } if (true) { string tileableBasePath = "TileableNoiseTextures"; Directory.CreateDirectory(tileableBasePath); string path = Path.Combine(tileableBasePath, "CellularValue_{0}"); WriteTileable < Vector256 <float>, Vector256 <int>, CellularValue <Vector256 <int>, Vector256 <float>, Vector256 <int>, Avx2Functions, DistanceEuclidean <Vector256 <int>, Vector256 <float>, Vector256 <int>, Avx2Functions> > >( path, generator: new(), seed, 1024, 1024); WriteTileable < Vector128 <float>, Vector128 <int>, CellularValue <Vector128 <int>, Vector128 <float>, Vector128 <int>, Sse2Functions, DistanceEuclidean <Vector128 <int>, Vector128 <float>, Vector128 <int>, Sse2Functions> > >( path, generator: new(), seed, 1024, 1024); WriteTileable < float, int, CellularValue <int, float, int, ScalarFunctions, DistanceEuclidean <int, float, int, ScalarFunctions> > >( path, generator: new(), seed, 1024, 1024); } if (false) { using var img = new Image <L16>(256, 256); float dx = 8; float dy = 8; float pi = MathF.PI; var noise = new CellularValue <int, float, int, ScalarFunctions, DistanceEuclidean <int, float, int, ScalarFunctions> >(); for (int y = 0; y < 256; y++) { for (int x = 0; x < 256; x++) { float s = x / 256f; float t = y / 256f; float nx = Utils <int, float, int, ScalarFunctions> .Cos_f32(s * 2 *pi) * dx / (2 * pi); float ny = Utils <int, float, int, ScalarFunctions> .Cos_f32(t * 2 *pi) * dy / (2 * pi); float nz = Utils <int, float, int, ScalarFunctions> .Sin_f32(s * 2 *pi) * dx / (2 * pi); float nw = Utils <int, float, int, ScalarFunctions> .Sin_f32(t * 2 *pi) * dy / (2 * pi); img[x, y] = new L16((ushort)((noise.Gen(nx, ny, nz, nw, 1234) + 1f) * 0.5f * ushort.MaxValue)); } } img.Save("what.png"); } }
/// <inheritdoc /> public void FromL16(L16 source) { throw new NotImplementedException(); }
static internal unsafe void Start(string[] args) { string sourceDirectory = "/media/nikolaev_ov/CEFE3C54FE3C36D5/DICOM/Fluorography/favorite/invalid-window"; ProcessDicomFile(sourceDirectory); // using var readStream = new FileStream("/media/nikolaev_ov/CEFE3C54FE3C36D5/DICOM/Mammography/favorite/presentation-lut-shape-inverse/sources/MG_1.2.276.0.7230010.3.1.4.50143260.1368.1571935817.381.dcm", FileMode.Open, FileAccess.ReadWrite); return; foreach (var fileName in new[] { "IDENTITY&MONOCHROME1.dcm", "IDENTITY&MONOCHROME2.dcm", "INVERSE&MONOCHROME1.dcm", "INVERSE&MONOCHROME2.dcm", "REMOVED&MONOCHROME1.dcm", "REMOVED&MONOCHROME2.dcm", "IDENTITY&REMOVED.dcm", "INVERSE&REMOVED.dcm", "REMOVED&REMOVED.dcm" }) { using var readStream = new FileStream(System.IO.Path.Combine(sourceDirectory, fileName), FileMode.Open, FileAccess.ReadWrite); var decodedDicomImage = DicomDatasetExtensions.DecodeImage(readStream, out _); // var decodedDicomImage = file.Dataset.ReadPixelData(); // var image = DicomPixelData.Create(file.Dataset, false); // var decodedDicomImage = new DecodedDicomImageModel() // { // PixelData = image.GetFrame(0).Data, // ChannelSize = (uint)(file.Dataset.GetSingleValue<ushort>(DicomTag.BitsAllocated) >> 3), // Signed = file.Dataset.GetSingleValue<ushort>(DicomTag.PixelRepresentation) == 1, // ChannelCount = file.Dataset.GetSingleValue<ushort>(DicomTag.SamplesPerPixel), // Width = file.Dataset.GetSingleValue<ushort>(DicomTag.Columns), // Height = file.Dataset.GetSingleValue<ushort>(DicomTag.Rows), // }; // decodedDicomImage.PixelCount = decodedDicomImage.Width * decodedDicomImage.Height; fixed(byte *p = &decodedDicomImage.PixelData[0]) { var pixelData = new Span <L16>(p, (int)(decodedDicomImage.PixelData.Length / decodedDicomImage.ChannelSize)); var min = ushort.MaxValue; var max = ushort.MinValue; foreach (var pixel in pixelData) { if (pixel.PackedValue < min) { min = pixel.PackedValue; } if (pixel.PackedValue > max) { max = pixel.PackedValue; } } for (int pixelIndex = 0; pixelIndex != pixelData.Length; pixelIndex++) { pixelData[pixelIndex] = new L16(checked ((ushort)(pixelData[pixelIndex].PackedValue * 64))); } var img = Image.LoadPixelData <L16>(pixelData, (int)decodedDicomImage.Width, (int)decodedDicomImage.Height); // img.Mutate(a => // { // // Color whiteColor = new Color(new Rgba64(ushort.MaxValue & 0x0FFF, ushort.MaxValue & 0x0FFF, ushort.MaxValue & 0x0FFF, ushort.MaxValue & 0x0FFF)); // Color whiteColor = new Color(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // Color blackColor = new Color(new Rgba64(ushort.MinValue, ushort.MinValue, ushort.MinValue, ushort.MinValue)); // a.Draw(Pens.Solid(whiteColor, 10), new EllipsePolygon(new PointF(image.Width * 0.5F, image.Height * 0.5F), 200F)); // FontCollection fontCollection = new FontCollection(); // fontCollection.Install(System.IO.Path.Combine(fontDirectory, "fonts/TIMES.TTF")); // string text = "ТОЛЬКО ДЛЯ ИССЛЕДОВАТЕЛЬСКИХ ЦЕЛЕЙ"; // Font font = new Font(fontCollection.Families.First(), 64, FontStyle.Regular); // FontRectangle fontRectangle = TextMeasurer.Measure(text, new RendererOptions(font)); // PointF textPoint = new PointF(image.Width * 0.5F - fontRectangle.Width * 0.5F, image.Height * 0.5F - 200F - fontRectangle.Height); // a.DrawText(text, font, blackColor, new PointF(textPoint.X + 5, textPoint.Y + 5)); // a.DrawText(text, font, whiteColor, textPoint); // }); using var writeStream = new FileStream(System.IO.Path.Combine(sourceDirectory, System.IO.Path.GetFileNameWithoutExtension(fileName) + ".jpg"), FileMode.OpenOrCreate, FileAccess.Write); img.Save(writeStream, new JpegEncoder() { Quality = 100, Subsample = JpegSubsample.Ratio444 }); for (int y = 0; y < img.Height; y++) { Span <L16> span = img.GetPixelRowSpan(y); fixed(L16 *p2 = &span[0]) Buffer.MemoryCopy(p2, p + y * img.Width * decodedDicomImage.ChannelSize, img.Width * decodedDicomImage.ChannelSize, img.Width * decodedDicomImage.ChannelSize); } } } }
// Update is called once per frame void Update() { NowCursorState = tmpCursor.GetComponent <AnimatedCursor>().tmpCursorState; PlaceBtnState = PlaceButton.GetComponent <ButtonInteraction>().NowButtonState; DeleteBtnState = DeleteButton.GetComponent <ButtonInteraction>().NowButtonState; CancelBtnState = CancelButton.GetComponent <ButtonInteraction>().NowButtonState; lineRenderer = GetComponent <LineRenderer>(); //Debug.Log("Cursor Position: " + tmpCursor.transform.position); //Vector3 CursorPosition = tmpCursor.GetComponent<Transform>().position; if ((ButtonInteraction.PosState == PosButtonType.PLACE) && (NowCursorState == CursorStateEnum.Release) && (PlaceBtnState != ButtonStateEnum.Targeted) && (PlaceBtnState != ButtonStateEnum.Pressed) && (DeleteBtnState != ButtonStateEnum.Observation) && (CancelBtnState != ButtonStateEnum.Observation)) { if (SizeButtonCollection.SizeButtonState == SizeButtonType.MEDIUM) { offset = 6.0f; } else if (SizeButtonCollection.SizeButtonState == SizeButtonType.LARGE) { offset = 8.0f; } else if (SizeButtonCollection.SizeButtonState == SizeButtonType.SMALL) { offset = 5.0f; } Vector3 FinalPos = tmpCursor.transform.position - new Vector3(0f, 0f, 0.1f) * offset; Instantiate(PlaneObject, FinalPos, transform.rotation, this.transform); //Genarate the drone ChildCount = this.transform.childCount; /*Use to process the three Red Light*/ if (ChildCount > 1) { Vector3 pos1, pos2; //the position of two way point(drone) Vector3 p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18; //Red light initial position pos1 = this.gameObject.transform.GetChild(ChildCount - 2).transform.position; pos2 = this.gameObject.transform.GetChild(ChildCount - 1).transform.position; p0 = (pos1 * 1 + pos2 * 19) / 20; p1 = (pos1 * 2 + pos2 * 18) / 20; p2 = (pos1 * 3 + pos2 * 17) / 20; p3 = (pos1 * 4 + pos2 * 16) / 20; p4 = (pos1 * 5 + pos2 * 15) / 20; p5 = (pos1 * 6 + pos2 * 14) / 20; p6 = (pos1 * 7 + pos2 * 13) / 20; p7 = (pos1 * 8 + pos2 * 12) / 20; p8 = (pos1 * 9 + pos2 * 11) / 20; p9 = (pos1 * 10 + pos2 * 10) / 20; p10 = (pos1 * 11 + pos2 * 9) / 20; p11 = (pos1 * 12 + pos2 * 8) / 20; p12 = (pos1 * 13 + pos2 * 7) / 20; p13 = (pos1 * 14 + pos2 * 6) / 20; p14 = (pos1 * 15 + pos2 * 5) / 20; p15 = (pos1 * 16 + pos2 * 4) / 20; p16 = (pos1 * 17 + pos2 * 3) / 20; p17 = (pos1 * 18 + pos2 * 2) / 20; p18 = (pos1 * 19 + pos2 * 1) / 20; L0 = Instantiate(CloneRedLight_0, p0, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L0.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L0.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L0.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L1 = Instantiate(CloneRedLight_1, p1, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L1.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L1.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L1.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L2 = Instantiate(CloneRedLight_2, p2, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L2.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L2.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L2.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L3 = Instantiate(CloneRedLight_3, p3, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L3.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L3.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L3.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L4 = Instantiate(CloneRedLight_4, p4, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L4.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L4.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L4.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L5 = Instantiate(CloneRedLight_5, p5, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L5.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L5.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L5.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L6 = Instantiate(CloneRedLight_6, p6, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L6.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L6.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L6.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L7 = Instantiate(CloneRedLight_7, p7, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L7.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L7.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L7.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L8 = Instantiate(CloneRedLight_8, p8, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L8.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L8.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L8.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L9 = Instantiate(CloneRedLight_9, p9, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L9.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L9.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L9.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L10 = Instantiate(CloneRedLight_10, p10, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L10.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L10.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L10.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L11 = Instantiate(CloneRedLight_11, p11, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L11.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L11.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L11.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L12 = Instantiate(CloneRedLight_12, p12, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L12.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L12.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L12.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L13 = Instantiate(CloneRedLight_13, p13, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L13.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L13.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L13.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L14 = Instantiate(CloneRedLight_14, p14, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L14.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L14.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L14.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; ///////////////////////////////////////// L15 = Instantiate(CloneRedLight_15, p15, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L15.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L15.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L15.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L16 = Instantiate(CloneRedLight_16, p16, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L16.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L16.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L16.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L17 = Instantiate(CloneRedLight_17, p17, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L17.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L17.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L17.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L18 = Instantiate(CloneRedLight_18, p18, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L18.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L18.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L18.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; } //WayPoint.Add(tmp); //Debug.Log("InstantiateInstantiateInstantiateInstantiateInstantiateInstantiate"); } /* Line Process*/ ChildCount = this.transform.childCount; lineRenderer.SetVertexCount(ChildCount); if (ChildCount > 1) { for (int i = 0; i < ChildCount; i++) { tmp = this.gameObject.transform.GetChild(i).gameObject; lineRenderer.SetPosition(i, tmp.transform.position); } /*Obstacle Detect*/ for (int i = 0; i < ChildCount - 1; i++) { Obj1 = this.gameObject.transform.GetChild(i).gameObject; Obj2 = this.gameObject.transform.GetChild(i + 1).gameObject; Ray ray = new Ray(Obj1.transform.position, Obj2.transform.position - Obj1.transform.position); RaycastHit hit; //Debug.Log( i + " -> " + (i+1) + " distance : " + Vector3.Distance(Obj1.transform.position, Obj2.transform.position)); float distance = Vector3.Distance(Obj1.transform.position, Obj2.transform.position) - 0.1f; Physics.Raycast(ray, out hit, distance, mask); //When collision is NOT NULL, there is obstacles if (hit.transform != null) { lineRenderer.material = LineMat2; // if collision the line become red //Debug.Log("BBBBBBBBB"); //LineCollision = false; // Let Other Script Know Collision State //LineCollisionNum = i + 1; Debug.Log("Blocked by : " + hit.transform.name); } //If is NULL -> No Obstacles else if (hit.transform == null) { lineRenderer.material = LineMat1; //LineCollision = true; //LineCollisionNum = -1; //Debug.Log("NNNNNNNNN"); } //Debug.Log("Line color : " + lineRenderer.material); } } //if(ChildCount == 2) lineRenderer.SetPosition(2, new Vector3(0,0,1)); }
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
public Color(L16 pixel) { this.data = new Rgba64(pixel.PackedValue, pixel.PackedValue, pixel.PackedValue, ushort.MaxValue); this.boxedHighPrecisionPixel = null; }