I am having a lot of trouble trying to perform the following transformation in openGL. I have two cylinders. One of them is pointing straight upwards at the origin and the other comes out of the first at a 45 degree angle (imagine a sort of slingshot shaped object and you’ve got the right idea). Now, what I’m trying (and failing) to do is rotate and then translate the first cylinder (the one that is pointing straight upwards) and ALSO perform the exact same transformations to the second cylinder so that the overall shape of my slingshot-like object is preserved.
Here is the code I have so far:
// draw second cylinder
glTranslated(0, 0.5, 0);
glRotated(45, 0.0, 1.0, 0.0);
glRotated(-45, 1.0, 0.0, 0.0);
gluCylinder(quadratic2, 0.1, 0.1, 1.0, 12, 2);
// draw first cylinder (points straight up)
glTranslated(0, -1, 0);
glRotated(-90, 1.0, 0.0, 0.0);
gluCylinder(quadratic, 0.3, 0.3, 3.0, 12, 2);
Could anyone please show me how to add the transformations to the above code? Rememeber that all I’m trying to do is move my slingshot object about in 3D space whilst maintaining the object’s exact shape. Everything I’ve tried so far has ended up altering the shape of the object.