Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ofApp.h"
- //--------------------------------------------------------------
- void ofApp::setup(){
- ofEnableDepthTest();
- image.load("sunflower.png");
- gridStepX=gridStepY=5;
- numGridPointsX=image.getWidth()/gridStepX;
- numGridPointsY=image.getHeight()/gridStepY;
- for(int y =0;y<numGridPointsY;y++){
- for(int x =0;x<numGridPointsX;x++){
- ofPoint p=ofPoint(x*gridStepX,y*gridStepY,0);
- mesh.addVertex(p);
- mesh.addColor(ofColor::black);
- }
- }
- //setup triangles -1 perchè non costruisco il triangolo alla fine per on uscire
- for(int y =0;y<numGridPointsY-1;y++){
- for(int x =0;x<numGridPointsX-1;x++){
- int i1=x+y*numGridPointsX;
- int i2=x+1+y*numGridPointsX;
- int i3=x+(y+1)*numGridPointsX;
- int i4=x+1+(y+1)*numGridPointsX;
- mesh.addTriangle(i1,i2,i3);
- mesh.addTriangle(i2,i3,i4);
- }
- }
- }
- //--------------------------------------------------------------
- void ofApp::update(){
- float time=ofGetElapsedTimef();
- for(int y =0;y<numGridPointsY;y++){
- for(int x =0;x<numGridPointsX;x++){
- int i=x+y*numGridPointsX;
- // ofSeedRandom(0);
- ofPoint p=mesh.getVertex(i);
- p.z = ofNoise(x*0.05,y*0.05,time)*100;
- mesh.setVertex(i,p);
- }
- }
- }
- //--------------------------------------------------------------
- void ofApp::draw(){
- cam.begin();
- mesh.drawWireframe();
- //mesh.draw();
- cam.end();
- }
- //--------------------------------------------------------------
- void ofApp::keyPressed(int key){
- }
- //--------------------------------------------------------------
- void ofApp::keyReleased(int key){
- }
- //--------------------------------------------------------------
- void ofApp::mouseMoved(int x, int y ){
- }
- //--------------------------------------------------------------
- void ofApp::mouseDragged(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void ofApp::mousePressed(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void ofApp::mouseReleased(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void ofApp::mouseEntered(int x, int y){
- }
- //--------------------------------------------------------------
- void ofApp::mouseExited(int x, int y){
- }
- //--------------------------------------------------------------
- void ofApp::windowResized(int w, int h){
- }
- //--------------------------------------------------------------
- void ofApp::gotMessage(ofMessage msg){
- }
- //--------------------------------------------------------------
- void ofApp::dragEvent(ofDragInfo dragInfo){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement