@irv wrote:
Hello,
I am trying to create a 3D Turtle. I have successfully been able to draw a line from (x,y,z) to (x',y',z') using ofPolyline lineTo and addVertex methods.
My issue arises when I try to move to another point without drawing. Is there a way I could do this using ofPolyline, or should I try another way? Which way, how?
Here is some of my code;
.h:
ofPolyline line;
.cpp:
float xCoord = 250.0; float yCoord = 250.0; float zCoord = 250.0; // -------- Vector variables float xVec = 1;// x of vector float yVec = 0;// y of vector float zVec = 0;// z of vector //-------------------------------------------------------------- void ofApp::setup(){ ofBackground(0,0,0); ofPoint pt; pt.set(xCoord , yCoord, zCoord); camDist = 1000; // set the camera distance cam.setDistance(camDist); } void ofApp::keyPressed(int key){ switch(key) { case 102: { xCoord = xCoord + (xVec * stepSize); yCoord = yCoord + (yVec * stepSize); zCoord = zCoord + (zVec * stepSize); ofPoint pt; pt.set(xCoord, yCoord, zCoord); line.addVertex(pt); line is an ofPolyline // // this also works: // line.lineTo(xCoord, yCoord, zCoord); } break; }
The question is how would I make it move without drawing, leave a gap, and then draw again without connecting to previous point. I tried leaving the addVertex method out by doing this:
case 70:// F, move forward but not draw // -------------------------------- { xCoord = xCoord + (xVec * stepSize); yCoord = yCoord + (yVec * stepSize); zCoord = zCoord + (zVec * stepSize); ofPoint pt; pt.set(xCoord, yCoord, zCoord);// sets a point and then draws the line to that point }
but as soon as I drew another line it would connect to the last drawn point.
Any help or suggestion is welcome.Thanks!
Irv.
Posts: 4
Participants: 3