0
votes

I have two cylinders which intersect on one end. I can change the radius of the intersection separately but still they meet at one end as shown below. However, I want the intersection between these two be smooth or in other words, their normals in the intersection to be shared as mentioned here: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/. I have set the normal updates TRUE, and also change all the y components of the normals to zero in the intersection. It is still not showing a smooth intersection. These two cylinders are made with BufferGeometry.enter image description here

so part of my code that is more important: 1- since the geometry is BufferGeometry, I use two commands below first for both geometries to create the normals:

comp.mesh.geometry.computeFaceNormals();
comp.mesh.geometry.computeVertexNormals();

2- then since both geometries has same number of vertices, I set y component of all vertices to 0:

for (i=0;i<comp.mesh.geometry.attributes.position.array.length;i++){
comp.mesh.geometry.attributes.normal.array[i*3 + 1]  = 0;
comp1.mesh.geometry.attributes.normal.array[i*3 + 1]  = 0;
}

When I let the program show the normals, their y component of normals is 0, but the geometry is not smooth yet.

1
Show your code.WestLangley
Thank you WestLangley. Please see the code in the added link.Hesamoy
Please share your code in your post (preferably as a snippet). If the jsfiddle is ever deleted, then the context of your question goes away with it.TheJim01

1 Answers

0
votes

I think the only way possible to do this is to weld these points. You need to check for duplicates, and assign them the same index. Use these indecis for triangulation and for vertex normal computation.