Author Topic: Nonuniform Scaling  (Read 7324 times)

Offline jtxx000

  • byte
  • *
  • Posts: 13
    • View Profile
Nonuniform Scaling
« on: July 03, 2003, 06:49:49 pm »
Is there a way to scale an object differently along different axises?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Nonuniform Scaling
« Reply #1 on: July 04, 2003, 12:15:45 am »
No...and yes...jPCT's standard scaling behaviour doesn't allow this. The reason for this is, that jPCT doesn't really use a scaling matrix but a virtual scaling matrix with sx=sy=sz=s. The easiest way to explain this quite strange behaviour is: "historical reasons"... :D
This may not satisfy you and i understand that. But i don't think that i'll break the current implementation to add support for non-uniform scaling.
However, jPCT 0.90 features support for what i've called "VertexController"s. So you may write yourself a VertexController that does the non-uniform scaling for you...should be quite easy to do once you got the concept of the VertexControllers. This is NOT an ideal solution...i know that. Anyway, it's the only way to do it ATM. Maybe i'll think about adding a real non-uniform scaling later if it's really important to you and you can't live with the "Controller-solution".

Offline jtxx000

  • byte
  • *
  • Posts: 13
    • View Profile
Nonuniform Scaling
« Reply #2 on: July 05, 2003, 06:33:30 pm »
Thanks

Offline stormp

  • byte
  • *
  • Posts: 38
    • View Profile
Re: Nonuniform Scaling
« Reply #3 on: June 23, 2007, 10:33:44 pm »
If you ever get the time, this would be a nice feature ^_^

Thanks.

Offline gargleblaster

  • byte
  • *
  • Posts: 1
    • View Profile
Re: Nonuniform Scaling
« Reply #4 on: September 12, 2009, 12:19:57 am »
Is this still the case?  I would like to create regtangular prisms with independent width, height, and depth.  Is it impossible to scale a cube independently along three axes?  What is the best alternative?

Thanks!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Nonuniform Scaling
« Reply #5 on: September 13, 2009, 09:08:01 am »
Yes, this is still the case. You can modify the rotation matrix by hand to work around this. There are some threads in the forum dealing with this, i just can't find one ATM... ??? This has the drawback, that the lighting intensity changes because the normals will be scaled too. A solution to this is to make the rotation, i.e. the scaling, permanent by using rotateMesh() on the object and reset the rotation matrix afterwards.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Nonuniform Scaling
« Reply #6 on: September 15, 2009, 09:53:37 pm »
I do it all the time by writing a VertexController like so:

Code: [Select]
class VertexController extends GenericVertexController {
    public VertexController(Object3D toCheck) {
super.init(toCheck.getMesh(), true);
    }

    protected void scale(SimpleVector scale) {
SimpleVector[] vertices = getSourceMesh();
SimpleVector[] destination = getDestinationMesh();
for (int i = 0; i < vertices.length; i++) {
    vertices[i].x *= scale.x;
    vertices[i].y *= scale.y;
    vertices[i].z *= scale.z;
    destination[i].x = vertices[i].x;
    destination[i].y = vertices[i].y;
    destination[i].z = vertices[i].z;
}
this.updateMesh();
    }
    public void apply() {}
}