jPCT - a 3d engine for Java => Support => Topic started by: jtxx000 on July 03, 2003, 06:49:49 pm

Title: Nonuniform Scaling
Post by: jtxx000 on July 03, 2003, 06:49:49 pm
Is there a way to scale an object differently along different axises?
Title: Nonuniform Scaling
Post by: EgonOlsen 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".
Title: Nonuniform Scaling
Post by: jtxx000 on July 05, 2003, 06:33:30 pm
Title: Re: Nonuniform Scaling
Post by: stormp on June 23, 2007, 10:33:44 pm
If you ever get the time, this would be a nice feature ^_^

Title: Re: Nonuniform Scaling
Post by: gargleblaster 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?

Title: Re: Nonuniform Scaling
Post by: EgonOlsen 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.
Title: Re: Nonuniform Scaling
Post by: AGP 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;
    public void apply() {}