I have two points in 3D space, with a mesh drawn between them. I want to be able to have free rotation of that inner mesh along it’s own x axis, but using ofRotate it throws the object far from it’s original position.

I have oscillating sine waves, and what I want to do is be able to rotate them to create a sort of braid.

```
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
mesh.addVertex(ofVec3f(ofGetWidth()/2-150,ofGetHeight()/2));
mesh.addColor(ofColor(255));
mesh.addVertex(ofVec3f(ofGetWidth()/2+150,ofGetHeight()/2));
mesh.addColor(ofColor(255));
mesh.addIndex(0);
mesh.addIndex(1);
mesh.setMode(OF_PRIMITIVE_POINTS);
glEnable(GL_POINT_SMOOTH);
glPointSize(3);
activeWave = false;
}
//--------------------------------------------------------------
void ofApp::update(){
if(activeWave){
for(int i=0;i<oscNum;i++){
updateWave(i);
}
}
}
//--------------------------------------------------------------
void ofApp::draw(){
ofEnableDepthTest();
ofBackgroundGradient(ofColor(50),ofColor(0));
cam.begin();
ofPushMatrix();
ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2,0);
mesh.draw();
for(int i=0;i<oscNum;i++){
ofRotateX(90); //THE OFFENDING ROTATION
oscMesh[i].draw();
}
ofPopMatrix();
cam.end();
ofDrawBitmapString("OSCNUM: " + ofToString(oscNum),10,10);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key=='p'){ //POINTS
for(int i=0;i<oscNum;i++){
oscMesh[i].setMode(OF_PRIMITIVE_POINTS);
}
}
if(key=='l'){ //LINES
for(int i=0;i<oscNum;i++){
oscMesh[i].setMode(OF_PRIMITIVE_LINE_STRIP);
}
}
if(key=='f'){ //FIRE
sendWave(0,1);
activeWave = TRUE;
}
}
//--------------------------------------------------------------
void ofApp::sendWave(int index, int burst){
ofVec3f firingPoint = mesh.getVertex(index);
ofVec3f destPoint = mesh.getVertex(index+1);
int res = 150;
for(int i=0;i<burst;i++){
oscNum++;
oscMesh.resize(oscNum);
for (float x=0;x<res;x++){
float delta = x/res;
ofVec3f signal = firingPoint.getInterpolated(destPoint, delta);
oscMesh[i].addVertex(signal);
oscMesh[i].addColor(ofColor(ofRandom(255),ofRandom(255),ofRandom(255)));
}
oscMesh[i].addVertex(destPoint);
oscMesh[i].addColor(ofColor(ofRandom(255),ofRandom(255),ofRandom(255)));
oscMesh[i].setupIndicesAuto();
oscMesh[i].setMode(OF_PRIMITIVE_LINE_STRIP);
}
}
//--------------------------------------------------------------
void ofApp::updateWave(int i){
int speed = 5;
int rotation = 90;
float time = ofGetElapsedTimef()/speed;
int res = oscMesh[i].getNumVertices(); //Resolution
for (int x=1;x<res;x++){
float delta = x/res;
float amp = 10; //Amplitude
float f = 10; //Frequency
float p = x; //Phase
float oscillation = amp * sin(2 * pi * f * time + p);
ofVec3f oscTemp = oscMesh[i].getVertex(x);
oscTemp.z = oscillation;
oscMesh[i].setVertex(x,oscTemp);
}
}
```

Before Rotation:

After Rotation: