Page 1 of 1

IndexfaceFactory with n-gon mixed with quadrilateral

Posted: Tue 4. May 2010, 20:25
by rafax
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

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Posted: Tue 4. May 2010, 22:14
by Andre
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);
};

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Posted: Wed 5. May 2010, 14:02
by rafax
Thanks :D

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Posted: Wed 5. May 2010, 14:05
by rafax
Does the gluing process merge vertices and edges?

Re: IndexfaceFactory with n-gon mixed with quadrilateral

Posted: Wed 5. May 2010, 14:46
by Andre
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