protected void AddVertsFromPointData(List<Vector3> verts, PointData data) { for (int i = 0; i < CylinderEdges; i++) { Vector3 direction = Quaternion.AngleAxis((i * 1.0f / (CylinderEdges - 1)) * 360, data.forwardVector) * data.upVector; verts.Add(data.point + (direction * SplineRadius)); } }
public void Enrich(PointData point) { point.Tags = point.Tags ?? new Dictionary<string, string>(); foreach (var tag in _tags) { if (!point.Tags.ContainsKey(tag.Key)) point.Tags.Add(tag.Key, tag.Value); } }
public void Emit(PointData[] points) { var payload = new LineProtocolPayload(); foreach (var point in points) { payload.Add(new LineProtocolPoint(point.Measurement, point.Fields, point.Tags, point.UtcTimestamp)); } var influxResult = _client.WriteAsync(payload).Result; if (!influxResult.Success) CollectorLog.WriteLine(influxResult.ErrorMessage); }
public void Emit(PointData[] points) { lock (_stateLock) { if (_unloading) return; if (!_started) { _started = true; _timer.Start(TimeSpan.Zero); } } lock (_queueLock) { foreach(var point in points) _queue.Enqueue(point); } }
void Update() { timeSinceLastUpdate += Time.deltaTime; //Debug.Log ("zero "+hand.transform.TransformPoint(Vector3.zero)); //Debug.Log ("pos "+hand.transform.position); //Debug.Log ("pp x"+hand.transform.TransformPoint(Vector3.zero).x+" pp y "+hand.transform.TransformPoint(Vector3.zero).y // +" pp z"+hand.transform.TransformPoint(Vector3.zero).z); PointData newPoint = new PointData(hand.transform.TransformPoint(Vector3.zero), hand.transform.localRotation, timeSinceLastUpdate, Time.timeSinceLevelLoad, previousPoint); //remove zero velocities just in case, in order for the speeds not to get polluted by nonexisting data //if (newPoint.velocity == Vector3.zero) return; points.Add(newPoint); previousPoint = newPoint; while (points.Count >= bufferLength) { points.RemoveAt(0); } //Debug.Log (points.Count + " br"); int maks = Math.Min(50, points.Count); //Debug.Log ("maks " + maks); for (int i = 0; i < maks; i++) { //Debug.Log ("pp x"+points [i].position.x); //Debug.Log ("pp y"+points [i].position.y); //Debug.Log ("pp z"+points [i].position.z); colliders [i].position = points [i].position; //-new Vector3(0,0,points[i].position.z); //colliders[i].position.z = 0; } //Debug.Log ("THREAD ID" + System.Threading.Thread.CurrentThread.ManagedThreadId); //Debug.Log ("brojTacaka"points.Count); //if (points.Count > bufferSize) points.RemoveAt(0); //InvalidateCaches(); //Debug.Log(averageSpeed); timeSinceLastUpdate = 0; }
public ResultData CheckJiangShuai() { ResultData result = new ResultData(); //最新走法 MoveData move = fen.moves[0]; int len = Constant.JiangShuaiZouFaDelta.Length; if ((Constant.RED == fen.current && !Utility.IsRedYingZhang(move.end)) || (Constant.BLACK == fen.current && !Utility.IsBlackYingZhang(move.end))) { //出界了 throw new AppException(ErrorMessage.AE0006); } for (int i = 0; i < len; i++) { PointData p = move.start + Constant.JiangShuaiZouFaDelta[i].target; if (p == move.end) { if (fen[move.end] == Qizi.KONGZI) { //空白移动 result.result = true; result.pgn.fen = fen; } else if ((fen.current & (int)fen[move.end]) == 0x0000) { result.result = true; result.caneat = true; result.pgn.fen = fen; } else { throw new AppException(ErrorMessage.AE0007); } break; } } if (!result.result) { throw new AppException(ErrorMessage.AE0005); } return(result); }
public void EndTargeting(IUser user, Vector3 targetPoint) { var app = App; if (app == null || Behavior == null) { return; } var targetData = new TargetData() { targetedPoints = new PointData[1] { PointData.CreateFromGodotVector3(targetPoint, Behavior.Actor.Node3D as Spatial, app.SceneRoot) } }; TargetAction.StopAction(user, targetData); }
//Patrol Mode Handles private void Mode_NextPoint(bool isConnected = true) { //Get point and store for (int i = 0; i < points.Length; i++) { //Get point PointData pointData = points[i]; //Get current and next point Vector3 point = pointData.point; Vector3 pointNext = (i != points.Length - 1) ? points[i + 1].point : points[0].point; //Show info Vector3 textPoint = point + Vector3.up * 5; //Make sure the text appears on top of stuff Handles.Label(textPoint, "Point " + i + "\n" + point + "\n" + pointData.moveDelay + "s movement delay", centeredStyle); //Connect up points if needed if (isConnected) { //Show arrow showing path dir Vector3 vec = pointNext - point; if (vec == Vector3.zero) { vec = Camera.main.transform.forward; } // Handles.color = goalColour; // Handles.ArrowHandleCap (0, point, Quaternion.LookRotation (vec), GetScaleSize(point, pointSize) , EventType.Repaint); //Show dotted line to next point if (showPointConnections) { Handles.color = pathColour; Handles.DrawDottedLine(point, pointNext, 4.0f); } } } }
/// <summary> /// /// </summary> /// <param name="arc"></param> protected private override void SetProps(object arc) { base.SetProps(arc); _centerPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(arc, "CenterPoint", null)); ChordDirection = ReflectionSupport.GetProperty(arc, "ChordDirection", double.NaN); ChordLength = ReflectionSupport.GetProperty(arc, "ChordLength", double.NaN); Clockwise = ReflectionSupport.GetProperty(arc, "Clockwise", false); AlignmentArcConstraintType = GetConstraint2(arc); DeflectedAngle = ReflectionSupport.GetProperty(arc, "DeflectedAngle", double.NaN); ExternalSecant = ReflectionSupport.GetProperty(arc, "ExternalSecant", double.NaN); ExternalTangent = ReflectionSupport.GetProperty(arc, "ExternalTangent", double.NaN); GreaterThan180 = ReflectionSupport.GetProperty(arc, "GreaterThan180", false); MidOrdinate = ReflectionSupport.GetProperty(arc, "MidOrdinate", double.NaN); MinimumRadius = ReflectionSupport.GetProperty(arc, "MinimumRadius", double.NaN); PIStation = ReflectionSupport.GetProperty(arc, "PIStation", double.NaN); Radius = ReflectionSupport.GetProperty(arc, "Radius", double.NaN); ReverseCurve = ReflectionSupport.GetProperty(arc, "ReverseCurve", false); }
private void GetBingZuList(out List <MoveData> list, PointData start) { list = new List <MoveData>(); int len = 1; if ((Constant.RED == fen.current && Utility.IsRedGuoHe(start)) || (Constant.BLACK == fen.current && Utility.IsBlackGuoHe(start))) { len = 3; } for (int i = 0; i < len; i++) { PointData target; if (Constant.RED == fen.current) { target = Constant.BingZouFaDelta[i].target; } else { target = Constant.ZuZouFaDelta[i].target; } PointData p = start + target; if (!Utility.IsOnQiPan(p)) { continue; } else if (fen[p] == Qizi.KONGZI) { //添加走法 AddZouFa(ref list, start, p); } else if ((fen.current & (int)fen[p]) == 0x0000) { //添加吃子 AddZouFa(ref list, start, p); } else { continue; } } }
public void EndTargeting(IUser user, Vector3 targetPoint) { var app = App; if (app == null) { return; } var targetData = new TargetData() { targetedPoints = new PointData[1] { PointData.CreateFromUnityVector3(targetPoint, Behavior.Actor.GameObject.transform, app.SceneRoot.transform) } }; TargetAction.StopAction(user, targetData); }
public ResultData GetXiang() { ResultData result = new ResultData(); //选中的坐标 PointData start = fen.selected; int len = Constant.XiangZouFaDelta.Length; for (int i = 0; i < len; i++) { PointData target = Constant.XiangZouFaDelta[i].target; PointData delta = Constant.XiangZouFaDelta[i].delta; PointData p = start + target; if (!Utility.IsOnQiPan(p)) { continue; } else if ((Constant.RED == fen.current && Utility.IsRedGuoHe(p)) || (Constant.BLACK == fen.current && Utility.IsBlackGuoHe(p))) { continue; } else if (fen[start + delta] != Qizi.KONGZI) { continue; } else if (fen[p] == Qizi.KONGZI) { fen[p] = Qizi.ZHANWEI; } else if ((fen.current & (int)fen[p]) == 0x0000) { fen[p] = fen[p] + Constant.QIZIGAOLIANG; } else { continue; } } result.result = true; result.pgn.fen = fen; return(result); }
public async Task DefaultTagsPoint() { Client.Dispose(); Environment.SetEnvironmentVariable("point-datacenter", "LA"); ConfigurationManager.AppSettings["point-sensor.version"] = "1.23a"; var options = new InfluxDBClientOptions.Builder().Url(InfluxDbUrl) .AuthenticateToken(_token.ToCharArray()) .AddDefaultTag("id", "132-987-655") .AddDefaultTag("customer", "California Miner") .AddDefaultTag("env-var", "${env.point-datacenter}") .AddDefaultTag("sensor-version", "${point-sensor.version}") .Build(); Client = InfluxDBClientFactory.Create(options); var point = PointData.Measurement("h2o_feet").Tag("location", "west").Field("water_level", 1); _writeApi = Client.GetWriteApi(); var listener = new WriteApiTest.EventListener(_writeApi); _writeApi.WritePoint(_bucket.Name, _organization.Id, point); _writeApi.Flush(); listener.WaitToSuccess(); _queryApi = Client.GetQueryApi(); var tables = await _queryApi.QueryAsync( "from(bucket:\"" + _bucket.Name + "\") |> range(start: 1970-01-01T00:00:00.000000001Z) |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")", _organization.Id); Assert.AreEqual(1, tables.Count); Assert.AreEqual(1, tables[0].Records.Count); Assert.AreEqual("h2o_feet", tables[0].Records[0].GetMeasurement()); Assert.AreEqual(1, tables[0].Records[0].GetValueByKey("water_level")); Assert.AreEqual("west", tables[0].Records[0].GetValueByKey("location")); Assert.AreEqual("132-987-655", tables[0].Records[0].GetValueByKey("id")); Assert.AreEqual("California Miner", tables[0].Records[0].GetValueByKey("customer")); Assert.AreEqual("1.23a", tables[0].Records[0].GetValueByKey("sensor-version")); Assert.AreEqual("LA", tables[0].Records[0].GetValueByKey("env-var")); }
private PointData getBorderData(byte[] bytes) { PointData isborderpoint = new PointData(size.Height * size.Width); bool prevtrans = false; bool currenttrans = false; for (int y = 0; y < size.Height; y++) { prevtrans = false; for (int x = 0; x < size.Width; x++) { currenttrans = bytes[y * stride + x * 4 + 3] == 0; if (prevtrans && !currenttrans) { isborderpoint.SetPoint(y * size.Width + x - 1, true); } if (!prevtrans && currenttrans && x != 0) { isborderpoint.SetPoint(y * size.Width + x, true); } prevtrans = currenttrans; } } for (int x = 0; x < size.Width; x++) { prevtrans = false; for (int y = 0; y < size.Height; y++) { currenttrans = bytes[y * stride + x * 4 + 3] == 0; if (prevtrans && !currenttrans) { isborderpoint.SetPoint((y - 1) * size.Width + x, true); } if (!prevtrans && currenttrans && y != 0) { isborderpoint.SetPoint(y * size.Width + x, true); } prevtrans = currenttrans; } } return(isborderpoint); }
public List <PointData> MovingAverage(List <PointData> data, int number) { List <PointData> movingAverage = new List <PointData>(); if (number < 0) { return(movingAverage); } for (int i = number; i < data.Count; i++) { double closeSum = 0, finalSum = 0, maxSum = 0, minSum = 0, openSum = 0, valueSum = 0; int numberOfDealsSum = 0, volumeSum = 0; PointData pointDataAverage = new PointData(); for (int j = 0; j < number; j++) { closeSum += data[i - j].Close; finalSum += data[i - j].Final; maxSum += data[i - j].Max; minSum += data[i - j].Min; numberOfDealsSum += data[i - j].NumberOfDeals; openSum += data[i - j].Open; valueSum += data[i - j].Value; volumeSum += data[i - j].Volume; } pointDataAverage.Close = closeSum / number; pointDataAverage.Date = data[i].Date; pointDataAverage.Final = finalSum / number; pointDataAverage.Max = maxSum / number; pointDataAverage.Min = minSum / number; pointDataAverage.NumberOfDeals = (int)(numberOfDealsSum / number); pointDataAverage.Open = openSum / number; pointDataAverage.Value = valueSum / number; pointDataAverage.Volume = (int)(volumeSum / number); movingAverage.Add(pointDataAverage); } return(movingAverage); }
public ResultData CheckMa() { ResultData result = new ResultData(); //最新走法 MoveData move = fen.moves[0]; int len = Constant.MaZouFaDelta.Length; for (int i = 0; i < len; i++) { PointData p = move.start + Constant.MaZouFaDelta[i].target; if (p == move.end) { //马腿 if (fen[move.start + Constant.MaZouFaDelta[i].delta] != Qizi.KONGZI) { throw new AppException(ErrorMessage.AE0007); } if (fen[move.end] == Qizi.KONGZI) { //空白移动 result.result = true; result.pgn.fen = fen; } else if ((fen.current & (int)fen[move.end]) == 0x0000) { result.result = true; result.caneat = true; result.pgn.fen = fen; } else { throw new AppException(ErrorMessage.AE0007); } break; } } if (!result.result) { throw new AppException(ErrorMessage.AE0005); } return(result); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Directory.GetCurrentDirectory(); if (ofd.ShowDialog() == DialogResult.OK) { int[] input = Array.ConvertAll(File.ReadAllText(ofd.FileName).Split(' '), s => int.Parse(s)); List <PointData> pd = new List <PointData>(); PointData p = new PointData(); for (int i = 2; i < input.Length - 2; i += 3) { p = new PointData(); p.X = input[i]; p.Y = input[i + 1]; p.Type = input[i + 2]; pd.Add(p); } chart1.Series.Clear(); chart1.Series.Add("Type1"); chart1.Series.Add("Type2"); chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; chart1.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false; chart1.ChartAreas[0].AxisX.Minimum = pd.Min(x => x.X); chart1.ChartAreas[0].AxisY.Minimum = pd.Min(x => x.Y); chart1.ChartAreas[0].AxisX.Maximum = pd.Max(x => x.X); chart1.ChartAreas[0].AxisY.Maximum = pd.Max(x => x.Y); pd.ForEach(x => { if (x.Type == 0) { chart1.Series[0].Points.AddXY(x.X, x.Y); } else { chart1.Series[1].Points.AddXY(x.X, x.Y); } }); } }
public override PointData CreatePoint(LogEntry logEntry) { var point = PointData.Measurement("syslog"); point = point.Timestamp(logEntry.PlcTimestamp.ToUniversalTime(), WritePrecision.Us); // add tags from context point = WriteContextToTags(point, logEntry); // add log4tc tags point = point .Tag("level", logEntry.Level.ToString()) .Tag("source", logEntry.Source) .Tag("taskName", logEntry.TaskName) .Tag("taskIndex", Convert.ToString(logEntry.TaskIndex, CultureInfo.InvariantCulture)); // Syslog Tags point = point .Tag("appname", logEntry.ProjectName) .Tag("facility", logEntry.AppName) .Tag("host", logEntry.Source) .Tag("hostname", logEntry.Hostname) .Tag("severity", LevelToSyslogSeverity(logEntry.Level)); // add fields from all arguments. because influxdb cannot change the // field type between logs, all arguments are written as string foreach ((string name, object value) in logEntry.MessageFormatter.Arguments.Zip(logEntry.ArgumentValues, (x, y) => (x, y))) { point = point.Field(name, Convert.ToString(value, CultureInfo.InvariantCulture)); } // Syslog Fields point = point .Field("facility_code", _settings.SyslogFacilityCode) .Field("message", logEntry.FormattedMessage) .Field("procid", logEntry.OnlineChangeCount.ToString()) .Field("severity_code", LevelToSyslogSeverityCode(logEntry.Level)) .Field("timestamp", new DateTimeOffset(logEntry.PlcTimestamp.ToUniversalTime()).ToUnixTimeMilliseconds() * 1000000) .Field("version", 1); return(point); }
public void SetPoint(int lineNum, int pointNum, PointData pointData) { if (m_PointsOnLines[lineNum][pointNum] == pointData) { return; } if (m_PointsOnLines[lineNum][pointNum] != null) { m_PointsOnLines[lineNum][pointNum].GeometryUpdated.Unsubscribe(GeometryUpdated); } m_PointsOnLines[lineNum][pointNum] = pointData; if (m_PointsOnLines[lineNum][pointNum] != null) { m_PointsOnLines[lineNum][pointNum].GeometryUpdated.Subscribe(GeometryUpdated); } GeometryUpdated.Invoke(); }
private void goToRegularMovementAfterExitingStructure(clsGroundAtom refGroundAtom) { clsActivityMovement backToNormal = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); clsPolygonOpeningEscapePoint escapePoint = Structure.EscapePoints[exitEdgeNumber]; PointData closestPoint = refGroundAtom.m_GameObject.lookForClosestRegularRoute(refGroundAtom); Route route = RouteUtils.typRouteToRoute(closestPoint.route); List <DPoint> trimmedRoutePoints = new List <DPoint>(); for (int i = closestPoint.legNum; i < route.Points.Count(); i++) { trimmedRoutePoints.Add(route.Points.ElementAt(i)); } route.Points = trimmedRoutePoints; refGroundAtom.currentStartWaypoint = closestPoint.routeIndex1; refGroundAtom.currentEndWaypoint = closestPoint.routeIndex2; refGroundAtom.resetMovementData(); refGroundAtom.currentSpeed = refGroundAtom.baselineSpeed; refGroundAtom.ChangeState(new GET_ON_SIDEWALK(backToNormal, new DPoint(escapePoint.x, escapePoint.y), route)); }
private void Button_Click(object sender, RoutedEventArgs e) { if (DataContext is TestGame tg) { Solver solver = new Solver(); PointData pd = solver.GetNextMove(tg.DeskData); if (tg.DeskData.CurrentPlayerSymbol == ESymbol.Circle) { tg.DeskData.CirclePoints.Add(pd); } else { tg.DeskData.CrossPoints.Add(pd); } tg.DeskData.IsMyTurn = !tg.DeskData.IsMyTurn; ucDesk.Draw(); } }
public void SetFirstPointOnParallelLine(PointData pointData) { if (m_FirstPointOnParallelLine == pointData) { return; } if (m_FirstPointOnParallelLine != null) { m_FirstPointOnParallelLine.GeometryUpdated.Unsubscribe(GeometryUpdated); } m_FirstPointOnParallelLine = pointData; if (m_FirstPointOnParallelLine != null) { m_FirstPointOnParallelLine.GeometryUpdated.Subscribe(GeometryUpdated); } GeometryUpdated.Invoke(); }
private Face ParseFace(string[] str) { var face = new Face(); for (var i = 1; i < str.Length; i++) { var data = str[i].Split('/'); var pointData = new PointData { VertexIndex = ParseIndex(data[0]), TextureIndex = ParseIndex(data[1]), NormalIndex = ParseIndex(data[2]) }; face[i - 1] = pointData; } return(face); }
public void OnClickTerrain(PointData pointData) { if (target.GetMoveFSM().isMoveLocked) { // GameCenter.messageMng.AddClientMsg(199);//提示玩家,正在晕眩中,不能移动 by吴江 return; } NavMeshHit navHit = new NavMeshHit(); Vector3 destPos = Vector3.zero; if (NavMesh.SamplePosition(pointData.hit.point, out navHit, 10.0f, NavMesh.AllAreas)) { destPos = navHit.position; } else { destPos = pointData.hit.point; } OnClickTerrain(destPos); }
private void MaJiangJun(PointData point) { int len = Constant.MaZouFaDelta.Length; for (int i = 0; i < len; i++) { PointData p = point + Constant.MaZouFaDelta[i].target; if (Utility.IsOnQiPan(p)) { if (((0x00F0 | fen.current) & (int)fen[p]) == 0x0040) { PointData delta2 = Constant.MaZouFaDelta[i].delta2; if (fen[point + delta2] == Qizi.KONGZI) { throw new AppException(ErrorMessage.AE0008); } } } } }
public void SetSecondPointOnTargetLine(PointData pointData) { if (m_SecondPointOnTargetLine == pointData) { return; } if (m_SecondPointOnTargetLine != null) { m_SecondPointOnTargetLine.GeometryUpdated.Unsubscribe(GeometryUpdated); } m_SecondPointOnTargetLine = pointData; if (m_SecondPointOnTargetLine != null) { m_SecondPointOnTargetLine.GeometryUpdated.Subscribe(GeometryUpdated); } GeometryUpdated.Invoke(); }
/// <summary> /// 计算每个节目的点位(x.y)数据 /// </summary> /// <param name="section"></param> /// <returns></returns> public static List <PointData> GetPointDatasBySection(Section section) { var list = new List <PointData>(); if (section.lines.Count > 0) { foreach (var line in section.lines) { var pd = new PointData { Name = line.name.Trim(), Data = AddNewPoint(line, !string.IsNullOrEmpty(section.EquipId)), IsShow = true }; list.Add(pd); } } return(list); }
public async Task WritePointList() { List <PointData> list = new List <PointData>(); for (int i = 0; i < 100; i++) { var value = new Random().Next(0, 100); var point = PointData.Measurement("point-list") .Tag("tag1", "PointTag1") .Tag("tag2", "PointTag2") .Field("value", value) .Timestamp(DateTime.UtcNow.AddSeconds(-i), WritePrecision.Ns); list.Add(point); Console.WriteLine($"WritePointList(): {value}"); } await _writer.WriteAsync(list); }
public async Task WritePointArray() { PointData[] array = new PointData[100]; for (int i = 0; i < 100; i++) { var value = new Random().Next(0, 100); var point = PointData.Measurement("point-array") .Tag("tag1", "PointTag1") .Tag("tag2", "PointTag2") .Field("value", value) .Timestamp(DateTime.UtcNow.AddSeconds(-i), WritePrecision.Ns); array[i] = point; Console.WriteLine($"WritePointList(): {value}"); } await _writer.WriteAsync(array); }
public void WriteData(List <SensorData> sensorData) { var point = sensorData.Select(u => PointData .Measurement("influxData") .Tag("equipmentId", u.Related_Equipment) .Tag("equipment", u.EquipmentName) .Tag("siteId", u.SiteId) .Tag("site", u.Site) .Field(u.Sensor_Name_Lookup, u.DecValue) .Timestamp(u.TimeStampDt, WritePrecision.S)).ToList(); using (var writeApi = client.GetWriteApi()) { foreach (PointData pd in point) { writeApi.WritePoint(bucket, org, pd); } } }
void SpawnObjects(List <Vector2> points, TerrainObjectData obj, float[,] heightMap) { float cellSize = 1f / LOD; foreach (Vector2 point in points) { PointData pointData = CalculatePointData(heightMap, cellSize, point); bool spawnAllowed = true; spawnAllowed &= pointData.height >= obj.minSpawnHeight && pointData.height <= obj.maxSpawnHeight; spawnAllowed &= Mathf.Abs(pointData.gradient.x) <= obj.maxSpawnSlopeValue && Mathf.Abs(pointData.gradient.y) <= obj.maxSpawnSlopeValue; if (spawnAllowed) { Vector3 position = new Vector3(point.x, mapGenerator.GetHeightAt(pointData.height), point.y); GameObject gameObj = Instantiate(obj.obj, position, Quaternion.Euler(0f, (float)prng.NextDouble(), 0f)); float scaleMultiplier = (float)prng.NextDouble() * (obj.scaleFactor * 2) - obj.scaleFactor; gameObj.transform.localScale += Vector3.one * scaleMultiplier; SetParent(gameObj); } } }
void recursiveSaveSpellPoint(Transform point, int parentIndex, List <PointData> points) { int index = -1; if (point.GetComponent <SpellPoint>()) { int duration = point.GetComponent <SpellPoint>().duration; int damage = point.GetComponent <SpellPoint>().damage; float movementSpeed = point.GetComponent <SpellPoint>().movementSpeed; int cost = point.GetComponent <SpellPoint>().cost; index = points.Count; int spriteIndex = point.GetComponent <SpellPoint>().spriteIndex; PointData p = new PointData(duration, damage, movementSpeed, cost, point.position, parentIndex, point.GetComponent <SpellPoint>().gameObjectIndex, spriteIndex); points.Add(p); } foreach (Transform child in point) { recursiveSaveSpellPoint(child, index, points); } }
public void SetProjectedPoint(PointData pointData) { if (m_ProjectedPoint == pointData) { return; } if (m_ProjectedPoint != null) { m_ProjectedPoint.GeometryUpdated.Unsubscribe(GeometryUpdated); } m_ProjectedPoint = pointData; if (m_ProjectedPoint != null) { m_ProjectedPoint.GeometryUpdated.Subscribe(GeometryUpdated); } GeometryUpdated.Invoke(); }
private void AddZouFa(ref List <MoveData> list, PointData start, PointData end) { //添加走法 MoveData move = new MoveData(start, end); //检查将军 try { fen.moves.Insert(0, move); new CheckZoufa(fen).CheckJiangjun(); list.Add(move); } catch (AppException) { } finally { fen.moves.Remove(move); } }
void LASDataConvert(string fileToRead) { PointData[] pointArray; Vector3 minCorner = new Vector3(Mathf.Infinity,Mathf.Infinity,Mathf.Infinity); Vector3 maxCorner = new Vector3(Mathf.NegativeInfinity,Mathf.NegativeInfinity,Mathf.NegativeInfinity); double x=0f,y=0f,z=0f; float r=0f,g=0f,b=0f; BinaryReader reader= new BinaryReader(File.OpenRead(fileToRead)); string fileSignature = new string(reader.ReadChars(4)); if (fileSignature != "LASF") Debug.LogError("LAS> FileSignature error: '"+fileSignature+"'"); // NOTE: Currently most of this info is not used ushort fileSourceID = reader.ReadUInt16(); ushort globalEncoding = reader.ReadUInt16(); ulong projectID1 = reader.ReadUInt32(); // optional? ushort projectID2 = reader.ReadUInt16(); // optional? ushort projectID3 = reader.ReadUInt16(); // optional? string projectID4 = new string(reader.ReadChars(8)); // optional? byte versionMajor = reader.ReadByte(); byte versionMinor = reader.ReadByte(); string systemIdentifier = new string(reader.ReadChars(32)); string generatingSoftware = new string(reader.ReadChars(32)); ushort fileCreationDayOfYear = reader.ReadUInt16(); ushort fileCreationYear = reader.ReadUInt16(); ushort headerSize = reader.ReadUInt16(); ulong offsetToPointData = reader.ReadUInt32(); ulong numberOfVariableLengthRecords = reader.ReadUInt32(); byte pointDataRecordFormat = reader.ReadByte(); ushort PointDataRecordLength = reader.ReadUInt16(); ulong legacyNumberOfPointRecords = reader.ReadUInt32(); ulong[] legacyNumberOfPointsByReturn = new ulong[] {reader.ReadUInt32(),reader.ReadUInt32(),reader.ReadUInt32(),reader.ReadUInt32(),reader.ReadUInt32()}; double xScaleFactor = reader.ReadDouble(); double yScaleFactor = reader.ReadDouble(); double zScaleFactor = reader.ReadDouble(); double xOffset = reader.ReadDouble(); double yOffset = reader.ReadDouble(); double zOffset = reader.ReadDouble(); double maxX = reader.ReadDouble(); double minX = reader.ReadDouble(); double MaxY = reader.ReadDouble(); double minY = reader.ReadDouble(); double maxZ = reader.ReadDouble(); double minZ = reader.ReadDouble(); // Only for 1.4 if (versionMajor==1 && versionMinor==4) { ulong startOfFirstExtentedVariableLengthRecord = reader.ReadUInt64(); ulong numberOfExtentedVariableLengthRecords = reader.ReadUInt32(); ulong numberOfPointRecords = reader.ReadUInt64(); ulong[] numberOfPointsByReturn = new ulong[] {reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(), reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(), reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64(),reader.ReadUInt64()}; } //ulong numberOfPointRecords = reader.ReadUInt64(); // VariableLengthRecords if (numberOfVariableLengthRecords>0) { ushort vlrReserved = reader.ReadUInt16(); string vlrUserID = new string(reader.ReadChars(16)); ushort vlrRecordID = reader.ReadUInt16(); ushort vlrRecordLengthAfterHeader = reader.ReadUInt16(); string vlrDescription = new string(reader.ReadChars(32)); /* Debug.Log("vlrReserved:"+vlrReserved); Debug.Log("vlrUserID:"+vlrUserID); Debug.Log("vlrRecordID:"+vlrRecordID); Debug.Log("vlrRecordLengthAfterHeader:"+vlrRecordLengthAfterHeader); Debug.Log("vlrDescription:"+vlrDescription);*/ } // jump to points start pos reader.BaseStream.Seek((long)offsetToPointData, SeekOrigin.Begin); // format #2 if (pointDataRecordFormat!=2 && pointDataRecordFormat!=3) Debug.LogWarning("LAS Import might fail - only pointDataRecordFormat #2 & #3 are supported (Your file is "+pointDataRecordFormat+")"); if (versionMinor!=2) Debug.LogWarning("LAS Import might fail - only version LAS 1.2 is supported. (Your file is "+versionMajor+"."+versionMinor+")"); masterPointCount = (int)legacyNumberOfPointRecords; // scaling enabled, scale manual offset if (useUnitScale) manualOffset*=unitScale; // progressbar float progress = 0; long progressCounter=0; EditorUtility.ClearProgressBar(); int rowCount = 0; bool haveMoreToRead = true; bool firstPointRead=false; int pointCounter = 0; // array index Vector3[] vertices = new Vector3[vertCount]; Vector2[] uvs = new Vector2[vertCount]; int[] triangles = new int[vertCount]; Color[] colors = new Color[vertCount]; Vector3[] normals = new Vector3[vertCount]; pointArray = new PointData[masterPointCount]; Debug.Log("Reading "+masterPointCount+" points.."); // process all points while (haveMoreToRead) { if (progressCounter>65000) { //EditorUtility.DisplayProgressBar(appName,"Reading LAS file ",progress/masterPointCount); if (EditorUtility.DisplayCancelableProgressBar(appName,"Counting lines..",progress/masterPointCount)) { Debug.Log("Cancelled at: "+progress); EditorUtility.ClearProgressBar(); return; } progressCounter=0; } progressCounter++; progress++; long intX = reader.ReadInt32(); long intY = reader.ReadInt32(); long intZ = reader.ReadInt32(); reader.ReadBytes(8); // unknown if (pointDataRecordFormat==3) reader.ReadBytes(8); // GPS Time for format#3 var colorR = reader.ReadBytes(2); // RED var colorG = reader.ReadBytes(2); // GREEN var colorB = reader.ReadBytes(2); // BLUE x=intX*xScaleFactor+xOffset; y=intY*yScaleFactor+yOffset; z=intZ*zScaleFactor+zOffset; // manual scaling enabled if (useUnitScale) { x *= unitScale; y *= unitScale; z *= unitScale; } if (flipYZ) { double yy=y; y=z; z=yy; } if (autoOffsetNearZero) { if (!firstPointRead) { manualOffset = new Vector3((float)x,(float)y,(float)z); firstPointRead=true; } x-=manualOffset.x; y-=manualOffset.y; z-=manualOffset.z; }else{ // only 1 can be used autooffset or manual if (enableManualOffset) { x-=manualOffset.x; y-=manualOffset.y; z-=manualOffset.z; } } vertices[pointCounter]=new Vector3((float)x,(float)y,(float)z); if (readRGB) { r = (float)System.BitConverter.ToUInt16(colorR, 0); g = (float)System.BitConverter.ToUInt16(colorG, 0); b = (float)System.BitConverter.ToUInt16(colorB, 0); //if (rowCount<100) Debug.Log("row:"+(rowCount+1)+" xyz:"+x+","+y+","+z+" : "+r+","+g+","+b); r = ((float)r)/256f;//float.Parse(row[3])/255; g = ((float)g)/256f;//float.Parse(row[4])/255; b = ((float)b)/256f;//float.Parse(row[5])/255; // fix for high values if (r>1) r/=256f; if (g>1) g/=256f; if (b>1) b/=256f; colors[pointCounter] = new Color(r,g,b,0.5f); // TODO: adjust alpha pointArray[rowCount].color = new Color(r,g,b,0.5f); } // get cloud corners minCorner.x = Mathf.Min((float)x,minCorner.x); minCorner.y = Mathf.Min((float)y,minCorner.y); minCorner.z = Mathf.Min((float)z,minCorner.z); maxCorner.x = Mathf.Max((float)x,maxCorner.x); maxCorner.y = Mathf.Max((float)y,maxCorner.y); maxCorner.z = Mathf.Max((float)z,maxCorner.z); pointArray[rowCount].vertex = new Vector3((float)x,(float)y,(float)z); pointArray[rowCount].uv = new Vector2((float)x,(float)y); pointArray[rowCount].indice = rowCount % vertCount; rowCount++; if (reader.BaseStream.Position >= reader.BaseStream.Length || rowCount>=masterPointCount) { haveMoreToRead = false; } } // while loop reading file // build mesh assets int indexCount=0; Vector3[] vertices2 = new Vector3[vertCount]; Vector2[] uvs2 = new Vector2[vertCount]; int[] triangles2 = new int[vertCount]; Color[] colors2 = new Color[vertCount]; Vector3[] normals2 = new Vector3[vertCount]; // Debug.Log("Total points: "+pointArray.Length); EditorUtility.DisplayProgressBar(appName,"Creating "+((int)(pointArray.Length/vertCount))+" mesh arrays",0.5f); for (int i = 0; i < pointArray.Length; i++) { vertices2[indexCount] = pointArray[i].vertex; uvs2[indexCount] = pointArray[i].uv; triangles2[indexCount] = pointArray[i].indice; if (readRGB) colors2[indexCount] = pointArray[i].color; if (decimatePoints) { if (i % removeEveryNth == 0) indexCount++; }else{ indexCount++; } if (indexCount>=vertCount || i==pointArray.Length-1) { // BuildMesh(vertices2, uvs2, triangles2, colors2, normals2); var go = BuildMesh(vertices2, uvs2, triangles2, colors2, normals2); if (createLODS) BuildLODS(go, vertices2, uvs2, triangles2, colors2, normals2); System.Array.Clear(vertices2,0,vertCount); System.Array.Clear(uvs2,0,vertCount); System.Array.Clear(triangles2,0,vertCount); if (readRGB || readIntensity) System.Array.Clear(colors2,0,vertCount); if (readNormals) System.Array.Clear(normals2,0,vertCount); indexCount=0; } } EditorUtility.ClearProgressBar(); // save meshes EditorUtility.DisplayProgressBar(appName,"Saving "+(cloudList.Count)+" mesh assets",0.75f); string pad=""; for (int i=0;i<cloudList.Count;i++) { if (i<1000) pad="0"; if (i<100) pad="00"; if (i<10) pad="000"; AssetDatabase.CreateAsset(cloudList[i],savePath+pad+i+".asset"); AssetDatabase.SaveAssets(); // not needed? } // save meshes EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); EditorUtility.ClearProgressBar(); }
/// <summary> /// 判定一个手掌是否处于弯曲状态。 /// 手掌中有matchNumber个手指满足即可,实际设定为2-3个 /// </summary> /// <param name="dic_FingersData"></param> /// <param name="matchNumber"></param> /// <param name="dir">【返回值】:如果匹配成功方向为掌心的方向</param> /// <returns>是否为弯曲状态</returns> bool BendState( Dictionary<Finger.FingerType, FingerData> dic_FingersData,PointData palmData, int matchNumber,out Vector dir ) { bool isBend = false; dir = Vector.Zero; int count = 0; Dictionary<Finger.FingerType, FingerData> fingersOutThumb = new Dictionary<Finger.FingerType, FingerData>(dic_FingersData); fingersOutThumb.Remove(Finger.FingerType.TYPE_THUMB); var values = fingersOutThumb.Values; //float eulerAngule = 0f; //遍历四指,匹配个数满足设定个数认定手掌为弯曲,并且设定弯曲的方向为掌心方向。 foreach (FingerData fingerData in values) { if (FingerMatch.BendState(fingerData))//,out eulerAngule)) { count++; } } //print ("Bend Count:"+count+" BendEuler:"+eulerAngule); if (count >= matchNumber) { isBend = true; dir = palmData.m_Direction; } return isBend; }
public void Set(PointData pd) { m_Position = pd.m_Position; m_Direction = pd.m_Direction; }
public void Set(FingerData fd) { m_Point = fd.m_Point; m_Position = fd.m_Position; }
public Vector m_Position; //手指根骨的位置,对于拇指来说是Proximal phalanges近端指骨的位置 #endregion Fields #region Constructors public FingerData(PointData pointData, Vector pos) { m_Point = pointData; m_Position = pos; }
void BendCtrl(Dictionary<Finger.FingerType, FingerData>[] dic,PointData[] palmDatas) { Vector[] bendDir = new Vector[2]; bool[] isBend = new bool[2]; isBend[0] = BendState(dic[0], palmDatas[0], m_MatchNumber, out bendDir[0]); isBend[1] = BendState(dic[1], palmDatas[1], m_MatchNumber, out bendDir[1]); //有几组数据就遍历几次-限1或2次 int count= dic.Length; for (int handIndex = 0; handIndex < count; handIndex++) { //这个if - else 结构依据m_IsEnterBended-isLeftOpen表示的二维坐标系,而出现的四个象限。 //此次左手伸掌状态的最开始,触发 //当不处于m_IsEnterBended状态,并且现在左手是伸掌状态才会触发 if (!m_IsEnterBended[handIndex] && isBend[handIndex]) { if (m_EnterBendFunc[handIndex] != null) { m_EnterBendFunc[handIndex](); } m_BendingTime[handIndex] = 0f; m_IsEnterBended[handIndex] = true; m_Dir[handIndex] = bendDir[handIndex]; } //持续进行左手的伸掌状态 //左手已经进入到伸掌状态,而且现在也是伸掌状态 else if (m_IsEnterBended[handIndex] && isBend[handIndex]) { m_BendingTime[handIndex] += Time.deltaTime;//该函数会在Update中调用。 m_Dir[handIndex] = bendDir[handIndex]; } //退出左手伸掌状态,这是此次持续伸掌的最后一瞬间伸掌 //左手已经进入伸掌状态,并且现在不是伸掌状态 else if (m_IsEnterBended[handIndex] && !isBend[handIndex]) { if (m_ExitBendFunc[handIndex] != null) { m_ExitBendFunc[handIndex](); } m_IsEnterBended[handIndex] = false; m_BendingTime[handIndex] = 0f; m_Dir[handIndex] = bendDir[handIndex]; } //本身不是处于伸掌状态,而且此次判断也不是伸掌状态 else { m_IsEnterBended[handIndex] = false; m_BendingTime[handIndex] = 0f; m_Dir[handIndex] = Vector.Zero; } } }
void onMouseDrag(PointData _pointData) { }
void DoConvert(UnityEngine.Object sourceFile) { string fileToRead = AssetDatabase.GetAssetPath(sourceFile); string filename = Path.GetFileNameWithoutExtension(fileToRead); string savePath = EditorUtility.SaveFilePanelInProject("Mesh assets output folder & basename", filename + ".asset", "asset", "Set base filename"); EditorUtility.DisplayProgressBar(_appName, "Checking file..", 0.5f); if (savePath.Length == 0) { Debug.LogWarning(_appName + "> Cancelled.."); EditorUtility.ClearProgressBar(); return; } if (fileToRead.Length == 0) { Debug.LogWarning(_appName + "> Cannot find file (" + fileToRead + ")"); EditorUtility.ClearProgressBar(); return; } string fileExtension = Path.GetExtension(fileToRead).ToLower(); if (fileExtension != ".ply") { Debug.LogWarning(_appName + "> Only .PLY files are supported."); EditorUtility.ClearProgressBar(); return; } if (!_folder && _createGameObjects) { _folder = new GameObject(); _folder.name = "PointClouds"; } long masterPointCount = 0; long lines = 0; int dataCount = 0; PointData[] pointArray; double minCornerX = Mathf.Infinity; double minCornerY = Mathf.Infinity; double minCornerZ = Mathf.Infinity; double maxCornerX = Mathf.NegativeInfinity; double maxCornerY = Mathf.NegativeInfinity; double maxCornerZ = Mathf.NegativeInfinity; // Settings bool readRGB = true; bool readIntensity = false; bool readNormals = false; bool autoOffsetNearZero = true; bool enableManualOffset = false; Vector3 manualOffset = Vector3.zero; int maxVertCount = 65000; using (StreamReader reader = new StreamReader(File.OpenRead(fileToRead))) { double x = 0, y = 0, z = 0, nx = 0, ny = 0, nz = 0; float r = 0, g = 0, b = 0; //,a=0; int indexR = 3, indexG = 4, indexB = 5; int indexNX = 3, indexNY = 4, indexNZ = 5; int indexI = 3; string rawLine = null; string origRawLine = null; string[] lineSplitted = null; int commentsLength = 0; int commentLines = 0; bool replaceCommas = false; // for cgo, catia asc (depends on pc regional settings) bool comments = true; bool hasNormals = false; while (comments && !reader.EndOfStream) { origRawLine = reader.ReadLine(); if (origRawLine.ToLower().Contains("property float nx")) hasNormals = true; if (masterPointCount == 0) { if (origRawLine.ToLower().Contains("element vertex")) { // get point count int tempParse = 0; if (int.TryParse(origRawLine.Split(' ')[2], out tempParse)) { masterPointCount = tempParse; } else { Debug.LogError("PLY Header parsing failed, point count not founded"); EditorUtility.ClearProgressBar(); return; } } } rawLine = Regex.Replace(origRawLine, "[^.0-9 ]+[^e\\-\\d]", ""); // cleanup non numeric rawLine = rawLine.Replace(" ", " ").Replace(" ", " ").Trim(); lineSplitted = rawLine.Split(' '); if (rawLine.StartsWith("#") || rawLine.StartsWith("!") || rawLine.StartsWith("*") || rawLine.ToLower().Contains("comment") || (!ValidateColumns(lineSplitted.Length))) { commentsLength += origRawLine.Length + 1; // +1 is end of line? commentLines++; } else { if (rawLine.Contains(",")) { replaceCommas = true; } if (replaceCommas) { rawLine = rawLine.Replace(",", "."); // for cgo/catia asc } lineSplitted = rawLine.Split(' '); if (readRGB && lineSplitted.Length < 6) { Debug.LogError("No RGB data founded after XYZ, disabling readRGB"); readRGB = false; } if (readIntensity && (lineSplitted.Length != 4 && lineSplitted.Length != 7)) { Debug.LogError("No Intensity data founded after XYZ, disabling readIntensity"); readIntensity = false; } if (readNormals) { if (!hasNormals) { Debug.LogError("No normals data founded, disabling readNormals. [" + lineSplitted.Length + " values founded]"); readNormals = false; } else { indexR += 3; indexG += 3; indexB += 3; } } else { if (hasNormals) { indexR += 3; indexG += 3; indexB += 3; } } dataCount = lineSplitted.Length; comments = false; lines++; } } bool skipRow = false; int skippedRows = 0; if (!double.TryParse(lineSplitted[0], out x)) skipRow = true; if (!double.TryParse(lineSplitted[1], out y)) skipRow = true; if (!double.TryParse(lineSplitted[2], out z)) skipRow = true; if (skipRow) { skippedRows++; Debug.LogWarning("First point data row was skipped, conversion will most likely fail (rawline:" + rawLine + ")"); } if (enableManualOffset || autoOffsetNearZero) { manualOffset = _flipYZ ? new Vector3((float)x, (float)z, (float)y) : new Vector3((float)x, (float)y, (float)z); } if (_useUnitScale) manualOffset *= _unitScale; EditorUtility.ClearProgressBar(); lines = masterPointCount; reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; if (commentLines > 0) { for (int i = 0; i < commentLines; i++) { reader.ReadLine(); } } pointArray = new PointData[masterPointCount]; long rowCount = 0; double tempVal = 0; for (rowCount = 0; rowCount < masterPointCount - 1; rowCount++) { if (rowCount % 64000 == 1) { EditorUtility.DisplayProgressBar(_appName, "Processing points..", rowCount / (float)lines); } rawLine = reader.ReadLine().Trim(); rawLine = rawLine.Replace(",", "."); // for cgo/catia asc rawLine = Regex.Replace(rawLine, "[^.0-9 ]+[^e\\-\\d]", "").Trim(); // cleanup non numeric rawLine = rawLine.Replace(" ", " ").Replace(" ", " ").Trim(); lineSplitted = rawLine.Split(' '); if (lineSplitted.Length == dataCount) { if (!double.TryParse(lineSplitted[0], out x)) skipRow = true; if (!double.TryParse(lineSplitted[1], out y)) skipRow = true; if (!double.TryParse(lineSplitted[2], out z)) skipRow = true; if (readRGB) { r = System.Convert.ToInt32(lineSplitted[indexR]); g = System.Convert.ToInt32(lineSplitted[indexG]); b = System.Convert.ToInt32(lineSplitted[indexB]); r /= 255f; g /= 255f; b /= 255f; } if (readIntensity) { if (!float.TryParse(lineSplitted[indexI], out r)) skipRow = true; g = r; b = r; } if (readNormals) { if (!double.TryParse(lineSplitted[indexNX], out nx)) skipRow = true; if (!double.TryParse(lineSplitted[indexNY], out ny)) skipRow = true; if (!double.TryParse(lineSplitted[indexNZ], out nz)) skipRow = true; } if (_flipYZ) { tempVal = z; z = y; y = tempVal; if (readNormals) { tempVal = nz; nz = ny; ny = tempVal; } } if (_useUnitScale) { x *= _unitScale; y *= _unitScale; z *= _unitScale; } if (autoOffsetNearZero || enableManualOffset) { x -= manualOffset.x; y -= manualOffset.y; z -= manualOffset.z; } if (!skipRow) { minCornerX = System.Math.Min(x, minCornerX); minCornerY = System.Math.Min(y, minCornerY); minCornerZ = System.Math.Min(z, minCornerZ); maxCornerX = System.Math.Max(x, maxCornerX); maxCornerY = System.Math.Max(y, maxCornerY); maxCornerZ = System.Math.Max(z, maxCornerZ); pointArray[rowCount].vertex.Set((float)x, (float)y, (float)z); } if (readRGB || readIntensity) { pointArray[rowCount].color.r = r; pointArray[rowCount].color.g = g; pointArray[rowCount].color.b = b; pointArray[rowCount].color.a = 0.5f; } if (readNormals) { pointArray[rowCount].normal.Set((float)nx, (float)ny, (float)nz); } } else { skipRow = true; } if (skipRow) { skippedRows++; skipRow = false; } } EditorUtility.ClearProgressBar(); if (skippedRows > 0) { Debug.LogWarning("Skipped " + skippedRows.ToString() + " rows (out of " + masterPointCount + " rows) because of parsing errors"); } } int vertexCount = 0; Vector3[] vertices2 = new Vector3[maxVertCount]; Vector2[] uvs2 = new Vector2[maxVertCount]; int[] triangles2 = new int[maxVertCount]; Color[] colors2 = new Color[maxVertCount]; Vector3[] normals2 = new Vector3[maxVertCount]; int numMeshes = ((int)((pointArray.Length * 4) / maxVertCount)) + 1; string pad = ""; string saveFileName = Path.GetFileNameWithoutExtension(savePath); string saveFilePath = Path.GetDirectoryName(savePath); int countMesh = 0; for (int i = 0; i < pointArray.Length; i++) { SetupVertex(ref vertices2, ref uvs2, ref triangles2, ref colors2, ref normals2, pointArray[i], -1, -1, vertexCount++, readRGB, readIntensity, readNormals); SetupVertex(ref vertices2, ref uvs2, ref triangles2, ref colors2, ref normals2, pointArray[i], -1, 1, vertexCount++, readRGB, readIntensity, readNormals); SetupVertex(ref vertices2, ref uvs2, ref triangles2, ref colors2, ref normals2, pointArray[i], 1, 1, vertexCount++, readRGB, readIntensity, readNormals); SetupVertex(ref vertices2, ref uvs2, ref triangles2, ref colors2, ref normals2, pointArray[i], 1, -1, vertexCount++, readRGB, readIntensity, readNormals); if (vertexCount >= (maxVertCount - 4) || i == pointArray.Length - 1) { EditorUtility.DisplayProgressBar(_appName, "Creating " + numMeshes + " mesh arrays", (float)countMesh/(float)numMeshes); Mesh mesh = new Mesh(); BuildMesh(ref mesh, vertices2, uvs2, triangles2, colors2, normals2, countMesh, readRGB, readIntensity, readNormals, vertexCount); if (_createGameObjects) { GameObject target = new GameObject(); target.AddComponent<MeshFilter>(); target.AddComponent<MeshRenderer>(); target.GetComponent<MeshFilter>().mesh = mesh; target.transform.name = "PC_" + countMesh; target.GetComponent<Renderer>().sharedMaterial = _meshMaterial; target.GetComponent<Renderer>().receiveShadows = false; target.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; target.transform.parent = _folder.transform; } if (countMesh < 10) pad = "000"; else if (countMesh < 100) pad = "00"; else if (countMesh < 1000) pad = "0"; AssetDatabase.CreateAsset(mesh, saveFilePath + "/" + saveFileName + pad + countMesh + ".asset"); AssetDatabase.SaveAssets(); // not needed? AssetDatabase.Refresh(); System.Array.Clear(vertices2, 0, maxVertCount); System.Array.Clear(uvs2, 0, maxVertCount); System.Array.Clear(triangles2, 0, maxVertCount); if (readRGB || readIntensity) System.Array.Clear(colors2, 0, maxVertCount); if (readNormals) System.Array.Clear(normals2, 0, maxVertCount); vertexCount = 0; countMesh++; } } EditorUtility.ClearProgressBar(); }
private void AddRoomNumber(MapShapeData shape) { PointData pinPoint = new PointData() { Location = shape.GeoBounds.Center, ZIndex = 7, ExtendedData = shape.ExtendedData }; this.visualizationLayer.Items.Add(pinPoint); }
private void RebuildBuffer() { List<PointInstance> tempInstances = null; lock (m_instances) { tempInstances = new List<PointInstance>(m_instances); } var length = tempInstances.Count; if (length != 0) { PointData[] data = new PointData[length]; Parallel.For(0, length, i => { var instance = tempInstances[i]; var matrix = Matrix4.Identity; data[i] = new PointData() { Color = instance.Color, Position = instance.P }; }); GL.BindVertexArray(m_vao); m_bufferSprite.SetData(data, GL.STREAM_DRAW); } else { GL.BindVertexArray(m_vao); m_bufferSprite.SetData(null, GL.STREAM_DRAW); } m_isDirty = false; }
void SetupVertex(ref Vector3[] vertices, ref Vector2[] uvs, ref int[] indices, ref Color[] colors, ref Vector3[] normals, PointData point, float offsetX, float offsetY, int vertexIndex, bool readRGB, bool readIntensity, bool readNormals) { vertices[vertexIndex] = point.vertex; uvs[vertexIndex] = new Vector2(offsetX, offsetY); indices[vertexIndex] = vertexIndex; if (readRGB || readIntensity) colors[vertexIndex] = point.color; if (readNormals) normals[vertexIndex] = point.normal; }
//显示单个手指的数据 //1.掌心到手指的连线-红色 //2.手指的方向-蓝色 void ShowFingerData(int handIndex,PointData palmData,FingerData fingerData) { Vector3 handPos = VectorTrans.ToUnityVector3 (palmData.m_Position); Vector3 handDir = VectorTrans.ToUnityVector3 (palmData.m_Direction); Vector3 fingerPos = VectorTrans.ToUnityVector3 (fingerData.m_Position); Vector3 fingerDistalPos = VectorTrans.ToUnityVector3 (fingerData.m_Point.m_Position); Vector3 fingerDir = VectorTrans.ToUnityVector3 (fingerData.m_Point.m_Direction); Debug.DrawLine (handPos,fingerPos,Color.red); Debug.DrawLine(fingerPos, fingerDistalPos, Color.red); //手心到指尖的连线 Debug.DrawLine(handPos, fingerDistalPos, Color.yellow); float vecLength = (fingerPos - fingerDistalPos).magnitude; Debug.DrawRay(fingerDistalPos, fingerDir * vecLength * 0.1f, Color.blue); Debug.DrawRay(handPos, handDir * vecLength * 0.1f, Color.blue); }
protected override void Emit(PointData[] points) { }
/// <summary> /// Convert a Revit mesh to a Helix mesh for visualization. /// In order to merge mesh vertices, this method uses a dictionary with a string key formed as x:y:z of the point. /// This assumes that where vertices are the "same" in the Revit mesh, they will have the same coordinates. This /// is NOT a safe strategy to use in other mesh-processing contexts where vertices might have small discrepancies. /// </summary> /// <param name="rmesh"></param> /// <param name="octree"></param> /// <param name="node"></param> /// <returns></returns> private static MeshGeometry3D RevitMeshToHelixMesh(Mesh rmesh, Octree.OctreeSearch.Octree octree, NodeModel node) { var builder = new MeshBuilder(); var points = new Point3DCollection(); var tex = new PointCollection(); var norms = new Vector3DCollection(); var tris = new List<int>(); //A dictionary which will contain a point, a normal, and an index //keyed on the location of the point as a hash var pointDict = new Dictionary<string, PointData>(); for (int i = 0; i < rmesh.NumTriangles; ++i) { var tri = rmesh.get_Triangle(i); //calculate the face normal by //getting the cross product of two edges var a = tri.get_Vertex(0); var b = tri.get_Vertex(1); var c = tri.get_Vertex(2); var e1 = b - a; var e2 = c - a; var normXYZ = e1.CrossProduct(e2).Normalize(); var normal = new Vector3D(normXYZ.X, normXYZ.Y, normXYZ.Z); for (int j = 0; j < 3; j++) { var pt = RevitPointToWindowsPoint(tri.get_Vertex(j)); var key = pt.X + ":" + pt.Y + ":" + pt.Z; if (!pointDict.ContainsKey(key)) { //if the dictionary doesn't contain the key var pd = new PointData(pt.X,pt.Y,pt.Z); pd.Normals.Add(normal); pd.Index = pointDict.Count; pointDict.Add(key, pd); tris.Add(pd.Index); } else { //add an index to our tris array //add a normal to our internal collection //for post processing var data = pointDict[key]; tris.Add(data.Index); data.Normals.Add(normal); } } } var lst = pointDict.ToList(); lst.ForEach(x => points.Add(x.Value.Position)); lst.ForEach(x=>octree.AddNode(x.Value.Position.X, x.Value.Position.Y, x.Value.Position.Z, node.GUID.ToString())); lst.ForEach(x=>tex.Add(x.Value.Tex)); //merge the normals foreach (var pd in lst) { var avg = new Vector3D(); var nList = pd.Value.Normals; foreach (var n in nList) { avg.X += n.X; avg.Y += n.Y; avg.Z += n.Z; } avg.X = avg.X / nList.Count; avg.Y = avg.Y / nList.Count; avg.Z = avg.Z / nList.Count; norms.Add(avg); } builder.Append(points, tris, norms, tex); Debug.WriteLine(string.Format("Mesh had {0} faces coming in and {1} faces going out.", rmesh.NumTriangles, builder.TriangleIndices.Count / 3)); return builder.ToMesh(true); }
void Convert2Mesh() { cloudList.Clear(); meshCounter = 1; savePath = EditorUtility.SaveFilePanelInProject("Mesh assets output folder & basename","PointChunk","asset","Set base filename"); EditorUtility.DisplayProgressBar(appName,"Checking file..",0.25f); // check path if(savePath.Length == 0) { Debug.LogWarning(appName+"> Cancelled.."); EditorUtility.ClearProgressBar(); return; } string fileToRead= AssetDatabase.GetAssetPath(sourceFile); if(fileToRead.Length != 0) { //Debug.Log ("readfile: "+path); }else{ Debug.LogWarning(appName+"> Cannot find file ("+fileToRead+")"); EditorUtility.ClearProgressBar(); return; } if (!File.Exists(fileToRead)) { Debug.LogWarning(appName+"> Cannot find file ("+fileToRead+")"); EditorUtility.ClearProgressBar(); return; } string fileExtension = Path.GetExtension(fileToRead).ToLower(); if (fileExtension!=".ply") { if (readNormals) { Debug.LogWarning(appName+"> Importing normals is only supported for .PLY files"); readNormals = false; } } // TEMPORARY: Custom reader for Brekel binary data if (fileExtension==".bin") { Debug.Log(fileExtension); EditorUtility.ClearProgressBar(); BrekelDataConvert(fileToRead); return; } // TEMPORARY: Custom reader for LAS binary data if (fileExtension==".las") { EditorUtility.ClearProgressBar(); LASDataConvert(fileToRead); return; } masterPointCount=0; long lines=0; int dataCount=0; PointData[] pointArray; //Vector3 minCorner = new Vector3(Mathf.Infinity,Mathf.Infinity,Mathf.Infinity); //Vector3 maxCorner = new Vector3(Mathf.NegativeInfinity,Mathf.NegativeInfinity,Mathf.NegativeInfinity); double minCornerX=Mathf.Infinity; double minCornerY=Mathf.Infinity; double minCornerZ=Mathf.Infinity; double maxCornerX=Mathf.NegativeInfinity; double maxCornerY=Mathf.NegativeInfinity; double maxCornerZ=Mathf.NegativeInfinity; using (StreamReader reader = new StreamReader(File.OpenRead(fileToRead))) { double x=0,y=0,z=0,nx=0,ny=0,nz=0; float r=0,g=0,b=0; //,a=0; int indexR=3,indexG=4,indexB=5; int indexNX=3,indexNY=4,indexNZ=5; int indexI=3; string rawLine = null; string origRawLine = null; string[] lineSplitted = null; int commentsLength=0; int commentLines=0; // formats bool replaceCommas=false; // for cgo, catia asc (depends on pc regional settings) // find first line of point data bool comments=true; bool hasNormals=false; // parse header while (comments && !reader.EndOfStream) { origRawLine = reader.ReadLine(); // check for normals if (origRawLine.ToLower().Contains("property float nx")) hasNormals=true; // early exit if certain file type if (fileExtension==".ply" && masterPointCount==0) { if (origRawLine.ToLower().Contains("element vertex")) { // get point count int tempParse=0; if (int.TryParse(origRawLine.Split(' ')[2], out tempParse)) { masterPointCount = tempParse; }else{ Debug.LogError("PLY Header parsing failed, point count not founded"); EditorUtility.ClearProgressBar(); return; } } } if ((fileExtension==".pts" || fileExtension==".cgo") && masterPointCount==0) { // get point count int tempParse=0; rawLine = Regex.Replace(origRawLine, "[^.0-9 ]+[^e\\-\\d]", "").Trim(); // cleanup non numeric if (int.TryParse(rawLine, out tempParse)) { masterPointCount = tempParse; commentLines=1; }else{ Debug.LogError(fileExtension.ToUpper()+" header parsing failed, point count not founded"); EditorUtility.ClearProgressBar(); return; } } // rawLine = origRawLine.Replace(",","."); // for cgo/catia asc rawLine = Regex.Replace(origRawLine, "[^.0-9 ]+[^e\\-\\d]", ""); // cleanup non numeric rawLine = rawLine.Replace(" "," ").Replace(" "," ").Trim(); lineSplitted = rawLine.Split(' '); if (rawLine.StartsWith("#") || rawLine.StartsWith("!") || rawLine.StartsWith("*") || rawLine.ToLower().Contains("comment") || (!ValidateColumns(lineSplitted.Length))) { commentsLength+=origRawLine.Length+1; // +1 is end of line? commentLines++; }else{ // actual data // test with split if (rawLine.Contains(",")) replaceCommas=true; if (replaceCommas) rawLine = rawLine.Replace(",","."); // for cgo/catia asc lineSplitted = rawLine.Split(' '); if (readRGB && lineSplitted.Length<6) {Debug.LogError("No RGB data founded after XYZ, disabling readRGB"); readRGB = false;} if (readIntensity && (lineSplitted.Length!=4 && lineSplitted.Length != 7)) {Debug.LogError("No Intensity data founded after XYZ, disabling readIntensity"); readIntensity = false;} if (readNormals) { //if (lineSplitted.Length!=6 && lineSplitted.Length != 7 && lineSplitted.Length != 9 && lineSplitted.Length != 10) { if (!hasNormals) { Debug.LogError("No normals data founded, disabling readNormals. ["+lineSplitted.Length+" values founded]"); readNormals = false; }else{ // we have normals // for PLY, RGB values are at the end indexR+=3; indexG+=3; indexB+=3; } }else{ // check if normals are there, but dont use them if (hasNormals) { indexR+=3; indexG+=3; indexB+=3; } } dataCount = lineSplitted.Length; comments=false; lines++; } } // while (parsing header) bool skipRow = false; int skippedRows = 0; // get first data row if (!double.TryParse(lineSplitted[0], out x)) skipRow = true; if (!double.TryParse(lineSplitted[1], out y)) skipRow = true; if (!double.TryParse(lineSplitted[2], out z)) skipRow = true; if (skipRow) { skippedRows++; Debug.LogWarning("First point data row was skipped, conversion will most likely fail (rawline:"+rawLine+")"); } if (enableManualOffset || autoOffsetNearZero) { manualOffset = flipYZ?new Vector3((float)x,(float)z,(float)y):new Vector3((float)x,(float)y,(float)z); } // scaling enabled, scale offset too if (useUnitScale) manualOffset*=unitScale; // jump back to start of first line EditorUtility.ClearProgressBar(); // use header count value from ply, cgo, pts.. if (fileExtension==".ply" || fileExtension==".pts" || fileExtension==".cgo") { lines = masterPointCount; }else{ // calculate rest of data lines while (!reader.EndOfStream) { origRawLine = reader.ReadLine(); if (replaceCommas) rawLine = origRawLine.Replace(",","."); rawLine = Regex.Replace(rawLine, "[^.0-9 ]+[^e\\-\\d]", ""); // cleanup non numeric rawLine= rawLine.Replace(" "," ").Replace(" "," ").Trim(); if (lines % 64000==1) { if (EditorUtility.DisplayCancelableProgressBar(appName,"Counting lines..",lines/20000000.0f)) { Debug.Log("Cancelled at: "+lines); EditorUtility.ClearProgressBar(); return; } } // check if data is valid if (!rawLine.StartsWith("!")) { if (!rawLine.StartsWith("*")) { if (!rawLine.StartsWith("#")) { lineSplitted = rawLine.Split(' '); if (lineSplitted.Length == dataCount) { lines++; } } } } } // count points EditorUtility.ClearProgressBar(); } // reset back to start reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; if (commentLines>0) { for (int i = 0; i < commentLines; i++) { reader.ReadLine(); } } masterPointCount = lines; pointArray = new PointData[masterPointCount]; long rowCount = 0; bool readMore = true; double tempVal=0; //read all point cloud data here for (rowCount = 0; rowCount < masterPointCount-1; rowCount++) { if (rowCount % 64000==1) { EditorUtility.DisplayProgressBar(appName,"Processing points..",rowCount/(float)lines); //progressCounter=0; } // process each line rawLine = reader.ReadLine().Trim(); // trim duplicate spaces rawLine = rawLine.Replace(",","."); // for cgo/catia asc rawLine = Regex.Replace(rawLine, "[^.0-9 ]+[^e\\-\\d]", "").Trim(); // cleanup non numeric rawLine= rawLine.Replace(" "," ").Replace(" "," ").Trim(); lineSplitted = rawLine.Split(' '); // have same amount of columns in data? if (lineSplitted.Length == dataCount) { if (!double.TryParse(lineSplitted[0], out x)) skipRow = true; if (!double.TryParse(lineSplitted[1], out y)) skipRow = true; if (!double.TryParse(lineSplitted[2], out z)) skipRow = true; if (readRGB) { // if (!float.TryParse(lineSplitted[indexR], out r)) skipRow = true; // if (!float.TryParse(lineSplitted[indexG], out g)) skipRow = true; // if (!float.TryParse(lineSplitted[indexB], out b)) skipRow = true; r = System.Convert.ToInt32(lineSplitted[indexR]); g = System.Convert.ToInt32(lineSplitted[indexG]); b = System.Convert.ToInt32(lineSplitted[indexB]); r/=255f; g/=255f; b/=255f; } if (readIntensity) { // TODO: handle different intensity values if (!float.TryParse(lineSplitted[indexI], out r)) skipRow = true; // re-range PTS intensity if (fileExtension==".pts") { r = Remap(r,-2048,2047,0,1); } g=r; b=r; } if (readNormals) { if (!double.TryParse(lineSplitted[indexNX], out nx)) skipRow = true; if (!double.TryParse(lineSplitted[indexNY], out ny)) skipRow = true; if (!double.TryParse(lineSplitted[indexNZ], out nz)) skipRow = true; } // if flip if (flipYZ) { tempVal = z; z=y; y=tempVal; // flip normals? if (readNormals) { tempVal = nz; nz=ny; ny=tempVal; } } // scaling enabled if (useUnitScale) { x *= unitScale; y *= unitScale; z *= unitScale; } // manual offset enabled if (autoOffsetNearZero || enableManualOffset) { x-=manualOffset.x; y-=manualOffset.y; z-=manualOffset.z; } // get cloud corners if (!skipRow) { minCornerX = System.Math.Min(x,minCornerX); minCornerY = System.Math.Min(y,minCornerY); minCornerZ = System.Math.Min(z,minCornerZ); maxCornerX = System.Math.Max(x,maxCornerX); maxCornerY = System.Math.Max(y,maxCornerY); maxCornerZ = System.Math.Max(z,maxCornerZ); pointArray[rowCount].vertex.Set((float)x,(float)y,(float)z); pointArray[rowCount].uv.Set((float)x,(float)y); pointArray[rowCount].indice = ((int)rowCount) % vertCount; } if (readRGB || readIntensity) { pointArray[rowCount].color.r = r; pointArray[rowCount].color.g = g; pointArray[rowCount].color.b = b; pointArray[rowCount].color.a = 0.5f; } if (readNormals) pointArray[rowCount].normal.Set((float)nx,(float)ny,(float)nz); }else{ // if row length skipRow=true; } // } // line len if (skipRow) { skippedRows++; skipRow = false; }else{ // rowCount++; } // if (reader.EndOfStream)// || rowCount>=masterPointCount) // { //Debug.Log(reader.EndOfStream); //Debug.Log(rowCount>=masterPointCount); //readMore = false; // Debug.LogError("Reached end of file too early ("+rowCount+"/"+masterPointCount+")"); // break; // } } // while reading file EditorUtility.ClearProgressBar(); if (skippedRows>0) Debug.LogWarning("Skipped "+skippedRows.ToString()+" rows (out of "+masterPointCount+" rows) because of parsing errors"); } // using reader // sort points, FIXME: something strange happens inside sort, points go missing or lose precision? if (optimizePoints) { EditorUtility.DisplayProgressBar(appName,"Optimizing points..",0.25f); // sort by val //System.Array.Sort<PointData>(pointArray, (a,b) => ((a.vertex.x)>(b.vertex.x))?1:-1); // distance sort //System.Array.Sort<PointData>(pointArray, (a,b) => (minCorner-a.vertex).sqrMagnitude.CompareTo((minCorner-b.vertex).sqrMagnitude)); // TODO: sorting loses precision?? // sort by x System.Array.Sort<PointData>(pointArray, (a,b) => (minCornerX-a.vertex.x).CompareTo(minCornerX-b.vertex.x)); EditorUtility.ClearProgressBar(); // TODO: split by slicing grid } // build mesh assets int indexCount=0; Vector3[] vertices2 = new Vector3[vertCount]; Vector2[] uvs2 = new Vector2[vertCount]; int[] triangles2 = new int[vertCount]; Color[] colors2 = new Color[vertCount]; Vector3[] normals2 = new Vector3[vertCount]; EditorUtility.DisplayProgressBar(appName,"Creating "+((int)(pointArray.Length/vertCount))+" mesh arrays",0.75f); // process all point data into meshes for (int i = 0; i < pointArray.Length; i++) { vertices2[indexCount] = pointArray[i].vertex; uvs2[indexCount] = pointArray[i].uv; triangles2[indexCount] = pointArray[i].indice; if (readRGB || readIntensity) colors2[indexCount] = pointArray[i].color; if (readNormals) normals2[indexCount] = pointArray[i].normal; if (decimatePoints) { if (i % removeEveryNth == 0) indexCount++; }else{ indexCount++; } if (indexCount>=vertCount || i==pointArray.Length-1) { var go = BuildMesh(vertices2, uvs2, triangles2, colors2, normals2); if (createLODS) BuildLODS(go, vertices2, uvs2, triangles2, colors2, normals2); indexCount=0; // need to clear arrays, should use lists otherwise last mesh has too many verts (or slice last array) System.Array.Clear(vertices2,0,vertCount); System.Array.Clear(uvs2,0,vertCount); System.Array.Clear(triangles2,0,vertCount); if (readRGB || readIntensity) System.Array.Clear(colors2,0,vertCount); if (readNormals) System.Array.Clear(normals2,0,vertCount); } } EditorUtility.ClearProgressBar(); // save meshes EditorUtility.DisplayProgressBar(appName,"Saving "+(cloudList.Count)+" mesh assets",0.95f); string pad=""; for (int i=0;i<cloudList.Count;i++) { if (i<1000) pad="0"; if (i<100) pad="00"; if (i<10) pad="000"; AssetDatabase.CreateAsset(cloudList[i],savePath+pad+i); AssetDatabase.SaveAssets(); // not needed? } // save meshes EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); Debug.Log("Total amount of points processed:"+masterPointCount); } // convert2meshOptimized2
private Vector4[] CreateFileData(out float minx, out float miny, out float minz, out float maxx, out float maxy, out float maxz) { //string file = "../../test/data/1.2-with-color.las"; string file = "../../test/data/hobu.las"; Vector4 red = new Vector4(1, 0, 0, 1); Vector4 green = new Vector4(0, 1, 0, 1); Vector4 blue = new Vector4(0, 0, 1, 1); List<Vector4> points = new List<Vector4>(); istream istr = Utils.openFile(file); m_reader = new LiblasReader(istr); Stage stage = m_reader; { int np = (int)m_reader.getNumPoints(); if (np > 100000) { int step = np / 100000; m_filter = new DecimationFilter(m_reader, step); stage = m_filter; } } Header header = stage.getHeader(); Bounds_double bounds = header.getBounds(); minx = (float)bounds.getMinimum(0); miny = (float)bounds.getMinimum(1); minz = (float)bounds.getMinimum(2); maxx = (float)bounds.getMaximum(0); maxy = (float)bounds.getMaximum(1); maxz = (float)bounds.getMaximum(2); // 1.2-with-color //minx 635619.9f //miny 848899.7f //minz 406.59f //maxx 638982.563 //maxy 853535.438 //maxz 586.38 ulong numPoints = stage.getNumPoints(); //numPoints = Math.Min(numPoints, 100000); Schema schema = stage.getHeader().getSchema(); SchemaLayout layout = new SchemaLayout(schema); PointData data = new PointData(layout,(uint)numPoints); uint numRead = stage.read(data); uint offsetX = (uint)schema.getDimensionIndex(Dimension.Field.Field_X); uint offsetY = (uint)schema.getDimensionIndex(Dimension.Field.Field_Y); uint offsetZ = (uint)schema.getDimensionIndex(Dimension.Field.Field_Z); uint offsetR = (uint)schema.getDimensionIndex(Dimension.Field.Field_Red); uint offsetG = (uint)schema.getDimensionIndex(Dimension.Field.Field_Green); uint offsetBG = (uint)schema.getDimensionIndex(Dimension.Field.Field_Blue); for (uint index=0; index<numRead; index++) { Int32 xraw = data.getField_Int32(index, offsetX); Int32 yraw = data.getField_Int32(index, offsetY); Int32 zraw = data.getField_Int32(index, offsetZ); float x = (float)schema.getDimension(offsetX).getNumericValue_Int32(xraw); float y = (float)schema.getDimension(offsetY).getNumericValue_Int32(yraw); float z = (float)schema.getDimension(offsetZ).getNumericValue_Int32(zraw); if (index == 0) { minx = maxx = x; miny = maxy = y; minz = maxz = z; } else { minx = Math.Min(x, minx); miny = Math.Min(y, miny); minz = Math.Min(z, minz); maxx = Math.Max(x, maxx); maxy = Math.Max(y, maxy); maxz = Math.Max(z, maxz); } UInt16 r = data.getField_UInt16(index, offsetX); UInt16 g = data.getField_UInt16(index, offsetY); UInt16 b = data.getField_UInt16(index, offsetZ); points.Add(new Vector4(x, y, z, 1)); float rf = (float)r / 65535.0f; float gf = (float)g / 65535.0f; float bf = (float)b / 65535.0f; points.Add(new Vector4(rf, gf, bf, 1)); //points.Add(blue); } Utils.closeFile(istr); return points.ToArray(); }