Example #1
0
//--------------------------------------------------------------
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()));
}
Example #2
0
Radar::Radar() {
  debug = false;
  subdivisions = 10;
  point_count = 8;
  thetaRate = 1/150.0;
  axis_length = 220;

  x = 100;
  y = 0;
  w = 400;
  h = 400;
  alphaSub = 0;

  absolute_center = ofPoint(300,200);

  time = 0;
  minTheta = 0;
  maxTheta = 2;
  change_index = 3;

  thetaStep = 6.28/point_count;
  index_update_rate = thetaStep / thetaRate;

  radialSplineShader.setGeometryInputType(GL_LINES);
	radialSplineShader.setGeometryOutputType(GL_TRIANGLE_STRIP);
	radialSplineShader.setGeometryOutputCount(4);
  radialSplineShader.load("shadersGL3/lines.vert", "shadersGL3/radialFade.frag", "shadersGL3/lines.geom");
  axisShader.setGeometryInputType(GL_LINES);
	axisShader.setGeometryOutputType(GL_TRIANGLE_STRIP);
	axisShader.setGeometryOutputCount(4);
  axisShader.load("shadersGL3/lines.vert", "shadersGL3/null.frag", "shadersGL3/lines.geom");
//  axisShader.load("shadersGL3/null.vert", "shadersGL3/radialFade.frag");

  axisMesh = ofMesh();
  axisMesh.setMode(OF_PRIMITIVE_LINES);
  for (int i = 0; i < axis_length; i += 10) {
    axisMesh.addVertex(ofPoint(i,0));
  }

  init_aframe();

  cam = ofEasyCam();
  cam.setTarget(ofVec3f(0,0,0));
  cam.setDistance(600);

  if (!debug)
    cam.disableMouseInput();
}
Example #3
0
//--------------------------------------------------------------
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));
    
}