QuadMeshFactory generateEdgesFromFaces problem

Have jReality programming problems or questions? Post them here.
Post Reply
goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

QuadMeshFactory generateEdgesFromFaces problem

Post by goose12 » Tue 24. Apr 2012, 10:44

Hi guys,

I am using the QuadMeshFactory to generate the geometry shown in the following pictures.
aircraft_regular.jpeg
aircraft with setGenerateEdgesFromFaces(false);
aircraft_regular.jpeg (13.86 KiB) Viewed 752 times
The problem is that I would like to display the mesh lines (similar to wireframe, but with the faces still showing), but when I use the methods factory.setGenerateEdgesFromFaces(true); and factory.setEdgeFromQuadMesh(true); I get the following result:

[attachment=0]aircraft.jpeg[/attachment]

How can I get the mesh lines to show correctly?? And why are they so crazy?

Here is a summary of my code:

Code: Select all

ArrayList<double[][][]> l;
int t = 0;
for(int i=0; i<liftingSurfaces.size(); i++){
		l = liftingSurfaces.get(i).getPanelCoords(); // get vertex coordinates
		for(int j=0; j<l.size(); j++){
			factory[t] = new QuadMeshFactory();		
			factory[t].setVLineCount(l.get(j).length);
			factory[t].setULineCount(l.get(j)[0].length);					
			factory[t].setClosedInUDirection(false);	
			factory[t].setClosedInVDirection(false);	
			factory[t].setVertexCoordinates(l.get(j));	
			factory[t].setGenerateFaceNormals(true);
			factory[t].setGenerateTextureCoordinates(true);		
			factory[t].setGenerateEdgesFromFaces(false);
			factory[t].setEdgeFromQuadMesh(true);	      // generate "long" edges: one for each u-, v- parameter curve					
			factory[t].update();
			faceSets[t]=factory[t].getIndexedFaceSet();
			t++;
		}
	}
GeometryMergeFactory mergeFact = new GeometryMergeFactory();    
mergeFact.setRespectFaces(true);
mergeFact.setRespectEdges(true);
mergeFact.setGenerateVertexNormals(true); 
mergeFact.setGenerateFaceNormals(true);
IndexedFaceSet result = mergeFact.mergeIndexedFaceSets(faceSets);
geometryNode.setGeometry(result);
My appearance settings are as follows:

Code: Select all

Appearance ap = geometryNode.getAppearance();
ap.setAttribute(LINE_SHADER+"."+DIFFUSE_COLOR, Color.red);
ap.setAttribute(POINT_SHADER+"."+DIFFUSE_COLOR, Color.black);
ap.setAttribute(POINT_SHADER+"."+POINT_RADIUS, .1);
ap.setAttribute(CommonAttributes.LINE_WIDTH, 0.1);
ap.setAttribute(CommonAttributes.TUBE_RADIUS, 0.1);
ap.setAttribute(POLYGON_SHADER+"."+SMOOTH_SHADING, false);
// turn on transparency for faces but keep tubes and spheres opaque
ap.setAttribute(TRANSPARENCY_ENABLED, true);
ap.setAttribute(OPAQUE_TUBES_AND_SPHERES, true);
ap.setAttribute(POLYGON_SHADER+"."+TRANSPARENCY, .4);
Attachments
aircraft.jpeg
aircraft with setGenerateEdgesFromFaces(true);
aircraft.jpeg (27.25 KiB) Viewed 752 times

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: QuadMeshFactory generateEdgesFromFaces problem

Post by gunn » Thu 26. Apr 2012, 21:35

It looks like the coordinates of your scene may be quite small. In that case, I would suggest you try to adjust the appearance attributes TUBE_RADIUS and POINT_RADIUS to be .001 (for example) instead of .1. Also, you may need to set VERTEX_DRAW to be true in order to see the vertices. Finally, I'd encourage you to turn off TRANSPARENCY_ENABLED until you've got the other problems straightened out.
jReality core developer

Post Reply