# Getting set of 3d primitive faces considering position and rotation

Hello. I’m starting to work with OF and I have following problem:
I create some 3-d scene with OF 3d-primitives (ofConePrimitive, ofBoxPrimitive and so on), using code like this:

``````ofBoxPrimitive box;
box.setMode(OF_PRIMITIVE_TRIANGLES);
box.setHeight(obj["height"].asFloat());
box.setWidth(obj["width"].asFloat());
box.setDepth(obj["depth"].asFloat());
box.setPosition(obj["x"].asFloat(), obj["y"].asFloat(), obj["z"].asFloat());
box.setResolution(obj["resolution"].asInt());
box.rotate(obj["spin_x"].asFloat(), 1.0, 0, 0);
box.rotate(obj["spin_y"].asFloat(), 0, 1.0, 0);
box.rotate(obj["spin_z"].asFloat(), 0, 0, 1.0);
``````

where obj is json-object of file I’m reading.
Then I need to get all triangles of scene for further processing, but when I call

``````std::vector<ofMeshFace> primitive_faces = some_primitive_.getMeshPtr()->getUniqueFaces();
``````

I get triangles like I haven’t called neither setPosition() nor rotate().
I understand how to add position, I will just add some_primitive_.getPosition() to each vertice of each face, but how can I apply rotation as well?
Or maybe there is just easy way to do it, without manual work?

Hi,
Perhaps…

``````ofVec3f theTransformedVertice = anUntransformedVertice * a_primitive.getGlobalTransformMatrix();
``````

… or something like that (not tested )

Thanks, it worked)