# How to draw a cylinder starting from 2 ofNode

I’ve two ofNode, A and B. Given this 2 node and the radius, I want to draw a cylinder.
I can retrieve the position of each of them with `node->getGlobalPosition` and the orientation with `getOrientationEuler()` (I think).
I’ve seen how to draw a cylinder with openGL, what is not clear to me is the orientation part, what in this picture is the `B` node, that is rotated on the z axis of 45 degree.

Can someone suggest me how should I proceed?

i would draw 2 circles and move each of them by multipliying their vertices by the node matrix. then just join the vertices of the 2 circles by creating triangles between them using the indices

Ok, now `ofNode` is officially my favourite class. I post the code here as reference, in case someone will have my same problem. I’ve used `TRIANGLE_STRIP`, because it looks like this is the way to go to draw when you want to draw cylinders, although I’ve seen also people using `TRIANGLES` and adding the indexes after.

``````//App.h
ofVboMesh mesh;
ofNode start;
ofNode end;
int resolution = 18;
// App.cpp
start.setPosition(0, 0, 0);
end.setPosition(0, 0, 200);
end.pan(45);

mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for (int i = 0; i <= resolution; i++){
//calculate x and y component
float theta = 2.0f * 3.1415926f * float(i) / float(resolution);
float x = radius * cosf(theta);
float y = radius * sinf(theta);
ofVec3f circleTemp = ofVec3f(x, y, 0.0);
ofVec3f direction = (ofVec3f() + circleTemp).getNormalized();

// bottom
//top
}
``````

My problem now are the normals. I think that for every vertices, the normal should has a direction that starts from the center of the circle and goes out. That’s why I’ve made `ofVec3f direction = (ofVec3f() + circleTemp).getNormalized();`, is it correct? I thing that the light looks a bit strange. Is there a way to debug the normals? to draw them on the screen?

to transform the normals the same way you do with the vertices you just need to get the rotation part of the matrix (unless you have scale since that gets mixed in the matrix) if you work with only local transformations then since ofNode stores the 3 transformations separately you can just get the orientation quaternion from it and multiply the normals by it . if you have global transformations then you need to get the rotation part fo the matrix but as long as you don’t use scale it should be ok:

``````        // bottom
//top
``````

also if you put the mesh into an of3dPrimitive you can call drawNormals on it. some other people have asked about drawing the normals on a mesh so we might want to move that method into ofMesh but not sure

You mean getRotate()? there is no getRotation().

``````// bottom