Created
December 20, 2017 19:53
-
-
Save stephanschulz/0806f9c3a63c8e1bd1eb2ca2c77874ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //-------------------------------------------------------------- | |
| void ofApp::update(){ | |
| ofSetWindowTitle(ofToString(ofGetFrameRate())); | |
| int x = ofGetMouseX(); | |
| int y = 400; | |
| int z = ofGetMouseY();//400; | |
| ray.set(ofPoint(0,0,0), ofPoint(x,y,z)); | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::draw(){ | |
| ofBackground(0); | |
| cam.begin(); | |
| ofSetColor(255, 0, 0); | |
| ray.draw(); | |
| mesh.drawWireframe(); | |
| IntersectionData id; | |
| mesh.getUniqueFaces().size();; | |
| int cnt = 0; | |
| ofPoint temp; | |
| for(int i=0;i<mesh.getUniqueFaces().size();i++){ | |
| IsTriangle triangle; | |
| ofMeshFace face=mesh.getUniqueFaces().at(i); | |
| triangle.set(face); | |
| id=is.RayTriangleIntersection(triangle, ray); | |
| if(id.isIntersection){ | |
| cnt++; | |
| ofSetColor(255, 0, 0,100); | |
| ofDrawSphere(id.pos,3); | |
| temp = id.pos; | |
| ofSetColor(200, 200, 200,150); | |
| }else{ | |
| ofSetColor(0,0,0,0); | |
| } | |
| triangle.draw(); | |
| } | |
| if(cnt % 2 == 0){ | |
| }else{ | |
| ofSetColor(0, 0, 255,150); | |
| ofDrawSphere(temp,5); | |
| } | |
| cam.end(); | |
| ofDrawBitmapStringHighlight("pos "+ofToString(ofGetMouseX())+", 400 , "+ofToString(ofGetMouseY()),10,30); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment