1

In reference to this question

Drawing a line between two points using SceneKit

I'm drawing a line in 3D and want to make it thicker by using this code

  func renderer(aRenderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: NSTimeInterval) {
    //Makes the lines thicker
    glLineWidth(20)
  }

but it doesn't work, iOS 8.2.

Is there another way?

Update

From the docs

https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNSceneRendererDelegate_Protocol/index.html#//apple_ref/occ/intfm/SCNSceneRendererDelegate/renderer:updateAtTime:

I did add SCNSceneRendererDelegate and a valid line width but still could not get the line width to increase.

Community
  • 1
  • 1

2 Answers2

2

You cannot assign any number to glLineWidth(). You can check the range of possible values of glLineWidth()by:

glGetFloatv(GL_LINE_WIDTH_RANGE,sizes);

One crazy idea is to use a cylinder for drawing lines ;). I use it when I want to have nice and controllable lines but I am not aware of a handy OpenGl function to do so.

Good Luck
  • 1,104
  • 5
  • 12
2

@G Alexander: here you go my implementation of cylinder. It is a bit tedious but it is what I have at the moment. If you give me points p0 and p1, Vector normal=(p1-p0).normalize() would be the axis of the cylinder. pick point p2 that is not on the vector Normal.

q=(p2-p0).normalize();
normal.crossproduct(q)=v0;
normal.crossproduct(v0)=v1;

Having these two vectors you can have circles with any radius that are stacked along the axis of the cylinder using the following function (A cylinder is a stack of circles):

public Circle make_circle(Point center, Vector v0, Vector v1, double radius)
        {
            Circle c;
            for (double i = 0; i < 2 * Math.PI; i += 0.05)
            {
                Point p = new Point(center + radius * Math.Cos(i) * v0 + radius * Math.Sin(i) * v1);
                c.Add(p);
            }
          return c;
        }

You only need to make circles using this function along the axis of the cylinder:

List<Circle> Cylinder = new List<Circle>();
for(double i=0;i<1;i+=0.1)
{
  Cylinder.add( make_circle(P0+i*normal, v0, v1,radius);

}

Now you should take two consecutive circles and connect them with quads by sampling uniformly.

I have implemented it this way since I had circles implemented already.

A simpler way to implement is make the circle along the x axis and then rotate and translate it to p0 and make it align with normal or to use gluCylinder if you are the fan of Glu....

Hopefully it works for you.

Good Luck
  • 1,104
  • 5
  • 12