PDA

View Full Version : objects for tree



lilawood
08-19-2012, 04:25 PM
Hello,
I'm new to openGl and I need some help. I've draw a tree thanks to glLineWidth() like that :


glLineWidth(2);
glBegin(GL_LINES); //créer une ligne
glVertex3f(0,0,0);
glVertex3f(0.0,2,0.0);
glEnd();
glTranslatef(0.0,2,0.0);
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 !
;)

Dark Photon
08-19-2012, 05:09 PM
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. :D

tksuoran
08-20-2012, 03:29 AM
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.