Author Topic: How to scale one object over another?  (Read 797 times)

Offline pakotbkr

  • byte
  • *
  • Posts: 1
    • View Profile
How to scale one object over another?
« on: March 31, 2017, 02:38:24 pm »
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
Code: [Select]
//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) {

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.setBoundingBox(bb[0], bb[1], bb[2], bb[3], bb[4], bb[5]);
    spider.translate(0, 0, 10);

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12094
    • View Profile
Re: How to scale one object over another?
« Reply #1 on: April 06, 2017, 12:30:51 pm »
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?