Can geometry be grouped ?

General discussion area.
Post Reply
Anar
Posts: 6
Joined: Thu 12. Sep 2013, 12:06

Can geometry be grouped ?

Post by Anar » Thu 12. Sep 2013, 12:19

Hi !
and first of all let me say thank you, jReality seems a very good 3D app to me.
I still exactly don't know what it does ans does not and what will be my use of it.
The very basic first thing I want to do is export some 3D into a PDF and jReality does it great.
I've been using LaTeX in the past to perform this task from U3D geometry.

This is where I'm stuck if anyone can help :
let's say I have 3 primitives in my scene : a sphere, a cylinder and a cube.
Is there anyway to "group" sphere with cube in a group ? (group might just not be the correct term but I hope you get the idea).
What I'd like is to have a Model Tree in the PDF that would look like this :
Scene
cylinder
MyGroup
sphere
cube

Is that possible ?
Thanks for any help and please try to explain it as if you where talking to a dummie, which I am...

Cheers !

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Can geometry be grouped ?

Post by Andre » Thu 12. Sep 2013, 19:22

This will basically do your job.

Code: Select all

import de.jreality.geometry.Primitives;
import de.jreality.math.MatrixBuilder;
import de.jreality.plugin.JRViewer;
import de.jreality.plugin.content.ContentAppearance;
import de.jreality.plugin.content.ContentLoader;
import de.jreality.plugin.content.ContentTools;
import de.jreality.scene.SceneGraphComponent;


public class test {

	public static void main(String[] args) {
		// customize a JRViewer to have Virtual Reality support (skyboxes, terrain, etc)
		JRViewer v = new JRViewer();
		v.addBasicUI();
		SceneGraphComponent root = new SceneGraphComponent();
		
		SceneGraphComponent child1 = new SceneGraphComponent("Cube");
		child1.setGeometry(Primitives.cube4(true));
		SceneGraphComponent child2 = new SceneGraphComponent("Group");
		
		SceneGraphComponent child2a = new SceneGraphComponent("Ico");
		child2a.setGeometry(Primitives.icosahedron());
		SceneGraphComponent child2b = new SceneGraphComponent("Tetrahedron");
		child2b.setGeometry(Primitives.tetrahedron(true));
		
		child2.addChild(child2a);
		child2.addChild(child2b);
		
		MatrixBuilder.euclidean().translate(5., 0., 0.).assignTo(child2a);
		MatrixBuilder.euclidean().translate(10., 0., 0.).assignTo(child2b);		
		
		root.addChild(child1);
		root.addChild(child2);
		
		
		v.setContent(root);
		v.registerPlugin(new ContentAppearance());
		v.registerPlugin(new ContentLoader());
		v.registerPlugin(new ContentTools());
		v.startup();
	}
}
Attachments
group.png
group.png (57.02 KiB) Viewed 1019 times

Anar
Posts: 6
Joined: Thu 12. Sep 2013, 12:06

Re: Can geometry be grouped ?

Post by Anar » Fri 13. Sep 2013, 07:08

Thanks Andre for such a fast answer !
Now I have to figure out what to do with that code but it(s something I have to learn anyway...
Because I see this kind of code is everywhere when using jReality.

Thanks a lot and have a nice day !

Anar

Edited : OK. I've been able to do your example by typing the code into the BeanShell.
PDF shows the Model Tree as I wish when exported via u3d.
Now I must try on my own OBJ imported geometry...
Thanks again Andre !

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Can geometry be grouped ?

Post by Andre » Fri 13. Sep 2013, 08:34

First of all, I totally forgot: Welcome to jReality!

It is easier to understand my code, when you start with the developer tutorials:
http://www3.math.tu-berlin.de/jreality/ ... r_Tutorial

Just follow them step by step. Specially the introduction and the geometry part should be useful for you. You probably need the io-part to understand how to load your geometry directly into the scene, too.

For developing your code you should use eclipse:
http://www3.math.tu-berlin.de/jreality/ ... p_tutorial

Please tell me if the Eclipse_tutorial isn't up to date anymore, I haven't checked it for a while. But my first impressions tells me everything is still alright with it.

If you have any further question, just let us know.

Anar
Posts: 6
Joined: Thu 12. Sep 2013, 12:06

Re: Can geometry be grouped ?

Post by Anar » Fri 13. Sep 2013, 09:29

Thanks for the kind words Andre !
I have the feeling that jReality is a programmer stuff and I'm just a 3D designer.
I do have a little programming knowledge but... little !
I will definitely look and start where you're pointing me out.
There's no reason why I should not be able to learn.

Cheers !

Post Reply