Loading...
Logo
Processing Forum
hello
newbie to the library and in general... patience required here

im trying to rotate a box (for example) created by hemesh library.
the normal rotation command does change its appearance, but not the real coordinates so that if i check for an
intersection with another box after the rotation - the result stays the same.
I beleive the WB_Transform class should do that, but i don't understand how to use it - 
could someone assist? current code attached

many thanks


import processing.opengl.*;

import peasy.*;
PeasyCam pcam;

import wblut.hemesh.modifiers.*;
import wblut.geom.frame.*;
import wblut.hemesh.composite.*;
import wblut.core.processing.*;
import wblut.hemesh.tools.*;
import wblut.hemesh.simplifiers.*;
import wblut.hemesh.subdividors.*;
import wblut.geom.nurbs.*;
import wblut.core.random.*;
import wblut.geom.triangulate.*;
import wblut.hemesh.creators.*;
import wblut.geom.tree.*;
import wblut.hemesh.core.*;
import wblut.geom.grid.*;
import wblut.core.structures.*;
import wblut.core.math.*;
import wblut.geom.core.*;

WB_Render render;
WB_AABB a = new WB_AABB(0,0,0,250,250,50);
WB_AABB b = new WB_AABB(250,250,0,500,500,50);
WB_Transform t = new WB_Transform();

void setup() {
  size (600,600,OPENGL);
  render = new WB_Render(this);
  
  pcam = new PeasyCam (this, 100);
  pcam.lookAt (100,0,300,1000,1);     //(look x, look y, look z, zoom, time to target);
}

void draw() {
  background (185);
  directionalLight(255, 255, 255, 1, 1, -1);
  directionalLight(127, 127, 127, -1, -1, 1);
  drawAxis();
  
  //t.addRotateX(30);
   fill(0,0,0,50);
  // a.apply(t);
  fill (0);
  render.draw(a);

  //rotate(PI/2);
  fill (10,190,30);
  render.draw(b);
  //rotate (-PI/2);
  println(a.checkIntersection(b));
}


void drawAxis() {
  stroke(#F52C2C);        //x is red
  line (0,0,0,1000,0,0);
  stroke(#8CF52C);       //y is green
  line (0,0,0,0,1000,0);
  stroke(#615DFF);       //z is blue
  line (0,0,0,0,0,1000);
}
  



Replies(2)

Hi, where to start...

First of, a WB_AABB is not a mesh, it's an axis-aligned box used for collision checks and such. Check the examples included in the distribution to create a mesh(e.g. HEC_Box). You might need to remove all imports and reimport the hemesh library to get the examples working properly.

Secondly, the Processing command rotate only changes the viewpoint in Processing, it doesn't change the actual geometry. Besides, rotating an axis-aligned box makes no sense, it' axis-aligned ;)

Once you have a mesh you can rotate it by using mesh.rotateAboutAxis(angle,origin.x,origin.y,origin.z,through.x,through.y,through.z)

angle = angle to rotate in radians
origin.x,y,z = coordinates of rotation axis origin
through.x,y,z = coordinaties of second point on rotation axis

Have fun!

Frederik

hey Frederik - 

thanks for the reply. got the part of moving to mesh from WB / HEC by now...
what I dont understand is this:
as WB_Intersection is only possible for WB_AABB / Sphere 3d bodies, how could you check for intersections on more complicated bodies?
ive managed to use the WB_SimpleMesh for instance, but than again if Im not using boxs, I can't check for no intersection between them.
and even more: as creating advanced meshes is easyer with the HEC, how do you take them to WB doing those collision checks etc? 

hope you find the time to answer, problem is a I can't seem to find enough implementation examples of the library.

best,

noam