How to scale one object over another?

Started by pakotbkr, March 31, 2017, 02:38:24 PM

Previous topic - Next topic

pakotbkr

Hi, I want to use a cube as a transparent container and that all new objects that I add to the world, have the same size as this one

I tried to do it with setBoundingBox but it does not work for me

//Log.d("OBJECT3D", "estoy entrando");
cube = new Object3D(Primitives.getCube(1));
///////////////con un OBJ
try {
spider= Object3D.mergeAll(Loader.loadOBJ(mActivity.getModel3D(),mActivity.getMaterial3D(), 1f));
} catch (IOException e) {

e.printStackTrace();
}
cube.calcBoundingBox();
float[] bb=cube.getMesh().getBoundingBox();
    float xDiff=bb[1]-bb[0];
    float yDiff=bb[3]-bb[2];
    float zDiff=bb[5]-bb[4];
    float s=cube.getScale();
  SimpleVector out = new SimpleVector(xDiff*s,yDiff*s,zDiff*s);

//Log.d("OBJECT3D", "he pasado!");
cube.translate(0, 0, 10);
   
spider.calcBoundingBox();
    spider.setBoundingBox(bb[0], bb[1], bb[2], bb[3], bb[4], bb[5]);
   
    spider.setCenter(cube.getCenter());
   
    spider.build();
    spider.translate(0, 0, 10);
//cube.setTexture("tl");
world.addObject(spider);
world.addObject(cube);

light= new Light(world);
light.setIntensity(128, 128, 128);

EgonOlsen

The bounding box is calculated based on the object's geometry and not vice versa. So that won't work. I'm not sure what you actual problem is!? If you want boxes of the same size...why can't you just create boxes of, well, the same size? Am I missing something?