Nonuniform Scaling

Started by jtxx000, July 03, 2003, 06:49:49 PM

Previous topic - Next topic

jtxx000

Is there a way to scale an object differently along different axises?

EgonOlsen

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".

jtxx000


stormp

If you ever get the time, this would be a nice feature ^_^

Thanks.

gargleblaster

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!

EgonOlsen

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.

AGP

I do it all the time by writing a VertexController like so:


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() {}
}