From b8473052bdaf49f8cb362ae1fcfdc887ab988105 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 31 Oct 2019 08:40:39 -0400 Subject: [PATCH] Updated examples to glm (#6389) #changelog #examples --- addons/ofxiOS/src/utils/ofxiOSCoreMotion.h | 45 +- addons/ofxiOS/src/utils/ofxiOSCoreMotion.mm | 44 +- examples/3d/3DPrimitivesExample/src/ofApp.cpp | 468 +++++++++--------- examples/3d/3DPrimitivesExample/src/ofApp.h | 64 +-- examples/3d/advanced3dExample/src/Swarm.cpp | 6 +- examples/3d/advanced3dExample/src/Swarm.h | 4 +- examples/3d/advanced3dExample/src/ofApp.cpp | 8 +- examples/3d/advanced3dExample/src/ofApp.h | 2 +- examples/3d/assimpExample/src/ofApp.cpp | 2 +- .../3d/cameraLensOffsetExample/src/ofApp.cpp | 16 +- .../3d/cameraLensOffsetExample/src/ofApp.h | 8 +- .../3d/cameraParentingExample/src/ofApp.cpp | 18 +- examples/3d/cameraRibbonExample/src/ofApp.cpp | 34 +- examples/3d/cameraRibbonExample/src/ofApp.h | 4 +- .../3d/meshFromCameraExample/src/ofApp.cpp | 12 +- examples/3d/modelNoiseExample/src/ofApp.cpp | 8 +- examples/3d/normalsExample/src/ofApp.cpp | 28 +- examples/3d/ofBoxExample/src/ofApp.cpp | 2 +- examples/3d/orientationExample/README.md | 2 +- examples/3d/orientationExample/src/ofApp.cpp | 40 +- examples/3d/orientationExample/src/ofApp.h | 4 +- examples/3d/pointCloudExample/src/ofApp.cpp | 4 +- examples/3d/pointPickerExample/src/ofApp.cpp | 10 +- .../3d/quaternionArcballExample/src/ofApp.cpp | 25 +- .../3d/quaternionArcballExample/src/ofApp.h | 6 +- .../3d/quaternionLatLongExample/README.md | 2 +- .../3d/quaternionLatLongExample/src/ofApp.cpp | 15 +- .../androidAccelerometerExample/src/ofApp.h | 2 +- .../androidAdvanced3DExample/src/Swarm.cpp | 6 +- .../androidAdvanced3DExample/src/Swarm.h | 6 +- .../androidAdvanced3DExample/src/ofApp.cpp | 9 +- .../androidAdvanced3DExample/src/ofApp.h | 2 +- .../android/androidGuiExample/src/ofApp.cpp | 4 +- .../android/androidGuiExample/src/ofApp.h | 2 +- .../androidShaderExample/src/ofApp.cpp | 2 +- .../android/androidVBOExample/src/ofApp.cpp | 4 +- .../android/androidVBOExample/src/ofApp.h | 4 +- .../androidVibratorExample/src/ofApp.cpp | 2 +- .../networkUdpReceiverExample/src/ofApp.cpp | 2 +- .../networkUdpReceiverExample/src/ofApp.h | 2 +- .../networkUdpSenderExample/src/ofApp.cpp | 2 +- .../networkUdpSenderExample/src/ofApp.h | 2 +- .../oscReceiveExample/src/ofApp.cpp | 2 +- examples/events/customEventExample/src/Bug.h | 6 +- .../events/customEventExample/src/Bullet.h | 2 +- .../events/customEventExample/src/ofApp.cpp | 32 +- .../events/customEventExample/src/ofApp.h | 2 +- .../events/simpleEventsExample/src/Circle.cpp | 6 +- .../events/simpleEventsExample/src/Circle.h | 4 +- .../events/simpleEventsExample/src/ofApp.cpp | 6 +- .../events/simpleEventsExample/src/ofApp.h | 6 +- examples/gl/areaLightExample/src/ofApp.cpp | 8 +- examples/gl/billboardExample/src/ofApp.cpp | 12 +- examples/gl/billboardExample/src/ofApp.h | 4 +- .../gl/billboardRotationExample/src/ofApp.cpp | 17 +- .../gl/billboardRotationExample/src/ofApp.h | 6 +- .../src/ofApp.cpp | 22 +- .../computeShaderParticlesExample/src/ofApp.h | 6 +- examples/gl/fboTrailsExample/src/ofApp.cpp | 12 +- .../gl/geometryShaderExample/src/ofApp.cpp | 2 +- examples/gl/geometryShaderExample/src/ofApp.h | 2 +- examples/gl/glInfoExample/src/ofApp.cpp | 4 +- .../gl/gpuParticleSystemExample/src/ofApp.cpp | 4 +- examples/gl/multiLightExample/src/ofApp.cpp | 6 +- examples/gl/multiLightExample/src/ofApp.h | 2 +- examples/gl/pixelBufferExample/src/ofApp.cpp | 21 +- .../gl/pointsAsTexturesExample/src/ofApp.cpp | 12 +- .../gl/pointsAsTexturesExample/src/ofApp.h | 4 +- examples/gl/singleLightExample/src/ofApp.cpp | 4 +- examples/gl/singleLightExample/src/ofApp.h | 2 +- .../gl/slowFastRenderingExample/src/ofApp.cpp | 13 +- .../gl/slowFastRenderingExample/src/ofApp.h | 8 +- .../src/ofApp.cpp | 2 +- .../textureBufferInstancedExample/src/ofApp.h | 2 +- .../threadedPixelBufferExample/src/ofApp.cpp | 8 +- examples/gl/vboExample/src/ofApp.cpp | 46 +- examples/gl/vboExample/src/ofApp.h | 10 +- .../colorsExtendedExample/src/ofApp.cpp | 2 +- .../colorsExtendedExample/src/ofApp.h | 2 +- .../floatingPointImageExample/README.md | 2 +- .../floatingPointImageExample/src/ofApp.cpp | 18 +- .../floatingPointImageExample/src/ofApp.h | 6 +- examples/graphics/lutFilterExample/README.md | 2 +- .../graphics/lutFilterExample/src/ofApp.cpp | 10 +- .../graphics/lutFilterExample/src/ofApp.h | 6 +- .../vectorGraphicsExample/src/ofApp.cpp | 4 +- .../vectorGraphicsExample/src/ofApp.h | 2 +- examples/gui/guiExample/src/ofApp.cpp | 4 +- .../guiFromParametersExample/src/ofApp.cpp | 4 +- .../gui/guiFromParametersExample/src/ofApp.h | 2 +- .../input_output/dragDropExample/src/ofApp.h | 2 +- .../input_output/pdfExample/src/ofApp.cpp | 4 +- examples/input_output/pdfExample/src/ofApp.h | 2 +- .../xmlSettingsExample/src/ofApp.cpp | 4 +- .../xmlSettingsExample/src/ofApp.h | 2 +- examples/ios/PrimitivesExample/src/ofApp.mm | 8 +- .../ios/iosCoreMotionExample/src/ofApp.mm | 10 +- .../ios/iosCoreMotionLegacyExample/src/Ball.h | 2 +- .../iosCoreMotionLegacyExample/src/ofApp.h | 2 +- examples/ios/ofxGuiExample/src/ofApp.h | 2 +- examples/ios/ofxGuiExample/src/ofApp.mm | 4 +- examples/ios/vboExample/src/ofApp.h | 4 +- examples/ios/vboExample/src/ofApp.mm | 2 +- .../math/noiseField2dExample/src/ofApp.cpp | 10 +- examples/math/noiseField2dExample/src/ofApp.h | 4 +- .../particlesExample/src/demoParticle.cpp | 18 +- .../math/particlesExample/src/demoParticle.h | 12 +- examples/math/particlesExample/src/ofApp.cpp | 2 +- examples/math/particlesExample/src/ofApp.h | 4 +- .../math/periodicSignalsExample/src/ofApp.cpp | 2 +- .../trigonometricMotionExample/src/ofApp.cpp | 12 +- .../trigonometricMotionExample/src/ofApp.h | 10 +- .../math/trigonometryExample/src/ofApp.cpp | 56 +-- examples/math/trigonometryExample/src/ofApp.h | 7 +- examples/math/vectorMathExample/README.md | 2 +- examples/math/vectorMathExample/src/ofApp.cpp | 40 +- examples/math/vectorMathExample/src/ofApp.h | 20 +- examples/tvOS/ofBoxExample/src/ofApp.mm | 2 +- .../windowing/multiWindowExample/src/main.cpp | 4 +- .../multiWindowOneAppExample/src/main.cpp | 4 +- 120 files changed, 783 insertions(+), 775 deletions(-) diff --git a/addons/ofxiOS/src/utils/ofxiOSCoreMotion.h b/addons/ofxiOS/src/utils/ofxiOSCoreMotion.h index 35699984510..db81322b851 100755 --- a/addons/ofxiOS/src/utils/ofxiOSCoreMotion.h +++ b/addons/ofxiOS/src/utils/ofxiOSCoreMotion.h @@ -8,7 +8,8 @@ #pragma once #import -#include "ofMatrix4x4.h" +#include "ofVectorMath.h" + class ofxiOSCoreMotion { @@ -30,22 +31,22 @@ class ofxiOSCoreMotion { void disableAttitude(); void resetAttitude(bool toCurrentReferenceFrame = true); - - void setUpdateFrequency(float updateFrequency); - void update(); - - ofVec3f getAccelerometerData(); - ofVec3f getGyroscopeData(); - ofVec3f getMagnetometerData(); + + void setUpdateFrequency(float updateFrequency); + void update(); + + glm::vec3 getAccelerometerData(); + glm::vec3 getGyroscopeData(); + glm::vec3 getMagnetometerData(); float getRoll(); float getPitch(); float getYaw(); - ofQuaternion getQuaternion(); - ofMatrix4x4 getRotationMatrix(); - ofVec3f getGravity(); - ofVec3f getUserAcceleration(); - ofVec3f getMagneticField(); - + glm::quat getQuaternion(); + glm::mat4 getRotationMatrix(); + glm::vec3 getGravity(); + glm::vec3 getUserAcceleration(); + glm::vec3 getMagneticField(); + protected: // core motion @@ -56,15 +57,15 @@ class ofxiOSCoreMotion { float updateFrequency; bool enableAttitude, enableGyro, enableAccelerometer, enableMagnetometer; - ofVec3f accelerometerData; - ofVec3f gyroscopeData; - ofVec3f magnetometerData; + glm::vec3 accelerometerData; + glm::vec3 gyroscopeData; + glm::vec3 magnetometerData; float roll, pitch, yaw; - ofQuaternion attitudeQuat; - ofMatrix4x4 rotMatrix; - ofVec3f gravity; - ofVec3f userAcceleration; - ofVec3f magneticField; + glm::quat attitudeQuat; + glm::mat4 rotMatrix; + glm::vec3 gravity; + glm::vec3 userAcceleration; + glm::vec3 magneticField; }; diff --git a/addons/ofxiOS/src/utils/ofxiOSCoreMotion.mm b/addons/ofxiOS/src/utils/ofxiOSCoreMotion.mm index 96ccc103b16..571b5357b8a 100755 --- a/addons/ofxiOS/src/utils/ofxiOSCoreMotion.mm +++ b/addons/ofxiOS/src/utils/ofxiOSCoreMotion.mm @@ -54,12 +54,12 @@ [motionManager stopDeviceMotionUpdates]; enableAttitude = false; roll = pitch = yaw = 0; - attitudeQuat.set(0, 0, 0, 1); - rotMatrix.makeIdentityMatrix(); - gravity.set(0,0,0); - userAcceleration.set(0, 0, 0); - magneticField.set(0, 0, 0); - + attitudeQuat = glm::quat(1,0,0,0); + rotMatrix = glm::mat4(1); + gravity = { 0, 0, 0 }; + userAcceleration = { 0, 0, 0 }; + magneticField = { 0, 0, 0 }; + } void ofxiOSCoreMotion::setupAccelerometer() { @@ -73,7 +73,7 @@ [motionManager stopAccelerometerUpdates]; enableAccelerometer = false; - accelerometerData.set(0, 0, 0); + accelerometerData = { 0, 0, 0 }; } void ofxiOSCoreMotion::setupGyroscope() { @@ -87,7 +87,7 @@ [motionManager stopGyroUpdates]; enableGyro = false; - gyroscopeData.set(0, 0, 0); + gyroscopeData = { 0, 0, 0 }; } void ofxiOSCoreMotion::setupMagnetometer() { @@ -101,7 +101,7 @@ [motionManager stopMagnetometerUpdates]; enableMagnetometer = false; - magnetometerData.set(0, 0, 0); + magnetometerData = { 0, 0, 0 }; } void ofxiOSCoreMotion::setUpdateFrequency(float updateFrequency) { @@ -167,15 +167,17 @@ // attitude quaternion - CMQuaternion quat = attitude.quaternion; - attitudeQuat.set(quat.x, quat.y, quat.z, quat.w); + attitudeQuat.x = attitude.quaternion.x; + attitudeQuat.y = attitude.quaternion.y; + attitudeQuat.z = attitude.quaternion.z; + attitudeQuat.w = attitude.quaternion.w; // attitude rotation matrix CMRotationMatrix rot = attitude.rotationMatrix; - rotMatrix.set(rot.m11, rot.m21, rot.m31, 0, + rotMatrix = { rot.m11, rot.m21, rot.m31, 0, rot.m12, rot.m22, rot.m32, 0, rot.m13, rot.m23, rot.m33, 0, - 0, 0, 0, 1); + 0, 0, 0, 1}; } if(enableAccelerometer) { @@ -200,15 +202,15 @@ } } -ofVec3f ofxiOSCoreMotion::getAccelerometerData() { +glm::vec3 ofxiOSCoreMotion::getAccelerometerData() { return accelerometerData; } -ofVec3f ofxiOSCoreMotion::getGyroscopeData() { +glm::vec3 ofxiOSCoreMotion::getGyroscopeData() { return gyroscopeData; } -ofVec3f ofxiOSCoreMotion::getMagnetometerData() { +glm::vec3 ofxiOSCoreMotion::getMagnetometerData() { return magnetometerData; } @@ -224,22 +226,22 @@ return yaw; } -ofQuaternion ofxiOSCoreMotion::getQuaternion() { +glm::quat ofxiOSCoreMotion::getQuaternion() { return attitudeQuat; } -ofMatrix4x4 ofxiOSCoreMotion::getRotationMatrix() { +glm::mat4 ofxiOSCoreMotion::getRotationMatrix() { return rotMatrix; } -ofVec3f ofxiOSCoreMotion::getGravity() { +glm::vec3 ofxiOSCoreMotion::getGravity() { return gravity; } -ofVec3f ofxiOSCoreMotion::getUserAcceleration() { +glm::vec3 ofxiOSCoreMotion::getUserAcceleration() { return userAcceleration; } -ofVec3f ofxiOSCoreMotion::getMagneticField() { +glm::vec3 ofxiOSCoreMotion::getMagneticField() { return magneticField; } diff --git a/examples/3d/3DPrimitivesExample/src/ofApp.cpp b/examples/3d/3DPrimitivesExample/src/ofApp.cpp index 23f5b6a5c23..4e7ba326e6d 100644 --- a/examples/3d/3DPrimitivesExample/src/ofApp.cpp +++ b/examples/3d/3DPrimitivesExample/src/ofApp.cpp @@ -6,69 +6,69 @@ void ofApp::setup(){ ofSetVerticalSync(true); ofBackground(20); - // GL_REPEAT for texture wrap only works with NON-ARB textures // - ofDisableArbTex(); - texture.load("of.png"); - texture.getTexture().setTextureWrap( GL_REPEAT, GL_REPEAT ); - vidGrabber.setup(640, 480, true); + // GL_REPEAT for texture wrap only works with NON-ARB textures // + ofDisableArbTex(); + texture.load("of.png"); + texture.getTexture().setTextureWrap( GL_REPEAT, GL_REPEAT ); + vidGrabber.setup(640, 480, true); - bFill = true; - bWireframe = true; - bDrawNormals= false; - bDrawAxes = false; - bDrawLights = false; - bHelpText = true; - bMousePressed = false; - bSplitFaces = false; + bFill = true; + bWireframe = true; + bDrawNormals= false; + bDrawAxes = false; + bDrawLights = false; + bHelpText = true; + bMousePressed = false; + bSplitFaces = false; - float width = ofGetWidth() * .12; - float height = ofGetHeight() * .12; + float width = ofGetWidth() * .12; + float height = ofGetHeight() * .12; - plane.set( width*1.5, height*1.5 ); - box.set( width*1.25 ); - sphere.setRadius( width ); - icoSphere.setRadius( width ); - cylinder.set(width*.7, height*2.2); - cone.set( width*.75, height*2.2 ); + plane.set( width*1.5, height*1.5 ); + box.set( width*1.25 ); + sphere.setRadius( width ); + icoSphere.setRadius( width ); + cylinder.set(width*.7, height*2.2); + cone.set( width*.75, height*2.2 ); - mode = 0; + mode = 0; - ofSetSmoothLighting(true); - pointLight.setDiffuseColor( ofFloatColor(.85, .85, .55) ); - pointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f)); + ofSetSmoothLighting(true); + pointLight.setDiffuseColor( ofFloatColor(.85, .85, .55) ); + pointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f)); - pointLight2.setDiffuseColor( ofFloatColor( 238.f/255.f, 57.f/255.f, 135.f/255.f )); - pointLight2.setSpecularColor(ofFloatColor(.8f, .8f, .9f)); + pointLight2.setDiffuseColor( ofFloatColor( 238.f/255.f, 57.f/255.f, 135.f/255.f )); + pointLight2.setSpecularColor(ofFloatColor(.8f, .8f, .9f)); - pointLight3.setDiffuseColor( ofFloatColor(19.f/255.f,94.f/255.f,77.f/255.f) ); - pointLight3.setSpecularColor( ofFloatColor(18.f/255.f,150.f/255.f,135.f/255.f) ); + pointLight3.setDiffuseColor( ofFloatColor(19.f/255.f,94.f/255.f,77.f/255.f) ); + pointLight3.setSpecularColor( ofFloatColor(18.f/255.f,150.f/255.f,135.f/255.f) ); - // shininess is a value between 0 - 128, 128 being the most shiny // - material.setShininess( 120 ); - // the light highlight of the material // - material.setSpecularColor(ofColor(255, 255, 255, 255)); + // shininess is a value between 0 - 128, 128 being the most shiny // + material.setShininess( 120 ); + // the light highlight of the material // + material.setSpecularColor(ofColor(255, 255, 255, 255)); - ofSetSphereResolution(24); + ofSetSphereResolution(24); } //-------------------------------------------------------------- void ofApp::update() { - pointLight.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.5)*(ofGetWidth()*.3), ofGetHeight()/2, 500); - pointLight2.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.15)*(ofGetWidth()*.3), - ofGetHeight()*.5 + sin(ofGetElapsedTimef()*.7)*(ofGetHeight()), -300); + pointLight.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.5)*(ofGetWidth()*.3), ofGetHeight()/2, 500); + pointLight2.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.15)*(ofGetWidth()*.3), + ofGetHeight()*.5 + sin(ofGetElapsedTimef()*.7)*(ofGetHeight()), -300); - pointLight3.setPosition( - cos(ofGetElapsedTimef()*1.5) * ofGetWidth()*.5, - sin(ofGetElapsedTimef()*1.5f) * ofGetWidth()*.5, - cos(ofGetElapsedTimef()*.2) * ofGetWidth() - ); + pointLight3.setPosition( + cos(ofGetElapsedTimef()*1.5) * ofGetWidth()*.5, + sin(ofGetElapsedTimef()*1.5f) * ofGetWidth()*.5, + cos(ofGetElapsedTimef()*.2) * ofGetWidth() + ); //ofSetWindowTitle("Framerate: "+ofToString(ofGetFrameRate(), 0)); - if(mode == 2 || ofGetElapsedTimef() < 10) { - vidGrabber.update(); - } + if(mode == 2 || ofGetElapsedTimef() < 10) { + vidGrabber.update(); + } } //-------------------------------------------------------------- @@ -105,12 +105,12 @@ void ofApp::draw() { float screenWidth = ofGetWidth(); float screenHeight = ofGetHeight(); - plane.setPosition( -screenWidth * .5 + screenWidth * 1/4.f, screenHeight * 1.1/6.f, 0); - box.setPosition( -screenWidth * .5 + screenWidth * 2/4.f, screenHeight * 1.1/6.f, 0); - sphere.setPosition( -screenWidth * .5 + screenWidth * 3/4.f, screenHeight * 1.1/6.f, 0); + plane.setPosition( -screenWidth * .5 + screenWidth * 1/4.f, screenHeight * 1.1/6.f, 0); + box.setPosition( -screenWidth * .5 + screenWidth * 2/4.f, screenHeight * 1.1/6.f, 0); + sphere.setPosition( -screenWidth * .5 + screenWidth * 3/4.f, screenHeight * 1.1/6.f, 0); icoSphere.setPosition( -screenWidth * .5 + screenWidth * 1/4.f, screenHeight * -1.1/6.f, 0); cylinder.setPosition( -screenWidth * .5 + screenWidth * 2/4.f, screenHeight * -1.1/6.f, 0); - cone.setPosition( -screenWidth * .5 + screenWidth * 3/4.f, screenHeight * -1.1/6.f, 0); + cone.setPosition( -screenWidth * .5 + screenWidth * 3/4.f, screenHeight * -1.1/6.f, 0); // Plane // @@ -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(); @@ -414,22 +414,22 @@ void ofApp::draw() { ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD); - ofDrawBitmapStringHighlight("ofPlanePrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen(plane.getGlobalPosition()) ); - ofDrawBitmapStringHighlight("ofBoxPrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen( box.getPosition())); - ofDrawBitmapStringHighlight("ofSpherePrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen( sphere.getPosition())); + ofDrawBitmapStringHighlight("ofPlanePrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen(plane.getGlobalPosition()) ); + ofDrawBitmapStringHighlight("ofBoxPrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen( box.getPosition())); + ofDrawBitmapStringHighlight("ofSpherePrimitive" , glm::vec3(-90,-160,0) + cam.worldToScreen( sphere.getPosition())); ofDrawBitmapStringHighlight("ofIcoSpherePrimitive", glm::vec3(-90,+160,0) + cam.worldToScreen( icoSphere.getPosition())); ofDrawBitmapStringHighlight("ofCylinderPrimitive" , glm::vec3(-90,+160,0) + cam.worldToScreen( cylinder.getPosition())); - ofDrawBitmapStringHighlight("ofConePrimitive" , glm::vec3(-90,+160,0) + cam.worldToScreen( cone.getPosition())); - - if(bHelpText) { - stringstream ss; - ss << "FPS: " << ofToString(ofGetFrameRate(),0) << endl << endl; - ss << "(f): Toggle Fullscreen"< 3) mode = 0; - if(mode==3){ - // to get unique triangles, you have to use triangles mode // - sphere.setMode( OF_PRIMITIVE_TRIANGLES ); - } - break; - case OF_KEY_LEFT: - mode--; - if(mode < 0) mode = 3; - if(mode==3){ - // to get unique triangles, you have to use triangles mode // - sphere.setMode( OF_PRIMITIVE_TRIANGLES ); - } - break; - case 'a': - bDrawAxes = !bDrawAxes; - break; - case 'l': - bDrawLights = !bDrawLights; - break; - case 'h': - bHelpText=!bHelpText; - break; - case 'z': - bSplitFaces = !bSplitFaces; - - if(mode == 3) bSplitFaces = false; - - if(bSplitFaces) { - sphere.setMode( OF_PRIMITIVE_TRIANGLES ); - vector triangles = sphere.getMesh().getUniqueFaces(); - sphere.getMesh().setFromTriangles( triangles, true ); - - icoSphere.setMode( OF_PRIMITIVE_TRIANGLES ); - triangles = icoSphere.getMesh().getUniqueFaces(); - icoSphere.getMesh().setFromTriangles(triangles, true); - - plane.setMode( OF_PRIMITIVE_TRIANGLES ); - triangles = plane.getMesh().getUniqueFaces(); - plane.getMesh().setFromTriangles(triangles, true); - - cylinder.setMode( OF_PRIMITIVE_TRIANGLES ); - triangles = cylinder.getMesh().getUniqueFaces(); - cylinder.getMesh().setFromTriangles(triangles, true); - - cone.setMode( OF_PRIMITIVE_TRIANGLES ); - triangles = cone.getMesh().getUniqueFaces(); - cone.getMesh().setFromTriangles(triangles, true); - - box.setMode( OF_PRIMITIVE_TRIANGLES ); - triangles = box.getMesh().getUniqueFaces(); - box.getMesh().setFromTriangles(triangles, true); - - } else { - // vertex normals are calculated with creation, set resolution // - sphere.setResolution( sphere.getResolution() ); - - icoSphere.setResolution( icoSphere.getResolution() ); - plane.setResolution( plane.getNumColumns(), plane.getNumRows() ); - - cylinder.setResolution( cylinder.getResolutionRadius(), cylinder.getResolutionHeight(), cylinder.getResolutionCap() ); - cone.setResolution( cone.getResolutionRadius(), cone.getResolutionHeight(), cone.getResolutionCap() ); - box.setResolution( box.getResolutionWidth() ); - } - break; + case 's': + bFill = !bFill; + break; + case 'w': + bWireframe = !bWireframe; + break; + case '1': + bSplitFaces=false; + sphere.setResolution(4); + // icosahedron // + icoSphere.setResolution(0); // number of subdivides // + plane.setResolution(3, 2); + cylinder.setResolution(4,2,0); + cone.setResolution(4, 1, 0); + box.setResolution(1); + break; + case '2': + bSplitFaces=false; + sphere.setResolution(8); + icoSphere.setResolution(1); + plane.setResolution(6, 4); + cylinder.setResolution(8,4,1); + cone.setResolution(7, 2, 1); + box.setResolution(2); + break; + case '3': + bSplitFaces=false; + sphere.setResolution(16); + icoSphere.setResolution(2); + plane.setResolution(8,5); + cylinder.setResolution(12, 9, 2); + cone.setResolution(10, 5, 2); + box.setResolution(6); + break; + case '4': + bSplitFaces=false; + sphere.setResolution(48); + icoSphere.setResolution(4); + plane.setResolution(12, 9); + cylinder.setResolution(20, 13, 4); + cone.setResolution(20, 9, 3); + box.setResolution(10); + break; + case 'n': + bDrawNormals = !bDrawNormals; + break; + case OF_KEY_RIGHT: + mode++; + if(mode > 3) mode = 0; + if(mode==3){ + // to get unique triangles, you have to use triangles mode // + sphere.setMode( OF_PRIMITIVE_TRIANGLES ); + } + break; + case OF_KEY_LEFT: + mode--; + if(mode < 0) mode = 3; + if(mode==3){ + // to get unique triangles, you have to use triangles mode // + sphere.setMode( OF_PRIMITIVE_TRIANGLES ); + } + break; + case 'a': + bDrawAxes = !bDrawAxes; + break; + case 'l': + bDrawLights = !bDrawLights; + break; + case 'h': + bHelpText=!bHelpText; + break; + case 'z': + bSplitFaces = !bSplitFaces; + + if(mode == 3) bSplitFaces = false; + + if(bSplitFaces) { + sphere.setMode( OF_PRIMITIVE_TRIANGLES ); + vector triangles = sphere.getMesh().getUniqueFaces(); + sphere.getMesh().setFromTriangles( triangles, true ); + + icoSphere.setMode( OF_PRIMITIVE_TRIANGLES ); + triangles = icoSphere.getMesh().getUniqueFaces(); + icoSphere.getMesh().setFromTriangles(triangles, true); + + plane.setMode( OF_PRIMITIVE_TRIANGLES ); + triangles = plane.getMesh().getUniqueFaces(); + plane.getMesh().setFromTriangles(triangles, true); + + cylinder.setMode( OF_PRIMITIVE_TRIANGLES ); + triangles = cylinder.getMesh().getUniqueFaces(); + cylinder.getMesh().setFromTriangles(triangles, true); + + cone.setMode( OF_PRIMITIVE_TRIANGLES ); + triangles = cone.getMesh().getUniqueFaces(); + cone.getMesh().setFromTriangles(triangles, true); + + box.setMode( OF_PRIMITIVE_TRIANGLES ); + triangles = box.getMesh().getUniqueFaces(); + box.getMesh().setFromTriangles(triangles, true); + + } else { + // vertex normals are calculated with creation, set resolution // + sphere.setResolution( sphere.getResolution() ); + + icoSphere.setResolution( icoSphere.getResolution() ); + plane.setResolution( plane.getNumColumns(), plane.getNumRows() ); + + cylinder.setResolution( cylinder.getResolutionRadius(), cylinder.getResolutionHeight(), cylinder.getResolutionCap() ); + cone.setResolution( cone.getResolutionRadius(), cone.getResolutionHeight(), cone.getResolutionCap() ); + box.setResolution( box.getResolutionWidth() ); + } + break; + } + + if(mode == 1) { + // resize the plane to the size of the texture // + plane.resizeToTexture( texture.getTexture() ); + // setTexCoordsFromTexture sets normalized or non-normalized tex coords based on an ofTexture passed in. + box.mapTexCoordsFromTexture( texture.getTexture() ); + sphere.mapTexCoordsFromTexture( texture.getTexture() ); + icoSphere.mapTexCoordsFromTexture( texture.getTexture() ); + cylinder.mapTexCoordsFromTexture( texture.getTexture() ); + cone.mapTexCoordsFromTexture( texture.getTexture() ); } - if(mode == 1) { - // resize the plane to the size of the texture // - plane.resizeToTexture( texture.getTexture() ); - // setTexCoordsFromTexture sets normalized or non-normalized tex coords based on an ofTexture passed in. - box.mapTexCoordsFromTexture( texture.getTexture() ); - sphere.mapTexCoordsFromTexture( texture.getTexture() ); - icoSphere.mapTexCoordsFromTexture( texture.getTexture() ); - cylinder.mapTexCoordsFromTexture( texture.getTexture() ); - cone.mapTexCoordsFromTexture( texture.getTexture() ); - } - - if(mode == 2) { - plane.resizeToTexture( vidGrabber.getTexture(), .5 ); - box.mapTexCoordsFromTexture( vidGrabber.getTexture() ); - sphere.mapTexCoordsFromTexture( vidGrabber.getTexture() ); - icoSphere.mapTexCoordsFromTexture( vidGrabber.getTexture() ); - cylinder.mapTexCoordsFromTexture( vidGrabber.getTexture() ); - cone.mapTexCoordsFromTexture( vidGrabber.getTexture() ); - } - - // - if( mode == 3 ) { - - bSplitFaces = false; - - // if the faces were split, we can get some weird results, since we - // might not know what the new strides were, - // so reset the primitives by calling their setMode function - // which recreates the mesh with the proper indicies // - sphere.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); - icoSphere.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); - cylinder.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); - cone.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); - // box only supports triangles // - box.setMode( OF_PRIMITIVE_TRIANGLES ); - - plane.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); - plane.mapTexCoords(0, 0, 5, 5); - - // rebuild the box, - box.mapTexCoords(0, 0, 5, 5); - sphere.mapTexCoords(0, 0, 5, 5); - icoSphere.mapTexCoords(0, 0, 5, 5); - cylinder.mapTexCoords(0, 0, 5, 5); - cone.mapTexCoords(0, 0, 5, 5); - - // store the box sides so that we can manipulate them later // - for(int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++ ) { - boxSides[i] = box.getSideMesh( i ); - } - } + if(mode == 2) { + plane.resizeToTexture( vidGrabber.getTexture(), .5 ); + box.mapTexCoordsFromTexture( vidGrabber.getTexture() ); + sphere.mapTexCoordsFromTexture( vidGrabber.getTexture() ); + icoSphere.mapTexCoordsFromTexture( vidGrabber.getTexture() ); + cylinder.mapTexCoordsFromTexture( vidGrabber.getTexture() ); + cone.mapTexCoordsFromTexture( vidGrabber.getTexture() ); + } + + // + if( mode == 3 ) { + + bSplitFaces = false; + + // if the faces were split, we can get some weird results, since we + // might not know what the new strides were, + // so reset the primitives by calling their setMode function + // which recreates the mesh with the proper indicies // + sphere.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); + icoSphere.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); + cylinder.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); + cone.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); + // box only supports triangles // + box.setMode( OF_PRIMITIVE_TRIANGLES ); + + plane.setMode( OF_PRIMITIVE_TRIANGLE_STRIP ); + plane.mapTexCoords(0, 0, 5, 5); + + // rebuild the box, + box.mapTexCoords(0, 0, 5, 5); + sphere.mapTexCoords(0, 0, 5, 5); + icoSphere.mapTexCoords(0, 0, 5, 5); + cylinder.mapTexCoords(0, 0, 5, 5); + cone.mapTexCoords(0, 0, 5, 5); + + // store the box sides so that we can manipulate them later // + for(int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++ ) { + boxSides[i] = box.getSideMesh( i ); + } + } } @@ -628,12 +628,12 @@ void ofApp::mouseDragged(int x, int y, int button){ //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ - bMousePressed = true; + bMousePressed = true; } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ - bMousePressed = false; + bMousePressed = false; } //-------------------------------------------------------------- diff --git a/examples/3d/3DPrimitivesExample/src/ofApp.h b/examples/3d/3DPrimitivesExample/src/ofApp.h index 57fb9c043cf..3a6ee9a14ca 100644 --- a/examples/3d/3DPrimitivesExample/src/ofApp.h +++ b/examples/3d/3DPrimitivesExample/src/ofApp.h @@ -21,36 +21,36 @@ class ofApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - bool bFill; - bool bWireframe; - bool bDrawNormals; - bool bDrawAxes; - bool bDrawLights; - bool bHelpText; - bool bMousePressed; - bool bSplitFaces; - - ofImage texture; - ofVideoGrabber vidGrabber; - int mode; - - ofSpherePrimitive sphere; - ofIcoSpherePrimitive icoSphere; - ofPlanePrimitive plane; - ofCylinderPrimitive cylinder; - ofConePrimitive cone; - ofBoxPrimitive box; - - ofLight pointLight; - ofLight pointLight2; - ofLight pointLight3; - ofMaterial material; - - // place to store the sides of the box // - ofVboMesh boxSides[ofBoxPrimitive::SIDES_TOTAL]; - ofVboMesh deformPlane; - ofVboMesh topCap, bottomCap, body; - vector triangles; - - ofCamera cam; + bool bFill; + bool bWireframe; + bool bDrawNormals; + bool bDrawAxes; + bool bDrawLights; + bool bHelpText; + bool bMousePressed; + bool bSplitFaces; + + ofImage texture; + ofVideoGrabber vidGrabber; + int mode; + + ofSpherePrimitive sphere; + ofIcoSpherePrimitive icoSphere; + ofPlanePrimitive plane; + ofCylinderPrimitive cylinder; + ofConePrimitive cone; + ofBoxPrimitive box; + + ofLight pointLight; + ofLight pointLight2; + ofLight pointLight3; + ofMaterial material; + + // place to store the sides of the box // + ofVboMesh boxSides[ofBoxPrimitive::SIDES_TOTAL]; + ofVboMesh deformPlane; + ofVboMesh topCap, bottomCap, body; + vector triangles; + + ofCamera cam; }; 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..1e9c40c3285 100644 --- a/examples/3d/cameraRibbonExample/src/ofApp.cpp +++ b/examples/3d/cameraRibbonExample/src/ofApp.cpp @@ -27,7 +27,7 @@ void ofApp::setup(){ void ofApp::update(){ //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]; @@ -53,23 +53,23 @@ void ofApp::draw(){ 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]; + 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); + glm::vec3 direction = (nextPoint - thisPoint); //get the distance from one point to the next - float distance = direction.length(); + 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(); + 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)); + 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. @@ -78,12 +78,12 @@ void ofApp::draw(){ //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; + 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)); + mesh.addVertex(glm::vec3(leftPoint.x, leftPoint.y, leftPoint.z)); + mesh.addVertex(glm::vec3(rightPoint.x, rightPoint.y, rightPoint.z)); } //end the shape @@ -112,23 +112,23 @@ void ofApp::mouseMoved(int x, int y ){ //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/README.md b/examples/3d/orientationExample/README.md index fb65fedd645..08250bdcbef 100644 --- a/examples/3d/orientationExample/README.md +++ b/examples/3d/orientationExample/README.md @@ -10,7 +10,7 @@ This is helpful if you want to have a shape follow the correct direction of a li The example creates a blue line using a mesh created from a deque of stored points. Those stored points are created using a noise function in `update()` -The points are then passed to the `rotateToNormal(ofVec3f normal)` function that effects the rotation of the white ofDrawBox and ensures that it stays aligned to the front of the path of the blue line. There are multiple ways to do this, and this is just one example of working with normals in 3D space. +The points are then passed to the `rotateToNormal(glm::vec3 normal)` function that effects the rotation of the white ofDrawBox and ensures that it stays aligned to the front of the path of the blue line. There are multiple ways to do this, and this is just one example of working with normals in 3D space. [Wikipedia on normals](https://en.wikipedia.org/wiki/Normal_(geometry) diff --git a/examples/3d/orientationExample/src/ofApp.cpp b/examples/3d/orientationExample/src/ofApp.cpp index 5c61838c93f..bbadb50c3bc 100644 --- a/examples/3d/orientationExample/src/ofApp.cpp +++ b/examples/3d/orientationExample/src/ofApp.cpp @@ -1,23 +1,29 @@ #include "ofApp.h" /* - rotateToNormal will rotate everything using ofRotate. the rotation amount - and axis are generated using an ofQuaternion. the trick is to use ofQuaternion - to determine the rotation that is required from a standard axis (0,0,1) to the - desired normal vector, then apply that rotation. -*/ + rotateToNormal will rotate everything using a rotation matrix which is generated using a quaternion (glm::quat). + for this we use the function glm::rotation(glm::vec3 v1, glm::vec3 v2) which takes in two normalized vectors and returns + a quaternion that represents the rotation between these two vectors. + We will use the normal which is passed to this function and the standard z axis. + */ //-------------------------------------------------------------- -void rotateToNormal(ofVec3f normal) { - normal.normalize(); - - float rotationAmount; - ofVec3f rotationAngle; - ofQuaternion rotation; - - ofVec3f axis(0, 0, 1); - rotation.makeRotate(axis, normal); - rotation.getRotate(rotationAmount, rotationAngle); - ofRotateDeg(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z); +void rotateToNormal(glm::vec3 normal) { + + // the normal must be normalized. + normal = glm::normalize(normal); + + // the standard Z axis. + glm::vec3 axis(0, 0, 1); + + // create the quaternion which represents the rotation between normal and axis + glm::quat rotation = glm::rotation(axis, normal); + + // transform the quaternion to a 4x4 matrix using the glm function for such. + glm::mat4 rotationMatrix = glm::toMat4(rotation); + + // multiply the rotation matrix with the current matrix. + // This means that the rotation matrix, thus the transformation it represents, will be applied on over the current transformation matrix. + ofMultMatrix( rotationMatrix ); } //-------------------------------------------------------------- @@ -78,7 +84,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..b418eb3564b 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/README.md b/examples/3d/quaternionLatLongExample/README.md index 838488c82bd..f5c65b0e324 100644 --- a/examples/3d/quaternionLatLongExample/README.md +++ b/examples/3d/quaternionLatLongExample/README.md @@ -16,7 +16,7 @@ In the code, pay attention to: * ```latRot.makeRotate(cities[i].latitude, 1, 0, 0);``` to create a quaternion which will perform a rotation of an angle * ```longRot.makeRotate(cities[i].longitude, 0, 1, 0);``` to create a quaternion which will perform a rotation of an angle * ``` spinQuat.makeRotate(ofGetFrameNum(), 0, 1, 0);``` to create another quaternion to ensure it spins on the y axis -* ```ofVec3f worldPoint = latRot * longRot * spinQuat * center;``` to generate the point to map the city by multiplying all of the quaternions and then multipying the center vector to apply the rotation to the center vector +* ```glm::vec3 worldPoint = latRot * longRot * spinQuat * center;``` to generate the point to map the city by multiplying all of the quaternions and then multipying the center vector to apply the rotation to the center vector ### Expected Behavior 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/androidAccelerometerExample/src/ofApp.h b/examples/android/androidAccelerometerExample/src/ofApp.h index 50acf035441..f9f7cde0a0e 100644 --- a/examples/android/androidAccelerometerExample/src/ofApp.h +++ b/examples/android/androidAccelerometerExample/src/ofApp.h @@ -34,6 +34,6 @@ class ofApp : public ofxAndroidApp{ void cancelPressed(); ofTrueTypeFont font; - ofVec3f accel, normAccel; + glm::vec3 accel, normAccel; string messages[3]; }; 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..af57f0e6199 100644 --- a/examples/android/androidGuiExample/src/ofApp.cpp +++ b/examples/android/androidGuiExample/src/ofApp.cpp @@ -18,7 +18,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")); @@ -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/androidShaderExample/src/ofApp.cpp b/examples/android/androidShaderExample/src/ofApp.cpp index a598d821a3b..b5486b767a6 100644 --- a/examples/android/androidShaderExample/src/ofApp.cpp +++ b/examples/android/androidShaderExample/src/ofApp.cpp @@ -21,7 +21,7 @@ void ofApp::setup(){ } boundingBox.alignTo(ofGetCurrentViewport(), OF_ALIGN_HORZ_CENTER, OF_ALIGN_VERT_CENTER); - ofVec2f textPos(boundingBox.getX(), boundingBox.getMaxY()); + glm::vec2 textPos(boundingBox.getX(), boundingBox.getMaxY()); text.translate(textPos); text.setFillColor(ofColor(245, 58, 135)); 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..a0e91efb128 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..19315e1d6a4 100644 --- a/examples/gl/slowFastRenderingExample/src/ofApp.cpp +++ b/examples/gl/slowFastRenderingExample/src/ofApp.cpp @@ -17,13 +17,11 @@ void ofApp::setup() { //-------------------------------------------------------------- void ofApp::update() { - - // add points all the time if(points.size() < 500000) { for (int i=0; i<30; i++) { addPoint(ofGetWidth()/2, ofGetHeight()/2); - } + } } // move all the points around @@ -34,9 +32,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; } @@ -113,7 +111,7 @@ void ofApp::keyPressed(int key) { if(key == 'z') { for (int i=0; i<400000; i++) { addPoint(ofRandomWidth(), ofRandomHeight()); - } + } } } @@ -130,7 +128,6 @@ void ofApp::mouseMoved(int x, int y ){ //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ - // add a bunch as you drag for (int i=0; i<400; i++) { addPoint(x, y); 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/README.md b/examples/graphics/floatingPointImageExample/README.md index b05dc609de3..e452fe41e08 100644 --- a/examples/graphics/floatingPointImageExample/README.md +++ b/examples/graphics/floatingPointImageExample/README.md @@ -13,7 +13,7 @@ In this example, pay attention to the following code: * ```mesh.advertex(a)``` adding vertices to mesh * ```mesh.setmode()``` specifies what primitive mode the mesh should be set to * ```mesh.draw()``` draws the mesh -* ```getVertexFromImg```gets the vertex from the image using ```ofVec3f``` +* ```getVertexFromImg```gets the vertex from the image using ```glm::vec3``` ### Expected Behavior 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/README.md b/examples/graphics/lutFilterExample/README.md index 736d4f90959..ee61290910c 100644 --- a/examples/graphics/lutFilterExample/README.md +++ b/examples/graphics/lutFilterExample/README.md @@ -9,7 +9,7 @@ This openFrameworks Example is designed to demonstrate how to create LUT filters In this example, pay attention to the following code: * ```void loadLUT(string path)``` -* ```void applyLUT(ofPixelsRef pix)``` uses ```ofVec3f``` and ```imgageName.setColor(x, y, color)``` to alter the color of every pixel of the image +* ```void applyLUT(ofPixelsRef pix)``` uses ```glm::vec3``` and ```imgageName.setColor(x, y, color)``` to alter the color of every pixel of the image ### Expected Behavior 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/ios/PrimitivesExample/src/ofApp.mm b/examples/ios/PrimitivesExample/src/ofApp.mm index e3a28982164..2cd072c762a 100644 --- a/examples/ios/PrimitivesExample/src/ofApp.mm +++ b/examples/ios/PrimitivesExample/src/ofApp.mm @@ -100,10 +100,10 @@ if(mode == 2) { deformPlane = plane.getMesh(); // x = columns, y = rows // - ofVec3f planeDims = plane.getResolution(); + glm::vec3 planeDims = plane.getResolution(); float planeAngleX = ofGetElapsedTimef()*3.6; float planeAngleInc = 3.f/(float)planeDims.x; - ofVec3f vert; + glm::vec3 vert; for(int i = 0; i < deformPlane.getNumIndices(); i++ ) { planeAngleX += planeAngleInc; int ii = deformPlane.getIndex( i ); @@ -193,7 +193,7 @@ if(mode == 2) { float angle = ofGetElapsedTimef()*3.2; float strength = (sin( angle )) * .25f * 2.f; - ofVec3f faceNormal; + glm::vec3 faceNormal; for(int i = 0; i < triangles.size(); i++ ) { // store the face normal here. // we change the vertices, which makes the face normal change @@ -233,7 +233,7 @@ if(mode == 2) { float angle = (ofGetElapsedTimef() * 1.4); - ofVec3f faceNormal; + glm::vec3 faceNormal; for(int i = 0; i < triangles.size(); i++ ) { float frc = ofSignedNoise(angle* (float)i * .1, angle*.05) * 4; faceNormal = triangles[i].getFaceNormal(); diff --git a/examples/ios/iosCoreMotionExample/src/ofApp.mm b/examples/ios/iosCoreMotionExample/src/ofApp.mm index 4e9c4a03ab2..39b8f1fab9e 100755 --- a/examples/ios/iosCoreMotionExample/src/ofApp.mm +++ b/examples/ios/iosCoreMotionExample/src/ofApp.mm @@ -26,7 +26,7 @@ // attitude- quaternion ofDrawBitmapStringHighlight("Attitude: (quaternion x,y,z,w)", 20, 25); ofSetColor(0); - ofQuaternion quat = coreMotion.getQuaternion(); + glm::quat quat = coreMotion.getQuaternion(); ofDrawBitmapString(ofToString(quat.x(),3), 20, 50); ofDrawBitmapString(ofToString(quat.y(),3), 90, 50); ofDrawBitmapString(ofToString(quat.z(),3), 160, 50); @@ -40,7 +40,7 @@ ofDrawBitmapString(ofToString(coreMotion.getYaw(),3), 220, 100); // accelerometer - ofVec3f a = coreMotion.getAccelerometerData(); + glm::vec3 a = coreMotion.getAccelerometerData(); ofDrawBitmapStringHighlight("Accelerometer: (x,y,z)", 20, 125); ofSetColor(0); ofDrawBitmapString(ofToString(a.x,3), 20, 150); @@ -48,7 +48,7 @@ ofDrawBitmapString(ofToString(a.z,3), 220, 150); // gyroscope - ofVec3f g = coreMotion.getGyroscopeData(); + glm::vec3 g = coreMotion.getGyroscopeData(); ofDrawBitmapStringHighlight("Gyroscope: (x,y,z)", 20, 175); ofSetColor(0); ofDrawBitmapString(ofToString(g.x,3), 20, 200 ); @@ -56,7 +56,7 @@ ofDrawBitmapString(ofToString(g.z,3), 220, 200 ); // magnetometer - ofVec3f m = coreMotion.getMagnetometerData(); + glm::vec3 m = coreMotion.getMagnetometerData(); ofDrawBitmapStringHighlight("Magnetometer: (x,y,z)", 20, 225); ofSetColor(0); ofDrawBitmapString(ofToString(m.x,3), 20, 250); @@ -71,7 +71,7 @@ // 1) quaternion rotations float angle; - ofVec3f axis;//(0,0,1.0f); + glm::vec3 axis;//(0,0,1.0f); quat.getRotate(angle, axis); ofRotate(angle, axis.x, -axis.y, axis.z); // rotate with quaternion diff --git a/examples/ios/iosCoreMotionLegacyExample/src/Ball.h b/examples/ios/iosCoreMotionLegacyExample/src/Ball.h index 9eb34ca0064..6dcba3636a9 100644 --- a/examples/ios/iosCoreMotionLegacyExample/src/Ball.h +++ b/examples/ios/iosCoreMotionLegacyExample/src/Ball.h @@ -34,7 +34,7 @@ class Ball{ } //---------------------------------------------------------------- - void update(const ofVec3f & accelerometerData) { + void update(const glm::vec3 & accelerometerData) { vel.x += ACCELEROMETER_FORCE * accelerometerData.x * ofRandomuf(); vel.y += -ACCELEROMETER_FORCE * accelerometerData.y * ofRandomuf(); // this one is subtracted cos world Y is opposite to opengl Y diff --git a/examples/ios/iosCoreMotionLegacyExample/src/ofApp.h b/examples/ios/iosCoreMotionLegacyExample/src/ofApp.h index 0c4765dc18b..a28b02fe0d3 100644 --- a/examples/ios/iosCoreMotionLegacyExample/src/ofApp.h +++ b/examples/ios/iosCoreMotionLegacyExample/src/ofApp.h @@ -27,7 +27,7 @@ class ofApp : public ofxiOSApp{ void gotMessage(ofMessage msg); ofxiOSCoreMotion coreMotion; - ofVec3f accelerometerData; + glm::vec3 accelerometerData; vector balls; ofImage arrow; diff --git a/examples/ios/ofxGuiExample/src/ofApp.h b/examples/ios/ofxGuiExample/src/ofApp.h index a5dd2f27d3f..69838d1da11 100644 --- a/examples/ios/ofxGuiExample/src/ofApp.h +++ b/examples/ios/ofxGuiExample/src/ofApp.h @@ -29,7 +29,7 @@ class ofApp : public ofxiOSApp{ ofParameter radius; ofParameter color; - ofParameter center; + ofParameter center; ofParameter circleResolution; ofParameter filled; ofxButton twoCircles; diff --git a/examples/ios/ofxGuiExample/src/ofApp.mm b/examples/ios/ofxGuiExample/src/ofApp.mm index a1309f5f5cc..39d84002443 100644 --- a/examples/ios/ofxGuiExample/src/ofApp.mm +++ b/examples/ios/ofxGuiExample/src/ofApp.mm @@ -19,7 +19,7 @@ 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()*.75),ofVec2f(0,0),ofVec2f(ofGetWidth(),ofGetHeight()))); + gui.add(center.set("center",glm::vec2(ofGetWidth()*.5,ofGetHeight()*.75),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")); @@ -63,7 +63,7 @@ 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/ios/vboExample/src/ofApp.h b/examples/ios/vboExample/src/ofApp.h index 859d8a15265..e73b64f6d70 100644 --- a/examples/ios/vboExample/src/ofApp.h +++ b/examples/ios/vboExample/src/ofApp.h @@ -26,8 +26,8 @@ class ofApp : public ofxiOSApp{ void deviceOrientationChanged(int newOrientation); 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/ios/vboExample/src/ofApp.mm b/examples/ios/vboExample/src/ofApp.mm index 53b7520d404..62b5fa2fcc3 100644 --- a/examples/ios/vboExample/src/ofApp.mm +++ b/examples/ios/vboExample/src/ofApp.mm @@ -47,7 +47,7 @@ if(!bPause) { - ofVec3f vec; + glm::vec3 vec; float r = 0.3; for (int i=0; i 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..4381dbc41bd 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); @@ -29,36 +29,30 @@ void ofApp::setup(){ angleArc.setCircleResolution(360); angleArc.setFilled(true); angleArc.setColor(ofColor(240, 130, 10)); - - + } //-------------------------------------------------------------- void ofApp::update(){ - cout << rotationSpeed << endl; - - if (!ofGetMousePressed()) {//press the mouse to stop the angle from incrementing. + + 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); tangent=tan(angle); - - - 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 +123,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 +140,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() 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;