Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - pakotbkr

#1
Support / How to scale one object over another?
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

//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);