ofCamera worldToScreen in combination with ofRotate / ofTranslate possible?

I’m trying to draw some ‘clickable’ content on top of a 3d cylinder I’m using for a panorama. I’ve managed to get the content positioned where I want it using ofRotate and ofTranslate, but I’m lost at how to convert that position to screen coordinates to check mouse interaction.

I’ve found this topic: Get 3d Object under Mouse
Which explains the use of ofCamera.worldToScreen() for vertex locations, however I can’t seem to figure out how to get the current location after rotating and translating the axis using ofRotate and ofTranslate.

Any help with this?

Code I’m using:

//start camera
camera.begin();

//draw contents
for(int i = 0; i < contents.size(); i++) {
	ofPushMatrix();

	//turn cylinder 90 degrees, so the panorama image is horizontal
	ofRotateX(90);

	//rotate the axis to match the position of the content on the panorama cylinder
	ofRotateZ((contents.at(i).x / mainImage->getWidth()) * 360.0f);

	//move to the edge of the cylinder and match the height for the content
	ofTranslate(
		0, 
		pRadius - CONTENTS_ICON_DEPTH_MARGIN, 
		((mainImage->getHeight() - contents.at(i).y) / mainImage->getHeight()) * -pHeight + pHeight / 2.0f
	);

	//rotate so the image faces towards the camera
	ofRotateX(-90);

	//draw the image centered
	contents.at(i).icon.draw(
		-contents.at(i).icon.getWidth() / 2.0f, 
		-contents.at(i).icon.getHeight() / 2.0f, 
		0
	);

	ofPopMatrix();
}

//end camera
camera.end();

After a lot of trial and error, I managed to position it correctly without using the ofRotate and ofTranslate functions. Works like a charm now.

//begin camera
camera.begin();

//draw contents
for(int i = 0; i < contents.size(); i++) {
	hvContent * content = &contents.at(i);

	float a = ofDegToRad((content->x / mainImage->getWidth()) * 360.0f + 90.0f);
	float x = (pRadius - CONTENTS_ICON_DEPTH_MARGIN) * cos(a);
	float y = (pRadius - CONTENTS_ICON_DEPTH_MARGIN) * sin(a);
	float z = (((mainImage->getHeight() - content->y) / mainImage->getHeight()) * -pHeight + pHeight / 2.0f) * -1;

	camera.end();
	ofVec3f sv = camera.worldToScreen(ofVec3f(x, z, y));
	content->icon.draw(sv.x - content->icon.getWidth() / 2, sv.y - content->icon.getHeight() / 2, sv.z);
	camera.begin();

}

//end camera
camera.end();