Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

How to convert ofVec2f in glm::vec2?

$
0
0

@sonotype wrote:

Hi, I’ve tried to replace ofVec2f with glm::vec2 but I can’t get the rotation method. Does anyone know how to solve it?

glm::vec<2, float> mousePos(ofGetMouseX(), ofGetMouseY());
    
    int numTriangoles = 10;
       int minOffset = 5;
       int maxOffest = 70;
       int alpha = 20;
    
    if (ofGetMousePressed(OF_MOUSE_BUTTON_LEFT)) {
    //ON MOUSE PRESSED
         /* ____________________________________________________________________ */
         for(int triangleInstance=0; triangleInstance<numTriangoles; triangleInstance++){
             float offsetDistance = ofRandom(minOffset, maxOffest);
             float transparency = 40;
             float brushWidth = 0.45;
// tried to use glm::vec2 and vector<glm::vec2>(don't remember exactly), but it didn't work
            ofVec2f p1(0., 25.*brushWidth);
             ofVec2f p2(100*brushWidth, 0);
             ofVec2f p3(0, -25.0*brushWidth);
         
             float rotation = ofRandom(360.0);
             p1.rotate(rotation);
             p2.rotate(rotation);
             p3.rotate(rotation);
             
             ofVec2f triangleoffset(offsetDistance);
             p1 += mousePos;
             p2 += mousePos;
             p3 += mousePos;

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles