项目作者: obsa-and

项目描述 :
Display projection into a 3D surface in Processing
高级语言: Processing
项目地址: git://github.com/obsa-and/proj3D.git
创建时间: 2017-07-18T09:28:54Z
项目社区:https://github.com/obsa-and/proj3D

开源协议:MIT License

下载


proj3D

Display projection into a 3D surface in Processing

Adjusting images projected from a beamer into a surface needs some perspective parametrization. A great option in Processing is using Keystone library by @davidbouchard. However, this does not work when the surface to project on is irregular, where more options are needed to adjust control points and adapt them to the surface.

Getting started

Create surface object that will allow to deform all its control points, and provide its vertices coordinates

  1. final LatLon[] ROI = new LatLon[] {
  2. new LatLon(42.505085,1.509961),
  3. new LatLon(42.517067,1.544024),
  4. new LatLon(42.508160,1.549798),
  5. new LatLon(42.496162,1.515728)
  6. };
  7. WarpSurface surface = new WarpSurface(this, 700, 300, 20, 10, ROI);

Create a canvas object to draw into and that will be used as the surface texture. Canvas must have defined its bounds coordinates, so the surface will select the area inside the Region of Interest

  1. final LatLon[] bounds = new LatLon[] {
  2. new LatLon(42.5181, 1.50803),
  3. new LatLon(42.495, 1.50803),
  4. new LatLon(42.495, 1.55216),
  5. new LatLon(42.5181, 1.55216)
  6. };
  7. WarpCanvas canvas = new WarpCanvas(this, 500, 300, bounds);

Draw into canvas as it would be done into any PGraphics object.

  1. canvas.beginDraw();
  2. canvas.background(0);
  3. canvas.fill(#FF0000);
  4. canvas.noStroke();
  5. canvas.ellipse(mouseX, mouseY, 5, 5);
  6. canvas.endDraw();

Apply the canvas into the surface

  1. surface.draw(canvas);

Mapping from (lat,lon) location to (x,y) screen position and vice versa is possible through the given methods. If screen position or geographic location don’t belong to surface, null value is returned

  1. PVector position = surface.mapPoint(42.246543, 1.568294);
  2. LatLon location = surface.unmapPoint(mouseX, mouseY);

The WarpSurface is observable and returns the location of the clicked point (if the point is inside the surface’s borders) to any class implementing the Observer interface that is observing it.

Licensing

This project is licensed under the terms of the MIT license