void CloudsVisualSystemExampleVectorMath::addInteraction(float xi, float yi){ float x = ofMap(xi, 0, getCanvasWidth(), -(getCanvasWidth()/2.0), (getCanvasWidth()/2.0)); float y = ofMap(yi, 0, getCanvasHeight(), -(getCanvasHeight()/2.0), (getCanvasHeight()/2.0)); if(!bAutoDraw) { DrawPoint pt; pt.pos.set(x, y); //pt.pos = cam.screenToWorld(ofVec3f(x, y, 0)); pt.color = color; pt.createdAt = ofGetElapsedTimef(); pts.push_back( pt ); } }
void CloudsVisualSystemYellowTail::selfBegin(){ //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() Gesture *introGesture = new Gesture(getCanvasWidth(), getCanvasHeight()); introGesture->fromXMLFile( getVisualSystemDataPath() + "strokes/y_stroke.xml" ); gestures.push_back(introGesture); }
// selfSetup is called when the visual system is first instantiated // This will be called during a "loading" screen, so any big images or // geometry should be loaded here void CloudsVisualSystemCirclePacking::selfSetup(){ // Circle::Font.loadFont(getVisualSystemDataPath() + "Verdana14.ttf", 14, true, true, true); Circle::Font.loadFont(CloudsCryptoGetFont("Helvetica.ttf"), 14); //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() //cout << "SIZE = " << getCanvasWidth() << " " << getCanvasHeight() << endl; pack = CirclePacker(1.0f*getCanvasWidth(),1.0f*getCanvasHeight(), 15); if (NASDAQ){ initializeNasdaq(); } else if (BLANKS){ initializeBlanks(); } else if (HASHTAGS){ initializeHashtags(); } alph = 1.f; pack.pack(); }
void CloudsIntroSequence::updateTitle(){ if(!extrudedTitleText.isLoaded() || currentFontSize != titleFontSize || currentFontExtrusion != titleFontExtrude) { currentFontSize = titleFontExtrude; currentFontExtrusion = titleFontExtrude; extrudedTitleText.loadFont(GetCloudsDataPath() + "font/materiapro_light.ttf", titleFontSize, currentFontExtrusion); } titleRect = ofRectangle(0,0,titleRectWidth * getSharedRenderTarget().getWidth(), titleRectHeight * getSharedRenderTarget().getHeight() ); titleRect.alignTo( ofPoint(getCanvasWidth()/2, getCanvasHeight()/2) ); hoveringTitle = titleRect.inside(GetCloudsInputX(), GetCloudsInputY()); // cout << "title rect is " << titleRect.getTopLeft() << " " << titleRect.getBottomLeft() << endl; // cout << "hovering? " << (hoveringTitle ? "YES" : "NO" ) << endl; titleNoisePosition += titleNoiseSpeed; float hoverTitleOpacity; if(hoveringTitle || (startedOnclick && timeline->getIsPlaying()) ){ hoverTitleOpacity = .9; } else{ hoverTitleOpacity = titleTypeOpacity; } currentTitleOpacity += (hoverTitleOpacity-currentTitleOpacity)*.05; }
//-------------------------------------------------------------- void CloudsVisualSystemYellowTail::selfInteractionStarted(CloudsInteractionEventArgs& args){ int touchId = args.playerId; /* if (neverTouchedBefore) { clearGestures(); neverTouchedBefore = false; } */ // if (touchId%2 == 0){ mNewGestureStyle = GestureStyleTraveling; // } else { // mNewGestureStyle = GestureStyleInPlace; // } //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() Gesture *newGesture = new Gesture(getCanvasWidth(), getCanvasHeight()); newGesture->clear(); newGesture->clearPolygons(); newGesture->addPoint((float)args.position.x, (float)args.position.y); newGesture->setStyle(mNewGestureStyle); potentialGestures.insert(newGesture); gestureForTouch[touchId] = newGesture; }
/** * @brief Predator logic Calculate the Movement of Vectors relativ to Boids and set them accordingly. * * The Vectors are: * v1: Describes the closest boid and set their velocity according to their position. * v2: Describes the Velocity of other Boids nearby and matches it. * v3: Holds Information so that every Predator doesn't collide with the boundaries. */ void Predator::update() { double forceX = 0.0; double forceY = 0.0; double force; Vector2 v1 = Vector2(); Vector2 v2 = Vector2(); Vector2 v3 = Vector2(); Vector2 center = Vector2(); center += neighbours[0].pos; if(center != Vector2()) v1 = center - position; // Rule3: Match velocity to surrounding Boids for(int i = 0; i < 3; i++){ v2 = v2 + neighbours[i].vel; } v2 = (v2/3)*1.3; if(position.getX() < PREDATOR_ATTENUATION) v3.setX(1); else if(position.getX() >= getCanvasWidth() - PREDATOR_ATTENUATION) v3.setX(-1); if(position.getY() < PREDATOR_ATTENUATION) v3.setY(1); else if(position.getY() >= getCanvasHeight() - PREDATOR_ATTENUATION) v3.setY(-1); if(position.getX() < PREDATOR_ATTENUATION) forceX = PREDATOR_ATTENUATION - position.getX(); else if(position.getX() >= getCanvasWidth() - PREDATOR_ATTENUATION) forceX = PREDATOR_ATTENUATION + position.getX() - getCanvasWidth() ; else if(position.getY() < PREDATOR_ATTENUATION) forceY = PREDATOR_ATTENUATION - position.getY(); else if(position.getY() >= getCanvasHeight() - PREDATOR_ATTENUATION) forceY = PREDATOR_ATTENUATION + position.getY() - getCanvasHeight(); force = 3.0 * (forceX + forceY); velocity = Vector2::lerp(lastVel, velocity + v1.normalize() * 1.3 + v2.normalize() * 1.3 + v3.normalize() * force, 0.016f); lastVel = velocity; }
void CloudsVisualSystemCirclePacking::initializeBlanks(){ for(int i = 0; i < initialNumberofCircles; i++){ if(ofRandomuf() > .9){ //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() pack.circles.push_back( Circle(ofRandom(getCanvasWidth()), ofRandom(getCanvasHeight()), ofMap(powf(ofRandomuf(), 3.), 0, 1.0, large1, large2), " ", primaryColor, secondaryColor, alph )); } else{ //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() pack.circles.push_back( Circle(ofRandom(getCanvasWidth()), ofRandom(getCanvasHeight()), ofMap(powf(ofRandomuf(), 3.), 0.,1.0, small1, small2), " ", primaryColor, secondaryColor, alph )); } } }
void CloudsVisualSystemTunnelDrawing::addInteractionPoint(CloudsInteractionEventArgs& args){ ofVec3f mousePoint = camera.screenToWorld( ofVec3f(args.position.x, args.position.y, screenSpaceProjectDistance), ofRectangle(0,0,getCanvasWidth(),getCanvasHeight())); if (currentTrails[args.playerId].points.empty() || currentTrails[args.playerId].points.back().distance(mousePoint) > 10.0) { currentTrails[args.playerId].points.push_back(mousePoint); } }
void CloudsVisualSystemCirclePacking::initializeNasdaq(){ string companies[50] = { "SQR", "ZNGA","ALBB","BIDU", "SMCI", "SSYS", "NCR", "DELL", "FTNT","RAX","VMW", "EQUIX", "XXIA", "CTSH", "OPEN", "SFLY", "SSTK","EPAM", "IPGP", "DDD","YHOO", "TWTR","MSFT","FB","IBM","GOOG","HPQ","AMZN","EBAY","AAPL","CSCO","SNE","NOK","INTC","NVDA","AMD","ADBE","EA","FSQR", "LNKD", "YELP", "TMBL","SNAP", "BNCH", "LPMT","LLBT","LYFT", "GIT", "AOL", "OVR" }; float marketCap[50] = { 4.1, 4.11, 149, 59.9, .700, 5.85, 5.37, 24.38, 2.89, 4.88, 36.9, 8.4, .942, 28.3, 1.78, 1.82, 2.62, 1.51, 3.75, 8.32, 40.3, 137, 306, 130, 187.6, 354.4, 51.345, 175.9, 66.736, 498.8, 108.2, 18.169, 27.991, 120.7, 8.539, 2.670, 30.438, 6.869, 1, 25.7, 4.23, 2, 3, 4, 5, 5, 4, 6, 5, 3 }; //int size = sizeof(marketCap)/sizeof(marketCap[0]); int size = 50; for(int i = 0; i < size; i++){ //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() pack.circles.push_back( Circle(ofRandom(getCanvasWidth()),ofRandom(getCanvasHeight()), marketCap[i]/2, companies[i], primaryColor, secondaryColor, alph )); } }
void CloudsVisualSystemCirclePacking::initializeHashtags(){ string hashtags[10] = { "IMHO", "Jacked-in", "Meatspace", "cyberbully", "datasexual", "Grrrl", "Hater", "Troll", "illiterati", "Infomania"}; //int size = sizeof(hashtags)/sizeof(hashtags[0]); int size = 10; for(int i = 0; i < 10; i++){ //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() pack.circles.push_back( Circle(ofRandom(getCanvasWidth()),ofRandom(getCanvasHeight()), ofRandom(40,100), hashtags[i], primaryColor, secondaryColor, alph )); // cout << "word " << i << hashtags[i] << endl; } }
void CloudsIntroSequence::updateIntroNodePosition(CalibrationNode& node){ node.baseOffset = introNodeOffset; node.titleTypeOffset = titleTypeOffset; node.holdTime = introNodeHoldTime; node.centerYAdjust = introNodeYAdjust; node.updateWorldPosition(); #ifdef OCULUS_RIFT node.activationDistance = questionTugDistance; #else node.activationDistance = ofRange(introNodeSize*3, introNodeSize*5); node.worldPosition.x += getCanvasWidth()/2; node.worldPosition.y += getCanvasHeight()/2; #endif node.updateScreenPosition(); }
void CloudsVisualSystemYellowTail::selfSetup(){ // It'll be 16 & 11 on iPad, 8 & 6 on iPhone //MA: changed ofGetHeight() to getCanvasHeight() float deviceScale = ofClamp(getCanvasHeight() / 1024,1, 1024); softMaxGestures = MIN(ceil(16.0 * deviceScale), MAX_GESTURES); softMaxTouches = MIN(ceil(11.0 * deviceScale), MAX_TOUCHES); // ofBackground(0,0,0); bUpdatingGeometry = true; bIs2D = true; minimumTravelForNewPoint = 3; mNewGestureStyle = GestureStyleTraveling; neverTouchedBefore = true; clearGestures(); }
//normal update call void CloudsVisualSystemOscillations::selfUpdate(){ //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() width = getCanvasWidth(); height = getCanvasHeight(); offsetX += speed; if (renderLines){ mesh.setMode(OF_PRIMITIVE_LINE_LOOP); } else { mesh.setMode(OF_PRIMITIVE_POINTS); } //FIXME: This shouldn't happen unprovoked. It needs to be a callback to the UI. BuildGrid(); getCameraRef().setNearClip(clipPlanes.min); getCameraRef().setFarClip(clipPlanes.max); }
void CloudsVisualSystemCirclePacking::regenerate(){ //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() pack = CirclePacker(getCanvasWidth(), getCanvasHeight(), 12); if (NASDAQ){ initializeNasdaq(); } else if (BLANKS){ initializeBlanks(); } else if (HASHTAGS){ initializeHashtags(); } pack.pack(); }
Predator::Predator() { component = new QQmlComponent(getEngine(), QUrl(QStringLiteral("qrc:/Predator.qml"))); if(component->status() == component->Ready) { object = component->create(getEngine()->rootContext()); object->setProperty("parent", QVariant::fromValue(getCanvas())); QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); } else qDebug() << component->errorString(); setY(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasHeight() - 100)); setX(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasWidth() - 100)); isPredator = true; // Randomize staring velocity to sweep velocity.setX(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0); velocity.setY(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0); lastVel = velocity; }
//normal update call void CloudsVisualSystemLaplacianTunnel::selfUpdate(){ tunnelCam.setPosition( ofVec3f(tunnelCam.getPosition().x, tunnelCam.getPosition().y + cameraSpeed, tunnelCam.getPosition().z) ); externalCam.setTarget(tunnelCam.getPosition()); ofVec2f targetLookAngle; targetLookAngle.x = ofMap(GetCloudsInputX(), 0, getCanvasWidth(), -maxLookAngle,maxLookAngle); targetLookAngle.y = ofMap(GetCloudsInputY(), 0, getCanvasHeight(),-maxLookAngle,maxLookAngle); currentLookAngle.interpolate(targetLookAngle, .05); ofQuaternion base, rx,ry; base.makeRotate(90, 1, 0, 0); //straight up rx.makeRotate(currentLookAngle.x, 0, 0, -1); ry.makeRotate(currentLookAngle.y, -1, 0, 0); tunnelCam.setOrientation(base * rx * ry); currentGrowthIndex += (ofGetElapsedTimef() - lastFrameTime) * growthFPS; lastFrameTime = ofGetElapsedTimef(); }
void CloudsIntroSequence::updateCamera(){ if(selectedQuestion == NULL){ ofVec2f wobble = ofVec2f(ofSignedNoise(100 + ofGetElapsedTimef()*camWobbleSpeed), ofSignedNoise(200 + ofGetElapsedTimef()*camWobbleSpeed)) * camWobbleRange; if(!paused){ warpCamera.dolly(-cameraForwardSpeed); warpCamera.setPosition(wobble.x, wobble.y, warpCamera.getPosition().z); } else{ warpCamera.setPosition(wobble.x, wobble.y, 0); } ofVec2f camSwing = ofVec2f(ofMap(GetCloudsInputPosition().x, 0, getCanvasWidth(), cameraSwingRange.x, -cameraSwingRange.x, true ), ofMap(GetCloudsInputPosition().y, 0, getCanvasHeight(), cameraSwingRange.y, -cameraSwingRange.y, true)); curCameraSwing.interpolate(camSwing,powf(cameraSwingDamp, 2.0)); warpCamera.lookAt( ofVec3f(curCameraSwing.x, curCameraSwing.y, warpCamera.getPosition().z + 50) ); } else { float percentZoomed = powf(ofMap(ofGetElapsedTimef(), selectedQuestionTime, selectedQuestionTime + 2.0, 0.0, 1.0, true),2.); warpCamera.setPosition(selectQuestionStartPos.interpolate(selectedQuestion->hoverPosition, percentZoomed)); } }
void CloudsIntroSequence::updateWaiting(){ // Trigger start manually if (startedOnclick) { nodeAlphaAttenuate = MAX(0,nodeAlphaAttenuate-0.02); clickToBeginAlpha *= .99; clickToBeginAlpha -= .001; clickToBeginAlpha = MAX(0,clickToBeginAlpha); return; } for(int i = 0; i < introNodes.size(); i++){ updateIntroNodePosition(*introNodes[i]); } for(int i = 0; i < introNodes.size(); i++){ updateIntroNodeInteraction(*introNodes[i]); //bail if we haven't completed this part of the sequence if(!introNodes[i]->finished){ break; } } if(introNodeThree.finished){ startedOnclick = true; timeline->play(); } #ifdef OCULUS_RIFT #elif defined(KINECT_INPUT) k4w::ViewerState viewerState = ((CloudsInputKinectOSC*)GetCloudsInput().get())->viewerState; if(startQuestions.size() > 0 && viewerState != k4w::ViewerState_None){ if(!promptShown && ofGetElapsedTimef() - timeSinceLastPrompt > 8){ if(viewerState == k4w::ViewerState_OutOfRange){ // CloudsPortalEventArgs args("MOVE CLOSER TO THE DISPLAY"); // ofNotifyEvent(events.portalHoverBegan, args); } else if(viewerState == k4w::ViewerState_PresentIdle){ // CloudsPortalEventArgs args("EXTEND YOUR HAND TO BEGIN"); // ofNotifyEvent(events.portalHoverBegan, args); } timeSinceLastPrompt = ofGetElapsedTimef(); promptShown = true; kinectHelperTargetAlpha = 1.0; } else if(promptShown && ofGetElapsedTimef() - timeSinceLastPrompt > 4){ CloudsPortalEventArgs args(""); ofNotifyEvent(events.portalHoverEnded, args); timeSinceLastPrompt = ofGetElapsedTimef(); promptShown = false; kinectHelperTargetAlpha = 0.0; } } #else if(startQuestions.size() > 0){ if(!promptShown && ofGetElapsedTimef() - timeSinceLastPrompt > 10){ // CloudsPortalEventArgs args("CLICK TO BEGIN"); // ofNotifyEvent(events.portalHoverBegan, args); timeSinceLastPrompt = ofGetElapsedTimef(); promptShown = true; } else if(promptShown && ofGetElapsedTimef() - timeSinceLastPrompt > 4){ CloudsPortalEventArgs args(""); ofNotifyEvent(events.portalHoverEnded, args); timeSinceLastPrompt = ofGetElapsedTimef(); promptShown = false; } } #endif #ifdef MOUSE_INPUT if(clickTextActive){ float timeSinceActive = ofGetElapsedTimef() - clickTextActiveTime; float timeSinceMouse = ofGetElapsedTimef() - mouseLastMovedTime; clickToBeginAlpha = ofMap(timeSinceActive, .5,1.5, 0.0,1.0,true) * ofMap(currentTitleOpacity,titleTypeOpacity,.9,0.3,.7,true); #ifdef TARGET_WIN32 if(timeSinceMouse > 4.){ clickToBeginAlpha *= ofMap(timeSinceMouse, 4.0, 5.0, 1.0, 0.0,true); if(timeSinceMouse > 5.0){ clickTextActive = false; glfwSetCursorPos( ofAppGLFWWindow::windowP, getCanvasWidth()/2, getCanvasHeight()/2); } } #endif } #endif }
void CloudsVisualSystemMemory::generateFromMemory(){ int blocksTotal = 10000*(10-blockScale); unsigned char * data = new unsigned char[blocksTotal]; int xMargin = 0; int yMargin = 0; //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() int width = getCanvasWidth()-xMargin*2.0; int height = getCanvasHeight()-yMargin*2.0; float widthBlocks = blockWidth*blockScale; float heightBlocks = blockHeight*blockScale; xBlocks = (float)width/(widthBlocks+margin*blockScale); yBlocks = (float)height/(heightBlocks+margin*blockScale); blocks.clear(); outlineMesh.clear(); outlineMesh.setMode(OF_PRIMITIVE_LINES); outlineMesh.setUsage(GL_STREAM_DRAW); fillMesh.clear(); fillMesh.setMode(OF_PRIMITIVE_TRIANGLES); outlineMesh.setUsage(GL_STATIC_DRAW); int index = 0; for (int j = 0; j < yBlocks; j++) { for (int i = 0; i < xBlocks; i++){ if (index < blocksTotal ){ int x = xMargin + ((margin + blockWidth)*blockScale)*i; int y = yMargin + ((margin + blockHeight)*blockScale)*j; if ( y > (getSharedRenderTarget().getHeight() + margin + heightBlocks)){ break; } Block block; block.x = x+widthBlocks*0.5; block.y = y+heightBlocks*0.5; block.width = widthBlocks; block.height = heightBlocks; if(baseColorRange.min == baseColorRange.max){ block.color = ofFloatColor(baseColorRange.min); } else{ block.color = ofFloatColor( ofMap((unsigned char)data[index], 0, 255, baseColorRange.min,baseColorRange.max), 1.0); } block.borderColor = borderColor; block.borderBase = borderBase; block.value = (int)data[index]; block.bSelected = false; block.outlineMesh = &outlineMesh; block.fillMesh = &fillMesh; block.setup(); blocks.push_back(block); } else { break; } index++; } } delete []data; }
void CloudsVisualSystemMemory::generateFromTexture(ofTexture &_tex){ ofPixels pixels; _tex.readToPixels(pixels); int xMargin = 0; int yMargin = 0; //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() int width = getCanvasWidth()-xMargin*2.0; int height = getCanvasHeight()-yMargin*2.0; ofRectangle block; block.width = blockWidth*blockScale; block.height = blockHeight*blockScale; xBlocks = (float)width/((blockWidth+margin)*blockScale); yBlocks = (float)height/((blockHeight+margin)*blockScale); outlineMesh.clear(); outlineMesh.setMode(OF_PRIMITIVE_LINES); outlineMesh.setUsage(GL_STREAM_DRAW); fillMesh.clear(); fillMesh.setMode(OF_PRIMITIVE_TRIANGLES); outlineMesh.setUsage(GL_STATIC_DRAW); blocks.clear(); for (int j = 0; j < yBlocks; j++) { for (int i = 0; i < xBlocks; i++){ int x = xMargin + ((margin + blockWidth)*blockScale)*i ; int y = xMargin + ((margin + blockHeight)*blockScale)*j ; Block newBlock; newBlock.set(block); newBlock.x = x+block.width*0.5; newBlock.y = y+block.height*0.5; ofPoint st = ofPoint( ((float)i)/((float)xBlocks), ((float)j)/((float)yBlocks)); st *= ofPoint(_tex.getWidth(),_tex.getHeight()); newBlock.value = pixels.getColor( st.x, st.y ).getBrightness(); // newBlock.color = ofColor( newBlock.value)/brightnessOffset; if(baseColorRange.min == baseColorRange.max){ newBlock.color = ofFloatColor(baseColorRange.min); } else{ newBlock.color = ofFloatColor(ofMap(newBlock.value, 0, 255, baseColorRange.min,baseColorRange.max), 1.0); } newBlock.borderBase = borderBase; newBlock.borderColor = borderColor; newBlock.bSelected = false; newBlock.outlineMesh = &outlineMesh; newBlock.fillMesh = &fillMesh; newBlock.setup(); blocks.push_back(newBlock); } } }
// selfSetup is called when the visual system is first instantiated // This will be called during a "loading" screen, so any big images or // geometry should be loaded here void CloudsVisualSystemTunnelDrawing::selfSetup(){ colorShader.load(getVisualSystemDataPath() + "shaders/ribbon"); camera.begin( ofRectangle(0,0,getCanvasWidth(),getCanvasHeight()) ); camera.end(); }
JBDungeonPainterGD::JBDungeonPainterGD( JBDungeon* dungeon, int gridSize, int border ) : JBDungeonPainter( dungeon, gridSize, border ) { m_image = gdImageCreate( getCanvasWidth(), getCanvasHeight() ); }
void CloudsVisualSystemFireworks::selfUpdate() { float t = ofGetElapsedTimef(); //camera if(bAnimateCamera) { ofVec3f eul = getCameraRef().getOrientationEuler(); float xDamp = ofMap( abs(eul.x), 70, 90, 1, 0, true ); float noiseTimeScl = .1; float noiseOffsetScl = 800; float panScl = -5; float noiseValX = ofSignedNoise( ofGetElapsedTimef() * noiseTimeScl + 1. ) * noiseOffsetScl; float noiseValY = ofSignedNoise( ofGetElapsedTimef() * noiseTimeScl ) * noiseOffsetScl; //pan and tilt with mouse //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight() float pan = ofMap(GetCloudsInputX() + noiseValX, 0, getCanvasWidth(), cameraMotionScl, -cameraMotionScl); float tilt = ofMap(GetCloudsInputY() + noiseValY, 0, getCanvasHeight(), cameraMotionScl, -cameraMotionScl) * xDamp; if(abs(eul.x) < 90) getCameraRef().tilt( tilt ); getCameraRef().pan( pan ); //roll it when we move left to right float roll = abs(pan) * pan * panScl; getCameraRef().roll( -roll ); getCameraRef().move(0, abs(roll), 0); //move it ofVec3f vel = getCameraRef().getLookAtDir(); getCameraRef().move( vel * camSpeed ); //use this to determine where to explode fireworks float targetDistance = 300; camTarget = vel * targetDistance + getCameraRef().getPosition(); } //emitters ofVec3f p0, nScl; float nx, ny, nz; ofVec3f relativeDown = getCameraRef().getUpDir() * gravity.y; for (int i=emitters.size()-1; i>=0; i--) { emitters[i].update( t ); if( emitters[i].bStarted ) { emitters[i].pos += relativeDown * emitters[i].span * CubicIn(emitters[i].age); p0 = emitters[i].pos; nScl = p0 * .01; nx = ofSignedNoise(nScl.x + emitters[i].age, nScl.y, nScl.z); ny = ofSignedNoise(nScl.x, nScl.y + emitters[i].age, nScl.z); nz = ofSignedNoise(nScl.x, nScl.y, nScl.z + emitters[i].age); p0 += ofVec3f( nx, ny, nz ) * 10. * emitters[i].age; trailPoint( p0, emitters[i].vel, emissonRate, emitters[i].textureIndex, emitters[i].colorIndex ); } if(emitters[i].bEnded) { emitters.erase( emitters.begin() + i ); } } //particles bool updateIndices = false; indexCount = 0; for(int i=0; i<FIREWORKS_NUM_PARTICLES; i++){ //if the age + lifespan is less then the current time we want to draw it. otherwise? it is dead to us. if(lifeData[i].r + lifeData[i].g / speed > t){ indices[indexCount] = i; indexCount++; updateIndices = true; } } if(updateIndices){ vbo.updateIndexData( &indices[0], indexCount ); } if( bUpdateVbo ) { updateVbo(); } if( nextFireworkExplosionTime < t ) { explodeFireWorkAtRandom(); } }
// -------------------------------------------------- void ofxProjectorBlend::draw(float x, float y) { ofSetHexColor(0xFFFFFF); ofPushMatrix(); ofTranslate(x, y, 0); if(showBlend) { blendShader.begin(); blendShader.setUniform2f("uDimensions", singleChannelWidth, singleChannelHeight); blendShader.setUniform2f("uCanvas", getCanvasWidth(), getCanvasHeight()); updateShaderUniforms(); if(layout == ofxProjectorBlend_Horizontal) { blendShader.setUniform1f("uOverlap.right", pixelOverlap); } else { blendShader.setUniform1f("uOverlap.top", pixelOverlap); } blendShader.setUniformTexture("uImage", fullTexture, 0); ofVec2f offset(0,0); ofPushMatrix(); // loop through each projector and translate to its position and draw. for(int i = 0; i < numProjectors; i++) { blendShader.setUniform2f("uOffset", offset.x, offset.y); if(i==1) { // set the first edge if(layout == ofxProjectorBlend_Horizontal) { blendShader.setUniform1f("uOverlap.left", pixelOverlap); } else { blendShader.setUniform1f("uOverlap.bottom", pixelOverlap); } } // if we're at the end of the list of projectors, turn off the second edge's blend if(i+1 == numProjectors) { if(layout == ofxProjectorBlend_Horizontal) { blendShader.setUniform1f("uOverlap.right", 0); } else { blendShader.setUniform1f("uOverlap.top", 0); } } ofPushMatrix(); { if(rotation == ofxProjectorBlend_RotatedRight) { ofRotate(90, 0, 0, 1); ofTranslate(0, -singleChannelHeight, 0); } else if(rotation == ofxProjectorBlend_RotatedLeft) { ofRotate(-90, 0, 0, 1); ofTranslate(-singleChannelWidth, 0, 0); } ofTranslate(0, (float)projectorHeightOffset[i], 0); quadMesh.draw(); } ofPopMatrix(); // move the texture offset and where we're drawing to. if(layout == ofxProjectorBlend_Horizontal) { offset.x += singleChannelWidth - pixelOverlap; } else { offset.y += singleChannelHeight - pixelOverlap; } if(rotation == ofxProjectorBlend_RotatedLeft || rotation == ofxProjectorBlend_RotatedRight) { ofTranslate(singleChannelHeight, 0, 0); } else { ofTranslate(singleChannelWidth, 0, 0); } } ofPopMatrix(); blendShader.end(); } else { fullTexture.draw(x, y); } ofPopMatrix(); }
// selfDraw draws in 3D using the default ofEasyCamera // you can change the camera by returning getCameraRef() void CloudsVisualSystem3DModelLoader::selfDraw() { //???: update... for some reason the selfUpdate is being called in stand alone. // bLeftCamIsActive = bFrontCamIsActive = bPlanCamIsActive = bPerspCamIsActive = false; glDisable(GL_CULL_FACE); if( cursorIsOverGUI() ) { leftCam.disableMouseInput(); planCam.disableMouseInput(); frontCam.disableMouseInput(); perspCam.disableMouseInput(); } else { if( bLeftCamIsActive && !leftCam.getMouseInputEnabled()) leftCam.enableMouseInput(); if( bFrontCamIsActive && !frontCam.getMouseInputEnabled()) frontCam.enableMouseInput(); if( bPlanCamIsActive && !planCam.getMouseInputEnabled()) planCam.enableMouseInput(); if( bPerspCamIsActive && !perspCam.getMouseInputEnabled()) perspCam.enableMouseInput(); } updateModelTransform(); aimMultipleViews( modelTransform.getPosition() ); //draw from single view if( bFourView ) { //MA: changed ofGetWidth() to GetCanvasWidth() and ofGetHeight() to GetCanvasHeight() int hw = getCanvasWidth()/2; int hh = getCanvasHeight()/2; drawSceneLeft( ofRectangle(0,0,hw,hh) ); drawSceneFront( ofRectangle(hw,0,hw,hh) ); drawScenePlan( ofRectangle(0,hh,hw,hh) ); drawScenePerspective( ofRectangle(hw,hh,hw,hh) ); } else if(currentSingleCam == &perspCam) { drawScenePerspective( ofGetCurrentViewport() ); } else if(currentSingleCam == &leftCam) { drawSceneLeft(); } else if(currentSingleCam == &frontCam) { drawSceneFront(); } else if(currentSingleCam == &planCam) { drawScenePlan(); } else if(currentSingleCam == &pathCamera) { if(bUseDuration) pathCamera.update(); else pathCamera.update( pathCameraPosition ); drawSceneCamera( &pathCamera ); } }