IndexfaceFactory with n-gon mixed with quadrilateral

Have jReality programming problems or questions? Post them here.
Post Reply
rafax
Posts: 16
Joined: Sat 17. Apr 2010, 12:39

IndexfaceFactory with n-gon mixed with quadrilateral

Post by rafax » Tue 4. May 2010, 20:25

How can I set up the face indices if my geometry containing n-gons and quadrilaterals glued each other. The problem is that the faceIndices for the quadrilaterals have 4 columns. But those of the n-gones have n columns, so I don't know how to set the indexFaces to be in one array in this case.

Regards
Faniry

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

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Post by Andre » Tue 4. May 2010, 22:14

Hi Faniry,

you don't have to glue the IndexedFaceSets together. Create different ones maybe one for the ngon and one for the sides:

Code: Select all

public static IndexedFaceSet ngon(int n){

		double [][] vertices = new double[n+1][3];
		...
		int [][] faces = new int[n][3] ;
		...
		IndexedFaceSetFactory ngonf = new IndexedFaceSetFactory();
		...
		return ngonf.getIndexedFaceSet();	
	};

Code: Select all

public static IndexedFaceSet prism(int n){

		double [][] vertices = new double[2*n][3];
		...
		int [][] faces = new int[2*n][3] ;
		...
		IndexedFaceSetFactory prismf = new IndexedFaceSetFactory();
		...
		return prismf.getIndexedFaceSet();	
	};
and then glue them together at the scenegraph

Code: Select all

public static void main(String[] args) {
		
	int n ;
	n = 9;
	SceneGraphComponent scg = new SceneGraphComponent();
	scg.setGeometry(prism(n));
	SceneGraphComponent scg2 = new SceneGraphComponent();
	scg2.setGeometry(ngon(n));
	scg.addChild(scg2);
	SceneGraphComponent scg3 = new SceneGraphComponent();
	scg3.setGeometry(ngon(n));
	//translates and rotates(for the normal) the second ngon
	MatrixBuilder.euclidean().translate(0,0,2).rotateY(Math.PI).assignTo(scg3);
	scg.addChild(scg3);
	JRViewer v = JRViewer.createJRViewerVR(scg);
};

rafax
Posts: 16
Joined: Sat 17. Apr 2010, 12:39

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Post by rafax » Wed 5. May 2010, 14:02

Thanks :D

rafax
Posts: 16
Joined: Sat 17. Apr 2010, 12:39

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Post by rafax » Wed 5. May 2010, 14:05

Does the gluing process merge vertices and edges?

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

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Post by Andre » Wed 5. May 2010, 14:46

rafax wrote:Does the gluing process merge vertices and edges?
No you will have 2 vertices at the same position

I've added the cylinder -example at our practice-workspace. To check my propositon, you can start it and then open the Navigator-panel: "Window"-> "[x] right slot"

Click at the left-side of "content" -> Left- side of "scaling" -> Left of "sgc 0" -> now click at "face-set 0". As result you will see, that the indexedfaceset("our prism") have 18 vertices. -> Click left of "sgc1" or Left of "sgc2", then at "face-set 1" or "face-set 2" and you will see, that the ngon has 10vertices

Post Reply