I think you can get an ofPolyline out of ofPath if you need one. ofPath will also draw a filled shape, where ofPolyline will not, if that makes any difference.
There are some different ways to use noise with a moving particle. ofNoise might be an option, which is simplex noise, and tends to have a nice, organic result. But it can be expensive to calculate.
There is a random-walker approach, where each particle determines its next step (direction, magnitude) in a random way. This motion can be somewhat jerky and confined, depending. One option would be to narrow the range of directions it can head in, which would smooth it out and probably give it a wider path.
There are also ways to generate “fractal” curves (an ofPolyline), where a particle would head in a general direction, but have some noise as it goes from A to B.
Finally, generating an ofPolyline from .curveTo() with random points will move it more or less smoothly in a defined path. A quick example (that will compile):
ofApp.h:
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void calcPline();
void drawPline();
ofPolyline pline;
ofEasyCam easyCam;
};
ofApp.cpp:
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
calcPline();
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
easyCam.begin();
drawPline();
easyCam.end();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == 'p'){
calcPline();
}
}
//--------------------------------------------------------------
void ofApp::calcPline(){
// clear the pline
pline.clear();
// 11 random points
std::vector<glm::vec3> seeds(11);
for(size_t i{0}; i < seeds.size(); ++i){
glm::vec3 seed(ofRandom(-1.f, 1.f), ofRandom(-1.f, 1.f), 0.0);
seed *= 400.f; // scale it if you like
seeds.at(i) = seed;
}
// a smooth, continuous pline
// start with the last point as a handle
pline.curveTo(seeds.at(seeds.size() - 1), 100);
// curveTo all of the seeds
for(size_t i{0}; i < seeds.size(); ++i){
pline.curveTo(seeds.at(i), 100);
}
// repeat the first two points to smoothly join the curve
pline.curveTo(seeds.at(0));
pline.curveTo(seeds.at(1));
// add the first vertex to the end of pline if needed
// pline.addVertex(pline.getVertices().at(0));
// close the pline
pline.close();
}
void ofApp::drawPline(){
ofSetColor(ofColor::white);
pline.draw();
ofSetColor(ofColor::green);
ofDrawCircle(pline.getVertices().at(0), 10.f);
ofSetColor(ofColor::red);
ofDrawCircle(pline.getVertices().at(pline.getVertices().size() - 1), 5.f);
}