//-------------------------------------------------------------- void testApp::draw(){ //flock myCam.begin(); ofPushMatrix();{ ofLight(); flocker.draw(); }ofPopMatrix(); myCam.end(); //end flock for( int i=0; i<springList.size(); i++ ){ springList[i].draw(); } for( int i=0; i<jointList.size(); i++ ){ jointList[i].draw(); } }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetLogLevel(OF_LOG_NOTICE); // ofSetDataPathRoot("../Resources/data/"); // Load map objects from JSON file JsonLoader jsonLoader = JsonLoader("vectorTile_1.json"); rootNode = jsonLoader.loadNodeGraph(); rootNode->setPosition(0, 0, 0); rootNode->printPosition(""); // General graphics setup ofBackground(0, 0, 0); ofSetFrameRate(60); ofEnableDepthTest(); // Camera setup camera = ofEasyCam(); camera.setPosition(rootNode->getGlobalPosition()); camera.move(0, 0, 300); camera.setTarget(rootNode->getGlobalPosition()); // Lighting setup mainLight = ofLight(); mainLight.setPointLight(); mainLight.setGlobalPosition(-100, 0, 500); mainLight.setDiffuseColor(ofColor(35, 35, 35)); mainLight.setSpecularColor(ofColor(255)); ofLog(OF_LOG_VERBOSE, "Camera at " + ofToString(camera.getX()) + ", " + ofToString(camera.getY()) + ", " + ofToString(camera.getZ())); }
//-------------------------------------------------------------- void ofApp::setup(){ hideGui = false; pointLight = ofLight(); material = ofMaterial(); gui.setup(); gui.add(radius.setup("radius", 100, 10, 300)); gui.add(sphereResolution.setup("resolution", 5, 3, 90)); gui.add(sphereCenter.setup("center",ofVec3f(ofGetWidth()/2, ofGetHeight()/2, 0), ofVec3f(-ofGetWidth(), -ofGetHeight(), -100), ofVec3f(ofGetWidth(), ofGetHeight(), 100))); gui.add(lightPosition.setup("light position", ofVec3f(ofGetWidth()/2 + 100, ofGetWidth()/2 + 100, 500), ofVec3f(-ofGetWidth(), -ofGetHeight(), -500), ofVec3f(ofGetWidth(), ofGetHeight(), 500))); gui.add(diffuseLightColor.setup("diffuse light color", ofColor(100, 0), ofColor(0), ofColor(255))); gui.add(specularLightColor.setup("specular light color", ofColor(100), ofColor(0), ofColor(255))); gui.add(ambientLightColor.setup("ambient light color", ofColor(50, 50, 50), ofColor(0), ofColor(255))); gui.add(applyMaterial.setup("apply material", true)); gui.add(diffuseMaterialColor.setup("diffuse material color", ofColor(100), ofColor(0), ofColor(255))); gui.add(specularMaterialColor.setup("specular material color", ofColor(255), ofColor(0), ofColor(255))); gui.add(ambientMaterialColor.setup("ambient material color", ofColor(255), ofColor(0), ofColor(255))); //confirmed that this must be > 0 and <= 128 gui.add(shininess.setup("shininess", 50.0, 0.1, 128.0)); //this is part of the default constructor; pointLight.setPointLight(); }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(0, 0, 0); ofSetFrameRate(60); ofEnableDepthTest(); cam.setNearClip(0.0001f); cam.setFarClip(10000.0f); cam.toggleControl(); cam.setPosition(0, 0, 700); mainOffSetXPos = (ofGetWidth() - (baseArch.fassadeCorner[0].x + baseArch.fassadeCorner[1].x)) * 0.5; mainOffSetYPos = (ofGetHeight() - (baseArch.fassadeCorner[0].y + baseArch.fassadeCorner[3].y)) * 0.5; baseArch.mainOffSetXPos = mainOffSetXPos; baseArch.mainOffSetYPos = mainOffSetYPos; FeatureNode* _rootNode_33975_22294; JsonLoader _jsonLoader_33975_22294 = JsonLoader("OSMJSON.json"); _rootNode_33975_22294 = _jsonLoader_33975_22294.loadNodeGraph(); ofxJSONElement _jsonMain; _jsonMain = _jsonLoader_33975_22294.jsonRoot; ofxJSONElement _jsonBuildings; _jsonBuildings = _jsonMain["features"]; for (int i=0; i<_jsonBuildings.size(); i++) { string _way = _jsonBuildings[i]["id"].asString(); if (_way.at(0) == 'w') { ofxJSONElement _jsonBuilding; _jsonBuilding = _jsonBuildings[i]["geometry"]["coordinates"][0]; ofMesh _m; _m.setMode(OF_PRIMITIVE_LINE_LOOP); ofPolyline _pl; _pl.setClosed(false); _pl.begin(); string _polygon = _jsonBuildings[i]["geometry"]["type"].asString(); if (_polygon == "Polygon") { for (int j=0; j<_jsonBuilding.size(); j++) { ofxJSONElement _coordinateBuilding; _coordinateBuilding = _jsonBuilding[j]; ofVec2f _v; _v.x = _jsonLoader_33975_22294.lon2x(_coordinateBuilding[0].asFloat()) - 740603; _v.y = _jsonLoader_33975_22294.lat2y(_coordinateBuilding[1].asFloat()) - 6.40447e+06; _m.addVertex(_v); _m.addColor( ofColor(255) ); _pl.addVertex( _v ); } buildings_33975_22294.push_back( _m ); _pl.end(); buildingsPolyline_33975_22294.push_back(_pl); } } } ofxJSONElement _jsonRoads; _jsonRoads = _jsonMain["features"]; for (int i=0; i<_jsonRoads.size(); i++) { ofxJSONElement _jsonRoad; string _way = _jsonRoads[i]["id"].asString(); if (_way.at(0) == 'w') { ofMesh _m; _m.setMode(OF_PRIMITIVE_LINE_STRIP); ofPolyline _pl; string _LineString = _jsonRoads[i]["geometry"]["type"].asString(); if (_LineString == "LineString") { _jsonRoad = _jsonRoads[i]["geometry"]["coordinates"]; for (int j=0; j<_jsonRoad.size(); j++) { ofxJSONElement _coordinateRoad; _coordinateRoad = _jsonRoad[j]; ofVec2f _v; _v.x = _jsonLoader_33975_22294.lon2x(_jsonRoad[j][0].asFloat()) - 740603; _v.y = _jsonLoader_33975_22294.lat2y(_jsonRoad[j][1].asFloat()) - 6.40447e+06; _m.addVertex(_v); _m.addColor( ofColor(255) ); _pl.addVertex(_v); } roads_33975_22294.push_back( _m ); roadsPolyline_33975_22294.push_back( _pl ); } else { // _jsonRoad = _jsonRoads[i]["geometry"]["coordinates"][0]; // // for (int j=0; j<_jsonRoad.size(); j++) { // // ofxJSONElement _coordinateRoad; // _coordinateRoad = _jsonRoad[j]; // // ofVec2f _v; // _v.x = _jsonLoader_33975_22294.lon2x(_jsonRoad[j][0].asFloat()) - 740603; // _v.y = _jsonLoader_33975_22294.lat2y(_jsonRoad[j][1].asFloat()) - 6.40447e+06; // // _m.addVertex(_v); // _m.addColor( ofColor(255) ); // // _pl.addVertex(_v); // // } // // roads_33975_22294.push_back( _m ); // roadsPolyline_33975_22294.push_back( _pl ); } } } _rootNode_33975_22294->setPosition(0, 0, 0); _rootNode_33975_22294->printPosition(""); camera = ofEasyCam(); camera.setPosition(_rootNode_33975_22294->getGlobalPosition()); camera.move(0, 0, 300); camera.setTarget(_rootNode_33975_22294->getGlobalPosition()); mainLight = ofLight(); mainLight.setPointLight(); mainLight.setGlobalPosition(-100, 0, 500); mainLight.setDiffuseColor(ofColor(35, 35, 35)); mainLight.setSpecularColor(ofColor(170, 170, 170)); }
void ofApp::setup() { snapCounter = 0; bSnapshot = true; phase = 0; radius = 40; rotationRadius = 500; lightSource = ofLight(); lightSource.setPointLight(); lightSource.setAttenuation(0.15f, 0.0013f, 0.f); // setup colors ofColor colors[4] = { ofColor(255, 100, 100), ofColor(255, 255, 100), ofColor(255, 255, 255), ofColor(100, 100, 255) }; // randomly select a color from 0.0-1.0 float colorRatio = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); if (colorRatio > 0.666f) { lightColor = colors[2].getLerped(colors[3], (colorRatio-0.666f)/(1-0.666f)); } else if (colorRatio > 0.333f) { lightColor = colors[1].getLerped(colors[2], (colorRatio - 0.333f) / (0.666f - 0.333f)); } else{ lightColor = colors[0].getLerped(colors[1], colorRatio / (0.333f)); } lightSource.setDiffuseColor(ofColor(255,255,255)); lightSource.setSpecularColor(lightColor); lightSource.setPosition((cos(phase) * rotationRadius), 0, sin(phase) * rotationRadius); //material.setShininess(40); //material.setSpecularColor(lightColor); // setup stars int numStars = 200 + rand() % 200; for (int i = 0; i < numStars; i++) { float theta = (float)rand(); float phi = (float)rand(); stars.push_back(Star(theta, phi, 2 * rotationRadius, ofColor(255, 255, 255))); } // setup camera cameraTheta = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); cameraTheta = (0.5-cameraTheta)*(3.1415926535)*(.6); // -.6pi to .6pi range cameraPhi = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); cameraPhi = (0.5-cameraPhi)*(3.1415926535)*(0.5); //-0.2pi to 0.2pi range camera.setPosition(150*sin(cameraTheta), 150*sin(cameraPhi), 150*cos(cameraTheta)); camera.lookAt(ofVec3f(0.f,0.f,0.f)); // GL configs ofSetVerticalSync(true); ofEnableDepthTest(); ofSetSmoothLighting(true); ofSetSphereResolution(64); ofDisableArbTex(); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glLightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); // load texture imgIn.load(fname); texture = imgIn.getTexture(); glEnable(GL_DEPTH_TEST); quadric = gluNewQuadric(); // Create A Pointer To The Quadric Object gluQuadricTexture(quadric, GL_TRUE); // Create Texture Coords gluQuadricNormals(quadric, GLU_SMOOTH); // Create Smooth Normals }