HoloLens绘制图表 [英] HoloLens Draw a graph
问题描述
为HoloLens统一绘制图表的最佳方法是什么?
我是这个平台的新手,不知道哪些软件包可以工作,哪些不用,图形动态获取数据。
编辑:我曾尝试LineRenderer但似乎在统一
一个粒子系统的组件脚本的简单例子:
><预类= 郎-C#prettyprint-越权>
公共类图形:MonoBehaviour {
中的图的//粒子分辨率
[范围(10,100)]
public int resolution = 10;
private int currentResolution;
private ParticleSystem.Particle [] points;
void Start()
{
currentResolution = resolution;
points = new ParticleSystem.Particle [resolution];
float increment = 1f /(resolution - 1);
for(int i = 0; i< resolution; i ++)
{
float x = i * increment;
points [i] .position = new Vector3(x,0f,0f);
points [i] .startColor = new Color(0f,0f,0f);
分[i] .startSize = 0.1f;
$ b无效更新()
{
if((currentResolution!= resolution)||(points == null))
{
CreatePoints();
}
FunctionDelegate f = functionDelegates [(int)function];
for(int i = 0; i {
Vector3 p = points [i] .position;
p.y = Sine(p.x);
points [i] .position = p;
颜色c = points [i] .GetCurrentColor(GetComponent< ParticleSystem>());
c.g = p.y;
c.r = 1f - p.y;
points [i] .startColor = c;
}
GetComponent< ParticleSystem>()。SetParticles(points,points.Length);
}
私有静态浮动正弦(float x)
{
返回0.5f + 0.5f * Mathf.Sin(2 * Mathf.PI * x + Time .timeSinceLevelLoad);
}
}
一个很好的教程用于使用CatLikeCoding(Jasper Flick)的粒子系统绘制2D / 3D图(包括本示例)。请参阅: http://catlikecoding.com/unity/tutorials/graphs/ 。这是一个有点过时,你必须使用startSize / startColor代替depreceated颜色/尺寸属性在这种情况下。
但随着hololens i'have testet它媒体链接,它工作得很好。如果您有大量的粒子,则需要使用HoloToolkit着色器进行更好性能的实验: - ) 如果您还有其他问题:请问我。
p>What is the best way to draw a graph for the HoloLens in unity? I am new to this platform and have no idea which packages will work and which dont, the graph gets data dynamically.
EDIT: I have tried LineRenderer but it seems very limited in version 5.4 of Unity
A possible Solution for drawing a 3D-Graph is using a particle system:
Simple Example for a Component Script for a particle system:
public class Graph: MonoBehaviour {
//Particle-Resolution of the Graph
[Range(10, 100)]
public int resolution = 10;
private int currentResolution;
private ParticleSystem.Particle[] points;
void Start()
{
currentResolution = resolution;
points = new ParticleSystem.Particle[resolution];
float increment = 1f / (resolution - 1);
for (int i = 0; i < resolution; i++)
{
float x = i * increment;
points[i].position = new Vector3(x, 0f, 0f);
points[i].startColor = new Color(0f, 0f, 0f);
points[i].startSize = 0.1f;
}
}
void Update()
{
if ((currentResolution != resolution) || (points == null))
{
CreatePoints();
}
FunctionDelegate f = functionDelegates[(int)function];
for (int i = 0; i < points.Length; i++)
{
Vector3 p = points[i].position;
p.y = Sine(p.x);
points[i].position = p;
Color c = points[i].GetCurrentColor(GetComponent<ParticleSystem>());
c.g = p.y;
c.r = 1f - p.y;
points[i].startColor = c;
}
GetComponent<ParticleSystem>().SetParticles(points, points.Length);
}
private static float Sine(float x)
{
return 0.5f + 0.5f * Mathf.Sin(2 * Mathf.PI * x + Time.timeSinceLevelLoad);
}
}
A good tutorial for drawing 2D/3D graphs (including this example) with a particle system from CatLikeCoding (Jasper Flick). Refer to: http://catlikecoding.com/unity/tutorials/graphs/. It's a bit outdated and you must use startSize/startColor instead the depreceated color/size-Properties in this case.
But i'have testet it with the hololens allready and it worked fine. Some experiments with the HoloToolkit shaders for a better performance are necessary if you have a big amount of particles :-)
If you have further questions: Just ask me.
这篇关于HoloLens绘制图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!