[SOLVED] Problems with of3dPrimitive Tilt

Continuing the discussion from Rotating an object along its local x axis:

Tilt has been working on my primitives, but after I’ve moved some of my functions into their own class, it seems to be broken wherever I place it. I have a vector of my custom class, and within that class, a setup() function where the initial vertices are created and where tilt is used. I can’t seem to figure out how tilt is being handled differently in this situation than it was when I wasn’t using it in my own class. Using getPitch, I can confirm some sort of transformation is happening, so maybe I’m not pushing and popping the matrix correctly…

( Setup() is being called inside of keyPressed() in ofApp)


void oscThread::setup()
    numVerts = this->getMesh().getNumVertices();
    for (float x=0;x<res;x++){
        float delta = x/res;
        ofVec3f signal = originP.getInterpolated(destP, delta);
    this->tilt(rot);        // TODO get tilt working

void oscThread::draw()


#ifndef _OSC_THREAD
#define _OSC_THREAD

#include "ofMain.h"

class oscThread : of3dPrimitive {
        void setup();
        void draw();
        void update();
        ofVec3f originP;
        ofVec3f destP;
        int   res;    //Resolution
        int   speed;  //Speed (lower=faster)
        float amp;    //Amplitude
        float f;      //Frequency
        float rot;    //Rotation
        int numVerts;
        oscThread(int origin, ofMesh mesh);


Hi AceSlowman,

Are you setting the rot variable somewhere?
You don’t need to call ofPushMatrix, ofPopMatrix around the tilt function call because it is not applying the transformation.

In the draw call, the node transformations are not being applied. Try calling

1 Like

I have rot set up in the constructor (sorry if I left out too much). But this works! In my old test, before I moved my functions into their own class and everything, tilt() was working without transformGL(). Any chance you know why that is?

Thanks a ton @NickHardeman

Did you override the draw function before? If not, the draw function from 3DPrimitive made those calls.
Without calling transform and restoreTransform, you will not visually see the tilt applied to the mesh.

Overriding the draw function is new with my change to OOP, so I guess that explains it. Perfect