Author Topic: Group Scale  (Read 3092 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Group Scale
« on: September 24, 2014, 05:41:20 pm »
Do you know what would most definitely be useful? Group stuff. For instance, a World.groupAll() method followed by a World.getGroup(...).scale(10f). Up until this latest build of jpct there was no real way of knowing the scale of your scene. I'm finding too many scenes are either too small or too large for their own good (shadows, for instance, get hurt from this). Anyway, it's just a suggestion.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Group Scale
« Reply #1 on: September 24, 2014, 08:54:21 pm »
I'm not sure what this is supposed to do...you can easily apply a scale on all objects of a world in maybe three lines of code. It this supposed to do anything different?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Group Scale
« Reply #2 on: September 24, 2014, 11:48:07 pm »
Yes, it scales them in place. As it is, if I were to increase both a set and a character, one would go right through the other. But not just scale, either, the title of the thread should have been "Group Stuff." Scaling, rotating, translating.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Group Scale
« Reply #3 on: September 25, 2014, 08:18:47 am »
I don't see the point. You can already build group by assigning objects to a common parent. Adding something similar to World is just replicating the same thing with different means.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Group Scale
« Reply #4 on: September 25, 2014, 06:55:27 pm »
Children don't get scaled along with their parents, and these groups would hold cameras, lights, and such. But alright.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Group Scale
« Reply #5 on: September 25, 2014, 08:33:34 pm »
That's would somehow make jPCT a scene graph engine through the back door. jPCT isn't meant to be a scene graph engine on purpose. If you want a container for cameras, lights and objects that belong to a virtual group, just use a World. Nothing prevents you from rendering multiple worlds into a scene. If you want to group objects in any other way, use parent/child relations. The only thing that remains is the scale. But if you really want this, just do something like

Code: [Select]
import java.util.Enumeration;

import com.threed.jpct.Object3D;
import com.threed.jpct.World;

public class ScalableWorld extends World {
public void scale(float value) {
for (@SuppressWarnings("unchecked")
Enumeration<Object3D> enny=this.getObjects(); enny.hasMoreElements();) {
enny.nextElement().setScale(value);
}
}
}


Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Group Scale
« Reply #6 on: September 25, 2014, 09:05:46 pm »
But again, won't that make things go through each other when scaling up and grow apart from each other when scaling down?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Group Scale
« Reply #7 on: September 25, 2014, 09:13:35 pm »
I think that i finally get what you actually meant... ;) Well, in that case, this should do it, at least for Object3Ds:

Code: [Select]
import java.util.Enumeration;

import com.threed.jpct.Object3D;
import com.threed.jpct.World;

public class ScalableWorld extends World {
public void scale(float value) {
for (@SuppressWarnings("unchecked")
Enumeration<Object3D> enny=this.getObjects(); enny.hasMoreElements();) {
                        Object3D obj=enny.nextElement();
obj.setScale(value);
                        SimpleVector t=obj.getTranslation();
                        obj.clearTranslation();
                        t.scalarMul(value);
                        obj.translate(t);
}
}
}

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Group Scale
« Reply #8 on: September 26, 2014, 09:24:37 pm »
That makes sense, thank you.