Resetting object scale: setScale/getScale discrepancy

Started by neo187, January 10, 2012, 01:20:19 AM

Previous topic - Next topic

neo187

Hi Egon

I am not sure if this is a bug or whether I am doing something wrong. So I'd like to have an option in my program to reset all of the object's transformations. clearRotation and clearTranslation are already there, for the scale however there's no such option. Through testing I realised that the only way to get the object back to its original size is by calling setScale(0). By after that if you call .getScale() you still get the incremented scale value from before resetting.

So basically:


obj.scale(2f);
obj.setScale(0);
float s = obj.getScale()


would return 2, whereas I'd like it to be back to 1 so that when parsing the object information the object is not scaled incorrectly?

Thank you

EgonOlsen

setScale(0) doesn't reset anything. Actually, it should cause an error in the log and maybe (depending on the setting in Logger) an exception. If you want to reset the scale, setScale(1f) will do it.

neo187

Well setScale(0) does somehow seem to do the job visually, whereas setScale(1) seems to make the model bigger than it originally was..... And still even after setting the scale to one the getScale() method still returns the accumulated value? I have tried this a couple of times just to be sure...?

EgonOlsen

setScale(0) can't do the job. It will create an error/exception but scale nothing. I also can't reproduce the problem you seem to have. I tried this:


import com.threed.jpct.Object3D;

public class ScaleTest2 {

public static void main(String[] args) {
Object3D obj = new Object3D(1);
System.out.println("Should be 1: " + obj.getScale());
obj.scale(2);
System.out.println("Should be 2: " + obj.getScale());
obj.scale(3);
System.out.println("Should be 6: " + obj.getScale());
obj.setScale(1);
System.out.println("Should be 1: " + obj.getScale());
}
}



...and all is fine... ???