简体   繁体   中英

3D motion graph in java

I'm working on a research project that involves visualising 3D position coordinates (x,y,z) in java together with other characteristics (such as size of the point).

If the position where in 2D, google motion chart would be perfect. However, it's in 3D as I'm visualising (over time) the movement in a 3 dimensional space.

I have researched this for quite a while now and I did discover that I could probably do it in java3D, but the library seems outdated and I'm not sure if it can handle smooth animation (given that I have the coordinates at each moment in time rather than the path). A connection with openGL (JOGL) seems very complicated for this task. And I am not sure processing can handle it.

Is there a straightforward way of animating spheres with 3D coordinates in an animation in java3D? And change their circumference meanwhile? I have been reading a bunch of tutorials but nothing quite does that exactly. Or am I going about this the wrong way and is there some kind of math/geometry library I could use?

Here is an example of what I want to achieve:

Second 0:
- sphere at (0,0,1): (relative) size 1, colour green
- sphere at (1,1,1): size 2, colour green

Second 1: 
- sphere at (0,2,2): size 3, colour green
- sphere at (4,4,1): size 4, colour red
- sphere at (1,2,1): size 1, colour green

Second 2: 
- sphere at (1,0,1): size 2, colour red

With or without smooth transitions. I have no idea how to get started on this with JOGL or if it's possible.

I never used Java3D, but I know Jogl.

What you describe is, as I already mentioned, a pretty easy task in OpenGL.

Basically what you need is a pseudo code like this:

loadData();

for(each spehere) {
    updatePositionAndScale(time);
    render();
}

You first load the triangle vertices for a single sphere geometry. Given the delta radius seems quite small, you may want to load just a single sphere, otherwise you could load several ones, based on the richness of the geometry. What I mean is essentially something similar

在此处输入图片说明

Anyway, since the number of spheres is really low (modern GPUs can easily handle hundred of triangles) you may want to go with a single high-detailed spehere.

Then you loop over your spheres and for each tick of time, you calculate the current transitioning position and scale of the i-th spehere. You can do this by a simple interpolation, if you need something linear. All these parameters, position and scaling, will affect what it is called as model matrix that transform your geometry for the model space , the space where your triangles first exist, into the world space . For each sphere, you will update these parameters and then you will just render it.

Let's talk now about the consequences ^^

Learning OpenGL will require you to invest some time. It is really hard to estimate, since everything depends on the level of knowledge you start from and you want to reach. If you want to keep it as minimal as possible, that is having it as simpleast as possible, I would say this wouldn't be a particularly complicate task (the last famous words). You may be done in a couple of days, depending also on your math skills. You will learn the basic of the shaders, how they read data and how they work, transformations and (simple)lighting in OpenGL.

Let's say that given the number of spheres is also very low, you could do this completely in java, without using any acceleration (such as OpenGL) and sparing some painful days. But since you were already investigating about Java3D and Jogl, I just wanted to tell you that what you want to achieve is really elementary (if you know OpenGL already, of course).

So the downside is that you will have to investigate some days (weeks?) learning the basic of an new API, such as OpenGL, before you reach what you want. Advantages are, instead, you will learn something new (this is always nice), you will get hardware acceleration, that means you could use all this power to make those spheres highly detailed and nice looking by using lighting effects. If you want to have a quick look, this how a simple Hello Triangle looks like

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM