1.生成相应的Mesh 2.构建所有顶点所对应的数据值 3.取相应的颜色值 里面颜色和具体范围数值可以根据自己项目需要自行修改。 具体知识讨论和源码需求可以关注私聊哦~
Unity 生成可控可视化三维热力图
vertices = new Vector3[(xSize + 1) * (ySize + 1)]; for (int i = 0, y = 0; y <= ySize; y++) { for (int x = 0; x <= xSize; x++, i++) { vertices[i] = new Vector3(x,0,y); } } mesh.vertices = vertices; int[] triangles = new int[xSize * ySize * 6]; for (int ti = 0, vi = 0, y = 0; y < ySize; y++, vi++) { for (int x = 0; x < xSize; x++, ti += 6, vi++) { triangles[ti] = vi; triangles[ti + 3] = triangles[ti + 2] = vi + 1; triangles[ti + 4] = triangles[ti + 1] = vi + xSize + 1; triangles[ti + 5] = vi + xSize + 2; } }
/// <param name="MaxPeopleNum">最大人数</param> /// <param name="range">影响范围</param> /// <param name="pox">x位置</param> /// <param name="temperatures">点属性数据</param> private void SetPonitValue(float MaxPeopleNum, int range, Vector3 pos, ref List<float> temperatures) { for (int i = 0; i < temperatures.Count; i++) { int num = i; float distance = Mathf.Sqrt(Mathf.Pow(Vector3.Distance(heatPointVec[i], pos), 2)); //算距离 if (distance <= range) { float ratio = 1 - (distance / range);//ratio等于0到1 float temp = ratio * MaxPeopleNum; // 只有比当前点人数高才选择覆盖 if (temp > heatPointValue[num]) heatPointValue[num] = temp; } } }
Color SetColor(float temperature) { Color colorOne = new Color(); if (temperature <=40) { colorOne = Color.Lerp(new Color(1, 0, 1, 0), new Color(0, 1, 1, 0f), (temperature) * 0.025f);//无 } else if (temperature >40 && temperature < 80) { colorOne = Color.Lerp(new Color(0, 1, 1, 0f), new Color(0, 1, 0), (temperature - 40) * 0.025f);//蓝=>绿 } else if (temperature >= 80 && temperature < 120) { colorOne = Color.Lerp(new Color(0, 1, 0), new Color(1, 1, 0), (temperature - 80) * 0.025f); //绿=>黄 } else if (temperature >= 120 && temperature < 160) { colorOne = Color.Lerp(new Color(1f, 1f, 0f), new Color(1f, 0f, 0f), (temperature - 120) * 0.025f); //黄=>红 } else { colorOne = new Color(1f, 0f, 0f, 1f); //红 } return colorOne; }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算