Package wolf.city.road

Examples of wolf.city.road.Intersection


      Coordinate startPoint = new Coordinate(x,y);
      double angle = Math.toDegrees(Angle.angle(startPoint, new Coordinate(0,0)));
      Turtle t = new Turtle(startPoint, angle);
      //t.turn(45);
      t.move(32);
      roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
    }
    int highwayCount = Math.max((city.sizeX*2+city.sizeY*2)/(3*1024),1);
    for(int i=0; i<highwayCount; i++){
      //highway from random side
      int direction = Math.abs(city.random.nextInt()%4);
      float length = 128;
      switch(direction){
      case 0:{ //North
        log.log("Highway from the north");
        float x = (float) ((this.city.random.nextFloat()-.5)*city.sizeX); //can place in center half of city
        Coordinate startPoint = new Coordinate(x, city.sizeY/2);
        Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+270);
        t.move(length);
        roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
        break;
      }
      case 1:{ //South
        log.log("Highway from the south");
        float x = (float) ((this.city.random.nextFloat()-.5)*city.sizeX); //can place in center half of city
        Coordinate startPoint = new Coordinate(x, -city.sizeY/2);
        Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+90);
        t.move(length);
        roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
        break;
      }
      case 2:{ //East
        log.log("Highway from the east");
        float y = (float) ((this.city.random.nextFloat()-.5)*city.sizeY);
        Coordinate startPoint = new Coordinate(-city.sizeX/2, y);
        Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+0);
        t.move(length);
        roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
        break;
      }
      case 3:{ //West
        log.log("Highway from the west");
        float y = (float) ((this.city.random.nextFloat()-.5)*city.sizeY);
        Coordinate startPoint = new Coordinate(city.sizeX/2, y);
        Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+180);
        t.move(length);
        roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
        break;
      }
      default:{
        System.out.println("You done goofed. Check the seedRoadMap function's direction variable");
      }
View Full Code Here


  @Override
  public void asOBJ(OBJ obj) {
    obj.startObject("roads");
   
    for(int i=0; i<Intersection.intersections.size(); i++){
      Intersection is = Intersection.intersections.get(i);
      if(is.connecting.size() > 1){ //if there is more than one road to make an intersection out of
        ArrayList<LineSegment> segments0 = new ArrayList<LineSegment>();
        ArrayList<LineSegment> segments1 = new ArrayList<LineSegment>();
        //compute intersection points and max radius of roads (minimum value for roadExtrusion value)
        double maxRadius = 0;
View Full Code Here

      //render intersections
      GL11.glPointSize(5);
      GL11.glBegin(GL11.GL_POINTS);
      GL11.glColor3f(1, 1, 0);
      for(int i=0; i<roads.size(); i++){
        Intersection a = roads.get(i).a;
        Coordinate p = a.pos;
        GL11.glVertex2d(p.x+c.sizeX/2,vSize-(p.y+c.sizeY/2));
      }
      }
      GL11.glEnd();
View Full Code Here

      s.executeUpdate("DROP TABLE IF EXISTS INTERSECTIONS;");
      s.executeUpdate("CREATE TABLE INTERSECTIONS (id, x, y, z);");

      PreparedStatement p = con.prepareStatement("INSERT INTO INTERSECTIONS VALUES (?, ?, ?, ?);");
      for(int i=0; i<Intersection.intersections.size(); i++){
        Intersection is = Intersection.intersections.get(i);
        p.setInt(1, is.id);
        p.setDouble(2, is.pos.x);
        p.setDouble(3, is.pos.y);
        p.setDouble(4, is.pos.z);
        p.addBatch();
View Full Code Here

      }

      t.angle = angle;
      t.move((float)roadLength);
     
      returnRoad = new Road(road.b, new Intersection(new Coordinate(t.pos)), nextRoadType, new Basic(c), road);
    }
    return returnRoad;
  }
View Full Code Here

      angle = RandomHelper.random(city.random.nextFloat(), 20, -20);
      nextRoadType = RoadType.HIGHWAY;
      double roadLength = Math.abs(Math.sin(Math.toRadians((previousAngle-angle)%360))*nextRoadLength); //sin approximates how long next road should be
      t.angle = angle;
      t.move((float)roadLength);
      returnRoad = new Road(road.b, new Intersection(new Coordinate(t.pos)), nextRoadType, this, road); //roads set to default should die.
    }else{
      returnRoad = new Road(road.b, new Intersection(bestPosition), nextRoadType, this, road); //roads set to default should die.
    }
    return returnRoad;
  }
View Full Code Here

    c = g.c;
  }
  @Override
  public Road globalGoals(City city, Road road, Direction d) {
    double previousAngle = Math.toDegrees(Angle.angle(road.a.pos, road.b.pos));
    Road r = new Road(road.b, new Intersection(road.b.pos), RoadType.STREET, this, road);
    Turtle t;
    if(road.getType() == RoadType.HIGHWAY){// || road.type == RoadType.MAIN){
      t = new Turtle(r.a.pos, previousAngle);
    }else{
      double angle = (Math.floor((previousAngle+45)/90)*90+direction);
 
View Full Code Here

  private City c;
  private Road testedRoad;
 
  public LCPanel(){
    roads = new LinkedList<Road>();
    testRoad = new Road(new Intersection(new Coordinate(10,100)),new Intersection(new Coordinate(400,400)), RoadType.HIGHWAY, null);
    roads.add(new Road(new Intersection(new Coordinate(100,10)),new Intersection(new Coordinate(400,300)), RoadType.HIGHWAY, null));
    roads.add(new Road(new Intersection(new Coordinate(50,25)),new Intersection(new Coordinate(400,200)), RoadType.HIGHWAY, null));
    c = new City(windowHeight*4, windowHeight*4, 0);
    rm = new Roadmap(c);
    for(Road r: roads){
      rm.roads.insert(r.getEnvelope(), r);
    }
View Full Code Here


  public Intersection getNearestIntersection(){
   
    double closestDistance = 25; //25 is largest distance to snap to
    Intersection closest = null;
   
    for(int i=0;i<roads.size();i++){
      if(roads.get(i).a.pos.distance(mouseLoc)<closestDistance) closest = roads.get(i).a;
      if(roads.get(i).b.pos.distance(mouseLoc)<closestDistance) closest = roads.get(i).b;
    }
View Full Code Here

TOP

Related Classes of wolf.city.road.Intersection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.