1
Support / Fitting an object inside the screen.
« on: August 20, 2020, 07:33:55 am »
Hello once again!!
In my app I will most probably have only one object on screen at a time. But that object may not be the same object every time like it can be a car, a chair, or something else like that.
Now the problem is those object may not have same size. But I want them to fit inside the screen.
I am able to get the realworld size of the object by using following function. Also I can get the screen resolution. But I dont know how to make relationship between them so that I can scale them accordingly.
Thank you..
In my app I will most probably have only one object on screen at a time. But that object may not be the same object every time like it can be a car, a chair, or something else like that.
Now the problem is those object may not have same size. But I want them to fit inside the screen.
I am able to get the realworld size of the object by using following function. Also I can get the screen resolution. But I dont know how to make relationship between them so that I can scale them accordingly.
Code: [Select]
public static SimpleVector getSize(Object3D object){
float[] bbox = object.getMesh().getBoundingBox();
Log.i("Util","getSize-bbox:"+bbox);
float s = object.getScale();
Log.i("Util","getSize-scale:"+object.getScale());
Object3D[] par;
par = object.getParents();
while(par.length>0){
s = s*par[0].getScale();
Log.i("Util","getSize-parent:"+par[0].getScale());
par = par[0].getParents();
}
SimpleVector out = new SimpleVector((bbox[1]-bbox[0])*s,(bbox[3]-bbox[2])*s,(bbox[5]-bbox[4])*s);
Log.i("Util", "getSize:"+out.toString());
return out;
}
Thank you..