www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: neo187 on January 10, 2012, 01:20:19 am

Title: Resetting object scale: setScale/getScale discrepancy
Post by: neo187 on January 10, 2012, 01:20:19 am
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:

Code: [Select]
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
Title: Re: Resetting object scale: setScale/getScale discrepancy
Post by: EgonOlsen on January 10, 2012, 09:38:16 am
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.
Title: Re: Resetting object scale: setScale/getScale discrepancy
Post by: neo187 on January 10, 2012, 12:44:16 pm
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...?
Title: Re: Resetting object scale: setScale/getScale discrepancy
Post by: EgonOlsen on January 10, 2012, 04:47:38 pm
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:

Code: [Select]
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... ???