Пример #1
0
//--------------------------------------------------------------
void testApp::draw() {
	ofEnableAlphaBlending();
	ofSetColor(255);
	
	ofEnablePointSprites();
	shader.begin();
	
	// we are getting the location of the point size attribute
	// we then set the pointSizes to the vertex attritbute
	// we then bind and then enable
	int pointAttLoc = shader.getAttributeLocation("pointSize");
	glVertexAttribPointer(pointAttLoc, 1, GL_FLOAT, false, 0, pointSizes);
	glBindAttribLocation(shader.getProgram(), pointAttLoc, "pointSize");
	glEnableVertexAttribArray(pointAttLoc);
	
	// rotate the snow based on the velocity
	int angleLoc = shader.getAttributeLocation("angle");
	glVertexAttribPointer(angleLoc, 1, GL_FLOAT, false, 0, rotations);
	glBindAttribLocation(shader.getProgram(), angleLoc, "angle");
	glEnableVertexAttribArray(angleLoc);
	
	texture.getTextureReference().bind();
	vbo.updateVertexData(pos, NUM_BILLBOARDS);
	vbo.draw(GL_POINTS, 0, NUM_BILLBOARDS);
	texture.getTextureReference().unbind();
	
	shader.end();
	ofDisablePointSprites();
	
	// disable vertex attributes
	glDisableVertexAttribArray(pointAttLoc); 
	glDisableVertexAttribArray(angleLoc);
}
Пример #2
0
//--------------------------------------------------------------
void testApp::draw() {
	ofBackgroundGradient(ofColor(255), ofColor(230, 240, 255));
	
	string info = ofToString(ofGetFrameRate(), 2)+"\n";
	info += "Particle Count: "+ofToString(NUM_BILLBOARDS);
	ofDrawBitmapStringHighlight(info, 30, 30);
	
	ofSetColor(255);
	
	ofPushMatrix();
	ofTranslate(ofGetWidth()/2, ofGetHeight()/2, zoom);
	ofRotate(cameraRotation.x, 1, 0, 0);
	ofRotate(cameraRotation.y, 0, 1, 0);
	ofRotate(cameraRotation.y, 0, 0, 1);
	
	// bind the shader so that wee can change the
	// size of the points via the vert shader
	billboardShader.begin();
	
	ofEnablePointSprites();
	texture.bind();
	billboards.draw();
	texture.unbind();
	ofDisablePointSprites();
	
	billboardShader.end();
	
	ofPopMatrix();
}
Пример #3
0
void ParticleSystem::draw(bool isTudorPetal)
{
	//ofEnableAlphaBlending();
	//ofSetColor(255, 0, 0, 50);
    
	shader.begin();
	ofEnablePointSprites();
	if (isTudorPetal)
        tudorImg->getTextureReference().bind();
    else
        petalImg->getTextureReference().bind();
	vbo.updateVertexData(pos, NUM_BILLBOARDS);
    
	// rotate the snow based on the velocity
	int angleLoc = shader.getAttributeLocation("angle");
	vbo.updateAttributeData(angleLoc, rotations, NUM_BILLBOARDS);
    
	vbo.draw(GL_POINTS, 0, NUM_BILLBOARDS);
	if (isTudorPetal)
        tudorImg->getTextureReference().unbind();
    else
        petalImg->getTextureReference().unbind();
        
    
	ofDisablePointSprites();
	shader.end();
}
Пример #4
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofPushStyle();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofEnablePointSprites();
    cam.begin();
    render.begin();

    // パーティクルの位置と経過時間

    render.setUniformTexture("u_posAndAgeTex", pingPong.src->getTextureReference(0), 0);
    particles.draw();
    render.end();
    cam.end();
    ofDisablePointSprites();
    ofPopStyle();
    
    if(showTex){
        ofPushStyle();
        ofEnableBlendMode(OF_BLENDMODE_ALPHA);
        pingPong.dst->getTextureReference(0).draw(0,0);
        ofDrawBitmapStringHighlight("Position", 0,14);
        pingPong.dst->getTextureReference(1).draw(texRes,0);
        ofDrawBitmapStringHighlight("Velocity", texRes,14);
        ofPopStyle();
    }
    ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), 0,ofGetHeight() - 2);
}
Пример #5
0
void testApp::draw() {
	
	ofPushMatrix();
		ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);
		cam.begin();
			
			// パーティクル描画設定
			glDepthMask(GL_FALSE);
			ofEnablePointSprites();
			texture.getTextureReference().bind();
			
			// パーティクルのZ軸の位置によって大きさを変化させる
			static GLfloat distance[] = { 0.0, 0.0, 1.0 }; 
			glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, distance);
			glPointSize(30000);
			
			// パーティクルを描画
			ofEnableBlendMode(OF_BLENDMODE_ADD);
			billboardVbo.draw(GL_POINTS, 0, NUM_BILLBOARDS);
			texture.getTextureReference().unbind();
			ofDisablePointSprites();
			glDepthMask(GL_TRUE);
		cam.end();
	ofPopMatrix();
	
	// ログを表示
	ofSetColor(255, 255, 255);
	string info = ofToString(ofGetFrameRate(), 2)+"\n";
	info += "Particle Count: "+ofToString(NUM_BILLBOARDS)+"\n";
	ofDrawBitmapString(info, 30, 30);
}
Пример #6
0
void Particles::render()
{
    string info = ofToString(ofGetFrameRate(), 2)+"\n";
    info += "Particle Count: "+ofToString(NUM_BILLBOARDS);
    ofDrawBitmapStringHighlight(info, 30, 30);
    
    ofSetColor(255);
    
    ofPushMatrix();
    
    ofEnableAlphaBlending();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    
    // bind the shader so that wee can change the
    // size of the points via the vert shader
    billboardShader.begin();
    
    ofEnablePointSprites();
    texture.getTextureReference().bind();
    billboards.draw();
    texture.getTextureReference().unbind();
    ofDisablePointSprites();
    
    billboardShader.end();
    
    ofPopMatrix();
}
Пример #7
0
//--------------------------------------------------------------
void ofApp::draw(){

	glDepthMask(GL_FALSE);
	
	ofColor c;
	c.setHsb(18,160,80);
	ofSetColor(c);
	
	// this makes everything look glowy :)
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	ofEnablePointSprites();
	
	// bind the shader and camera
	// everything inside this function
	// will be effected by the shader/camera
	shader.begin();
	camera.begin();

	// bind the texture so that when all the swarm.positions 
	// are drawn they are replace with our dot image
	texture.bind();
	vbo.draw(GL_POINTS, 0, (int)swarm.positions.size());
	texture.unbind();

	camera.end();
	shader.end();
	
	ofDisablePointSprites();
	ofDisableBlendMode();

	ofDrawBitmapString("framerate: " + ofToString(ofGetFrameRate()),ofGetWidth() - 160, 20);

}
Пример #8
0
//--------------------------------------------------------------
void ofApp::drawPointCloud() {
    meshPoints = mesh.getNumVertices();
    glPointSize(20);
    ofEnableAlphaBlending();
    ofEnablePointSprites();
    spriteImg.getTexture().bind();
    mesh.drawVertices();
    ofDisablePointSprites();
}
Пример #9
0
//--------------------------------------------------------------
void ofApp::draw() {

	glDepthMask(GL_FALSE);
	
	ofSetColor(255, 100, 90);
	
	// this makes everything look glowy :)
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	ofEnablePointSprites();
	
	// bind the shader and camera
	// everything inside this function
	// will be effected by the shader/camera
	shader.begin();
	camera.begin();
	
	// bind the texture so that when all the points 
	// are drawn they are replace with our dot image
	texture.bind();
	vbo.draw(GL_POINTS, 0, (int)points.size());
	texture.unbind();
	
	camera.end();
	shader.end();
	
	ofDisablePointSprites();
	ofDisableBlendMode();
	
	// check to see if the points are 
	// sizing to the right size
	ofEnableAlphaBlending();
	camera.begin();
	for (unsigned int i=0; i<points.size(); i++) {
		ofSetColor(255, 80);
		ofVec3f mid = points[i];
		mid.normalize();
		mid *= 300;
		ofLine(points[i], mid);
	} 
	camera.end();
	
	glDepthMask(GL_TRUE);
	
	ofSetColor(255, 100);
	ofRect(0, 0, 250, 90);
	ofSetColor(0);
	string info = "FPS "+ofToString(ofGetFrameRate(), 0) + "\n";
	info += "Total Points "+ofToString((int)points.size())+"\n";
	info += "Press 'a' to add more\n";
	info += "Press 'c' to remove all";
	
	ofDrawBitmapString(info, 20, 20);
	
}
Пример #10
0
void SceneC::draw(){
	glDepthMask(GL_FALSE);
	ofEnablePointSprites();
	//パーティクルの位置に画像を表示
	for (int i = 0; i < particles.size(); i++){
		float posx = particles[i].pos.x - 16;
		float posy = particles[i].pos.y - 16;
		img.draw(posx, posy);
	}
	ofDisablePointSprites();
	glDepthMask(GL_TRUE);
}
Пример #11
0
//--------------------------------------------------------------
void ofApp::draw() {
    ofBackground(0);
	
	ofSetColor(255);
    
    huntForBlendFunc(1000, 4, 5); // 4 5 is good
    
	ofPushMatrix();
    
	ofTranslate(xTrans, yTrans, zoom);
    ofRotate(cameraRotation.y, 0, 1, 0);
	ofRotate(cameraRotation.x, 1, 0, 0);
	ofRotate(cameraRotation.z, 0, 0, 1);
    ofScale(0.4, 0.4, 0.4);
	
	// bind the shader so that we can change the
	// size of the points via the vert shader
	billboardShader.begin();
    
    billboardShader.setUniform1f("time", ofGetElapsedTimeMillis());
    billboardShader.setUniform1f("seed", 0.9389124);
    billboardShader.setUniform1fv("weights", &weights[0]);
    billboardShader.setUniform1fv("scaling", &scaling[0]);
    billboardShader.setUniform1f("normalization", 100.0);
    
    billboardShader.setUniform1f("minPointDist", minPointDist);
    billboardShader.setUniform1f("maxPointDist", maxPointDist);
    
    billboardShader.setUniform1f("pointSizeMultiplier", pointSizeMultiplier);
    billboardShader.setUniform1f("pointSizePower", pointSizePower);
    billboardShader.setUniform1f("minPointSize", minPointSize);
    billboardShader.setUniform1f("maxPointSize", maxPointSize);
    
    billboardShader.setUniform1f("pointOpacityMultiplier", pointOpacityMultiplier);
    billboardShader.setUniform1f("pointOpacityPower", pointOpacityPower);
    billboardShader.setUniform1f("minPointOpacity", minPointOpacity);
    billboardShader.setUniform1f("maxPointOpacity", maxPointOpacity);
    
	ofEnablePointSprites(); // not needed for GL3/4
	texture.getTextureReference().bind();
	billboards.draw();
	texture.getTextureReference().unbind();
	ofDisablePointSprites(); // not needed for GL3/4
	
	billboardShader.end();
    
	ofPopMatrix();
    
    if (!bHideControls) {
        panel.draw();
        ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), 10, 20);
    }
}
Пример #12
0
void ofApp::drawSPK() {
    ofEnableBlendMode(OF_BLENDMODE_ADD);
	
	// sys.debugDraw();
	
	// bind texture, enable point sprite while drawing particles
	sprite.bind();
	ofEnablePointSprites();
	sys.draw();
	ofDisablePointSprites();
	sprite.unbind();
    particlePos.clear();
}
Пример #13
0
void ofApp::drawShader(){
    
    
    
    ofBackground(0);
    
   // fbo.begin();
   
   	ofBackgroundGradient(ofColor(255), ofColor(230, 240, 255));
	
	string info = ofToString(ofGetFrameRate(), 2)+"\n";
	info += "Particle Count: "+ofToString(NUM_BILLBOARDS);
	ofDrawBitmapStringHighlight(info, 30, 30);
	
	ofSetColor(255);

    
	billboardShader.begin();

    billboardShader.setUniform1f("scaleBen", 132);
    billboardShader.setUniform1f("numPoints", ofGetMouseX());
	ofEnablePointSprites(); // not needed for GL3/4
  
	texture.getTextureReference().bind();
        cam.begin();
	billboards.draw();
         cam.end();
	texture.getTextureReference().unbind();
    
	ofDisablePointSprites(); // not needed for GL3/4
	
	billboardShader.end();
	
  
   // fbo.end();
    //    }
    
    
    
    
    
    
    
   // fbo.draw(ofGetWidth()/2, 0, ofGetWidth()/2, ofGetHeight()/2);
    
    
    
}
Пример #14
0
//--------------------------------------------------------------
void ofApp::draw() {
    ofBackgroundGradient(ofColor(255), ofColor(230, 240, 255));
    
    string info = ofToString(ofGetFrameRate(), 2)+"\n";
    info += "Particle Count: "+ofToString(NUM_BILLBOARDS);
    ofDrawBitmapStringHighlight(info, 30, 30);
    
    ofSetColor(255);
    
    ofPushMatrix();
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2, zoom);
    ofRotate(cameraRotation.x, 1, 0, 0);
    ofRotate(cameraRotation.y, 0, 1, 0);
    ofRotate(cameraRotation.y, 0, 0, 1);
    
    // bind the shader so that wee can change the
    // size of the points via the vert shader
    billboardShader.begin();
    
    ofEnablePointSprites(); // not needed for GL3/4
    texture.getTextureReference().bind();
    billboards.draw();
    texture.getTextureReference().unbind();
    ofDisablePointSprites(); // not needed for GL3/4
    
    billboardShader.end();
    
    ofPopMatrix();
    
    //we have to disable depth testing to draw the video frame
    ofDisableDepthTest();
    //	vidGrabber.draw(20,20);
    
    //but we want to enable it to show the mesh
    ofEnableDepthTest();
    cam.begin();
    
    //You can either draw the mesh or the wireframe
    // mainMesh.drawWireframe();
    mainMesh.drawFaces();
    cam.end();
    
    //draw framerate for fun
    ofSetColor(255);
    string msg = "fps: " + ofToString(ofGetFrameRate(), 2);
    ofDrawBitmapString(msg, 10, 20);

}
Пример #15
0
//--------------------------------------------------------------
void pbVertexRender::drawEnd( float part ){ //конец рисования
    if ( points.empty() ) { return; }
    part = ofClamp( part, 0, 1 );
    int total = (int)points.size() * part;
    if ( total == 0 ) return;
    
    texture.bind();
	vbo.draw(GL_POINTS, 0, total);
	texture.unbind();
	
    if ( useShader_ ) {
        shader_.end();
    }
	
	ofDisablePointSprites();
	//ofDisableBlendMode();
    
    //    ofEnableAlphaBlending();
}
void BillboardLayer::draw(bool deactiveBlendMode)
{
  if(useShader&&!deactiveBlendMode)
    billboardShader.begin();
  if(useAddBlendMode&&!deactiveBlendMode)
      ofEnableBlendMode(OF_BLENDMODE_ADD);
  ofEnablePointSprites(); // not needed for GL3/4
  texture.getTexture().bind();
  ofPushMatrix();
  ofTranslate(0, 0, posZ);
  drawBillboard();
  ofPopMatrix();
  texture.getTexture().unbind();
  ofDisablePointSprites(); // not needed for GL3/4
  if(useAddBlendMode&&!deactiveBlendMode)
    ofDisableBlendMode();
  if(useShader&&!deactiveBlendMode)
    billboardShader.end();
}
Пример #17
0
void ParticleSystem::draw() {

	renderTrails();

	spriteShader.begin();
	ofEnablePointSprites(); // not needed for GL3/4
	sprite.getTexture().bind();

    if(particles.size() > 0) {
        int angleLoc = spriteShader.getAttributeLocation("angle");
        billboards.getVbo().setAttributeData(angleLoc, &rotations[0], 1, particles.size(), GL_DYNAMIC_DRAW);
    }

	billboards.draw();

	sprite.getTexture().unbind();
	ofDisablePointSprites(); // not needed for GL3/4
	spriteShader.end();

}
// selfDraw draws in 3D using the default ofEasyCamera
// you can change the camera by returning getCameraRef()
void CloudsVisualSystemFlocking::selfDraw(){
    glDepthMask(false);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofEnablePointSprites();
    ofSetColor(0,255);
    rdrShader.begin();
    rdrShader.setUniform3f("u_color", redColor, greenColor, blueColor);
    rdrShader.setUniformTexture("posData", posFboSrc.getTextureReference(), posFboSrc.getTextureReference().getTextureData().textureID);
    rdrShader.setUniformTexture("accData", accFboSrc.getTextureReference(), accFboSrc.getTextureReference().getTextureData().textureID);

    glow.bind();
    glPointSize(pointSize);
    vbo.draw(GL_POINTS, 0, size);
    glow.unbind();
    
    rdrShader.end();
    ofDisablePointSprites();
    glDepthMask(true);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
}
Пример #19
0
void CloudsIntroSequence::drawTunnel(){
	ofPushStyle();
	
	tunnelShader.begin();
	tunnelShader.setUniform1f("minPointSize", pointSize.min);
	tunnelShader.setUniform1f("maxPointSize", pointSize.max);
	tunnelShader.setUniform1f("minDistance", distanceRange.min);
	
	if(bUseOculusRift){
		tunnelShader.setUniform1f("maxDistance", distanceRange.max + currentTitleOpacity * 120.);
	}
	else{
		tunnelShader.setUniform1f("maxDistance", distanceRange.max + currentTitleOpacity * 120.);
	}
	
	tunnelShader.setUniform1f("cameraZ", warpCamera.getPosition().z);
	tunnelShader.setUniform1f("tunnelDepth", tunnelMax.z);
	tunnelShader.setUniform1f("noiseAmplitude", perlinAmplitude);
	tunnelShader.setUniform1f("noiseDensity", perlinDensity);
	perlinOffset += perlinSpeed;
	tunnelShader.setUniform1f("noisePosition", perlinOffset);
	tunnelShader.setUniform1f("colorAttenuate", 1.0);
	ofFloatColor tinted = ofFloatColor::fromHsb(tint.r, tint.g, tint.b);
	tunnelShader.setUniform4f("tint",tinted.r,tinted.g,tinted.b, 1.0);
	
	ofSetColor(255);
	ofEnablePointSprites();
	tunnelShader.setUniformTexture("sprite", sprite, 0);
	tunnelShader.setUniform1f("useSprite", 1);
	tunnelMeshTight.drawVertices();
	ofDisablePointSprites();
	
	ofSetLineWidth(1);
	tunnelShader.setUniform1f("colorAttenuate", wireframeAlpha);
	tunnelShader.setUniform1f("useSprite", 0);
	tunnelMeshLoose.draw();
	
	tunnelShader.end();
	
	ofPopStyle();
}
Пример #20
0
void TrailParticles::draw(float x, float y, float w, float h)
{
    if(!bEnabled) return;

    if(bPlayAnim) {
        ofPushStyle();
        ofSetColor(255);
        ofPushMatrix();

        //billboardShader.begin();

        ofEnablePointSprites();
        billboards.draw();
        ofDisablePointSprites();

        //billboardShader.end();

        ofPopMatrix();
        ofPopStyle();
    }
}
Пример #21
0
//--------------------------------------------------------------
void ofApp::draw() {
	ofEnableAlphaBlending();
	ofSetColor(255);
	
	shader.begin();
	ofEnablePointSprites();
	
	
	texture.getTexture().bind();
	vbo.updateVertexData(pos, NUM_BILLBOARDS);

	// rotate the snow based on the velocity
	int angleLoc = shader.getAttributeLocation("angle");
	vbo.updateAttributeData(angleLoc, rotations, NUM_BILLBOARDS);

	vbo.draw(GL_POINTS, 0, NUM_BILLBOARDS);
	texture.getTexture().unbind();

	ofDisablePointSprites();
	shader.end();
}
Пример #22
0
void BufferCont::drawPoint(ofRectangle &view, ofEasyCam & cam, vector <ofVec3f> &data){

	m_vbo.setVertexData(&data[0], data.size(), GL_STATIC_DRAW);
	m_vbo.setNormalData(&m_sizes.front()[0], m_sizes.front().size(), GL_STATIC_DRAW);
	m_vbo.setColorData(&m_indiColor.front()[0], m_indiColor.front().size(), GL_STATIC_DRAW);
	glDepthMask(GL_FALSE);
	//ofEnableBlendMode(OF_BLENDMODE_ADD);
	ofEnablePointSprites();

	m_shader.begin();
	cam.begin(view);
	m_texture.bind();
	m_vbo.draw(GL_POINTS, 0, data.size());
	m_texture.unbind();
	cam.end();
	m_shader.end();

	ofDisablePointSprites();
	//ofDisableBlendMode();
	glDepthMask(GL_TRUE);
}
Пример #23
0
void ParticleSystem::renderTrails()
{
   // ofBlendMode(OF_BLENDMODE_ADD);
    if(trailType == TRAIL_NONE) return;

	trails.clear();

	for( vector<Particle>::iterator it = particles.begin(); it != particles.end(); ++it ) {
        if((trailType == TRAIL_LINE) || (trailType == TRAIL_TAIL)) {
            it->renderTrailPoints(trails);
        } else if(trailType == TRAIL_QUADS) {
            it->renderTrails(trails);
        }
	}
	trails.setupIndicesAuto();

    if(trailType == TRAIL_QUADS) {
        trailShader.begin();

        spriteTrail.getTexture().bind();
        trails.draw(OF_MESH_FILL);
        spriteTrail.getTexture().unbind();

        trailShader.end();
    } else if ((trailType == TRAIL_LINE) || (trailType == TRAIL_TAIL)) {
       trailBillboardShader.begin();
        ofEnablePointSprites();

        spriteTrail.getTexture().bind();
        trails.draw();
        spriteTrail.getTexture().unbind();

        ofDisablePointSprites();
       trailBillboardShader.end();
		
    }
}
Пример #24
0
//--------------------------------------------------------------
void testApp::draw() {
	ofBackgroundGradient(ofColor(255), ofColor(230, 240, 255));
	
	string info = ofToString(ofGetFrameRate(), 2)+"\n";
	info += "Particle Count: "+ofToString(NUM_BILLBOARDS);
	ofDrawBitmapStringHighlight(info, 30, 30);
	
	ofEnableAlphaBlending();
	ofSetColor(255);
	
	ofPushMatrix();
	ofTranslate(ofGetWidth()/2, ofGetHeight()/2, zoom);
	ofRotate(cameraRotation.x, 1, 0, 0);
	ofRotate(cameraRotation.y, 0, 1, 0);
	ofRotate(cameraRotation.y, 0, 0, 1);
	
	// bind the shader so that wee can change the
	// size of the points via the vert shader
	billboardShader.begin();
	billboardShader.setUniform1fv("pointSize", billboardSize, NUM_BILLBOARDS); 
	
	ofEnablePointSprites();
	texture.getTextureReference().bind();
	billboardVbo.bind();
	billboardVbo.setVertexData(billboardVerts, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);
	//billboardVbo.setColorData(billboardColor, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);
	billboardVbo.draw(GL_POINTS, 0, NUM_BILLBOARDS);
	
	billboardVbo.unbind();
	texture.getTextureReference().unbind();
	ofDisablePointSprites();
	
	billboardShader.end();
	
	ofPopMatrix();
}
Пример #25
0
void testApp::drawScene()
{

    light.enable();
    ofPushMatrix();
    
    
    ofScale(whole_scene_scale,whole_scene_scale,whole_scene_scale);
    ofRotateX(scene_rx);
    ofRotateY(scene_ry);
    ofRotateZ(scene_rz);
    ofTranslate(whole_scene_x, whole_scene_y, whole_scene_z);
    ofPushMatrix();

    
    ofVboMesh theCloud;
    theCloud.setUsage(GL_DYNAMIC_DRAW);
    theCloud.setMode(OF_PRIMITIVE_POINTS);
    theCloud.getNormals().resize(cloudField,ofVec3f(0));
    for (int i=0; i<cloud.size();i++) {
        theCloud.addVertex(cloud[i].location);
        theCloud.setNormal(i,ofVec3f(
                                     ofMap(meditationLevel, 0, 100, 5, 0)
                                     +ofNoise(ofGetElapsedTimef()+i),0,0));
        
    }
    
    billboardShader.begin();
    glDisable(GL_DEPTH_TEST);
    ofEnablePointSprites();
    texture.getTextureReference().bind();
    theCloud.draw();
    texture.getTextureReference().unbind();
    ofDisablePointSprites();
    billboardShader.end();
    glEnable(GL_DEPTH_TEST);
	ofPopMatrix();
    
    
    //   ----   room   ----
    
    if(showRoom){
        ofPushMatrix();
        ofEnableDepthTest();
        ofSetColor(255);
        ofRotateX(270);
        ofRotateY(roomRotateY);
        ofTranslate(roomModelPos);
        roomModel.draw();
        ofPopMatrix();
    }
    //   ----   end room   ----
    
    ofPushMatrix();
    drawPointCloud();
    ofPopMatrix();
#ifdef USE_TWO_KINECTS
    ofPushMatrix();
    drawAnotherPointCloud();
    ofPopMatrix();
#endif
    ofPopMatrix();
}
Пример #26
0
//--------------------------------------------------------------
void testApp::draw(){
	
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	lineBlurTarget.begin();
	ofClear(0,0,0,0);
	ofPushStyle();
	
	cam.begin(ofRectangle(0,0,1920,1080));
	ofSetLineWidth(	lineThickness *2);
	ofSetColor(255);
	traversal.setMode(OF_PRIMITIVE_LINE_STRIP);
	traversal.draw();
	cam.end();
	
	ofPopStyle();
	lineBlurTarget.end();
	
	renderTarget.begin();
	ofClear(0,0,0,0);
	
	cam.begin(ofRectangle(0,0,1920,1080));
	ofPushStyle();

	ofSetColor(255);
	
	ofSetLineWidth(	timeline.getValue("line width") );
	lineAttenuate.begin();
	lineAttenuate.setUniform1f("focalPlane", powf(timeline.getValue("line focal dist"),2));
	lineAttenuate.setUniform1f("focalRange", powf(timeline.getValue("line focal range"),2));
	lineAttenuate.setUniform1f("lineFade", lineAlpha);
	lineAttenuate.setUniform3f("attractor", trailHead.x, trailHead.y, trailHead.z);
	lineAttenuate.setUniform1f("radius", 300.);
	
	geometry.setMode(OF_PRIMITIVE_LINE_STRIP);
	geometry.draw();
	
	lineAttenuate.end();
	
	traversal.setMode(OF_PRIMITIVE_LINE_STRIP);
	traversal.draw();

	//POINT SPRITES
	billboard.begin();
	ofEnablePointSprites();
	ofDisableArbTex();

	nodeSpriteBasic.getTextureReference().bind();
	ofSetColor(255*.5);
	
	//glPointSize(replicatePointSize);
	billboard.setUniform1f("minSize", replicatePointSize);
	billboard.setUniform3f("attractor", trailHead.x, trailHead.y, trailHead.z);
	billboard.setUniform1f("radius", 300.);
	
	nodeCloudPoints.drawVertices();
	nodeSpriteBasic.getTextureReference().unbind();

	//FUZZIES
//	glPointSize(pointSize);
//	ofSetColor(255*.15);
//	nodeRingSprite.getTextureReference().bind();
//	nodeCloudPoints.drawVertices();
//	nodeRingSprite.getTextureReference().unbind();
	
	//NODES
	nodeSprite.getTextureReference().bind();
	traversedNodePoints.drawVertices();
	nodeSprite.getTextureReference().unbind();
	
	billboard.end();
	ofDisablePointSprites();
	ofEnableArbTex();
	
	ofPopStyle();
	cam.end();
	
	//line blur
	gaussianBlur.begin();
	
	ofPushStyle();
	//ofSetColor(255 * lineBlurFade);
	ofSetColor(255*lineBlurFade);

	gaussianBlur.setUniform1i("tex", 0);
	gaussianBlur.setUniform2f("sampleOffset", lineBlurAmount, 0);
	lineBlurTarget.getTextureReference().draw(0, 0, 1920, 1080);
	
	gaussianBlur.setUniform2f("sampleOffset", 0, lineBlurAmount);
	lineBlurTarget.getTextureReference().draw(0, 0,1920, 1080);
	
	gaussianBlur.end();
	
	ofPopStyle();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	if(ofGetKeyPressed('=')){
		lineBlurTarget.draw(fboRect.getX(), fboRect.getMaxY(), fboRect.width,-fboRect.height);
	}
	else{
		renderTarget.draw(fboRect.getX(), fboRect.getMaxY(), fboRect.width,-fboRect.height);
	}
	
	if(rendering && timeline.getIsPlaying()){
		char fileName[1024];
		sprintf(fileName, "%sframe_%05d.png", renderFolder.c_str(), frameNum++);
		ofImage image;
		image.setUseTexture(false);
		renderTarget.readToPixels(image.getPixelsRef());
		image.mirror(true, false);
		image.saveImage(string(fileName));
	}
	
	timeline.draw();
	gui.draw();
}
void Dimentions::selfDraw(){
    
    if (!bDebug){
        ofEnableAlphaBlending();
        
        ofPushMatrix();
        ofPushStyle();
        materials["MATERIAL 1"]->begin();
        
        //  Labels
        //
        if(categoriesTintColor.a > 0.0 ){
            for(int i = 0; i < categories.size(); i++){
                ofSetColor(categoriesTintColor);
                drawBrakets(categories[i], 15, 10);
                
                categories[i].draw(bDebug);
            }
        }
        
        for (int i = 0; i < booksWithTags.size(); i++) {
            drawLabel( *booksWithTags[i], booksWithTags[i]->text );
        }
        
        if(categoriesNodesTintColor.a > 0.0){
            for(int i = 0; i < categories.size(); i++){
                for(int j = 0; j < categories[i].nodes.size(); j++){
                    ofPushMatrix();
                    ofTranslate(categories[i].nodes[j]->x,
                                categories[i].nodes[j]->y,
                                categories[i].nodes[j]->z);
                    ofSetColor(categoriesNodesTintColor);
                    float scale = 0.4;
                    ofScale(scale,scale,scale);
                    //orientBillBoard();
                    ofRectangle box = font.getStringBoundingBox(categories[i].nodesText[j], 0, 0);
                    font.drawStringAsShapes(categories[i].nodesText[j], -box.width*0.5,0);
                    ofPopMatrix();
                }
            }
        }
    
        
        {
            ofSetColor(255);
            ofDisableArbTex();
            glDepthMask(GL_FALSE);
            glEnable(GL_NORMALIZE);
            ofEnablePointSprites();
            
            spriteShader.begin();
            spriteTexture.bind();
            
            spriteShader.setUniformTexture("tex", spriteTexture, 0);
            spriteShader.setUniform1f("nearClip", getCameraRef().getNearClip());
            spriteShader.setUniform1f("farClip", getCameraRef().getFarClip());
            spriteShader.setUniform1f("size",spriteSize);
            spriteShader.setUniform1f("minPointSize", 1.0);//spriteSizeMin);
            spriteShader.setUniform1f("maxPointSize", spriteSizeMax);
            spriteShader.setUniform1f("focusDistance", spriteFocusDistance);
            spriteShader.setUniform1f("focusAperture", spriteFocusAperture*0.01);
            
            spriteVBO.draw(GL_POINTS, 0, TOTAL_OF_BOOKS );
            
            spriteTexture.unbind();
            spriteShader.end();
            
            ofDisablePointSprites();
            glDisable(GL_NORMALIZE);
            glDepthMask(GL_TRUE);
            ofEnableArbTex();
        }

        materials["MATERIAL 1"]->end();
        ofPopStyle();
        ofPopMatrix();
    }
}
Пример #28
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;
    }
}
Пример #29
0
//--------------------------------------------------------------
void testApp::draw(){
	
	updateParticleSystem();
	updatePerlinLuminosity();

	renderTarget.begin();
	ofClear(0,0,0,255);
	cam.begin(ofRectangle(0,0,renderTarget.getWidth(), renderTarget.getHeight()));
			
    if(player.isLoaded()){
		drawGeometry();
	}

	ofPushMatrix();
//	ofScale(1,-1,1);
	ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset"));
	glEnable(GL_DEPTH_TEST);
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	
	ofSetColor(0);
	ofPushMatrix();
	ofScale(1, -1, 1);
	meshBuilder.getMesh().disableColors();
	meshBuilder.getMesh().draw();
	meshBuilder.getMesh().enableColors();
	ofPopMatrix();
	ofSetColor(255);
	
	ambientShader.begin();
	ofEnablePointSprites();
	ofDisableArbTex();
	crossSprite.getTextureReference().bind();
	
	ambientShader.setUniform1f("maxDisance", particleMaxDistance) ;
	ambientShader.setUniform1f("maxSize", particeMaxSize) ;

	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	ofPushStyle();
	glPointSize(3.0);
	ofSetColor(particleFade*255);
	ambientParticles.drawVertices();
	ofPopStyle();
	ambientShader.end();

	crossSprite.getTextureReference().unbind();
	
	glDisable(GL_DEPTH_TEST);
	ofDisablePointSprites();
	ofEnableArbTex();

	ofPopMatrix();
	
//	randomUnits.drawVertices();
//	clusters.drawVertices();

	cam.end();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	ofPushStyle();
	ofSetColor(0);
	ofRect(fboRect);
	ofPopStyle();

	
	renderTarget.getTextureReference().draw(fboRect.x,fboRect.getBottom(),fboRect.width,-fboRect.height);
	
	if(rendering){

		saveImage.setUseTexture(false);
		renderTarget.readToPixels(saveImage.getPixelsRef());
		saveImage.mirror(true, false);
		char filename[1024];
		sprintf(filename, "%sframe_%05d.png",renderFolder.c_str(), currentFrameNumber);
		saveImage.saveImage(filename);
		currentFrameNumber++;
		
	}
	timeline.draw();
    gui.draw();
}
Пример #30
0
//--------------------------------------------------------------
void testApp::drawPointCloud(){
    //===================================================
    //DEEP MEDITATION MODE===============================
    //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
    //===================================================
    if(meditationLevel >= 80){
        ofVboMesh mesh;
        mesh.setUsage(GL_DYNAMIC_DRAW);
        mesh.setMode(OF_PRIMITIVE_POINTS);
        mesh.getNormals().resize(5000,ofVec3f(0));
        int w = 640;
        int h = 480;
        int i = 0;
        float t = (ofGetElapsedTimef()) * 0.9f;
        vector<target> targets;
        for(int y=0;y<h;y+=step){
            for(int x=0;x<w;x+=step){
                if(kinect.getDistanceAt(x, y) > 200 && kinect.getDistanceAt(x, y) < 1300){
                    mesh.addVertex(ofVec3f(kinect.getWorldCoordinateAt(x, y)));
                    mesh.setNormal(i,ofVec3f(particleSize+ofNoise(t+i),0,0));
                    i++;
                }
            }
        }
        ofPushMatrix();
        ofSetColor(255);
        glDisable(GL_DEPTH_TEST);
        ofScale(-1,-1,1);
        ofRotateY(yangle);
        ofRotateZ(zangle);
        ofRotateX(xangle);
        ofTranslate(pointCloudPos);
        ofScale(kinectImageScale, kinectImageScale, kinectImageScale);
        billboardShader.begin();
        ofEnablePointSprites();
        texture.getTextureReference().bind();
        mesh.draw();
        texture.getTextureReference().unbind();
        ofDisablePointSprites();
        billboardShader.end();
        glEnable(GL_DEPTH_TEST);
        ofPopMatrix();
        //===================================================
        //LOW MEDITATION MODE===============================
        //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
        //===================================================
    }else{
        ofVboMesh mesh;
        mesh.setUsage(GL_DYNAMIC_DRAW);
        mesh.setMode(OF_PRIMITIVE_POINTS);
        int w = 640;
        int h = 480;
        //Get original data from kinect and strore them into 'targets'
        vector<target> targets;
        for(int y=0;y<h;y+=step){
            for(int x=0;x<w;x+=step){
                if(kinect.getDistanceAt(x, y) > 200 && kinect.getDistanceAt(x, y) < 1300){
                    targets.push_back(ofVec3f(kinect.getWorldCoordinateAt(x, y)));
                    //arrange all of the particle to the correct position in the first time so they won't seek the same target...
                    if(firstRun == false){
                        ps.push_back(ofVec3f(kinect.getWorldCoordinateAt(x, y)));
                    }
                }
            }
        }
        firstRun = true;
        //compare the amount between our Particle Vector and all kinect particles
        while(targets.size() > ps.size()){
            ps.push_back(ofVec3f(ofRandom(-300,300), ofRandom(-300,300) , 800));
        }
        //set normals
        mesh.getNormals().resize(ps.size(),ofVec3f(0));
        //===============SET TARGETS===============
        for(int i=0;i<ps.size();i++){
            //=========== if meditationlevel is too low, make particles move totally randomly ======
            if (meditationLevel < 15) {
                if(ofGetFrameNum()%20==0){
                    
                    
                    ps[i].seek(ofVec3f(
                                       ofRandom(-6000,6000),ofRandom(-6000,6000),ofRandom(-6000,6000)
                                       )
                               );
                }
                ps[i].update();
            }else{
                float minDistance = 1000000;
                float index = 0;
                for(int b=0;b<targets.size();b++){
                    if(targets[b].choosen==false){
                        float distance;
                        distance = ps[i].location.distance(targets[b].location);
                        if(distance < minDistance){
                            minDistance = distance;
                            index = b;
                        }
                    }
                }
                ps[i].seek(targets[index].location
                           + ofVec3f(
                                     ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1),
                                     ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1),
                                     ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1)
                                     )
                           );
                ps[i].target_assigned = true;
                targets[index].choosen = true;
                ps[i].update();
                //adjust movement parameter based on Meditation Level
                if(meditationLevel > 60){
                    ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) * 2;
                    ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 10;
                }else if(meditationLevel > 40 && meditationLevel <= 60){
                    ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) * 1;
                    ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 7;
                }else if(meditationLevel >= 15){
                    ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) / 2 ;
                    ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 16;
                }else{
                    if(ofGetFrameNum()%50==0){
                        ps[i].maxforce = ofRandom(-0.01,0.1);
                        ps[i].maxspeed = ofRandom(1,3);
                    }
                }
            }
            mesh.addVertex(ps[i].getPosition());
            mesh.setNormal(i,ofVec3f(particleSize+ofNoise(ofGetElapsedTimef()+i),0,0));
            i++;
        }
        //==================JUST DRAW===============
        ofPushMatrix();
        ofPushStyle();
        ofSetColor(255);
        //point one flip function...
        // ofScale(1,-1,1);
        glDisable(GL_DEPTH_TEST);
        ofScale(-1, -1,1);
        ofRotateY(yangle);
        ofRotateZ(zangle);
        ofRotateX(xangle);
        ofTranslate(pointCloudPos);
        ofScale(kinectImageScale, kinectImageScale, kinectImageScale);
        billboardShader.begin();
        ofEnablePointSprites();
        texture.getTextureReference().bind();
        mesh.draw();
        texture.getTextureReference().unbind();
        ofDisablePointSprites();
        billboardShader.end();
        glEnable(GL_DEPTH_TEST);
        ofPopStyle();
        ofPopMatrix();
    }
}