- Home /
Can I use unity3D for data visualizations, I mean 3d graphs like 3d pie charts
I am working on a project which demands some complex 3d data visualizations. for example http://mbostock.github.com/protovis/ex/crimea-rose-full.html imagine it in 3d or something like this. And is it possible to show a 3d tag cloud like this example http://openeer.dfki.de/AloeView/action/tagCloudFlash using unity 3d?
Answer by SilverTabby · Aug 23, 2011 at 04:51 AM
A video game IS a complex data visualization. The only difference between that (what Unity was designed for) and what you are looking for is user input.
Given, Unity was not designed to make graphs from scratch, but there is absolutely nothing stopping you from using it in the way you specified.
Can you tell me from where I can start it. I am very new to unity 3d and have very less time to accomplish my task so can you direct me in the specific direction with some example project or tutorial. thank you
Answer by Joshua · Aug 23, 2011 at 08:03 AM
Doing what is shown in your first picture would actually be quite hard if you're not skilled at procedural mesh creation.
What is shown in the second picture, on the other hand, is extremely easy in Unity.
"Can you tell me where I can start?" Start by following one of the tons of guides.
Joshua, you say creating the tag sphere is extremely easy. Could you perhaps give a hint on how to do this? Can I stick the Text$$anonymous$$eshes to a sphere GameObject? Or is it better to create a custom spherical function which declares the movement of the meshes?
Do you also perhaps have some advice on how to make the tags clickable, with all this overlapping?
the clickable area of each text is a rectangle around it, for each text object, place it inside a box Collider that doesn't rotate on itself but that always stay is facing front wise.
To place the text and collider-box in space is less easy, you need a bunch of points that you can easily rotate in the nice way of example does according to the mouse position.
Actually the movement of the sphere points obviously is relative to the position of the mouse on the screen, I think you can do that.
I think you have to use a spherical mesh in unity because it is so easy to rotate that in world space, that you won't have to do any of the Quaternion calculations, if you tried to do it with an array of points.
That said, you could try using the functions-Vector3 rota$$anonymous$$round on raw Vector3's it could be actually a very fulfilling an easy thing to do you just have to put all the points in a loop and rotate them all together
this is an awesome equation for generating spherical points, and then he can calculate rotation using rotate around,each point will be appointed in space without rotation, you just have to figure a way to add rotation, if you use rotate around function, then chances are, it will only be a few lines and you can rotate every points by the same angle from its base position or from its updated position on every frame. And then we have the position of each text.
#pragma strict
public var cube: GameObject;
public var random = 0.0;
//this function places objects in equally spaced spherical coordinates of any number
public var counter = 0;
var size = .03;
function Start () {
//random = random;
sphere(123);//number of points
}
function Update () {
var i = 0;
}
function sphere ( N:float){
var inc = $$anonymous$$athf.PI * (3 - $$anonymous$$athf.Sqrt(5));
var off = 2 / N;
for (var k = 0; k < (N); k++)
{
var y = k * off - 1 + (off / 2);
var r = $$anonymous$$athf.Sqrt(1 - y*y);
var phi = k * inc;
var pos = Vector3(($$anonymous$$athf.Cos(phi)*r*size), y*size, $$anonymous$$athf.Sin(phi)*r*size);
// var dist = Vector3.Distance(pos, Vector3(0,size,0));
Instantiate(cube,pos, Quaternion.identity);
}
};
the other option is using a sphere object and is vertex positions in world space as you rotate the sphere, if you take a sphere with 1000 vertices, and choose randomly 20 vertices from it it should be pretty well spaced. rotate the sphere andask where it is a vertex positions are on every update and you will have the positions where to place your text.
that said I highly encourage you to take a round object, use a number of mesh vertices to decide the position of the text, and rotate it somewhere offscreen, and then add a number so that we know about points rotating in the middle of the screen, and use that to fix your text positions
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Updating LCD display? 1 Answer
Making a Roadsign?(or : help on how to use textMeshes) 3 Answers
NullReferenceException After A Few Hours? 1 Answer
How to make GUI text disappear after a few seconds? 1 Answer