Beispiel #1
0
void ofCapsule(const ofShapeCapsule2& Capsule,float z,bool DrawCenterLine)
{
	if ( !Capsule.IsValid() )
		return;

	//	generate triangle points
	float mRadius = Capsule.mRadius;
	ofLine2 Line = Capsule.mLine;
	vec2f Normal = Line.GetNormal();
	vec2f Right = Normal.getPerpendicular();

	//	BL TL TR BR (bottom = start)
	vec2f Quad_BL2( Line.mStart - (Right*mRadius) );
	vec2f Quad_TL2( Line.mEnd - (Right*mRadius) );
	vec2f Quad_TR2( Line.mEnd + (Right*mRadius) );
	vec2f Quad_BR2( Line.mStart + (Right*mRadius) );

	vec3f Quad_BL( Quad_BL2.x, Quad_BL2.y, z );
	vec3f Quad_TL( Quad_TL2.x, Quad_TL2.y, z );
	vec3f Quad_TR( Quad_TR2.x, Quad_TR2.y, z );
	vec3f Quad_BR( Quad_BR2.x, Quad_BR2.y, z );

	if ( ofGetFill() == OF_FILLED )
	{
		ofTriangle( Quad_BL, Quad_TL, Quad_TR );
		ofTriangle( Quad_TR, Quad_BR, Quad_BL );
	}
	else if ( ofGetFill() == OF_OUTLINE )
	{
		ofLine( Quad_BL, Quad_TL );
		ofLine( Quad_BR, Quad_TR );
		//ofLine( Line.mStart, Line.mEnd );
		//ofRect( Line.mStart, mRadius/4.f, mRadius/4.f );
	}

	if ( ofGetFill() == OF_OUTLINE && DrawCenterLine )
	{
		ofLine( Line.mStart, Line.mEnd );
	}

	//	http://digerati-illuminatus.blogspot.co.uk/2008/05/approximating-semicircle-with-cubic.html
	vec3f BLControl = Quad_BL - (Normal * mRadius * 4.f/3.f) + (Right * mRadius * 0.10f );
	vec3f BRControl = Quad_BR - (Normal * mRadius * 4.f/3.f) - (Right * mRadius * 0.10f );
	vec3f TLControl = Quad_TL + (Normal * mRadius * 4.f/3.f) + (Right * mRadius * 0.10f );
	vec3f TRControl = Quad_TR + (Normal * mRadius * 4.f/3.f) - (Right * mRadius * 0.10f );
	BLControl.z = 
	BRControl.z =
	TLControl.z = 
	TRControl.z = z;
	ofBezier( Quad_BL, BLControl, BRControl, Quad_BR );
	ofBezier( Quad_TL, TLControl, TRControl, Quad_TR );
}
//----------------------------------------
void ofxBox2dPolygon::draw() {
	if(body == NULL) {
        ofLog(OF_LOG_ERROR, "ofxBox2dPolygon::draw body null\n");
        return;
	}
    ofPushMatrix();
    ofTranslate(getPosition());
    ofRotate(getRotation(), 0, 0, 1);
    mesh.draw(ofGetFill()==OF_OUTLINE?OF_MESH_WIREFRAME:OF_MESH_FILL);
    ofPopMatrix();
	
    /*
	const b2Transform& xf = body->GetTransform();
    for (b2Fixture * f = body->GetFixtureList(); f; f = f->GetNext()) {
		b2PolygonShape * poly = (b2PolygonShape*)f->GetShape();
		if(poly) {
            drawShape.clear();
            for(int i=0; i<poly->GetVertexCount(); i++) {
                drawShape.addVertex( worldPtToscreenPt(b2Mul(xf, poly->GetVertex(i))) );
			}
			if(isClosed()) drawShape.close();
            drawShape.draw();
		}
	}
	*/
}
void ramStripe(const ramNode& n1, const ramNode& n2, const ramNode& n3, const ramNode& n4, const ramNode& n5, const ramNode& n6, const ramNode& n7, const ramNode& n8, const ramNode& n9, const ramNode& n10, const ramNode& n11, const ramNode& n12)
{
	const ofVec3f v[] = { n1.getGlobalPosition(), n2.getGlobalPosition(), n3.getGlobalPosition(), n4.getGlobalPosition(), n5.getGlobalPosition(), n6.getGlobalPosition(), n7.getGlobalPosition(), n8.getGlobalPosition(), n9.getGlobalPosition(), n10.getGlobalPosition(), n11.getGlobalPosition(), n12.getGlobalPosition() };
	glBegin(ofGetFill() ? GL_POLYGON : GL_LINE_LOOP);
	for (int i = 0; i < 12; i++)
	{
		glVertex3fv(v[i].getPtr());
	}
	glEnd();
}
void ramStripe(const ramNode& n1, const ramNode& n2, const ramNode& n3, const ramNode& n4, const ramNode& n5)
{
	const ofVec3f v[] = { n1.getGlobalPosition(), n2.getGlobalPosition(), n3.getGlobalPosition(), n4.getGlobalPosition(), n5.getGlobalPosition() };
	glBegin(ofGetFill() ? GL_POLYGON : GL_LINE_LOOP);
	for (int i = 0; i < 5; i++)
	{
		glVertex3fv(v[i].getPtr());
	}
	glEnd();
}
void ramStripe(const vector<ramNode> &nodes)
{
	glBegin(ofGetFill() ? GL_POLYGON : GL_LINE_LOOP);
	for (int i = 0; i < nodes.size(); i++)
	{
		ofVec3f v = nodes[i].getGlobalPosition();
		glVertex3fv(v.getPtr());
	}
	glEnd();
}
Beispiel #6
0
//------------------------------------------------
void ofxBox2dRect::draw() {
	
	if(body == NULL) {
		return;	
	}
    
    ofPushMatrix();
    ofTranslate(ofxBox2dBaseShape::getPosition());
    ofRotateDeg(getRotation());
    mesh.draw(ofGetFill()==OF_FILLED?OF_MESH_FILL:OF_MESH_WIREFRAME);
    ofPopMatrix();
    
    /*
    const b2Transform& xf = body->GetTransform();
    ofPolyline shape;
    for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext()) {
        b2PolygonShape* poly = (b2PolygonShape*)f->GetShape();
        if(poly) {
            for(int i=0; i<poly->m_count; i++) {
                b2Vec2 pt = b2Mul(xf, poly->m_vertices[i]);
                shape.addVertex(worldPtToscreenPt(pt));
            }
        }
    }
    shape.close();
    shape.draw();*/


    // update the polyline
    // getRectangleShape();
    /*
    ofPath path;
    for (int i=0; i<shape.size(); i++) {
        if(i==0)path.moveTo(shape[i]);
        else path.lineTo(shape[i]);
    }
    
    // draw the path
    path.setColor(ofGetStyle().color);
    path.setFilled(ofGetStyle().bFill);
    path.draw();
    
    // are we sleeping
    if(isSleeping()) {
        ofPushStyle();
        ofEnableAlphaBlending();
        path.setColor(ofColor(255, 100));
        path.setFilled(true);
        path.draw();
        ofPopStyle();
    }
	*/
}
Beispiel #7
0
//--------------------------------------------------------------
// TODO
// from : https://github.com/openframeworks/openFrameworks/issues/798
void ofxMuiBox::ofxRect(float _x, float _y, float _width, float _height, bool inner) {
    //ofRect(_x,_y,_width,_height);
    
    if(ofGetFill()) {
        ofRect(_x, _y, _width, _height);
    } else {
        if(inner) {
            ofRect(_x + .5, _y + .5, _width - 1, _height - 1);
        } else {
            ofRect(_x - .5, _y - .5, _width + 1, _height + 1);
        }
    }
    
}