I’m new to openGl and I need some help. I’ve draw a tree thanks to glLineWidth() like that :
glBegin(GL_LINES); //créer une ligne
It works well but I want to use cylinders or quads to obtain something more “realistic”.
The question is which object can I use to do this ? I think cylinders but I’m not sure. I’ve tried cylinders
but they are all distant from each others.
Thanks in advice !
You can use either. If you just want a prettier line, you can use a quad stretched between the nodes with a 1D texture with a hill gradient in the center. If you want nice lighting effects as if the connection is really 3D, you could use a cylinder (with possibly high tessellation), or simulate the presence of one with custom lighting calcs in a shader. This is more an artist question though, and an artist I’m definitely not.
If you use basic cylinders, there will be a crack if they are joined at an angle. You can fix this slightly by placing spheres at the joints, however, this is not perfect.
If you want a perfect joint then you will need to generate a joint geometry. Some maths are involved here: Take the orientation from each line end and interpolate these in a number of steps, placing rings on the way, you should get smooth joints. Notice that if the line is thick and/or the joint is sharp, the generated geometry will intersect itself. Watch out for special cases such as small cross product on line directions.