示例#1
0
文件: ofApp.cpp 项目: Mana-Hanno/oF
void ofApp::drawTwoRings() {
    //additional---------------------------------
    ofPushMatrix();
    ofTranslate(ofGetWidth()/8*3, 0);
    //-------------------------------------------
    
    //ofDrawSphere(0, ofGetHeight()/2, -ofGetHeight()/2, 10+250*lVol);
    for (int i = 0; i < 360; i+=15) {
        
        //float moveDim = ofGetElapsedTimef()/2;
        //if (midD.bang) midD.moveDim++;
        if (lowD.bang && i%2==0) lowD.moveDim++;
        
        float rad = i*PI/180;
        float posx = ofGetWidth()/12 *cos(rad + lowD.moveDim);
        float posz = ofGetHeight()/2;
        float posy = ofGetHeight()/2 + ofGetWidth()/10 *sin(rad + lowD.moveDim);
        
        //ofDrawSphere(posx, posy, posz, 10);
        ofPushMatrix();
        ofTranslate(posx, posy, posz);
        ofRotate(120, 1, 1, 1);
        ofDrawCone(0, -20-500*midD.vol, 0, 10, 20+1000*midD.vol);
        ofPopMatrix();
        
    }
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate(ofGetWidth()/8*5, 0);
    //ofDrawSphere(0, ofGetHeight()/2,-ofGetHeight()/2, 10+250*lVol);
    for (int i = 0; i < 360; i+=15) {
        
        //float moveDim = ofGetElapsedTimef()/2;
        //if (midD.bang) midD.moveDim++;
        if (lowD.bang && i%2==0) lowD.moveDim++;
        
        float rad = i*PI/180;
        float posx = ofGetWidth()/12 *cos(rad + lowD.moveDim);
        float posz = ofGetHeight()/2;
        float posy = ofGetHeight()/2 + ofGetWidth()/10 *sin(rad + lowD.moveDim);
        
        //ofDrawSphere(posx, posy, posz, 10);
        ofPushMatrix();
        ofTranslate(posx, posy, posz);
        ofRotate(120, 1, 1, 1);
        ofDrawCone(0, -20-500*midD.vol, 0, 10, 20+1000*midD.vol);
        ofPopMatrix();
        
    }
    
    ofPopMatrix();
}
void ofxStreetView::draw(){
if(meshDepth.getNumVertices()){
    // 
    ofPushMatrix();
    ofRotate(getDirection(), 0, 0, 1);
    getTextureReference().bind();
    meshDepth.drawVertices();
    getTextureReference().unbind();
    //
    ofVec3f centerMesh = meshDepth.getCentroid();
    ofPushStyle();
    ofSetColor(0,0,250);
    ofNoFill();
    ofDrawBox( centerMesh.x,centerMesh.y, (centerMesh.z-45),10,10,10);
    ofSetColor(255,0,0);
    ofPushMatrix();
    ofTranslate( centerMesh.x,centerMesh.y,(centerMesh.z-45) );
    ofRotateY(-120);
    ofDrawCone(3,8);
    ofPopMatrix();
    ofPopStyle();
    //meshDepth.drawWireframe();
    ofPopMatrix();
}
   //
}
示例#3
0
//--------------------------------------------------------------
void ofxBulletCone::draw() {
	if(!_bCreated || _rigidBody == NULL) {
		ofLog(OF_LOG_WARNING, "ofxBulletCone :: draw : must call create() first and add() after");
		return;
	}
	transformGL();
    ofPushMatrix();
    ofRotate(180, 1, 0, 0);
    ofDrawCone( 0, 0, 0, getRadius(), getHeight() );
    ofPopMatrix();
    restoreTramsformGL();
}
示例#4
0
void Vehicle::Display()
{
	float theta = velocity.angle(Vector2(0, 1)) + PI / 2;
	ofSetColor(0, 255, 0);
	ofPushMatrix();
	{
		ofTranslate(position.x, position.y);
		ofRotateZ(theta);
		ofDrawCone(15, 50);
	}
	ofPopMatrix();
	ofSetColor(255, 0, 0);
	ofDrawArrow(position, position + (velocity*10),0.1f);
}
示例#5
0
//--------------------------------------------------------------
void ofDrawArrow(const ofVec3f& start, const ofVec3f& end, float headSize) {
	
	//draw line
	ofLine(start, end);
	
	//draw cone
	ofMatrix4x4 mat;
	mat.makeRotationMatrix( ofVec3f(0,1,0), start - end );
	ofPushMatrix();
	ofTranslate(end);
	ofMultMatrix(mat.getPtr());
	ofTranslate(0, headSize*0.5 ,0);
    ofDrawCone(headSize, headSize*2.);
	ofPopMatrix();
}
示例#6
0
void CyrilConeOp::eval(CyrilState &_s) {
  c->eval(_s);
  float r, h;
  switch (c->size()) {
    case 2:
      h = _s.stk->top(); _s.stk->pop();
      r = _s.stk->top(); _s.stk->pop();
      break;
    case 1:
      h = _s.stk->top(); _s.stk->pop();
      r = h;
      break;
    case 0:
      h = 1;
      r = 1;
      break;
  }
  ofDrawCone(r, h);
}
示例#7
0
文件: ofApp.cpp 项目: Mana-Hanno/oF
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofEnableAlphaBlending();
    ofBackground(0,0,0,0);
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofEnableLighting();
    pointLight.enable();
    
    ofSetColor(255);
    
    //drawTwoRings();
    
    for (int i = 0; i < 360; i+=15) {
        
        //float moveDim = ofGetElapsedTimef()/2;
        //if (midD.bang) midD.moveDim++;
        if (midD.bang && i%2==0) midD.moveDim++;
        
        float rad = i*PI/180;
        float posx = ofGetWidth()/2 + ofGetWidth()/10 *cos(rad + midD.moveDim);
        float posz = ofGetHeight()/2;
        float posy = ofGetHeight()/2 + ofGetWidth()/10 *sin(rad + midD.moveDim);
        
        //ofDrawSphere(posx, posy, posz, 10);
        ofPushMatrix();
        ofTranslate(posx, posy, posz);
        ofRotate(120, 1, 1, 1);
        ofDrawCone(0, -20-500*midD.vol, 0, 10, 20+1000*midD.vol);
        ofPopMatrix();
        
    }
    /*
    for (int i = 0; i < 8; i++) {
        float lastx = -999;
        float lasty = -999;
        float ynoise = ofRandom(10);
        
        float orientX = 10;
        float orientY = 0;

        float y;

        float limitX = orientX + ofGetWidth()*hVol;
        
        for (int x = orientX; x < limitX ; x++) {
            y = orientY + ofNoise(ynoise) * 80;
            if (lastx > -999) {
                ofLine(x, y, lastx, lasty);
            }
            lastx = x;
            lasty = y;
            ynoise += 0.1;
        }
        
    }*/
    float ynoise = ofRandom(10);
    //float y;
    float x;
    
//    float orientX = ofGetWidth()/2;
//    float orientY = 0;

    float orientY = ofGetHeight()/2;
    float orientX = 10;

//    float limitX    = orientX + ofGetWidth()*hVol;
//    float limitMinX = orientX - ofGetWidth()*hVol;

    float multiplyVal = 80;
    //if (highD.bang) multiplyVal = 500;
    
    float limitY    = 0 + ofGetHeight()/2*highD.vol*3.5;
    float limitMinY = ofGetHeight() - ofGetHeight()/2*highD.vol*3.5;
    
    float lastx = -999;
    float lasty = -999;
    for (int y = 0; y < limitY ; y++) {
        
        float xNoise = ofNoise(ynoise);
        x = orientX + xNoise * multiplyVal;
        if (lasty > -999) {
            ofLine(x, y, lastx, lasty);
        }
        ynoise += 0.1;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lasty > -999) {
            ofLine(x, y, lastx, lasty);
        }
        lastx = x;
        lasty = y;
        ynoise += 0.1;
        
        //if (y%2==0) xNoise *= -1;

        orientX += xNoise;
    }
    

    orientX = 10;
    float lastMinX = -999;
    float lastMinY = -999;
    for (int y = ofGetHeight(); y > limitMinY ; y--) {
        float xNoise = ofNoise(ynoise);
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinY > -999) {
            ofLine(x, y, lastMinX, lastMinY);
        }
        ynoise += 0.1;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinY > -999) {
            ofLine(x, y, lastMinX, lastMinY);
        }
        lastMinX = x;
        lastMinY = y;
        ynoise += 0.1;
        orientX += xNoise;
    }
    
    float lastx2 = -999;
    float lasty2 = -999;
    orientX = ofGetWidth()-100;
    for (int y = 0; y < limitY ; y++) {
        float xNoise = ofNoise(ynoise);
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lasty2 > -999) {
            ofLine(x, y, lastx2, lasty2);
        }
        ynoise += 0.1;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lasty2 > -999) {
            ofLine(x, y, lastx2, lasty2);
        }
        
        lastx2 = x;
        lasty2 = y;
        ynoise += 0.1;
        orientX -=xNoise;
    }

    float lastMinX2 = -999;
    float lastMinY2 = -999;
    orientX = ofGetWidth()-100;
    for (int y = ofGetHeight(); y > limitMinY ; y--) {
        float xNoise = ofNoise(ynoise);
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinY2 > -999) {
            ofLine(x, y, lastMinX2, lastMinY2);
        }
        ynoise += 0.1;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinY2 > -999) {
            ofLine(x, y, lastMinX2, lastMinY2);
        }
        lastMinX2 = x;
        lastMinY2 = y;
        ynoise += 0.1;
        orientX -=xNoise;
    }

    if (highD.bang) {
        orientX = ofGetWidth()/2-50;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastx > -999) {
            ofLine(x, orientY, lastx, lasty);
        }
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinX > -999) {
            ofLine(x, orientY, lastMinX, lastMinY);
        }
        orientX = ofGetWidth()/2-30;
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastx2 > -999) {
            ofLine(x, orientY, lastx2, lasty2);
        }
        x = orientX + ofNoise(ynoise) * multiplyVal;
        if (lastMinX2 > -999) {
            ofLine(x, orientY, lastMinX2, lastMinY2);
        }

    }
    
    drawShader();
    pointLight.disable();
    ofDisableLighting();
    
}
示例#8
0
void createPrimitive::draw(property &p) {
    prop = p;
    if(prop.points.size() == 0) return;
    switch (prop.dType) {
        case CP_POINT:
            glDepthMask(GL_FALSE);
            ofEnableAlphaBlending();
            ofEnableBlendMode(OF_BLENDMODE_ALPHA);
            ofEnablePointSprites();
            shader.begin();
            texture.bind();
            prop.vbo.draw(GL_POINTS, 0, (int)prop.points.size());
            texture.unbind();
            
            shader.end();
            ofDisablePointSprites();
            glDepthMask(GL_TRUE);
            
            break;
        case CP_LINE:
            //ofSetLineWidth(mags[0].x/10);
            ofSetLineWidth(20);
            prop.vbo.drawElements(GL_LINE_STRIP, prop.points.size());
            break;
        case CP_CYLINDER:
            for (int i = 0; i < prop.points.size(); i++) {
                ofPushMatrix();
                //glDepthMask(GL_FALSE);
                ofEnableDepthTest();
                ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255);
                ofTranslate(prop.points[i].x, prop.points[i].y-prop.mags[i].x/2, prop.points[i].z);
                ofDrawCylinder(0,0,0, 10, prop.mags[i].x);
                //glDepthMask(GL_TRUE);
                ofPopMatrix();
            }
            break;
        case CP_CYLINDER_SPECTRUM:
            //if (!prop.drawBins.size()) break;
            for (int i = 0; i < prop.points.size(); i++) {
                if(prop.origMags[i] == 0)  continue ;
                ofPushMatrix();
                ofTranslate(prop.points[i].x, prop.points[i].y- prop.drawBins[(i % 10)] *200/2, prop.points[i].z);
                ofDrawCylinder(0,0,0, 10, prop.drawBins[(i % 10)] * 200);
                ofPopMatrix();
                
                //cout << (i % 10) << " " << prop.drawBins[(i % 10)] << endl;
                
            }
            break;
        case CP_RECT:
            //ofNoFill();
            for (int i = 0; i < prop.points.size(); i++) {
                ofPushMatrix();
                ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255);
                ofTranslate(prop.points[i].x-prop.mags[i].x/2, prop.points[i].y-prop.mags[i].x/4, prop.points[i].z);
                ofRotate(-prop.angle, 0, 0, 1);
                //ofRect(0, 0, mags[i].x, mags[i].x/2);
                ofDrawBox(0, 0, 0, prop.mags[i].x, prop.mags[i].x, prop.mags[i].x);
                ofPopMatrix();
            }
            break;
        case CP_RECT_ROUNDED:
            for (int i = 0; i < prop.points.size(); i++) {
                ofRectRounded(prop.points[i].x-prop.mags[i].x/2, prop.points[i].y-prop.mags[i].x/4, prop.mags[i].x, prop.mags[i].x/2, prop.mags[i].x/4);
            }
            break;
        case CP_ELLIPPSE:
            for (int i = 0; i < prop.points.size(); i++) {
                ofEllipse(prop.points[i].x, prop.points[i].y, prop.mags[i].x, prop.mags[i].x/2);
                //ofRect(points[i].x-mags[i].x/2, points[i].y-mags[i].x/2, mags[i].x, mags[i].x);
            }
            break;
        case CP_LINE_IND:
            ofSetLineWidth(10);
            for (int i = 0; i < prop.points.size(); i++) {
                ofLine(prop.points[i].x, prop.points[i].y, prop.points[i].x, prop.points[i].y+prop.mags[i].x);
            }
            break;
        case CP_SPHERE:
            for (int i = 0; i < prop.points.size(); i++) {
                ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255);
                ofDrawSphere(prop.points[i].x, prop.points[i].y, prop.points[i].z, prop.mags[i].x);
            }
        
            if (particleFlg) {
                for (int i = 0; i < prop.mags.size(); i++) {
                    prop.mags[i] *= 10.0;
                }
                prop.vbo.setNormalData(&prop.mags[0], prop.mags.size(), GL_DYNAMIC_DRAW);
                
                glDepthMask(GL_FALSE);
                ofEnableAlphaBlending();
                ofEnableBlendMode(OF_BLENDMODE_ALPHA);
                ofEnablePointSprites();
                shader.begin();
                texture.bind();
                prop.vbo.draw(GL_POINTS, 0, (int)prop.points.size());
                texture.unbind();
                
                shader.end();
                ofDisablePointSprites();
                glDepthMask(GL_TRUE);

            }
            break;
        case CP_TRIANGLE:
            prop.vbo.drawElements(GL_TRIANGLE_STRIP, prop.points.size());
            break;
        case CP_TRIANGLE_IND:
            prop.angle+=5;
            //ofNoFill();
            ofSetLineWidth(10);
            for (int i = 0; i < prop.points.size(); i++) {
                ofPushMatrix();
                //glDepthMask(GL_FALSE);
                ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255);
                ofTranslate(prop.points[i].x, prop.points[i].y);
                ofRotate(prop.angle, 0, 0, 1);
                /*
                ofTriangle(0,
                           -prop.mags[i].x,
                           prop.mags[i].x/-2,
                           prop.mags[i].x/2*sqrt(3),
                           prop.mags[i].x/2,
                           prop.mags[i].x/2*sqrt(3));
                 */
                ofDrawCone(0, prop.mags[i].x/-2,prop.points[i].z, prop.mags[i].x/2, prop.mags[i].x);
                //  glDepthMask(GL_TRUE);
                ofPopMatrix();
            }
            break;
        case CP_CIRCLE:
            for (int i = 0; i < prop.points.size(); i++) {
                ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255);
                ofCircle(prop.points[i].x, prop.points[i].y, prop.points[i].z, prop.mags[i].x/2);
            }
        default:
            break;
    }
}