public unsafe (ProbeResult result, ProbeInfo info) ProbeTerrain(float x, float y, float z) { var info = new ProbeInfo { structSize = Unsafe.SizeOf <ProbeInfo>() }; var result = SceneryAPI.ProbeTerrainXYZ(_ref, x, y, x, &info); return(result, info); }
public void AddProbe(Index _index, ProbeInfo _info) { if (m_probeDict.ContainsKey(_index)) { // TODO: //m_probeDict[_index] = _info; } else { m_probeDict.Add(_index, _info); } }
public ProbeInfo[] GetAllProbes() { List <ProbeInfo> probes = new List <ProbeInfo>(); ProbeInfo constructedProbe = default; var output = RunCommand("srv PROBELIST"); foreach (var line in output) { if (line.Trim() == "") { if (constructedProbe.Index != 0 && constructedProbe.SerialNumber != null) { probes.Add(constructedProbe); } constructedProbe = default; } int idx = line.IndexOf('='); if (idx != -1) { string key = line.Substring(0, idx).Trim(); string value = line.Substring(idx + 1).Trim(); switch (key) { case "Index": int.TryParse(value, out constructedProbe.Index); break; case "Manufacturer": constructedProbe.Manufacturer = value; break; case "Description": constructedProbe.Description = value; break; case "Serial Number": constructedProbe.SerialNumber = value; break; } } } if (constructedProbe.Index != 0 && constructedProbe.SerialNumber != null) { probes.Add(constructedProbe); } return(probes.ToArray()); }
//[Test] public void WrapTest_One() { IStudentService student = Lark.Core.Lark.Wrap <IStudentService>(""); for (int i = 0; i < 1; i++) { student = Lark.Core.Lark.Wrap <IStudentService>(BaseUrl); WrapBase wrap = (WrapBase)student; // Assert.IsTrue("Hello!" == student.SayHello("myid","testheader",null)); HttpResponseMessage responseMessage = wrap.OriginalResponseMessage; ProbeInfo probeInfo = Util.GetProbe(responseMessage) ?? throw new Exception("probeinfo is null"); Assert.IsTrue(probeInfo.Url.EndsWith("/api/student/sayhello")); Assert.IsTrue(probeInfo.Method == "GET"); Assert.IsTrue(probeInfo.Headers.Exists(x => x.Key == "myheader" && x.Value == "hello")); } }
public Task InvokeAsync(HttpContext context, RequestDelegate next) { context.Request.EnableBuffering(); HttpRequest httpRequest = context.Request; HttpResponse httpResponse = context.Response; ProbeInfo probeInfo = new ProbeInfo(); IHeaderDictionary headers = httpRequest.Headers; probeInfo.Url = httpRequest.Host + httpRequest.Path.Value + httpRequest.QueryString; probeInfo.Method = httpRequest.Method; foreach (string key in headers.Keys) { probeInfo.Headers.Add(new KeyValuePair <string, string>(key, headers[key])); } if (null != httpRequest.ContentLength) { long conlength = httpRequest.ContentLength.Value; byte[] conBytes = new byte[conlength]; Stream bodyStream = httpRequest.Body; long c = 1; long index = 0; while (c > 0 && (conlength - index) > 0) { c = bodyStream.Read(conBytes, int.Parse(index.ToString()), int.Parse((conlength - index).ToString())); index += c; } string constr = System.Text.UTF8Encoding.UTF8.GetString(conBytes); probeInfo.Body = constr; bodyStream.Position = 0; } httpResponse.Headers.Add("probeInfo", System.Text.Encodings.Web.HtmlEncoder.Default.Encode(Newtonsoft.Json.JsonConvert.SerializeObject(probeInfo))); return(next.Invoke(context)); }
public static ProbeInfo GetProbe(HttpResponseMessage responseMessage) { IEnumerable <string> ies = responseMessage.Headers.GetValues("probeInfo"); IEnumerator <string> ietors = ies.GetEnumerator(); string value = null; while (ietors.MoveNext()) { value = ietors.Current; } if (string.IsNullOrEmpty(value) == false) { value = WebUtility.HtmlDecode(value); System.Console.WriteLine(value); ProbeInfo probeInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ProbeInfo>(value); return(probeInfo); } return(null); }
public static void OptimizeProbes(float gridSize) { if (gridSize < Mathf.Epsilon) { Debug.Log("间矩是个无效数值"); return; } Bounds bounds = GetNavMeshBounds(); if (bounds.extents.magnitude < Mathf.Epsilon) { Debug.Log("场景没有物件的layer属性设置为Terrain,请先完成相应设置."); return; } if (LightmapSettings.lightProbes == null || LightmapSettings.lightProbes.positions.Length < 1) { Debug.Log("场景还没有烘培,请先烘培场景"); return; } GameObject lightProbeHolder = GameObject.Find("LightProbeHolder"); LightProbeGroup lpg = lightProbeHolder.GetComponent <LightProbeGroup>(); if (!lpg) { Debug.Log("场景没有light probe,请先通过[Tools/场景工具/LightProbe/LightProbes生成]菜单生成lightProbe"); return; } int count1 = LightmapSettings.lightProbes.positions.Length; ProbeOptimize probeOpt = new ProbeOptimize(bounds.min, bounds.max, gridSize); // the last 8 lightProbes are aabb-box, and 3-layers(3rd layer doesn't cover all the 1st layer) for (int i = 0, len = (count1 - 8) / 2; i < len; i++) { Index index = new Index(LightmapSettings.lightProbes.positions[i].x, LightmapSettings.lightProbes.positions[i].z); ProbeInfo info = new ProbeInfo(LightmapSettings.lightProbes.positions[i], LightmapSettings.lightProbes.bakedProbes[i]); probeOpt.AddProbe(index, info); } //clear probes int count2; int stepMax = (int)Mathf.Min(probeOpt.Extend(), 4); for (int i = stepMax; i > 1; i--) { probeOpt.RemoveProbeInRow(); probeOpt.RemoveProbeInCol(); } count2 = probeOpt.Size(); Debug.Log("count1: " + count1 + " ,count2: " + count2); Vector3[] positions = probeOpt.VolumizeProbes(bounds); lpg.probePositions = positions; #if false //light probe aabbb-box GameObject lightProbeBox = GameObject.Find("LightProbeBox"); if (!lightProbeBox) { lightProbeBox = new GameObject("LightProbeBox", typeof(LightProbeGroup)); } if (!lightProbeBox) { return; } LightProbeGroup lpgBox = lightProbeBox.GetComponent <LightProbeGroup>(); if (!lpgBox) { return; } //light probe aabb initialized Vector3 min = bounds.min; Vector3 max = bounds.max; min.y -= 500; max.y += 500; Vector3[] vecBound = new Vector3[8]; vecBound[0] = new Vector3(min.x, min.y, min.z); vecBound[1] = new Vector3(min.x, max.y, min.z); vecBound[2] = new Vector3(max.x, min.y, min.z); vecBound[3] = new Vector3(max.x, max.y, min.z); vecBound[4] = new Vector3(min.x, min.y, max.z); vecBound[5] = new Vector3(min.x, max.y, max.z); vecBound[6] = new Vector3(max.x, min.y, max.z); vecBound[7] = new Vector3(max.x, max.y, max.z); lpgBox.probePositions = vecBound; Debug.Log("gernerate extra aabb lightProbes"); #endif //Lightmapping.Bake(); }