Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #include "ofApp.h"
  2.  
  3. //--------------------------------------------------------------
  4. void ofApp::setup(){
  5.  
  6. ofEnableDepthTest();
  7.  
  8. image.load("sunflower.png");
  9.  
  10. gridStepX=gridStepY=5;
  11.  
  12. numGridPointsX=image.getWidth()/gridStepX;
  13. numGridPointsY=image.getHeight()/gridStepY;
  14.  
  15. for(int y =0;y<numGridPointsY;y++){
  16. for(int x =0;x<numGridPointsX;x++){
  17. ofPoint p=ofPoint(x*gridStepX,y*gridStepY,0);
  18. mesh.addVertex(p);
  19. mesh.addColor(ofColor::black);
  20. }
  21. }
  22.  
  23. //setup triangles -1 perchè non costruisco il triangolo alla fine per on uscire
  24. for(int y =0;y<numGridPointsY-1;y++){
  25. for(int x =0;x<numGridPointsX-1;x++){
  26. int i1=x+y*numGridPointsX;
  27. int i2=x+1+y*numGridPointsX;
  28. int i3=x+(y+1)*numGridPointsX;
  29. int i4=x+1+(y+1)*numGridPointsX;
  30.  
  31. mesh.addTriangle(i1,i2,i3);
  32. mesh.addTriangle(i2,i3,i4);
  33.  
  34. }
  35. }
  36. }
  37.  
  38. //--------------------------------------------------------------
  39. void ofApp::update(){
  40. float time=ofGetElapsedTimef();
  41. for(int y =0;y<numGridPointsY;y++){
  42. for(int x =0;x<numGridPointsX;x++){
  43. int i=x+y*numGridPointsX;
  44.  
  45. // ofSeedRandom(0);
  46. ofPoint p=mesh.getVertex(i);
  47.  
  48.  
  49. p.z = ofNoise(x*0.05,y*0.05,time)*100;
  50.  
  51.  
  52. mesh.setVertex(i,p);
  53.  
  54. }
  55. }
  56.  
  57. }
  58.  
  59. //--------------------------------------------------------------
  60. void ofApp::draw(){
  61. cam.begin();
  62. mesh.drawWireframe();
  63. //mesh.draw();
  64. cam.end();
  65. }
  66.  
  67. //--------------------------------------------------------------
  68. void ofApp::keyPressed(int key){
  69.  
  70. }
  71.  
  72. //--------------------------------------------------------------
  73. void ofApp::keyReleased(int key){
  74.  
  75. }
  76.  
  77. //--------------------------------------------------------------
  78. void ofApp::mouseMoved(int x, int y ){
  79.  
  80. }
  81.  
  82. //--------------------------------------------------------------
  83. void ofApp::mouseDragged(int x, int y, int button){
  84.  
  85. }
  86.  
  87. //--------------------------------------------------------------
  88. void ofApp::mousePressed(int x, int y, int button){
  89.  
  90. }
  91.  
  92. //--------------------------------------------------------------
  93. void ofApp::mouseReleased(int x, int y, int button){
  94.  
  95. }
  96.  
  97. //--------------------------------------------------------------
  98. void ofApp::mouseEntered(int x, int y){
  99.  
  100. }
  101.  
  102. //--------------------------------------------------------------
  103. void ofApp::mouseExited(int x, int y){
  104.  
  105. }
  106.  
  107. //--------------------------------------------------------------
  108. void ofApp::windowResized(int w, int h){
  109.  
  110. }
  111.  
  112. //--------------------------------------------------------------
  113. void ofApp::gotMessage(ofMessage msg){
  114.  
  115. }
  116.  
  117. //--------------------------------------------------------------
  118. void ofApp::dragEvent(ofDragInfo dragInfo){
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement