How to rescale a object3D to a desired size.

Started by Melssj5, May 07, 2006, 11:56:08 PM

Previous topic - Next topic

Melssj5

Hi, how can I resize an object3D to a specific size. I mean one method to let resize an object giving a parameter of size, for example Object3D.scaleUntilY(25f); to rescale to object until the Y size is 25f relative units.

It would be nice to have a method like that.
Nada por ahora

EgonOlsen

If i understand you correctly, this is something that your application should do, not the API. Because it's based on a time frame or whatever (i.e. how fast should be scaling happen). And about the how to of applying a none-uniform scale: You either have to do this using a VertexController or by manipulating the matrix yourself. There is a thread somewhere here about this topic IIRC.

Melssj5

Well, I need to load some md2 or 3DS person models, one at time, but I need it to fit so the camera looks it completly. I cant change the camera position so I need to rescale the object3d. in anyway I can do it manually, but I dont know how to get the y size of a model. I wa thinking on doing this.



while (Math.abs (Object3D.getYSize ()-desiredSize)<0.5) {
   if (Object3D.getYSize ()<desiredSize) Object3D.rescale (1.1f);
   else {
        Object3D.rescale (0.99f);
   }
}



But I dont know how to get the size of the Object3D.
Nada por ahora

EgonOlsen

If you have a desired target size and the current size you may simply calculate the scaling needed. There's no need in doing this linear approximation you suggest. To get the size, you may get the bounding box from the Mesh of the Object3D and calculate the current dimensions from that (Math.abs(maxY-minY) for example).

eye1

Hello

Is it possible to scale object only by one koordinate x,y,z

Thanks

Melssj5

Once you have get the actual size of a coordinate dimension you can do it, because you just must specify a proporcional size. the scalation is make conserving the original shape, so getting the relationship between actual x and desired x is the same of actual y with the desired y.

Now if you mean just making a kind of extrude to just ine face, i guess that that was answered on a recently post somethere.
Nada por ahora


Melssj5

No, I said that was recently, that was ansered 3 years ago.

But is not an easy way to extrude object fces or things like that, you must manually modify the shape or something like that. Let me find the post for you. Anyway I guess that Egon could answer this not me.

I cant find the post, just wait until Egon answer this.
Nada por ahora

EgonOlsen

Yes, you can manually modify the rotation matrix to include the desired scaling. It's a bit hacky but has been done before. But like Melssj5, i can't find the damn thread...i have no clue how it was called or what the keywords were. But it IS here somewhere...

eye1


EgonOlsen

Me too. But it HAS to be here somewhere...it must have a silly topic so that nobody can find it.

eye1

Quote from: "radvani7"
The custom scaling worked out very well; I just multiplied a single-axis scale matrix with the rotation matrix, and set that composite matrix as the Object's rotation matrix.

Since I don't use the build-in scaling it doesn't cause any problems there!

is that it?

http://www.jpct.net/forum/viewtopic.php?t=341

eye1

single-axis scale matrix... can anyone tell me how to get it?

i can get only translate matrix and rotation matrix from Object3D

EgonOlsen

You have to manipulate the rotation matrix yourself to do this. X-scaling is at 0,0, y at 1,1 z at 2,2. But i'm still not sure that this won't interfere with some stuff deep inside the engine itself.

eye1

     Matrix rot = object.getRotationMatrix();
     float[] dump = rot.getDump();
     dump[0] = trackLength;
     rot.setDump(dump);
     object.setRotationMatrix(rot);


This code scaled object by x axis :)

4 now i didn't found any problem.

I'm wondering if there is a way to limit which properties are inherited by child of parent object?