@cuinjune wrote:
Hi, I'm trying to test if it's possible to draw any 3d shape I want using ofPath so I can later use it as a ofPolyline or ofMesh.
First, I'm trying to draw a simple pyramid-like shape made of 4 isosceles triangles. (without the bottom square)
Here's the test code I wrote,
void ofApp::draw(){
ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofRotate(60, 1, 1, 1); ofPath path; path.clear(); //upper triangle (as if seeing the pyramid from the sky) path.moveTo(-50, -50, 0); path.lineTo(0, 0, 150); path.lineTo(50, -50, 0); path.close(); //left triangle path.moveTo(-50, -50, 0); path.lineTo(0, 0, 150); path.lineTo(-50, 50, 0); path.close(); //right triangle path.moveTo(50, -50, 0); path.lineTo(0, 0, 150); path.lineTo(50, 50, 0); path.close(); //lower triangle path.moveTo(-50, 50, 0); path.lineTo(0, 0, 150); path.lineTo(50, 50, 0); path.close(); path.draw();
}
And unfortunately, this draws nothing.
But if I set the path unfilled by adding the two lines below after path.clear();
path.setFilled(false);
path.setStrokeWidth(2);Then it shows a stroke of the shape properly as the image below.
But I don't know why it doesn't draw anything when I try to fill the shape.
Does this have to do with overlapping lines between triangles? do they cancel the path?
Or should I make 4 different paths that draw separately? (I'm sure this will work at least)I want to know if it is possible to properly draw any 3d shape using just one ofPath.
Thank you very much in advance!
Posts: 1
Participants: 1