Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: objects for tree

  1. #1
    Newbie Newbie
    Join Date
    Aug 2012

    Talking objects for tree

    I'm new to openGl and I need some help. I've draw a tree thanks to glLineWidth() like that :
    Code :
      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 !

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    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.

  3. #3
    Junior Member Regular Contributor tksuoran's Avatar
    Join Date
    Mar 2008
    Cambridge, UK
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts