Advertisement
itblanco

drawingApp

Jun 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. import wblut.hemesh.*;
  2. import wblut.processing.*;
  3. import wblut.geom.*;
  4. import java.util.*;
  5. import peasy.*;
  6.  
  7. HE_Mesh mesh;
  8. WB_Render render;
  9.  
  10. PeasyCam cam;
  11. List<WB_Segment> contour = new ArrayList<WB_Segment>();
  12. WB_Plane pln = new WB_Plane(0, 0, 0, 0, 0, 1);
  13.  
  14. void setup() {
  15.   size(500, 900, P3D);
  16.   //cam = new PeasyCam(this, 500);
  17.   render = new WB_Render(this);
  18.   ortho();
  19.   createMesh();
  20.   pln = new WB_Plane(0, 0, plnZ, 0, 0, 1);
  21. }
  22.  
  23. void draw() {
  24.   background(0);
  25.   contour = HET_Contours.contours(mesh, pln);
  26.   stroke(255);
  27.   strokeWeight(10);
  28.   strokeJoin(ROUND);
  29.   strokeCap(ROUND);
  30.   render.drawSegment(contour);
  31.   //noStroke();
  32.   //render.drawFaces(mesh);
  33.   //strokeWeight(1);
  34.   //stroke(0);
  35.   //render.drawEdges(mesh);
  36. }
  37.  
  38. void createMesh() {
  39.   HEC_Creator creator = new HEC_FromOBJFile("C:/Users/it/Desktop/vanaVenturi.obj");
  40.   mesh = new HE_Mesh(creator);
  41.   mesh.scaleSelf(0.7);
  42.   mesh.moveToSelf(meshLoc);
  43. }
  44.  
  45. float plnZ = -20;
  46.  
  47. void keyPressed() {
  48.   if (key == 'w') {
  49.     plnZ--;
  50.     pln = new WB_Plane(0, 0, plnZ, 0, 0, 1);
  51.   }
  52.   if (key == 's') {
  53.     plnZ++;
  54.     pln = new WB_Plane(0, 0, plnZ, 0, 0, 1);
  55.   }
  56.   if (key == 'a') {
  57.     mesh.scaleSelf(1.1);
  58.   }
  59.   if (key == 'd') {
  60.     mesh.scaleSelf(0.9);
  61.   }
  62. }
  63.  
  64. WB_Vector meshLoc = new WB_Vector(width/2, height/2, 0);
  65. void mouseDragged() {
  66.   if (mouseButton == RIGHT) {
  67.     WB_Vector mouse = new WB_Vector(mouseX-width/2, mouseY-height/2, 0);
  68.     WB_Vector pmouse = new WB_Vector(pmouseX-width/2, pmouseY-height/2, 0);
  69.     WB_Vector diff = WB_Vector.sub(mouse, pmouse);
  70.     meshLoc.addSelf(diff);
  71.     mesh.moveToSelf(meshLoc);
  72.   }
  73.   if (mouseButton == LEFT) {
  74.     WB_Vector mouse = new WB_Vector(mouseX-width/2, mouseY-height/2, 0);
  75.     WB_Vector pmouse = new WB_Vector(pmouseX-width/2, pmouseY-height/2, 0);
  76.     WB_Vector diff = WB_Vector.sub(mouse, pmouse);
  77.     mesh.rotateAboutCenterSelf(diff.getLength()*0.001, diff);
  78.   }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement