wblut/HE_Mesh

Planes facing each other

Closed this issue · 0 comments

Dear @wblut,

I would like to attach a mesh to another mesh based on face selection.

In the example below I am trying to move the mesh on the left close to the mesh on the right so as face n°6 touches face n°8 of the latter:

Annotation 2020-07-02 122858

At the moment I am applying a transformation to the mesh on the left using transformSelf combined with WB_Transform3D() but as you can see faces are not aligned:

Annotation 2020-07-02 123017

Using HE_Mesh, what would be the correct way to compute this kind of transformation while keeping the faces aligned ? (maybe using planes ?)

My code so far:

import wblut.processing.*;

HE_Mesh m1, m2;
PeasyCam cam;

WB_Render3D render;
void setup() {
  size(1000, 1000, P3D);
  perspective(60 * DEG_TO_RAD, width/float(height), 2, 6000);
  smooth(8);
  background(55); 
  render=new WB_Render3D(this);
  cam = new PeasyCam(this, 40);
  create();
}

void create() {

  m1 = new HE_Mesh(new HEC_FromOBJFile("C:/Users/solub/Desktop/m1.obj"));
  m2 = new HE_Mesh(new HEC_FromOBJFile("C:/Users/solub/Desktop/m2.obj"));
  WB_Transform3D T=new WB_Transform3D(m1.getFaceCenter(6), m1.getFaceNormal(6), m2.getFaceCenter(8), m2.getFaceNormal(8).mul(-1));
  m1.transformSelf(T);// or .applySelf(T)
}


void draw() {
  background(50);
  stroke(0);
  render.drawFaces(m1);
  render.drawFaces(m2);
}

obj files if necessary