Package org.nlogo.api

Examples of org.nlogo.api.World3D


  }

  @Override
  void setClippingPlanes(GL gl) {
    super.setClippingPlanes(gl);
    World3D w = (World3D) world;

    // don't clip in the z-direction with 2D models.
    if (w.worldDepth() > 1) {
      // offset the planes ever so slightly so they don't cut off the tops of the patches
      renderClippingPlane
          (gl, new double[]
              {0.0f, 0.0, 1.0f, (float) (-(w.minPzcor() - 0.5) * WORLD_SCALE) + 0.01f},
              GL.GL_CLIP_PLANE4);
      renderClippingPlane
          (gl, new double[]
              {0.0, 0.0, -1.0, (float) ((w.maxPzcor() + 0.5) * WORLD_SCALE) + 0.01f},
              GL.GL_CLIP_PLANE5);
    }
  }
View Full Code Here


    // worldRenderer.renderDrawing( gl ) ;
  }

  @Override
  public void translateWorld(GL gl, World world) {
    World3D w = (World3D) world;

    gl.glTranslated
        (((world.maxPxcor() + world.minPxcor()) / 2.0) * Renderer.WORLD_SCALE,
            ((world.maxPycor() + world.minPycor()) / 2.0) * Renderer.WORLD_SCALE,
            ((w.maxPzcor() + w.minPzcor()) / 2.0) * Renderer.WORLD_SCALE);
  }
View Full Code Here

  void pickPatches(List<Agent> agents, double[][] ray) {
    if (agents == null) {
      return;
    }

    World3D w = (World3D) world;

    // detect any patches in the pick-ray ( ( Renderer.WORLD_SCALE / 2 )
    // is the offset of the patches plane in the z-axis - jrn)
    double scale = (1 / WORLD_SCALE);
    double deltaz = Math.abs(ray[0][2] - ray[1][2]);
    double deltay = Math.abs(ray[0][1] - ray[1][1]);
    double deltax = Math.abs(ray[0][0] - ray[1][0]);

    double xi = ray[0][0] * scale;
    double yi = ray[0][1] * scale;
    double zi = ray[0][2] * scale;
    double xinc = 0;
    double yinc = 0;
    double zinc = 0;
    double t = 0;
    double min = 0;
    double max = 0;

    if (deltaz >= deltay && deltaz >= deltax) {
      zinc = 1;
      t = 1 / (ray[1][2] - ray[0][2]);
      xinc = (ray[1][0] - ray[0][0]) * t;
      yinc = (ray[1][1] - ray[0][1]) * t;
      min = w.minPzcor();
      max = w.maxPzcor();
      zi = min;
      xi -= xinc * ray[0][2] * scale - (min * xinc);
      yi -= yinc * ray[0][2] * scale - (min * yinc);
    } else if (deltay >= deltax) {
      yinc = 1;
      t = 1 / (ray[1][1] - ray[0][1]);
      xinc = (ray[1][0] - ray[0][0]) * t;
      zinc = (ray[1][2] - ray[0][2]) * t;
      min = w.minPycor();
      max = w.maxPycor();
      yi = min;
      xi -= xinc * ray[0][1] * scale - (min * xinc);
      zi -= zinc * ray[0][1] * scale - (min * zinc);
    } else {
      xinc = 1;
      t = -1 / (ray[0][0] - ray[1][0]);
      yinc = (ray[1][1] - ray[0][1]) * t;
      zinc = (ray[1][2] - ray[0][2]) * t;
      min = w.minPxcor();
      max = w.maxPxcor();
      xi = min;
      yi -= yinc * ray[0][0] * scale - (min * yinc);
      zi -= zinc * ray[0][0] * scale - (min * zinc);
    }

    for (double c = min; c <= max; c++) {
      double x = xi;
      double y = yi;
      double z = zi;

      if ((x < world.maxPxcor() + 0.5) && (x >= world.minPxcor() - 0.5) &&
          (y < world.maxPycor() + 0.5) && (y >= world.minPycor() - 0.5) &&
          (z < w.maxPzcor() + 0.5) && (z >= w.minPzcor() - 0.5)) {
        try {
          agents.add(w.getPatchAt(wrapX(x + w.followOffsetX()),
              wrapY(y + w.followOffsetY()),
              wrapZ(z + w.followOffsetZ())));
        } catch (AgentException e) {
          org.nlogo.util.Exceptions.ignore(e);
        }
      }
      xi += xinc;
View Full Code Here

TOP

Related Classes of org.nlogo.api.World3D

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.