diff --git a/examples/3d/3DPrimitivesExample/src/ofApp.cpp b/examples/3d/3DPrimitivesExample/src/ofApp.cpp index 23f5b6a5c23..ce60a12314f 100644 --- a/examples/3d/3DPrimitivesExample/src/ofApp.cpp +++ b/examples/3d/3DPrimitivesExample/src/ofApp.cpp @@ -122,10 +122,10 @@ void ofApp::draw() { if (mode == 3) { deformPlane = plane.getMesh(); // x = columns, y = rows // - ofVec3f planeDims = plane.getResolution(); + glm::vec2 planeDims = plane.getResolution(); float planeAngleX = ofGetElapsedTimef()*3.6; - float planeAngleInc = 3.f / (float)planeDims.x; - ofVec3f vert; + float planeAngleInc = 3.f / (float)planeDims.x; + glm::vec3 vert; for (size_t i = 0; i < deformPlane.getNumIndices(); i++) { planeAngleX += planeAngleInc; int ii = deformPlane.getIndex(i); @@ -214,7 +214,7 @@ void ofApp::draw() { if (mode == 3) { float angle = ofGetElapsedTimef()*3.2; float strength = (sin(angle + .25)) * .5f * 5.f; - ofVec3f faceNormal; + glm::vec3 faceNormal; for (size_t i = 0; i < triangles.size(); i++) { // store the face normal here. // we change the vertices, which makes the face normal change @@ -254,7 +254,7 @@ void ofApp::draw() { if (mode == 3) { float angle = (ofGetElapsedTimef() * 1.4); - ofVec3f faceNormal; + glm::vec3 faceNormal; for (size_t i = 0; i < triangles.size(); i++) { float frc = ofSignedNoise(angle* (float)i * .1, angle*.05) * 4; faceNormal = triangles[i].getFaceNormal(); diff --git a/examples/3d/advanced3dExample/src/Swarm.cpp b/examples/3d/advanced3dExample/src/Swarm.cpp index 53cf8096acc..917d6447402 100644 --- a/examples/3d/advanced3dExample/src/Swarm.cpp +++ b/examples/3d/advanced3dExample/src/Swarm.cpp @@ -19,7 +19,7 @@ void swarm::init(int nParticles, float positionDispersion, float velocityDispers ofSeedRandom(); // - ofVec3f position, velocity; + glm::vec3 position, velocity; ofColor color; for(int i = 0; i < nParticles; i++){ position.x = (ofRandom(1.0f) - 0.5f) * positionDispersion; @@ -145,8 +145,8 @@ void swarm::update(){ // [4] Force a maximum velocity - if(particles[i].velocity.length() > MAX_VELOCITY){ - particles[i].velocity /= particles[i].velocity.length() * MAX_VELOCITY; + if(glm::length(particles[i].velocity) > MAX_VELOCITY){ + particles[i].velocity /= glm::length(particles[i].velocity) * MAX_VELOCITY; } // diff --git a/examples/3d/advanced3dExample/src/Swarm.h b/examples/3d/advanced3dExample/src/Swarm.h index f5a6fa2d378..0035d66ffe5 100644 --- a/examples/3d/advanced3dExample/src/Swarm.h +++ b/examples/3d/advanced3dExample/src/Swarm.h @@ -8,8 +8,8 @@ // with 'simple harmonic motion' class swarm : public ofNode { struct particle { - ofVec3f position; - ofVec3f velocity; + glm::vec3 position; + glm::vec3 velocity; ofColor color; }; diff --git a/examples/3d/advanced3dExample/src/ofApp.cpp b/examples/3d/advanced3dExample/src/ofApp.cpp index ac57465e665..42f8a9040f2 100644 --- a/examples/3d/advanced3dExample/src/ofApp.cpp +++ b/examples/3d/advanced3dExample/src/ofApp.cpp @@ -255,8 +255,8 @@ void ofApp::drawScene(int cameraIndex){ // Now lets get the inverse ViewProjection // for the camera - ofMatrix4x4 inverseCameraMatrix; - inverseCameraMatrix.makeInvertOf(camEasyCam.getModelViewProjectionMatrix(boundsToUse)); + glm::mat4 inverseCameraMatrix; + inverseCameraMatrix = glm::inverse(camEasyCam.getModelViewProjectionMatrix(boundsToUse)); // By default, we can say // 'we are drawing in world space' @@ -329,8 +329,8 @@ void ofApp::drawScene(int cameraIndex){ //-------------------------------------------------------------- void ofApp::updateMouseRay(){ // Define ray in screen space - ray[0] = ofVec3f(ofGetMouseX(), ofGetMouseY(), -1); - ray[1] = ofVec3f(ofGetMouseX(), ofGetMouseY(), 1); + ray[0] = glm::vec3(ofGetMouseX(), ofGetMouseY(), -1); + ray[1] = glm::vec3(ofGetMouseX(), ofGetMouseY(), 1); // Transform ray into world space ray[0] = cameras[iMainCamera]->screenToWorld(ray[0], viewMain); diff --git a/examples/3d/advanced3dExample/src/ofApp.h b/examples/3d/advanced3dExample/src/ofApp.h index dd7012a85e1..6f4a356fe99 100644 --- a/examples/3d/advanced3dExample/src/ofApp.h +++ b/examples/3d/advanced3dExample/src/ofApp.h @@ -61,5 +61,5 @@ class ofApp : public ofBaseApp { grid nodeGrid; //ray drawn under mouse cursor [start,end] - ofVec3f ray[2]; + glm::vec3 ray[2]; }; diff --git a/examples/3d/assimpExample/src/ofApp.cpp b/examples/3d/assimpExample/src/ofApp.cpp index ea6b6b69410..1568e0353dd 100644 --- a/examples/3d/assimpExample/src/ofApp.cpp +++ b/examples/3d/assimpExample/src/ofApp.cpp @@ -99,7 +99,7 @@ void ofApp::draw(){ //-------------------------------------------------------------- void ofApp::keyPressed(int key){ - ofPoint modelPosition(ofGetWidth() * 0.5, (float)ofGetHeight() * 0.75); + glm::vec3 modelPosition(ofGetWidth() * 0.5, (float)ofGetHeight() * 0.75, 0); switch (key) { case '1': model.loadModel("astroBoy_walk.dae"); diff --git a/examples/3d/cameraLensOffsetExample/src/ofApp.cpp b/examples/3d/cameraLensOffsetExample/src/ofApp.cpp index 7f10cc098ad..b99fcdd1c66 100644 --- a/examples/3d/cameraLensOffsetExample/src/ofApp.cpp +++ b/examples/3d/cameraLensOffsetExample/src/ofApp.cpp @@ -13,7 +13,7 @@ void ofApp::setup(){ previewCamera.setNearClip(0.01f); previewCamera.setFarClip(500.0f); previewCamera.setPosition(0.4f, 0.2f, 0.8f); - previewCamera.lookAt(ofVec3f(0.0f, 0.0f, 0.0f)); + previewCamera.lookAt(glm::vec3(0.0f, 0.0f, 0.0f)); headTrackedCamera.setNearClip(0.01f); headTrackedCamera.setFarClip(1000.0f); @@ -22,13 +22,13 @@ void ofApp::setup(){ windowWidth = 0.3f; windowHeight = 0.2f; - windowTopLeft = ofVec3f(-windowWidth / 2.0f, + windowTopLeft = glm::vec3(-windowWidth / 2.0f, +windowHeight / 2.0f, 0.0f); - windowBottomLeft = ofVec3f(-windowWidth / 2.0f, + windowBottomLeft = glm::vec3(-windowWidth / 2.0f, - windowHeight / 2.0f, 0.0f); - windowBottomRight = ofVec3f(+windowWidth / 2.0f, + windowBottomRight = glm::vec3(+windowWidth / 2.0f, -windowHeight / 2.0f, 0.0f); @@ -42,7 +42,7 @@ void ofApp::update(){ video.update(); finder.findHaarObjects(video.getPixels()); - ofVec3f headPosition(0,0,viewerDistance); + glm::vec3 headPosition(0,0,viewerDistance); if (finder.blobs.size() > 0) { //get the head position in camera pixel coordinates @@ -59,11 +59,11 @@ void ofApp::update(){ float worldHeadY = ofMap(cameraHeadY, 0, video.getHeight(), windowTopLeft.y, windowBottomLeft.y); //set position in a pretty arbitrary way - headPosition = ofVec3f(worldHeadX, worldHeadY, viewerDistance); + headPosition = glm::vec3(worldHeadX, worldHeadY, viewerDistance); } else { if (!video.isInitialized()) { //if video isn't working, just make something up - headPosition = ofVec3f(0.5f * windowWidth * sin(ofGetElapsedTimef()), 0.5f * windowHeight * cos(ofGetElapsedTimef()), viewerDistance); + headPosition = glm::vec3(0.5f * windowWidth * sin(ofGetElapsedTimef()), 0.5f * windowHeight * cos(ofGetElapsedTimef()), viewerDistance); } } @@ -140,7 +140,7 @@ void ofApp::drawScene(bool isPreview){ ofSetLineWidth(5.0f); ofBeginShape(); for (unsigned int i=0; i headPositionHistory; + deque headPositionHistory; ofVboMesh window; }; diff --git a/examples/3d/cameraParentingExample/src/ofApp.cpp b/examples/3d/cameraParentingExample/src/ofApp.cpp index d6089b23166..2275917feb1 100644 --- a/examples/3d/cameraParentingExample/src/ofApp.cpp +++ b/examples/3d/cameraParentingExample/src/ofApp.cpp @@ -55,9 +55,9 @@ void ofApp::update(){ // all testNodes move in simple circles // but because they are parented to each other, complex paths emerge for(int i=0; i= 0) { ofSetColor(0, 255, 255); - ofVec3f v1 = cam[i].getGlobalPosition(); - ofVec3f v2 = testNodes[lookatIndex[i]].getGlobalPosition(); + glm::vec3 v1 = cam[i].getGlobalPosition(); + glm::vec3 v2 = testNodes[lookatIndex[i]].getGlobalPosition(); ofDrawLine(v1,v2); } // draw line from cam to its parent if(parentIndex[i] >= 0) { ofSetColor(255, 255, 0); - ofVec3f v1 = cam[i].getGlobalPosition(); - ofVec3f v2 = testNodes[parentIndex[i]].getGlobalPosition(); + glm::vec3 v1 = cam[i].getGlobalPosition(); + glm::vec3 v2 = testNodes[parentIndex[i]].getGlobalPosition(); ofDrawLine(v1,v2); } } @@ -236,8 +236,8 @@ void ofApp::keyPressed(int key){ case 'p': parentIndex[camToConfigure]++ ; - ofVec3f oldP = cam[camToConfigure].getGlobalPosition(); - ofQuaternion oldQ = cam[camToConfigure].getGlobalOrientation(); + glm::vec3 oldP = cam[camToConfigure].getGlobalPosition(); + glm::quat oldQ = cam[camToConfigure].getGlobalOrientation(); if(parentIndex[camToConfigure]>=kNumTestNodes) { parentIndex[camToConfigure] = -1; cam[camToConfigure].clearParent(); diff --git a/examples/3d/cameraRibbonExample/src/ofApp.cpp b/examples/3d/cameraRibbonExample/src/ofApp.cpp index 351342a5545..d5d318ce6a4 100644 --- a/examples/3d/cameraRibbonExample/src/ofApp.cpp +++ b/examples/3d/cameraRibbonExample/src/ofApp.cpp @@ -14,20 +14,21 @@ //-------------------------------------------------------------- void ofApp::setup(){ - //just set up the openFrameworks stuff + // Just set up the openFrameworks stuff. ofSetFrameRate(60); ofSetVerticalSync(true); ofBackground(255); - //initialize the variable so it's off at the beginning + // Initialize the variable so it's off at the beginning. usecamera = false; } //-------------------------------------------------------------- void ofApp::update(){ - //don't move the points if we are using the camera + // Don't move the points if we are using the camera. + if(!usecamera){ - ofVec3f sumOfAllPoints(0,0,0); + glm::vec3 sumOfAllPoints(0,0,0); for(unsigned int i = 0; i < points.size(); i++){ points[i].z -= 4; sumOfAllPoints += points[i]; @@ -38,69 +39,67 @@ void ofApp::update(){ //-------------------------------------------------------------- void ofApp::draw(){ - - - //if we're using the camera, start it. - //everything that you draw between begin()/end() shows up from the view of the camera + // If we're using the camera, start it. + // Everything that you draw between begin()/end() shows up from the view of the camera. if(usecamera){ camera.begin(); } - ofSetColor(0); - //do the same thing from the first example... + ofSetColor(0); + // Do the same thing from the first example... ofMesh mesh; - mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); - for(unsigned int i = 1; i < points.size(); i++){ + mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); + for(unsigned int i = 1; i < points.size(); i++){ - //find this point and the next point - ofVec3f thisPoint = points[i-1]; - ofVec3f nextPoint = points[i]; + //find this point and the next point + glm::vec3 thisPoint = points[i-1]; + glm::vec3 nextPoint = points[i]; - //get the direction from one to the next. - //the ribbon should fan out from this direction - ofVec3f direction = (nextPoint - thisPoint); + //get the direction from one to the next. + //the ribbon should fan out from this direction + glm::vec3 direction = (nextPoint - thisPoint); - //get the distance from one point to the next - float distance = direction.length(); + //get the distance from one point to the next + float distance = glm::length(direction); - //get the normalized direction. normalized vectors always have a length of one - //and are really useful for representing directions as opposed to something with length - ofVec3f unitDirection = direction.getNormalized(); + //get the normalized direction. normalized vectors always have a length of one + //and are really useful for representing directions as opposed to something with length + glm::vec3 unitDirection = glm::normalize(direction); - //find both directions to the left and to the right - ofVec3f toTheLeft = unitDirection.getRotated(-90, ofVec3f(0,0,1)); - ofVec3f toTheRight = unitDirection.getRotated(90, ofVec3f(0,0,1)); + //find both directions to the left and to the right + glm::vec3 toTheLeft = glm::rotate(unitDirection, -90.f, glm::vec3(0,0,1)); + glm::vec3 toTheRight = glm::rotate(unitDirection, 90.f, glm::vec3(0,0,1)); - //use the map function to determine the distance. - //the longer the distance, the narrower the line. - //this makes it look a bit like brush strokes - float thickness = ofMap(distance, 0, 60, 20, 2, true); + //use the map function to determine the distance. + //the longer the distance, the narrower the line. + //this makes it look a bit like brush strokes + float thickness = ofMap(distance, 0, 60, 20, 2, true); - //calculate the points to the left and to the right - //by extending the current point in the direction of left/right by the length - ofVec3f leftPoint = thisPoint+toTheLeft*thickness; - ofVec3f rightPoint = thisPoint+toTheRight*thickness; + //calculate the points to the left and to the right + //by extending the current point in the direction of left/right by the length + glm::vec3 leftPoint = thisPoint+toTheLeft*thickness; + glm::vec3 rightPoint = thisPoint+toTheRight*thickness; - //add these points to the triangle strip - mesh.addVertex(ofVec3f(leftPoint.x, leftPoint.y, leftPoint.z)); - mesh.addVertex(ofVec3f(rightPoint.x, rightPoint.y, rightPoint.z)); - } + //add these points to the triangle strip + mesh.addVertex(glm::vec3(leftPoint.x, leftPoint.y, leftPoint.z)); + mesh.addVertex(glm::vec3(rightPoint.x, rightPoint.y, rightPoint.z)); + } - //end the shape - mesh.draw(); + //end the shape + mesh.draw(); - //if we're using the camera, take it away + //if we're using the camera, take it away if(usecamera){ - camera.end(); + camera.end(); } } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ - //hitting any key swaps the camera view - usecamera = !usecamera; + //hitting any key swaps the camera view + usecamera = !usecamera; } //-------------------------------------------------------------- @@ -109,26 +108,26 @@ void ofApp::keyReleased(int key){ //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ - //if we are using the camera, the mouse moving should rotate it around the whole sculpture + //if we are using the camera, the mouse moving should rotate it around the whole sculpture if(usecamera){ float rotateAmount = ofMap(ofGetMouseX(), 0, ofGetWidth(), 0, 360); - ofVec3f furthestPoint; + glm::vec3 furthestPoint; if (points.size() > 0) { furthestPoint = points[0]; } else { - furthestPoint = ofVec3f(x, y, 0); + furthestPoint = glm::vec3(x, y, 0); } - ofVec3f directionToFurthestPoint = (furthestPoint - center); - ofVec3f directionToFurthestPointRotated = directionToFurthestPoint.getRotated(rotateAmount, ofVec3f(0,1,0)); + glm::vec3 directionToFurthestPoint = (furthestPoint - center); + glm::vec3 directionToFurthestPointRotated = glm::rotate(directionToFurthestPoint, rotateAmount, glm::vec3(0,1,0)); camera.setPosition(center + directionToFurthestPointRotated); camera.lookAt(center); } //otherwise add points like before else{ - ofVec3f mousePoint(x,y,0); + glm::vec3 mousePoint(x,y,0); points.push_back(mousePoint); } } diff --git a/examples/3d/cameraRibbonExample/src/ofApp.h b/examples/3d/cameraRibbonExample/src/ofApp.h index e40d526d8c0..3760621fc81 100644 --- a/examples/3d/cameraRibbonExample/src/ofApp.h +++ b/examples/3d/cameraRibbonExample/src/ofApp.h @@ -33,9 +33,9 @@ class ofApp : public ofBaseApp{ void gotMessage(ofMessage msg); //this holds all of our points - vector points; + vector points; //this keeps track of the center of all the points - ofVec3f center; + glm::vec3 center; //our camera objects for looking at the scene from multiple perspectives ofCamera camera; diff --git a/examples/3d/meshFromCameraExample/src/ofApp.cpp b/examples/3d/meshFromCameraExample/src/ofApp.cpp index 30c9cc737a8..1b91c766d5f 100644 --- a/examples/3d/meshFromCameraExample/src/ofApp.cpp +++ b/examples/3d/meshFromCameraExample/src/ofApp.cpp @@ -30,7 +30,7 @@ void ofApp::setup(){ //add one vertex to the mesh for each pixel for (int y = 0; y < height; y++){ for (int x = 0; xcurrent,current->next; we could similarly go next->current,current-prev, which would flip all of our normals; @@ -48,7 +48,7 @@ void ofApp::setup(){ */ // since we want smooth normals, we'll sum the two adjacent face normals, then normalize (since usually, only the direction and not the magnitude of the normal is what matters) - mesh.addNormal((previousFaceNormal + nextFaceNormal).normalize()); + mesh.addNormal(glm::normalize(previousFaceNormal + nextFaceNormal)); //add a color too ofColor c; @@ -130,7 +130,7 @@ void ofApp::draw(){ ofSetColor(255); ofDrawBitmapString("press any key or mouse button to disable mesh normals", 20,20); - ofDrawBitmapString("light", cam.worldToScreen(light.getGlobalPosition()) + ofPoint(10,0)); + ofDrawBitmapString("light", cam.worldToScreen(light.getGlobalPosition()) + glm::vec3(20,0,0)); } //-------------------------------------------------------------- diff --git a/examples/3d/ofBoxExample/src/ofApp.cpp b/examples/3d/ofBoxExample/src/ofApp.cpp index 6bb9664f592..101e906b065 100644 --- a/examples/3d/ofBoxExample/src/ofApp.cpp +++ b/examples/3d/ofBoxExample/src/ofApp.cpp @@ -41,7 +41,7 @@ void ofApp::draw(){ ofPushMatrix(); float t = (ofGetElapsedTimef() + i * spacing) * movementSpeed; - ofVec3f pos( + glm::vec3 pos( ofSignedNoise(t, 0, 0), ofSignedNoise(0, t, 0), ofSignedNoise(0, 0, t)); diff --git a/examples/3d/orientationExample/src/ofApp.cpp b/examples/3d/orientationExample/src/ofApp.cpp index 5c61838c93f..dfbac52758d 100644 --- a/examples/3d/orientationExample/src/ofApp.cpp +++ b/examples/3d/orientationExample/src/ofApp.cpp @@ -78,7 +78,7 @@ void ofApp::draw(){ ofDrawLine(current.x, current.y, current.z, current.x, 0, current.z); ofTranslate(current.x, current.y, current.z); - if( (current - previous ).length() > 0.0 ){ + if( glm::length(current - previous ) > 0.0 ){ // translate and rotate every 3D object after this line to the current position and orientation of our line, but only if the line is longer than 0 or has a length rotateToNormal(current - previous); } diff --git a/examples/3d/orientationExample/src/ofApp.h b/examples/3d/orientationExample/src/ofApp.h index 04103944661..75e8a1c103b 100644 --- a/examples/3d/orientationExample/src/ofApp.h +++ b/examples/3d/orientationExample/src/ofApp.h @@ -20,9 +20,9 @@ class ofApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - ofVec3f previous, current; + glm::vec3 previous, current; ofEasyCam easyCam; - deque pathVertices; + deque pathVertices; ofMesh pathLines; }; diff --git a/examples/3d/pointCloudExample/src/ofApp.cpp b/examples/3d/pointCloudExample/src/ofApp.cpp index fbbd1f8d86c..17ce9294d20 100644 --- a/examples/3d/pointCloudExample/src/ofApp.cpp +++ b/examples/3d/pointCloudExample/src/ofApp.cpp @@ -20,7 +20,7 @@ void ofApp::setup() { float z = ofMap(cur.a, 0, 255, -300, 300); cur.a = 255; mesh.addColor(cur); - ofVec3f pos(x, y, z); + glm::vec3 pos(x, y, z); mesh.addVertex(pos); } } @@ -102,4 +102,4 @@ void ofApp::gotMessage(ofMessage msg){ //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ -} \ No newline at end of file +} diff --git a/examples/3d/pointPickerExample/src/ofApp.cpp b/examples/3d/pointPickerExample/src/ofApp.cpp index 14936ad3095..ed027b6a893 100644 --- a/examples/3d/pointPickerExample/src/ofApp.cpp +++ b/examples/3d/pointPickerExample/src/ofApp.cpp @@ -28,12 +28,12 @@ void ofApp::draw(){ int n = mesh.getNumVertices(); float nearestDistance = 0; - ofVec2f nearestVertex; + glm::vec2 nearestVertex; int nearestIndex = 0; - ofVec2f mouse(mouseX, mouseY); + glm::vec3 mouse(mouseX, mouseY,0); for(int i = 0; i < n; i++) { - ofVec3f cur = cam.worldToScreen(mesh.getVertex(i)); - float distance = cur.distance(mouse); + glm::vec3 cur = cam.worldToScreen(mesh.getVertex(i)); + float distance = glm::distance(cur, mouse); if(i == 0 || distance < nearestDistance) { nearestDistance = distance; nearestVertex = cur; @@ -50,7 +50,7 @@ void ofApp::draw(){ ofDrawCircle(nearestVertex, 4); ofSetLineWidth(1); - ofVec2f offset(10, -10); + glm::vec2 offset(10, -10); ofDrawBitmapStringHighlight(ofToString(nearestIndex), mouse + offset); } diff --git a/examples/3d/quaternionArcballExample/src/ofApp.cpp b/examples/3d/quaternionArcballExample/src/ofApp.cpp index 8495e73beb4..a4de10a00ca 100644 --- a/examples/3d/quaternionArcballExample/src/ofApp.cpp +++ b/examples/3d/quaternionArcballExample/src/ofApp.cpp @@ -28,15 +28,16 @@ void ofApp::update(){ void ofApp::draw(){ //translate so that 0,0 is the center of the screen - ofPushMatrix(); - ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 40); - //Extract the rotation from the current rotation - ofVec3f axis; - float angle; - curRot.getRotate(angle, axis); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 40); + auto axis = glm::axis(curRot); //apply the quaternion's rotation to the viewport and draw the sphere - ofRotateDeg(angle, axis.x, axis.y, axis.z); + ofRotateDeg(ofRadToDeg(glm::angle(curRot)), axis.x, axis.y, axis.z); + /// You can actually use the folling line instead, just showing this other option as example +/// ofRotateRad(glm::angle(curRot), axis.x, axis.y, axis.z); + + ofDrawSphere(0, 0, 0, 200); ofPopMatrix(); @@ -61,17 +62,17 @@ void ofApp::mouseDragged(int x, int y, int button){ //every time the mouse is dragged, track the change //accumulate the changes inside of curRot through multiplication - ofVec2f mouse(x,y); - ofQuaternion yRot((x-lastMouse.x)*dampen, ofVec3f(0,1,0)); - ofQuaternion xRot((y-lastMouse.y)*dampen, ofVec3f(-1,0,0)); - curRot *= yRot*xRot; + glm::vec2 mouse(x,y); + glm::quat yRot = glm::angleAxis(ofDegToRad(x-lastMouse.x)*dampen, glm::vec3(0,1,0)); + glm::quat xRot = glm::angleAxis(ofDegToRad(y-lastMouse.y)*dampen, glm::vec3(-1,0,0)); + curRot = xRot * yRot * curRot; lastMouse = mouse; } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ //store the last mouse point when it's first pressed to prevent popping - lastMouse = ofVec2f(x,y); + lastMouse = glm::vec2(x,y); } //-------------------------------------------------------------- diff --git a/examples/3d/quaternionArcballExample/src/ofApp.h b/examples/3d/quaternionArcballExample/src/ofApp.h index 905da05c631..d1bb7b89d34 100644 --- a/examples/3d/quaternionArcballExample/src/ofApp.h +++ b/examples/3d/quaternionArcballExample/src/ofApp.h @@ -32,11 +32,11 @@ class ofApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - //current state of the rotation - ofQuaternion curRot; + //current state of the rotation + glm::quat curRot; //a place to store the mouse position so we can measure incremental change - ofVec2f lastMouse; + glm::vec2 lastMouse; //slows down the rotation 1 = 1 degree per pixel float dampen; diff --git a/examples/3d/quaternionLatLongExample/src/ofApp.cpp b/examples/3d/quaternionLatLongExample/src/ofApp.cpp index 0c89184ee21..bbd53ceacc4 100644 --- a/examples/3d/quaternionLatLongExample/src/ofApp.cpp +++ b/examples/3d/quaternionLatLongExample/src/ofApp.cpp @@ -69,20 +69,21 @@ void ofApp::draw(){ //three rotations //two to represent the latitude and lontitude of the city //a third so that it spins along with the spinning sphere - ofQuaternion latRot, longRot, spinQuat; - latRot.makeRotate(cities[i].latitude, 1, 0, 0); - longRot.makeRotate(cities[i].longitude, 0, 1, 0); - spinQuat.makeRotate(ofGetFrameNum(), 0, 1, 0); + glm::quat latRot, longRot, spinQuat; + latRot = glm::angleAxis(ofDegToRad(cities[i].latitude), glm::vec3(1, 0, 0)); + longRot = glm::angleAxis(ofDegToRad(cities[i].longitude), glm::vec3(0, 1, 0)); + + spinQuat = glm::angleAxis(ofDegToRad(ofGetFrameNum()), glm::vec3(0, 1, 0)); //our starting point is 0,0, on the surface of our sphere, this is where the meridian and equator meet - ofVec3f center = ofVec3f(0,0,300); + glm::vec3 center = glm::vec3(0,0,300); //multiplying a quat with another quat combines their rotations into one quat //multiplying a quat to a vector applies the quat's rotation to that vector //so to to generate our point on the sphere, multiply all of our quaternions together then multiple the centery by the combined rotation - ofVec3f worldPoint = latRot * longRot * spinQuat * center; + glm::vec3 worldPoint = spinQuat * longRot * latRot * center; //draw it and label it - ofDrawLine(ofVec3f(0,0,0), worldPoint); + ofDrawLine(glm::vec3(0,0,0), worldPoint); //set the bitmap text mode billboard so the points show up correctly in 3d ofDrawBitmapString(cities[i].name, worldPoint ); diff --git a/examples/android/androidAdvanced3DExample/src/Swarm.cpp b/examples/android/androidAdvanced3DExample/src/Swarm.cpp index 6233d228a75..a1dc5ffdce0 100644 --- a/examples/android/androidAdvanced3DExample/src/Swarm.cpp +++ b/examples/android/androidAdvanced3DExample/src/Swarm.cpp @@ -45,8 +45,8 @@ void Swarm::init(int _nParticles, float positionDispersion, float velocityDisper // SETUP ARRAYS /////////////////////////////////////////// // - positions = new ofVec3f[nParticles]; - velocities = new ofVec3f[nParticles]; + positions = new glm::vec3[nParticles]; + velocities = new glm::vec3[nParticles]; colors = new ofColor[nParticles]; // /////////////////////////////////////////// @@ -114,7 +114,7 @@ void Swarm::customDraw() ofSetColor(255, 255, 255); ofDrawSphere(positions[0], 2.0); ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL); - ofDrawBitmapString(" light", (ofPoint)positions[0]); + ofDrawBitmapString(" light", (glm::vec3)positions[0]); ofPopStyle(); } diff --git a/examples/android/androidAdvanced3DExample/src/Swarm.h b/examples/android/androidAdvanced3DExample/src/Swarm.h index b1c34530f12..326d69a5b14 100644 --- a/examples/android/androidAdvanced3DExample/src/Swarm.h +++ b/examples/android/androidAdvanced3DExample/src/Swarm.h @@ -34,8 +34,8 @@ class Swarm : public ofNode float timeLastUpdate; //objects - ofVec3f *positions; - ofVec3f *velocities; + glm::vec3 *positions; + glm::vec3 *velocities; ofColor *colors; -}; \ No newline at end of file +}; diff --git a/examples/android/androidAdvanced3DExample/src/ofApp.cpp b/examples/android/androidAdvanced3DExample/src/ofApp.cpp index 195d566c1fd..b13c166e904 100644 --- a/examples/android/androidAdvanced3DExample/src/ofApp.cpp +++ b/examples/android/androidAdvanced3DExample/src/ofApp.cpp @@ -252,7 +252,6 @@ void ofApp::drawScene(int iCameraDraw){ //transformed into a frustum in //world space. - ofMatrix4x4 inverseCameraMatrix; //the camera's matricies are dependant on //the aspect ratio of the viewport @@ -260,7 +259,7 @@ void ofApp::drawScene(int iCameraDraw){ //the same as fullscreen // //watch the aspect ratio of preview camera - inverseCameraMatrix.makeInvertOf(camEasyCam.getModelViewProjectionMatrix( (iMainCamera == 0 ? viewMain : viewGrid[0]) )); + glm::mat4 inverseCameraMatrix = glm::inverse(camEasyCam.getModelViewProjectionMatrix( (iMainCamera == 0 ? viewMain : viewGrid[0]) )); // By default, we can say // 'we are drawing in world space' @@ -277,7 +276,7 @@ void ofApp::drawScene(int iCameraDraw){ // transformation. // ofPushMatrix(); - glMultMatrixf(inverseCameraMatrix.getPtr()); + ofMultMatrix(inverseCameraMatrix); ofSetColor(255, 100, 100); @@ -371,8 +370,8 @@ void ofApp::updateMouseRay() { //define ray in screen space - ray[0] = ofVec3f(ofGetMouseX(), ofGetMouseY(), -1); - ray[1] = ofVec3f(ofGetMouseX(), ofGetMouseY(), 1); + ray[0] = glm::vec3(ofGetMouseX(), ofGetMouseY(), -1); + ray[1] = glm::vec3(ofGetMouseX(), ofGetMouseY(), 1); //transform ray into world space ray[0] = cameras[iMainCamera]->screenToWorld(ray[0], viewMain); diff --git a/examples/android/androidAdvanced3DExample/src/ofApp.h b/examples/android/androidAdvanced3DExample/src/ofApp.h index b39bd083d75..964f7527d31 100644 --- a/examples/android/androidAdvanced3DExample/src/ofApp.h +++ b/examples/android/androidAdvanced3DExample/src/ofApp.h @@ -80,7 +80,7 @@ class ofApp : public ofxAndroidApp{ Grid nodeGrid; //ray drawn under mouse cursor [start,end] - ofVec3f ray[2]; + glm::vec3 ray[2]; }; /* diff --git a/examples/android/androidGuiExample/src/ofApp.cpp b/examples/android/androidGuiExample/src/ofApp.cpp index b9b0994924e..d20a798137a 100644 --- a/examples/android/androidGuiExample/src/ofApp.cpp +++ b/examples/android/androidGuiExample/src/ofApp.cpp @@ -27,7 +27,7 @@ void ofApp::setup(){ bHide = true; - ring.loadSound("ring.wav"); + ring.load("ring.wav"); } //-------------------------------------------------------------- diff --git a/examples/android/androidGuiExample/src/ofApp.h b/examples/android/androidGuiExample/src/ofApp.h index 11e9bee4749..be449b747fc 100644 --- a/examples/android/androidGuiExample/src/ofApp.h +++ b/examples/android/androidGuiExample/src/ofApp.h @@ -31,7 +31,7 @@ class ofApp : public ofBaseApp{ ofParameter radius; ofParameter color; - ofParameter center; + ofParameter center; ofParameter circleResolution; ofParameter filled; ofxButton twoCircles; diff --git a/examples/android/androidVBOExample/src/ofApp.cpp b/examples/android/androidVBOExample/src/ofApp.cpp index a4ae38e567b..f20dc8ed4b4 100644 --- a/examples/android/androidVBOExample/src/ofApp.cpp +++ b/examples/android/androidVBOExample/src/ofApp.cpp @@ -45,7 +45,7 @@ void ofApp::setup(){ void ofApp::update(){ if(!bPause) { - ofVec3f vec; + glm::vec3 vec; float r = 0.3; for (int i=0; i 0.0) { pos[index + k] = pos[index + k-1] + (vec * restLength) /d; } diff --git a/examples/android/androidVBOExample/src/ofApp.h b/examples/android/androidVBOExample/src/ofApp.h index 5ef515a3439..7d4a14d7177 100644 --- a/examples/android/androidVBOExample/src/ofApp.h +++ b/examples/android/androidVBOExample/src/ofApp.h @@ -35,8 +35,8 @@ class ofApp : public ofxAndroidApp { void cancelPressed(); ofVbo vbo; - ofVec3f pos[GRID_WIDTH*GRID_HEIGHT*LENGTH]; - ofVec3f center; + glm::vec3 pos[GRID_WIDTH*GRID_HEIGHT*LENGTH]; + glm::vec3 center; float restLength; int total; diff --git a/examples/android/androidVibratorExample/src/ofApp.cpp b/examples/android/androidVibratorExample/src/ofApp.cpp index 19f4e216166..4353b01bf0e 100644 --- a/examples/android/androidVibratorExample/src/ofApp.cpp +++ b/examples/android/androidVibratorExample/src/ofApp.cpp @@ -54,7 +54,7 @@ void ofApp::touchDown(int x, int y, int id){ void ofApp::touchMoved(int x, int y, int id){ bool found=false; for(int i=0;i stroke; + vector stroke; }; diff --git a/examples/communication/networkUdpSenderExample/src/ofApp.cpp b/examples/communication/networkUdpSenderExample/src/ofApp.cpp index 935fbae444b..74daea3ec0d 100644 --- a/examples/communication/networkUdpSenderExample/src/ofApp.cpp +++ b/examples/communication/networkUdpSenderExample/src/ofApp.cpp @@ -54,7 +54,7 @@ void ofApp::mouseMoved(int x, int y ){ //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ - stroke.push_back(ofPoint(x,y)); + stroke.push_back(glm::vec3(x,y,0)); } //-------------------------------------------------------------- diff --git a/examples/communication/networkUdpSenderExample/src/ofApp.h b/examples/communication/networkUdpSenderExample/src/ofApp.h index 4e4d69cf4cc..ea80d9ac647 100644 --- a/examples/communication/networkUdpSenderExample/src/ofApp.h +++ b/examples/communication/networkUdpSenderExample/src/ofApp.h @@ -26,6 +26,6 @@ class ofApp : public ofBaseApp{ ofTrueTypeFont mono; ofTrueTypeFont monosm; - vector stroke; + vector stroke; }; diff --git a/examples/communication/oscReceiveExample/src/ofApp.cpp b/examples/communication/oscReceiveExample/src/ofApp.cpp index d2c5a7c0da6..0a1cdce3ea4 100644 --- a/examples/communication/oscReceiveExample/src/ofApp.cpp +++ b/examples/communication/oscReceiveExample/src/ofApp.cpp @@ -110,7 +110,7 @@ void ofApp::draw(){ ofDrawBitmapStringHighlight(buf, 10, 20); // draw mouse state - ofPoint mouseIn(mouseXf*ofGetWidth(), mouseYf*ofGetHeight()); + glm::vec3 mouseIn(mouseXf*ofGetWidth(), mouseYf*ofGetHeight(),0); if(mouseButtonInt == 0){ ofSetColor(255); } else{ diff --git a/examples/events/customEventExample/src/Bug.h b/examples/events/customEventExample/src/Bug.h index 3e174e6d1ca..6e68274de4c 100644 --- a/examples/events/customEventExample/src/Bug.h +++ b/examples/events/customEventExample/src/Bug.h @@ -5,9 +5,9 @@ class Bug { public: - ofVec2f pos, vel; + glm::vec2 pos, vel; float size; - vector squashPts; + vector squashPts; bool bSquashed; bool bRemove; float timeBugKilled; @@ -22,7 +22,7 @@ class Bug { // make a squash shape int nPts = 10; for(int i=0; i ofGetWidth()-size) bugs[i].pos.x = -size; @@ -124,11 +124,11 @@ void ofApp::update() { for(unsigned int i=0; i bullets; vector bugs; - vector holes; + vector holes; unsigned int maxBullets; int bugsKilled; diff --git a/examples/events/simpleEventsExample/src/Circle.cpp b/examples/events/simpleEventsExample/src/Circle.cpp index 4eb4f001874..f6faf131bd9 100644 --- a/examples/events/simpleEventsExample/src/Circle.cpp +++ b/examples/events/simpleEventsExample/src/Circle.cpp @@ -9,7 +9,7 @@ #include "Circle.h" // the static event, or any static variable, must be initialized outside of the class definition. -ofEvent Circle::clickedInsideGlobal = ofEvent(); +ofEvent Circle::clickedInsideGlobal = ofEvent(); Circle::Circle() { bRegisteredEvents = false; @@ -50,7 +50,7 @@ void Circle::mouseReleased(ofMouseEventArgs & args){ if (inside(args.x, args.y)) { // if the mouse is pressed over the circle an event will be notified (broadcasted) // the circleEvent object will contain the mouse position, so this values are accesible to any class that is listening. - ofVec2f mousePos = ofVec2f(args.x, args.y); + glm::vec2 mousePos = glm::vec2(args.x, args.y); ofNotifyEvent(clickedInside, mousePos, this); ofNotifyEvent(clickedInsideGlobal, mousePos); } @@ -61,5 +61,5 @@ void Circle::mouseExited(ofMouseEventArgs & args){} //this function checks if the passed arguments are inside the circle. bool Circle::inside(float _x, float _y ){ - return (ofVec2f(_x, _y).distance(ofVec2f(x, y)) can be whatever you want, event a custom class. - ofEvent clickedInside; + ofEvent clickedInside; //this is a shared event for all the instances of this class, so any instance of this class will broadcast to the same event, //this way you'll have to register only one listener to listen to any class instance broadcasting to this event. // "static" tells the compiler that all of this class instances will share a single variable - static ofEvent clickedInsideGlobal; + static ofEvent clickedInsideGlobal; void setup(int radius, int x, int y, ofColor color); void draw(); diff --git a/examples/events/simpleEventsExample/src/ofApp.cpp b/examples/events/simpleEventsExample/src/ofApp.cpp index 127c8f39751..5813cd2a9eb 100644 --- a/examples/events/simpleEventsExample/src/ofApp.cpp +++ b/examples/events/simpleEventsExample/src/ofApp.cpp @@ -44,10 +44,10 @@ void ofApp::draw(){ ofDrawBitmapStringHighlight(msg, 30,30); } //-------------------------------------------------------------- -void ofApp::onMouseInCircle(ofVec2f & e){ - clickedPoint.set(e); +void ofApp::onMouseInCircle(glm::vec2 & e){ + clickedPoint = e; } //-------------------------------------------------------------- -void ofApp::onMouseInAnyCircle(ofVec2f & e){ +void ofApp::onMouseInAnyCircle(glm::vec2 & e){ bg.set(ofRandom(255), ofRandom(255), ofRandom(255)); } diff --git a/examples/events/simpleEventsExample/src/ofApp.h b/examples/events/simpleEventsExample/src/ofApp.h index 0e96be0ba31..8b1f343ea74 100644 --- a/examples/events/simpleEventsExample/src/ofApp.h +++ b/examples/events/simpleEventsExample/src/ofApp.h @@ -13,11 +13,11 @@ class ofApp : public ofBaseApp{ void setup(); void update(); void draw(); - void onMouseInCircle(ofVec2f & e); - void onMouseInAnyCircle(ofVec2f & e); + void onMouseInCircle(glm::vec2 & e); + void onMouseInAnyCircle(glm::vec2 & e); Circle redCircle; Circle grayCircles [TOTAL_GRAY_CIRCLES]; ofColor bg; - ofVec2f clickedPoint; + glm::vec2 clickedPoint; }; diff --git a/examples/gl/areaLightExample/src/ofApp.cpp b/examples/gl/areaLightExample/src/ofApp.cpp index 5487b805b0a..f14d9b9bc81 100644 --- a/examples/gl/areaLightExample/src/ofApp.cpp +++ b/examples/gl/areaLightExample/src/ofApp.cpp @@ -12,14 +12,14 @@ void ofApp::setup(){ areaLight.setAttenuation(1.0,0.0001,0.0001); areaLight.setDiffuseColor(ofFloatColor(1,1,1)); areaLight.setSpecularColor(ofFloatColor(1,1,1)); - areaLight.rotateDeg(-90,ofVec3f(1,0,0)); - areaLight.rotateDeg(30,ofVec3f(0,0,1)); + areaLight.rotateDeg(-90,glm::vec3(1,0,0)); + areaLight.rotateDeg(30,glm::vec3(0,0,1)); areaLight.setPosition(0,-200,0); ofBackground(0); plane.set(20000,20000,2,2); - plane.rotateDeg(-90,ofVec3f(1,0,0)); - plane.move(ofVec3f(0,-300,0)); + plane.rotateDeg(-90,glm::vec3(1,0,0)); + plane.move(glm::vec3(0,-300,0)); materialPlane.setAmbientColor(ofFloatColor(0.1,0.1,0.1,1.0)); materialPlane.setDiffuseColor(ofFloatColor(0.8,0.8,0.8,1.0)); materialPlane.setSpecularColor(ofFloatColor(0.8,0.8,0.8,1.0)); diff --git a/examples/gl/billboardExample/src/ofApp.cpp b/examples/gl/billboardExample/src/ofApp.cpp index ad8b3159b73..8c42246ac51 100644 --- a/examples/gl/billboardExample/src/ofApp.cpp +++ b/examples/gl/billboardExample/src/ofApp.cpp @@ -4,18 +4,18 @@ void ofApp::setup() { ofBackground(0, 0, 0); - cameraRotation.set(0); + cameraRotation ={0,0,0}; zoom = -500; zoomTarget = 200; billboards.getVertices().resize(NUM_BILLBOARDS); billboards.getColors().resize(NUM_BILLBOARDS); - billboards.getNormals().resize(NUM_BILLBOARDS,ofVec3f(0)); + billboards.getNormals().resize(NUM_BILLBOARDS,glm::vec3(0)); // ------------------------- billboard particles for (int i=0; i ofGetHeight()) pos[i].y = 0; - ofVec2f center(ofGetWidth()/2, ofGetHeight()/2); - ofVec2f frc = home[i] - pos[i]; - if(frc.length() > 20.0) { - frc.normalize(); + glm::vec2 center(ofGetWidth()/2, ofGetHeight()/2); + glm::vec2 frc = home[i] - pos[i]; + if(glm::length(frc) > 20.0) { + frc = glm::normalize(frc); frc *= 0.84; vel[i] += frc; } diff --git a/examples/gl/billboardRotationExample/src/ofApp.h b/examples/gl/billboardRotationExample/src/ofApp.h index 02199e5fd8b..dee6a3ffe2b 100644 --- a/examples/gl/billboardRotationExample/src/ofApp.h +++ b/examples/gl/billboardRotationExample/src/ofApp.h @@ -25,9 +25,9 @@ class ofApp : public ofBaseApp { ofVbo vbo; ofShader shader; ofImage texture; - ofVec2f pos[NUM_BILLBOARDS]; - ofVec2f vel[NUM_BILLBOARDS]; - ofVec2f home[NUM_BILLBOARDS]; + glm::vec2 pos[NUM_BILLBOARDS]; + glm::vec2 vel[NUM_BILLBOARDS]; + glm::vec2 home[NUM_BILLBOARDS]; float pointSizes[NUM_BILLBOARDS]; float rotations[NUM_BILLBOARDS]; }; diff --git a/examples/gl/computeShaderParticlesExample/src/ofApp.cpp b/examples/gl/computeShaderParticlesExample/src/ofApp.cpp index a66158528c8..6c788f03862 100644 --- a/examples/gl/computeShaderParticlesExample/src/ofApp.cpp +++ b/examples/gl/computeShaderParticlesExample/src/ofApp.cpp @@ -13,14 +13,14 @@ void ofApp::setup(){ p.pos.y = ofRandom(-ofGetHeight()*0.5,ofGetHeight()*0.5); p.pos.z = ofRandom(-ofGetHeight()*0.5,ofGetHeight()*0.5); p.pos.w = 1; - p.vel.set(0,0,0,0); + p.vel = {0,0,0,0}; i++; } particlesBuffer.allocate(particles,GL_DYNAMIC_DRAW); particlesBuffer2.allocate(particles,GL_DYNAMIC_DRAW); vbo.setVertexBuffer(particlesBuffer,4,sizeof(Particle)); - vbo.setColorBuffer(particlesBuffer,sizeof(Particle),sizeof(ofVec4f)*2); + vbo.setColorBuffer(particlesBuffer,sizeof(Particle),sizeof(glm::vec4)*2); vbo.disableColors(); dirAsColor = false; @@ -54,15 +54,15 @@ void ofApp::update(){ compute.setUniform1f("timeLastFrame",ofGetLastFrameTime()); compute.setUniform1f("elapsedTime",ofGetElapsedTimef()); float size = 4; - atractor1.set(ofMap(ofNoise(ofGetElapsedTimef()*0.3),0,1,-ofGetWidth()*size,ofGetWidth()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.3+0.2),0,1,-ofGetHeight()*size,ofGetHeight()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.3+0.5),0,1,0,-ofGetHeight()*size)); - atractor2.set(ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.3),0,1,-ofGetWidth()*size,ofGetWidth()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.2),0,1,-ofGetHeight()*size,ofGetHeight()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.1),0,1,0,-ofGetHeight()*size)); - atractor3.set(ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.1),0,1,-ofGetWidth()*size,ofGetWidth()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.5),0,1,-ofGetHeight()*size,ofGetHeight()*size), - ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.7),0,1,0,-ofGetHeight()*size)); + atractor1 = {ofMap(ofNoise(ofGetElapsedTimef()*0.3),0,1,-ofGetWidth()*size,ofGetWidth()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.3+0.2),0,1,-ofGetHeight()*size,ofGetHeight()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.3+0.5),0,1,0,-ofGetHeight()*size)}; + atractor2 = {ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.3),0,1,-ofGetWidth()*size,ofGetWidth()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.2),0,1,-ofGetHeight()*size,ofGetHeight()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.5+0.1),0,1,0,-ofGetHeight()*size)}; + atractor3 = {ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.1),0,1,-ofGetWidth()*size,ofGetWidth()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.5),0,1,-ofGetHeight()*size,ofGetHeight()*size), + ofMap(ofNoise(ofGetElapsedTimef()*0.9+0.7),0,1,0,-ofGetHeight()*size)}; compute.setUniform3f("attractor1",atractor1.x,atractor1.y,atractor1.z); compute.setUniform3f("attractor2",atractor2.x,atractor2.y,atractor2.z); diff --git a/examples/gl/computeShaderParticlesExample/src/ofApp.h b/examples/gl/computeShaderParticlesExample/src/ofApp.h index b35c113e4c0..01191b5b731 100644 --- a/examples/gl/computeShaderParticlesExample/src/ofApp.h +++ b/examples/gl/computeShaderParticlesExample/src/ofApp.h @@ -25,8 +25,8 @@ class ofApp : public ofBaseApp{ void gotMessage(ofMessage msg); struct Particle{ - ofVec4f pos; - ofVec4f vel; + glm::vec4 pos; + glm::vec4 vel; ofFloatColor color; }; @@ -36,7 +36,7 @@ class ofApp : public ofBaseApp{ GLuint vaoID; ofEasyCam camera; ofVbo vbo; - ofVec3f atractor1, atractor2, atractor3; + glm::vec3 atractor1, atractor2, atractor3; ofxPanel gui; ofParameter attractionCoeff, cohesionCoeff, repulsionCoeff; ofParameter maxSpeed; diff --git a/examples/gl/fboTrailsExample/src/ofApp.cpp b/examples/gl/fboTrailsExample/src/ofApp.cpp index 0e973f6975a..d0a83ff174c 100644 --- a/examples/gl/fboTrailsExample/src/ofApp.cpp +++ b/examples/gl/fboTrailsExample/src/ofApp.cpp @@ -114,12 +114,12 @@ void ofApp::drawFboTest(){ //-------------------------------------------------------------- void ofApp::draw(){ - ofSetColor(255,255,255); - rgbaFbo.draw(0,0); - rgbaFboFloat.draw(410,0); + ofSetColor(255, 255, 255); + rgbaFbo.draw(0, 0); + rgbaFboFloat.draw(410, 0); - ofDrawBitmapString("non floating point FBO", ofPoint(10,20)); - ofDrawBitmapString("floating point FBO", ofPoint(420,20)); + ofDrawBitmapString("non floating point FBO", 10, 20); + ofDrawBitmapString("floating point FBO", 420, 20); string alphaInfo = "Current alpha fade amnt = " + ofToString(fadeAmnt); alphaInfo += "\nHold '1' to set alpha fade to 1"; @@ -127,7 +127,7 @@ void ofApp::draw(){ alphaInfo += "\nHold '3' to set alpha fade to 15"; alphaInfo += "\nHold 'c' to clear the fbo each frame\n\nMove mouse to draw with a circle"; - ofDrawBitmapString(alphaInfo, ofPoint(10,430)); + ofDrawBitmapString(alphaInfo, 10, 430); } diff --git a/examples/gl/geometryShaderExample/src/ofApp.cpp b/examples/gl/geometryShaderExample/src/ofApp.cpp index 8b120426418..65135684129 100644 --- a/examples/gl/geometryShaderExample/src/ofApp.cpp +++ b/examples/gl/geometryShaderExample/src/ofApp.cpp @@ -18,7 +18,7 @@ void ofApp::setup(){ // create a bunch of random points float r = ofGetHeight()/2; for(int i=0; i<100; i++) { - points.push_back(ofPoint(ofRandomf() * r, ofRandomf() * r, ofRandomf() * r)); + points.push_back(glm::vec3(ofRandomf() * r, ofRandomf() * r, ofRandomf() * r)); } doShader = true; diff --git a/examples/gl/geometryShaderExample/src/ofApp.h b/examples/gl/geometryShaderExample/src/ofApp.h index 672613d718e..d84e607c470 100644 --- a/examples/gl/geometryShaderExample/src/ofApp.h +++ b/examples/gl/geometryShaderExample/src/ofApp.h @@ -25,6 +25,6 @@ class ofApp : public ofBaseApp{ ofShader shader; bool doShader; - vector points; + vector points; }; diff --git a/examples/gl/glInfoExample/src/ofApp.cpp b/examples/gl/glInfoExample/src/ofApp.cpp index dd4966c6b85..b5862b8bc18 100644 --- a/examples/gl/glInfoExample/src/ofApp.cpp +++ b/examples/gl/glInfoExample/src/ofApp.cpp @@ -236,8 +236,8 @@ void ofApp::draw(){ - ofDrawBitmapStringHighlight(output, ofPoint(20,20)); - ofDrawBitmapStringHighlight("press ' ' to load full report", ofPoint(20,220), ofColor::magenta, ofColor::white); + ofDrawBitmapStringHighlight(output, 20, 20); + ofDrawBitmapStringHighlight("press ' ' to load full report", 20, 220, ofColor::magenta, ofColor::white); } diff --git a/examples/gl/gpuParticleSystemExample/src/ofApp.cpp b/examples/gl/gpuParticleSystemExample/src/ofApp.cpp index e9a86b650aa..e8696bcf151 100644 --- a/examples/gl/gpuParticleSystemExample/src/ofApp.cpp +++ b/examples/gl/gpuParticleSystemExample/src/ofApp.cpp @@ -80,8 +80,8 @@ void ofApp::setup(){ mesh.setMode(OF_PRIMITIVE_POINTS); for(int x = 0; x < textureRes; x++){ for(int y = 0; y < textureRes; y++){ - mesh.addVertex(ofVec3f(x,y)); - mesh.addTexCoord(ofVec2f(x, y)); + mesh.addVertex({x,y,0}); + mesh.addTexCoord({x, y}); } } diff --git a/examples/gl/multiLightExample/src/ofApp.cpp b/examples/gl/multiLightExample/src/ofApp.cpp index ff6d6f646f4..2907691ad46 100644 --- a/examples/gl/multiLightExample/src/ofApp.cpp +++ b/examples/gl/multiLightExample/src/ofApp.cpp @@ -21,7 +21,7 @@ void ofApp::setup(){ // radius of the sphere // radius = 180.f; - center.set(ofGetWidth()*.5, ofGetHeight()*.5, 0); + center = {ofGetWidth()*.5, ofGetHeight()*.5, 0}; // Point lights emit light in all directions // // set the diffuse color, color reflected from the light source // @@ -55,7 +55,7 @@ void ofApp::setup(){ // set the direction of the light // set it pointing from left to right -> // - directionalLight.setOrientation( ofVec3f(0, 90, 0) ); + directionalLight.setOrientation( {0, 90, 0} ); bShiny = true; @@ -80,7 +80,7 @@ void ofApp::update() { sin(ofGetElapsedTimef()*.8f) * radius * 2 + center.y, -cos(ofGetElapsedTimef()*.8f) * radius * 2 + center.z); - spotLight.setOrientation( ofVec3f( 0, cos(ofGetElapsedTimef()) * RAD_TO_DEG, 0) ); + spotLight.setOrientation( { 0, cos(ofGetElapsedTimef()) * RAD_TO_DEG, 0 } ); spotLight.setPosition( mouseX, mouseY, 200); } diff --git a/examples/gl/multiLightExample/src/ofApp.h b/examples/gl/multiLightExample/src/ofApp.h index f0c456a9002..8756f8296f6 100644 --- a/examples/gl/multiLightExample/src/ofApp.h +++ b/examples/gl/multiLightExample/src/ofApp.h @@ -29,7 +29,7 @@ class ofApp : public ofBaseApp{ ofImage ofLogoImage; float radius; - ofVec3f center; + glm::vec3 center; bool bShiny; bool bSmoothLighting; bool bPointLight, bSpotLight, bDirLight; diff --git a/examples/gl/pixelBufferExample/src/ofApp.cpp b/examples/gl/pixelBufferExample/src/ofApp.cpp index c854ea1c968..39ba6459f9c 100644 --- a/examples/gl/pixelBufferExample/src/ofApp.cpp +++ b/examples/gl/pixelBufferExample/src/ofApp.cpp @@ -1,5 +1,4 @@ #include "ofApp.h" -#include "ofConstants.h" // this example will probably only work in real time in release mode @@ -10,15 +9,27 @@ void ofApp::setup(){ pixelBufferFront.allocate(ofGetWidth()*ofGetHeight()*3,GL_DYNAMIC_READ); box.set(400); box.setResolution(1); - box.setPosition(ofVec3f(ofGetWidth()*0.5, ofGetHeight()*0.5)); + box.setPosition({ofGetWidth()*0.5, ofGetHeight()*0.5, 0}); record = false; } //-------------------------------------------------------------- void ofApp::update(){ - box.setOrientation(ofQuaternion(45, ofVec3f(1,0,0), - 45,ofVec3f(0,0,1), - ofGetElapsedTimef()*10, ofVec3f(0,1,0))); + + // Set the angles of rotation on each axis. + float xAngleRad = ofDegToRad(45.0); + float yAngleRad = ofDegToRad(ofGetElapsedTimef() * 10); + float zAngleRad = ofDegToRad(45.0); + + // Construct a quaternion. + glm::quat quat; + + quat *= glm::angleAxis(xAngleRad, glm::vec3(1, 0, 0)); + quat *= glm::angleAxis(yAngleRad, glm::vec3(0, 1, 0)); + quat *= glm::angleAxis(zAngleRad, glm::vec3(0, 0, 1)); + + // Set the orientation of the box based on the construxcted quaternion. + box.setOrientation(quat); ofEnableDepthTest(); fbo.begin(); diff --git a/examples/gl/pointsAsTexturesExample/src/ofApp.cpp b/examples/gl/pointsAsTexturesExample/src/ofApp.cpp index 97737e2d347..d16ff0c8a78 100644 --- a/examples/gl/pointsAsTexturesExample/src/ofApp.cpp +++ b/examples/gl/pointsAsTexturesExample/src/ofApp.cpp @@ -23,7 +23,7 @@ void ofApp::setup() { float theta1 = ofRandom(0, TWO_PI); float theta2 = ofRandom(0, TWO_PI); - ofVec3f p; + glm::vec3 p; p.x = cos( theta1 ) * cos( theta2 ); p.y = sin( theta1 ); p.z = cos( theta1 ) * sin( theta2 ); @@ -87,8 +87,8 @@ void ofApp::draw() { camera.begin(); for (unsigned int i=0; i points; - vector sizes; + vector points; + vector sizes; ofVbo vbo; ofShader shader; diff --git a/examples/gl/singleLightExample/src/ofApp.cpp b/examples/gl/singleLightExample/src/ofApp.cpp index 9f146a75484..3fc96160638 100644 --- a/examples/gl/singleLightExample/src/ofApp.cpp +++ b/examples/gl/singleLightExample/src/ofApp.cpp @@ -15,7 +15,7 @@ void ofApp::setup(){ ofSetSphereResolution(32); radius = 300.f; - center.set(ofGetWidth()*.5, ofGetHeight()*.5, 0); + center = {ofGetWidth()*.5, ofGetHeight()*.5, 0}; // Point lights emit light in all directions // // set the diffuse color, color reflected from the light source // @@ -156,4 +156,4 @@ void ofApp::gotMessage(ofMessage msg){ //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ -} \ No newline at end of file +} diff --git a/examples/gl/singleLightExample/src/ofApp.h b/examples/gl/singleLightExample/src/ofApp.h index 8ae3ac6fadb..61f9cc9807a 100644 --- a/examples/gl/singleLightExample/src/ofApp.h +++ b/examples/gl/singleLightExample/src/ofApp.h @@ -28,7 +28,7 @@ class ofApp : public ofBaseApp{ float radius; float sphereRadius; int numSpheres; - ofVec3f center; + glm::vec3 center; bool bDrawWireframe; ofColor lightColor; diff --git a/examples/gl/slowFastRenderingExample/src/ofApp.cpp b/examples/gl/slowFastRenderingExample/src/ofApp.cpp index b61c093f755..38f561f6607 100644 --- a/examples/gl/slowFastRenderingExample/src/ofApp.cpp +++ b/examples/gl/slowFastRenderingExample/src/ofApp.cpp @@ -34,9 +34,9 @@ void ofApp::update() { speeds[i] *= 0.98; // move from the mouse - ofVec2f mouseVec = ofVec2f(ofGetMouseX(), ofGetMouseY()) - points[i]; - if(mouseVec.length() < 100) { - mouseVec.normalize(); + glm::vec2 mouseVec = glm::vec2(ofGetMouseX(), ofGetMouseY()) - points[i]; + if(glm::length(mouseVec) < 100) { + mouseVec = glm::normalize(mouseVec); speeds[i] -= mouseVec; } diff --git a/examples/gl/slowFastRenderingExample/src/ofApp.h b/examples/gl/slowFastRenderingExample/src/ofApp.h index fa276a42daf..f4016378361 100644 --- a/examples/gl/slowFastRenderingExample/src/ofApp.h +++ b/examples/gl/slowFastRenderingExample/src/ofApp.h @@ -22,13 +22,13 @@ class ofApp : public ofBaseApp{ void gotMessage(ofMessage msg); void addPoint(float x, float y) { - points.push_back(ofVec2f(x, y)); - speeds.push_back(ofVec2f(ofRandom(-1, 1), ofRandom(-1, 1))); + points.push_back(glm::vec2(x, y)); + speeds.push_back(glm::vec2(ofRandom(-1, 1), ofRandom(-1, 1))); } // a simple vector of points - vector points; - vector speeds; + vector points; + vector speeds; // in super fast mode we use a vbo ofVbo vbo; diff --git a/examples/gl/textureBufferInstancedExample/src/ofApp.cpp b/examples/gl/textureBufferInstancedExample/src/ofApp.cpp index d738db8ba65..5c3398673b4 100644 --- a/examples/gl/textureBufferInstancedExample/src/ofApp.cpp +++ b/examples/gl/textureBufferInstancedExample/src/ofApp.cpp @@ -59,7 +59,7 @@ void ofApp::update(){ ofNode node; float t = (now + i * spacing) * movementSpeed; - ofVec3f pos( + glm::vec3 pos( ofSignedNoise(t, 0, 0), ofSignedNoise(0, t, 0), ofSignedNoise(0, 0, t)); diff --git a/examples/gl/textureBufferInstancedExample/src/ofApp.h b/examples/gl/textureBufferInstancedExample/src/ofApp.h index bad859d14ed..f259f621df3 100644 --- a/examples/gl/textureBufferInstancedExample/src/ofApp.h +++ b/examples/gl/textureBufferInstancedExample/src/ofApp.h @@ -23,7 +23,7 @@ class ofApp : public ofBaseApp{ ofTexture tex; ofBufferObject buffer; - vector matrices; + vector matrices; ofVboMesh mesh; ofShader shader; ofEasyCam camera; diff --git a/examples/gl/threadedPixelBufferExample/src/ofApp.cpp b/examples/gl/threadedPixelBufferExample/src/ofApp.cpp index c392690f19a..a65243e5f6b 100644 --- a/examples/gl/threadedPixelBufferExample/src/ofApp.cpp +++ b/examples/gl/threadedPixelBufferExample/src/ofApp.cpp @@ -10,16 +10,16 @@ void ofApp::setup(){ pixelBufferFront.allocate(ofGetWidth()*ofGetHeight()*3,GL_DYNAMIC_READ); box.set(400); box.setResolution(1); - box.setPosition(ofVec3f(ofGetWidth()*0.5, ofGetHeight()*0.5)); + box.setPosition({ofGetWidth()*0.5, ofGetHeight()*0.5,0}); record = false; firstFrame = true; } //-------------------------------------------------------------- void ofApp::update(){ - box.setOrientation(ofQuaternion(45, ofVec3f(1,0,0), - 45,ofVec3f(0,0,1), - ofGetElapsedTimef()*10, ofVec3f(0,1,0))); + box.setOrientation(glm::angleAxis(ofDegToRad(ofGetElapsedTimef()*10), glm::vec3(0,1,0))* + glm::angleAxis(45.0f,glm::vec3(0,0,1))* + glm::angleAxis(45.0f, glm::vec3(1,0,0))); ofEnableDepthTest(); fbo.begin(); diff --git a/examples/gl/vboExample/src/ofApp.cpp b/examples/gl/vboExample/src/ofApp.cpp index 80368cccb42..4d01e0322b2 100644 --- a/examples/gl/vboExample/src/ofApp.cpp +++ b/examples/gl/vboExample/src/ofApp.cpp @@ -12,27 +12,27 @@ vertices, or texture coordinates. */ //-------------------------------------------------------------- -void ofApp::addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) { +void ofApp::addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c) { mesh.addVertex(a); mesh.addVertex(b); mesh.addVertex(c); } //-------------------------------------------------------------- -void ofApp::addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c, ofVec3f d) { +void ofApp::addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c, const glm::vec3& d) { addFace(mesh, a, b, c); addFace(mesh, a, c, d); } //-------------------------------------------------------------- -void ofApp::addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c) { +void ofApp::addTexCoords(ofMesh& mesh, const glm::vec2& a, const glm::vec2& b, const glm::vec2& c) { mesh.addTexCoord(a); mesh.addTexCoord(b); mesh.addTexCoord(c); } //-------------------------------------------------------------- -void ofApp::addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c, ofVec2f d) { +void ofApp::addTexCoords(ofMesh& mesh, const glm::vec2& a, const glm::vec2& b, const glm::vec2& c, const glm::vec2& d) { addTexCoords(mesh, a, b, c); addTexCoords(mesh, a, c, d); } @@ -42,13 +42,13 @@ void ofApp::addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c, ofVec2f a 3d point from the current x,y image position. */ //-------------------------------------------------------------- -ofVec3f ofApp::getVertexFromImg(ofImage& img, int x, int y) { +glm::vec3 ofApp::getVertexFromImg(ofImage& img, int x, int y) { ofColor color = img.getColor(x, y); if(color.a > 0) { float z = ofMap(color.a, 0, 255, -480, 480); - return ofVec3f(x - img.getWidth() / 2, y - img.getHeight() / 2, z); + return glm::vec3(x - img.getWidth() / 2, y - img.getHeight() / 2, z); } else { - return ofVec3f(0, 0, 0); + return glm::vec3(0, 0, 0); } } @@ -72,9 +72,9 @@ void ofApp::setup() { int width = img.getWidth(); int height = img.getHeight(); - ofVec2f imageSize(width,height); + glm::vec2 imageSize(width,height); - ofVec3f zero(0, 0, 0); + glm::vec3 zero(0, 0, 0); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { /* @@ -83,14 +83,14 @@ void ofApp::setup() { beneath. These are called nw, ne, se and sw. To get the texture coords we need to use the actual image indices. */ - ofVec3f nw = getVertexFromImg(img, x, y); - ofVec3f ne = getVertexFromImg(img, x + skip, y); - ofVec3f sw = getVertexFromImg(img, x, y + skip); - ofVec3f se = getVertexFromImg(img, x + skip, y + skip); - ofVec2f nwi(x, y); - ofVec2f nei(x + skip, y); - ofVec2f swi(x, y + skip); - ofVec2f sei(x + skip, y + skip); + glm::vec3 nw = getVertexFromImg(img, x, y); + glm::vec3 ne = getVertexFromImg(img, x + skip, y); + glm::vec3 sw = getVertexFromImg(img, x, y + skip); + glm::vec3 se = getVertexFromImg(img, x + skip, y + skip); + glm::vec2 nwi(x, y); + glm::vec2 nei(x + skip, y); + glm::vec2 swi(x, y + skip); + glm::vec2 sei(x + skip, y + skip); // ignore any zero-data (where there is no depth info) if(nw != zero && ne != zero && sw != zero && se != zero) { @@ -131,7 +131,7 @@ void ofApp::draw() { img.bind(); // bind the image to begin texture mapping int n = 5; // make a 5x5 grid - ofVec2f spacing(img.getWidth(), img.getHeight()); // spacing between meshes + glm::vec2 spacing(img.getWidth(), img.getHeight()); // spacing between meshes ofTranslate(-spacing.x * n / 2, -spacing.y * n / 2, 0); // center the grid for(int i = 0; i < n; i++) { // loop through the rows for(int j = 0; j < n; j++) { // loop through the columns @@ -159,15 +159,13 @@ void ofApp::draw() { } //-------------------------------------------------------------- -void ofApp::keyPressed(int key){ - if(key == ' ') { - ofToggleFullscreen(); - } -} +void ofApp::keyPressed(int key){} //-------------------------------------------------------------- void ofApp::keyReleased(int key){ - + if(key == ' ') { + ofToggleFullscreen(); + } } //-------------------------------------------------------------- diff --git a/examples/gl/vboExample/src/ofApp.h b/examples/gl/vboExample/src/ofApp.h index 826a7841962..efebd2a91f5 100644 --- a/examples/gl/vboExample/src/ofApp.h +++ b/examples/gl/vboExample/src/ofApp.h @@ -21,11 +21,11 @@ class ofApp : public ofBaseApp { void gotMessage(ofMessage msg); // helper functions - void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c); - void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c, ofVec3f d); - void addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c); - void addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c, ofVec2f d); - ofVec3f getVertexFromImg(ofImage& img, int x, int y); + void addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c); + void addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c, const glm::vec3& d); + void addTexCoords(ofMesh& mesh, const glm::vec2& a, const glm::vec2& b, const glm::vec2& c); + void addTexCoords(ofMesh& mesh, const glm::vec2& a, const glm::vec2& b, const glm::vec2& c, const glm::vec2& d); + glm::vec3 getVertexFromImg(ofImage& img, int x, int y); ofEasyCam cam; ofMesh mesh; diff --git a/examples/graphics/colorsExtendedExample/src/ofApp.cpp b/examples/graphics/colorsExtendedExample/src/ofApp.cpp index 471db7c3c16..027179b5db4 100644 --- a/examples/graphics/colorsExtendedExample/src/ofApp.cpp +++ b/examples/graphics/colorsExtendedExample/src/ofApp.cpp @@ -200,7 +200,7 @@ void ofApp::update(){ // smoothing the mouse a bit over time - mouseSmoothed = 0.95 * mouseSmoothed + 0.05 * ofPoint(mouseX, mouseY); + mouseSmoothed = 0.95 * mouseSmoothed + 0.05 * glm::vec3(mouseX, mouseY,0); } diff --git a/examples/graphics/colorsExtendedExample/src/ofApp.h b/examples/graphics/colorsExtendedExample/src/ofApp.h index 654118b91f8..35030c71cd1 100644 --- a/examples/graphics/colorsExtendedExample/src/ofApp.h +++ b/examples/graphics/colorsExtendedExample/src/ofApp.h @@ -33,7 +33,7 @@ class ofApp : public ofBaseApp{ vector < colorNameMapping > colorNames; - ofPoint mouseSmoothed; + glm::vec3 mouseSmoothed; int sortedType; // keep track of which sort we've done diff --git a/examples/graphics/floatingPointImageExample/src/ofApp.cpp b/examples/graphics/floatingPointImageExample/src/ofApp.cpp index 95eba0034ba..5ef58854874 100644 --- a/examples/graphics/floatingPointImageExample/src/ofApp.cpp +++ b/examples/graphics/floatingPointImageExample/src/ofApp.cpp @@ -2,8 +2,8 @@ //Some helper functions //-------------------------------------------------------------- -void ofApp::addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) { - ofVec3f normal = ((b - a).cross(c - a)).normalize(); +void ofApp::addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c) { + glm::vec3 normal = glm::normalize(glm::cross((b - a),(c - a))); mesh.addNormal(normal); mesh.addVertex(a); mesh.addNormal(normal); @@ -13,14 +13,14 @@ void ofApp::addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) { } //-------------------------------------------------------------- -void ofApp::addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c, ofVec3f d) { +void ofApp::addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c, const glm::vec3& d) { addFace(mesh, a, b, c); addFace(mesh, a, c, d); } //-------------------------------------------------------------- -ofVec3f ofApp::getVertexFromImg(ofFloatImage& img, int x, int y) { - return ofVec3f(x, y, 100 * img.getColor(x, y).getBrightness()); +glm::vec3 ofApp::getVertexFromImg(ofFloatImage& img, int x, int y) { + return glm::vec3(x, y, 100 * img.getColor(x, y).getBrightness()); } //-------------------------------------------------------------- @@ -40,10 +40,10 @@ void ofApp::setup(){ int height = img.getHeight(); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { - ofVec3f nw = getVertexFromImg(img, x, y); - ofVec3f ne = getVertexFromImg(img, x + skip, y); - ofVec3f sw = getVertexFromImg(img, x, y + skip); - ofVec3f se = getVertexFromImg(img, x + skip, y + skip); + glm::vec3 nw = getVertexFromImg(img, x, y); + glm::vec3 ne = getVertexFromImg(img, x + skip, y); + glm::vec3 sw = getVertexFromImg(img, x, y + skip); + glm::vec3 se = getVertexFromImg(img, x + skip, y + skip); addFace(mesh, nw, ne, se, sw); } diff --git a/examples/graphics/floatingPointImageExample/src/ofApp.h b/examples/graphics/floatingPointImageExample/src/ofApp.h index b0a089ac2fa..8b3cc83d636 100644 --- a/examples/graphics/floatingPointImageExample/src/ofApp.h +++ b/examples/graphics/floatingPointImageExample/src/ofApp.h @@ -21,9 +21,9 @@ class ofApp : public ofBaseApp{ void gotMessage(ofMessage msg); // helper functions - void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c); - void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c, ofVec3f d); - ofVec3f getVertexFromImg(ofFloatImage& img, int x, int y); + void addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c); + void addFace(ofMesh& mesh, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c, const glm::vec3& d); + glm::vec3 getVertexFromImg(ofFloatImage& img, int x, int y); ofFloatImage img; ofEasyCam easyCam; diff --git a/examples/graphics/lutFilterExample/src/ofApp.cpp b/examples/graphics/lutFilterExample/src/ofApp.cpp index d393501b94b..08c31dbe309 100644 --- a/examples/graphics/lutFilterExample/src/ofApp.cpp +++ b/examples/graphics/lutFilterExample/src/ofApp.cpp @@ -19,8 +19,8 @@ void ofApp::setup(){ vidGrabber.setup(640,480); - thumbPos.set(lutImg.getWidth()*0.5f-80, -lutImg.getHeight()*0.5f - 60, 0); - lutPos.set(-lutImg.getWidth()*0.5f, -lutImg.getHeight()*0.5f, 0); + thumbPos = {lutImg.getWidth()*0.5f-80, -lutImg.getHeight()*0.5f - 60, 0}; + lutPos = {-lutImg.getWidth()*0.5f, -lutImg.getHeight()*0.5f, 0}; ofBackground(0); ofSetColor(255); @@ -71,7 +71,7 @@ void ofApp::loadLUT(string path){ for(int z=0; z<32; z++){ for(int y=0; y<32; y++){ for(int x=0; x<32; x++){ - ofVec3f cur; + glm::vec3 cur; file >> cur.x >> cur.y >> cur.z; lut[x][y][z] = cur; } @@ -97,8 +97,8 @@ void ofApp::applyLUT(ofPixelsRef pix){ } } - ofVec3f start = lut[lutPos[0]][lutPos[1]][lutPos[2]]; - ofVec3f end = lut[lutPos[0]+1][lutPos[1]+1][lutPos[2]+1]; + glm::vec3 start = lut[lutPos[0]][lutPos[1]][lutPos[2]]; + glm::vec3 end = lut[lutPos[0]+1][lutPos[1]+1][lutPos[2]+1]; for (int k=0; k<3; k++) { float amount = (color[k] % 8) / 8.0f; diff --git a/examples/graphics/lutFilterExample/src/ofApp.h b/examples/graphics/lutFilterExample/src/ofApp.h index c806ed7fcbf..fee166bca1e 100644 --- a/examples/graphics/lutFilterExample/src/ofApp.h +++ b/examples/graphics/lutFilterExample/src/ofApp.h @@ -28,11 +28,11 @@ class ofApp : public ofBaseApp{ ofVideoGrabber vidGrabber; int dirLoadIndex; ofDirectory dir; - ofPoint lutPos; - ofPoint thumbPos; + glm::vec3 lutPos; + glm::vec3 thumbPos; bool LUTloaded; - ofVec3f lut[32][32][32]; + glm::vec3 lut[32][32][32]; ofImage lutImg; diff --git a/examples/graphics/vectorGraphicsExample/src/ofApp.cpp b/examples/graphics/vectorGraphicsExample/src/ofApp.cpp index 8cd2f2931c3..ac01428a4bf 100644 --- a/examples/graphics/vectorGraphicsExample/src/ofApp.cpp +++ b/examples/graphics/vectorGraphicsExample/src/ofApp.cpp @@ -342,7 +342,7 @@ void ofApp::mouseMoved(int x, int y ){ void ofApp::mouseDragged(int x, int y, int button){ //we add a new point to our line - pts.push_back(ofPoint()); + pts.push_back(glm::vec3()); int last = pts.size()-1; pts[last].x = x; @@ -355,7 +355,7 @@ void ofApp::mousePressed(int x, int y, int button){ pts.clear(); //lets store the first point of the line - pts.push_back(ofPoint()); + pts.push_back(glm::vec3()); pts[0].x = x; pts[0].y = y; diff --git a/examples/graphics/vectorGraphicsExample/src/ofApp.h b/examples/graphics/vectorGraphicsExample/src/ofApp.h index bf065c74161..1e116649a57 100644 --- a/examples/graphics/vectorGraphicsExample/src/ofApp.h +++ b/examples/graphics/vectorGraphicsExample/src/ofApp.h @@ -27,7 +27,7 @@ class ofApp : public ofBaseApp{ bool capture; bool bFill; - vector pts; + vector pts; }; diff --git a/examples/gui/guiExample/src/ofApp.cpp b/examples/gui/guiExample/src/ofApp.cpp index 4d1751bb2bd..e2ca5a29e0f 100644 --- a/examples/gui/guiExample/src/ofApp.cpp +++ b/examples/gui/guiExample/src/ofApp.cpp @@ -11,7 +11,7 @@ void ofApp::setup(){ gui.setup(); // most of the time you don't need a name gui.add(filled.setup("fill", true)); gui.add(radius.setup("radius", 140, 10, 300)); - gui.add(center.setup("center", ofVec2f(ofGetWidth()*.5, ofGetHeight()*.5), ofVec2f(0, 0), ofVec2f(ofGetWidth(), ofGetHeight()))); + gui.add(center.setup("center", {ofGetWidth()*.5, ofGetHeight()*.5}, {0, 0}, {ofGetWidth(), ofGetHeight()})); gui.add(color.setup("color", ofColor(100, 100, 140), ofColor(0, 0), ofColor(255, 255))); gui.add(circleResolution.setup("circle res", 5, 3, 90)); gui.add(twoCircles.setup("two circles")); @@ -58,7 +58,7 @@ void ofApp::draw(){ ofDrawCircle(center->x-radius*.5, center->y, radius ); ofDrawCircle(center->x+radius*.5, center->y, radius ); }else{ - ofDrawCircle((ofVec2f)center, radius ); + ofDrawCircle(center, radius ); } // auto draw? diff --git a/examples/gui/guiFromParametersExample/src/ofApp.cpp b/examples/gui/guiFromParametersExample/src/ofApp.cpp index 7d0c504d106..97985481a66 100644 --- a/examples/gui/guiFromParametersExample/src/ofApp.cpp +++ b/examples/gui/guiFromParametersExample/src/ofApp.cpp @@ -12,7 +12,7 @@ void ofApp::setup(){ gui.setup("panel"); // most of the time you don't need a name but don't forget to call setup gui.add(filled.set("bFill", true)); gui.add(radius.set( "radius", 140, 10, 300 )); - gui.add(center.set("center",ofVec2f(ofGetWidth()*.5,ofGetHeight()*.5),ofVec2f(0,0),ofVec2f(ofGetWidth(),ofGetHeight()))); + gui.add(center.set("center",glm::vec2(ofGetWidth()*.5,ofGetHeight()*.5),glm::vec2(0,0),glm::vec2(ofGetWidth(),ofGetHeight()))); gui.add(color.set("color",ofColor(100,100,140),ofColor(0,0),ofColor(255,255))); gui.add(circleResolution.set("circleRes", 5, 3, 90)); gui.add(twoCircles.setup("twoCircles")); @@ -58,7 +58,7 @@ void ofApp::draw(){ ofDrawCircle(center->x-radius*.5, center->y, radius ); ofDrawCircle(center->x+radius*.5, center->y, radius ); }else{ - ofDrawCircle((ofVec2f)center, radius ); + ofDrawCircle((glm::vec2)center, radius ); } if( !bHide ){ diff --git a/examples/gui/guiFromParametersExample/src/ofApp.h b/examples/gui/guiFromParametersExample/src/ofApp.h index 11e9bee4749..be449b747fc 100644 --- a/examples/gui/guiFromParametersExample/src/ofApp.h +++ b/examples/gui/guiFromParametersExample/src/ofApp.h @@ -31,7 +31,7 @@ class ofApp : public ofBaseApp{ ofParameter radius; ofParameter color; - ofParameter center; + ofParameter center; ofParameter circleResolution; ofParameter filled; ofxButton twoCircles; diff --git a/examples/input_output/dragDropExample/src/ofApp.h b/examples/input_output/dragDropExample/src/ofApp.h index 58901354025..fe1659e95be 100644 --- a/examples/input_output/dragDropExample/src/ofApp.h +++ b/examples/input_output/dragDropExample/src/ofApp.h @@ -22,6 +22,6 @@ class ofApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); vector draggedImages; - ofPoint dragPt; + glm::vec2 dragPt; }; diff --git a/examples/input_output/pdfExample/src/ofApp.cpp b/examples/input_output/pdfExample/src/ofApp.cpp index 2aea8afefc3..5c8db558281 100644 --- a/examples/input_output/pdfExample/src/ofApp.cpp +++ b/examples/input_output/pdfExample/src/ofApp.cpp @@ -113,8 +113,8 @@ void ofApp::draw(){ ofDrawRectangle(0, 0, 30, 30); ofPopMatrix(); - if( boxTrail.size() == 0 || ( boxTrail.back() - ofPoint(x, y) ).length() > 1.5 ){ - boxTrail.push_back(ofPoint(x, y)); + if( boxTrail.size() == 0 || glm::distance( boxTrail.back(), glm::vec3(x, y, 0) ) > 1.5 ){ + boxTrail.push_back(glm::vec3(x, y, 0)); } if(boxTrail.size() > 800 ){ diff --git a/examples/input_output/pdfExample/src/ofApp.h b/examples/input_output/pdfExample/src/ofApp.h index 22f31c5ee56..8d09ebd0c17 100644 --- a/examples/input_output/pdfExample/src/ofApp.h +++ b/examples/input_output/pdfExample/src/ofApp.h @@ -26,7 +26,7 @@ class ofApp : public ofBaseApp{ vector dropZoneRects; vector images; - vector boxTrail; + vector boxTrail; ofTrueTypeFont font; diff --git a/examples/input_output/xmlSettingsExample/src/ofApp.cpp b/examples/input_output/xmlSettingsExample/src/ofApp.cpp index 1cd60a99fbd..085d13b55e6 100644 --- a/examples/input_output/xmlSettingsExample/src/ofApp.cpp +++ b/examples/input_output/xmlSettingsExample/src/ofApp.cpp @@ -76,7 +76,7 @@ void ofApp::setup(){ //which tag out of multiple tags you are refering to. int x = XML.getValue("PT:X", 0, i); int y = XML.getValue("PT:Y", 0, i); - dragPts[i].set(x, y); + dragPts[i] = {x, y}; pointCount++; } } @@ -220,7 +220,7 @@ void ofApp::mouseDragged(int x, int y, int button){ //------------ //we also record the x y points into an array - so we can draw it if(pointCount < NUM_PTS -1){ - dragPts[pointCount].set(x, y); + dragPts[pointCount]= {x, y}; pointCount++; } diff --git a/examples/input_output/xmlSettingsExample/src/ofApp.h b/examples/input_output/xmlSettingsExample/src/ofApp.h index 54677fe2132..a3f23da02c9 100644 --- a/examples/input_output/xmlSettingsExample/src/ofApp.h +++ b/examples/input_output/xmlSettingsExample/src/ofApp.h @@ -31,7 +31,7 @@ class ofApp : public ofBaseApp{ string xmlStructure; string message; - ofPoint dragPts[NUM_PTS]; + glm::vec2 dragPts[NUM_PTS]; int pointCount; int lineCount; diff --git a/examples/math/noiseField2dExample/src/ofApp.cpp b/examples/math/noiseField2dExample/src/ofApp.cpp index 63bbe238c27..ab83fcaeced 100644 --- a/examples/math/noiseField2dExample/src/ofApp.cpp +++ b/examples/math/noiseField2dExample/src/ofApp.cpp @@ -30,12 +30,12 @@ bool debugMode = false; for the v. */ //-------------------------------------------------------------- -ofVec2f ofApp::getField(ofVec2f position) { +glm::vec2 ofApp::getField(const glm::vec2& position) { float normx = ofNormalize(position.x, 0, ofGetWidth()); float normy = ofNormalize(position.y, 0, ofGetHeight()); float u = ofNoise(t + phase, normx * complexity + phase, normy * complexity + phase); float v = ofNoise(t - phase, normx * complexity - phase, normy * complexity + phase); - return ofVec2f(u, v); + return glm::vec2(u, v); } //-------------------------------------------------------------- @@ -46,7 +46,7 @@ void ofApp::setup() { // randomly allocate the points across the screen points.resize(nPoints); for(int i = 0; i < nPoints; i++) { - points[i] = ofVec2f(ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight())); + points[i] = glm::vec2(ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight())); } // we'll be drawing the points into an ofMesh that is drawn as bunch of points @@ -60,7 +60,7 @@ void ofApp::update() { t = ofGetFrameNum() * timeSpeed; for(int i = 0; i < nPoints; i++) { float x = points[i].x, y = points[i].y; - ofVec2f field = getField(points[i]); // get the field at this position + glm::vec2 field = getField(points[i]); // get the field at this position // use the strength of the field to determine a speed to move // the speed is changing over time and velocity-space as well float speed = (1 + ofNoise(t, field.x, field.y)) / pollenMass; @@ -88,7 +88,7 @@ void ofApp::draw() { // draw a vector field for the debug screen for(int i = 0; i < width; i += step) { for(int j = 0; j < height; j += step) { - ofVec2f field = getField(ofVec2f(i, j)); + glm::vec2 field = getField(glm::vec2(i, j)); ofPushMatrix(); ofTranslate(i, j); ofSetColor(0); diff --git a/examples/math/noiseField2dExample/src/ofApp.h b/examples/math/noiseField2dExample/src/ofApp.h index d84eb38cb3b..4717f04d86b 100644 --- a/examples/math/noiseField2dExample/src/ofApp.h +++ b/examples/math/noiseField2dExample/src/ofApp.h @@ -20,9 +20,9 @@ class ofApp : public ofBaseApp { void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - ofVec2f getField(ofVec2f position); + glm::vec2 getField(const glm::vec2& position); - vector points; + vector points; ofMesh cloud; float t; float width, height; diff --git a/examples/math/particlesExample/src/demoParticle.cpp b/examples/math/particlesExample/src/demoParticle.cpp index 3ab5b8d3205..52090062c0a 100644 --- a/examples/math/particlesExample/src/demoParticle.cpp +++ b/examples/math/particlesExample/src/demoParticle.cpp @@ -11,7 +11,7 @@ void demoParticle::setMode(particleMode newMode){ } //------------------------------------------------------------------ -void demoParticle::setAttractPoints( vector * attract ){ +void demoParticle::setAttractPoints( vector * attract ){ attractPoints = attract; } @@ -26,7 +26,7 @@ void demoParticle::reset(){ vel.x = ofRandom(-3.9, 3.9); vel.y = ofRandom(-3.9, 3.9); - frc = ofPoint(0,0,0); + frc = glm::vec3(0,0,0); scale = ofRandom(0.5, 1.0); @@ -44,20 +44,20 @@ void demoParticle::update(){ //1 - APPLY THE FORCES BASED ON WHICH MODE WE ARE IN if( mode == PARTICLE_MODE_ATTRACT ){ - ofPoint attractPt(ofGetMouseX(), ofGetMouseY()); + glm::vec3 attractPt(ofGetMouseX(), ofGetMouseY(), 0); frc = attractPt-pos; // we get the attraction force/vector by looking at the mouse pos relative to our pos - frc.normalize(); //by normalizing we disregard how close the particle is to the attraction point + glm::normalize(frc); //by normalizing we disregard how close the particle is to the attraction point vel *= drag; //apply drag vel += frc * 0.6; //apply force } else if( mode == PARTICLE_MODE_REPEL ){ - ofPoint attractPt(ofGetMouseX(), ofGetMouseY()); + glm::vec3 attractPt(ofGetMouseX(), ofGetMouseY(), 0); frc = attractPt-pos; //let get the distance and only repel points close to the mouse - float dist = frc.length(); - frc.normalize(); + float dist = glm::length(frc); + glm::normalize(frc); vel *= drag; if( dist < 150 ){ @@ -91,12 +91,12 @@ void demoParticle::update(){ if( attractPoints ){ //1 - find closest attractPoint - ofPoint closestPt; + glm::vec3 closestPt; int closest = -1; float closestDist = 9999999; for(unsigned int i = 0; i < attractPoints->size(); i++){ - float lenSq = ( attractPoints->at(i)-pos ).lengthSquared(); + float lenSq = glm::length2( attractPoints->at(i)-pos ); if( lenSq < closestDist ){ closestDist = lenSq; closest = i; diff --git a/examples/math/particlesExample/src/demoParticle.h b/examples/math/particlesExample/src/demoParticle.h index 00fbf48ad83..eef2b5643f9 100644 --- a/examples/math/particlesExample/src/demoParticle.h +++ b/examples/math/particlesExample/src/demoParticle.h @@ -14,15 +14,15 @@ class demoParticle{ demoParticle(); void setMode(particleMode newMode); - void setAttractPoints( vector * attract ); + void setAttractPoints( vector * attract ); void reset(); void update(); void draw(); - ofPoint pos; - ofPoint vel; - ofPoint frc; + glm::vec3 pos; + glm::vec3 vel; + glm::vec3 frc; float drag; float uniqueVal; @@ -30,5 +30,5 @@ class demoParticle{ particleMode mode; - vector * attractPoints; -}; \ No newline at end of file + vector * attractPoints; +}; diff --git a/examples/math/particlesExample/src/ofApp.cpp b/examples/math/particlesExample/src/ofApp.cpp index f356fdbf6d5..caa8ab8ef81 100644 --- a/examples/math/particlesExample/src/ofApp.cpp +++ b/examples/math/particlesExample/src/ofApp.cpp @@ -19,7 +19,7 @@ void ofApp::resetParticles(){ //these are the attraction points used in the forth demo attractPoints.clear(); for(int i = 0; i < 4; i++){ - attractPoints.push_back( ofPoint( ofMap(i, 0, 4, 100, ofGetWidth()-100) , ofRandom(100, ofGetHeight()-100) ) ); + attractPoints.push_back( glm::vec3( ofMap(i, 0, 4, 100, ofGetWidth()-100) , ofRandom(100, ofGetHeight()-100) , 0) ); } attractPointsWithMovement = attractPoints; diff --git a/examples/math/particlesExample/src/ofApp.h b/examples/math/particlesExample/src/ofApp.h index a7aa83a0822..768e611b435 100644 --- a/examples/math/particlesExample/src/ofApp.h +++ b/examples/math/particlesExample/src/ofApp.h @@ -27,7 +27,7 @@ class ofApp : public ofBaseApp{ string currentModeStr; vector p; - vector attractPoints; - vector attractPointsWithMovement; + vector attractPoints; + vector attractPointsWithMovement; }; diff --git a/examples/math/periodicSignalsExample/src/ofApp.cpp b/examples/math/periodicSignalsExample/src/ofApp.cpp index e6f5ebccf60..4836590910f 100644 --- a/examples/math/periodicSignalsExample/src/ofApp.cpp +++ b/examples/math/periodicSignalsExample/src/ofApp.cpp @@ -67,7 +67,7 @@ void ofApp::update(){ if(xhorizontalOscilators; //In this vector object we're going to save our horizontal oscillators. vectorverticalOscilators; //In this vector object we're going to save our vertical oscillators. - ofVec3f waveHistory [TAIL_LENGTH]; // This array object is to save the previous positions of the composite wave we're creating, so we can draw it's path later. + glm::vec3 waveHistory [TAIL_LENGTH]; // This array object is to save the previous positions of the composite wave we're creating, so we can draw its path later. float horWaveHistory [WAVEFORM_HISTORY];//This and the following array are for saving the wave form history. float vertWaveHistory [WAVEFORM_HISTORY]; - ofPoint center; //This is to store the center location for the composite wave . + glm::vec3 center; //This is to store the center location for the composite wave . float scale; // the amount by which the waveforms get scaled. bool bScaleMouse;//just to know that you're using the mouse to change the scale. diff --git a/examples/math/trigonometryExample/src/ofApp.cpp b/examples/math/trigonometryExample/src/ofApp.cpp index 95997c718e7..580e878d989 100644 --- a/examples/math/trigonometryExample/src/ofApp.cpp +++ b/examples/math/trigonometryExample/src/ofApp.cpp @@ -21,7 +21,7 @@ void ofApp::setup(){ tangent=0; rotationSpeed=0.01; radius = 180; - center.set(ofGetWidth()*0.3f, ofGetHeight()*0.6f, 0); + center = {ofGetWidth()*0.3f, ofGetHeight()*0.6f, 0 }; ofSetCircleResolution(40); @@ -35,15 +35,13 @@ void ofApp::setup(){ //-------------------------------------------------------------- void ofApp::update(){ - cout << rotationSpeed << endl; if (!ofGetMousePressed()) {//press the mouse to stop the angle from incrementing. angle+=rotationSpeed;//at each update the angle get's incremented } - if (angle>=TWO_PI) { //if the angle is more than or equal to two PI (a full rotation measured in Radians) then make it zero. - angle=0; - } - + //if the angle is more than or equal to two PI (a full rotation measured in Radians) then make it zero. + angle = ofWrap(angle, 0, TWO_PI); + //here we get the sine and cosine values for the angle cosine=cos(angle); sine=sin(angle); @@ -51,11 +49,12 @@ void ofApp::update(){ - point.set(cosine * radius, sine * radius, 0);//here we set the cyan circle position + point = { cosine * radius, sine * radius, 0 };//here we set the cyan circle position //this is just to draw the arc that represents the angle angleArc.clear(); - angleArc.arc( 0, 0, radius * 0.5f, radius * 0.5f, 0, ofRadToDeg(angle)); + angleArc.arc( 0, 0, radius * 0.5f, radius * 0.5f, 0, ofRadToDeg(angle)); + angleArc.lineTo(0,0); angleArc.close(); @@ -129,7 +128,7 @@ void ofApp::draw(){ ofDrawBitmapString("Angle cosine: " + ofToString(cosine), 0, -radius *2 -20); ofDrawBitmapString("cosine x radius: " + ofToString(cosine * radius), 0, -radius *2 -5 ); - + } //-------------------------------------------------------------- @@ -146,27 +145,25 @@ void ofApp::keyReleased(int key){ void ofApp::mouseMoved(int x, int y ){ } - +//-------------------------------------------------------------- +void ofApp::checkMouse(float x, float y){ + glm::vec2 mousePos(x-center.x, y-center.y); + + if (glm::length(mousePos) < radius ) {//if the mouse is inside the circle + // get the angle between the line from the mouse to the center of the circle and the positive x axis + angle = atan2( mousePos.y , mousePos.x); + // wrap the angle so it is always between 0 and TWO_PI (one full rotation) + angle = ofWrap(angle, 0, TWO_PI); + } +} //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ - ofVec2f mousePos(x-center.x, y-center.y); - if (mousePos.length()(); + if(players[i]->load(dir.getPath(i))){ + auto chans = players[i]->getSoundFile().getNumChannels(); + //create a vector object that will define which are the channels you want to connect to + // + vector v; + v.resize(chans); + for(int j =0 ; j < v.size(); j++){ + v[j] = j+count; + } + // SUPER IMPORTANT!!! + // the following line of code is the important one + // + // As an alternative you could define the channels manually in the following way + // output.getOrCreateChannelGroup({0,1}); + // which will create an output for channels 0 and 1. + // Channels start at 0. The first channel of your audio interface is 0 not 1. + ofxSoundObject& playerOutput = output.getOrCreateChannelGroup(v); + // the next line is just a regular way of connecting sound objects. + players[i]->connectTo(playerOutput); + players[i]->play(); + count += chans ; + } + } + } + } + // Setup the sound stream. + ofSoundStreamSettings settings; + settings.bufferSize = 256; + settings.numBuffers = 1; + settings.numInputChannels = 0; + settings.numOutputChannels = count; + if(players.size()){ + // we setup the samplerate of the sound stream according to the one of the first player + settings.sampleRate = players[0]->getSoundFile().getSampleRate(); + } + +// auto devices = ofSoundStreamListDevices(); +// stream.printDeviceList(); + + // IMPORTANT!!! + // The following two lines of code is where you set which audio interface to use. + // The number you put inside the square braquets in devices[ ] is the one + // printed in the list in the console. + + + // IMPORTANT!!! + // The following two lines of code is where you set which audio interface to use. + + inDeviceIndex = 0; + outDeviceIndex = 0; + + + auto inDevices = ofxSoundUtils::getInputSoundDevices(); + auto outDevices = ofxSoundUtils::getOutputSoundDevices(); + + + + cout << "========================" << endl; + cout << ofxSoundUtils::getSoundDeviceString(inDevices[inDeviceIndex], true, true) << endl; + + cout << "========================" << endl; + + + + settings.setInDevice(devices[0]); + settings.setOutDevice(devices[0]); + + + stream.setup(settings); + stream.setOutput(output); + + +} + +//-------------------------------------------------------------- +void ofApp::update(){ + +} +//helper function to convert milliseconds to MM:SS format. +string msToMMSS(unsigned long ms){ + ms /=1000; + return ofToString((int)floor(ms/60.0))+":"+ofToString(ms%60); +} +//-------------------------------------------------------------- +void ofApp::draw(){ + ofDrawBitmapStringHighlight("READ THE COMMENTS IN THE setup() function!!!", 100,100); + + stringstream ss; + for(auto & c: output.getChannelGroups()){ + auto pl = ((ofxSoundPlayerObject*)c.second.getInputObject()); + auto& f = pl->getSoundFile(); + + ss << "Playing " << ofFilePath::getBaseName(f.getPath()) << " to channels " << ofToString(c.first)<getPositionMS()) << " - " << msToMMSS(pl->getDurationMS()) << endl < mainWindow = ofCreateWindow(settings); settings.setSize(300, 300); - settings.setPosition(ofVec2f(0,0)); + settings.setPosition(glm::vec2(0,0)); settings.resizable = false; shared_ptr guiWindow = ofCreateWindow(settings); diff --git a/examples/windowing/multiWindowOneAppExample/src/main.cpp b/examples/windowing/multiWindowOneAppExample/src/main.cpp index 3847c7f66f8..bb0b6e37fde 100644 --- a/examples/windowing/multiWindowOneAppExample/src/main.cpp +++ b/examples/windowing/multiWindowOneAppExample/src/main.cpp @@ -6,12 +6,12 @@ int main( ){ ofGLFWWindowSettings settings; settings.setSize(600, 600); - settings.setPosition(ofVec2f(300,0)); + settings.setPosition(glm::vec2(300,0)); settings.resizable = true; shared_ptr mainWindow = ofCreateWindow(settings); settings.setSize(300, 300); - settings.setPosition(ofVec2f(0,0)); + settings.setPosition(glm::vec2(0,0)); settings.resizable = false; // uncomment next line to share main's OpenGL resources with gui //settings.shareContextWith = mainWindow;