Author Topic: How to rescale a object3D to a desired size.  (Read 7733 times)

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
How to rescale a object3D to a desired size.
« on: May 07, 2006, 11:56:08 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
How to rescale a object3D to a desired size.
« Reply #1 on: May 08, 2006, 06:39:24 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
How to rescale a object3D to a desired size.
« Reply #2 on: May 09, 2006, 04:56:20 pm »
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.

Code: [Select]


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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
How to rescale a object3D to a desired size.
« Reply #3 on: May 09, 2006, 06:58:01 pm »
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).

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
How to rescale a object3D to a desired size.
« Reply #4 on: October 04, 2006, 04:45:23 pm »
Hello

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

Thanks

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
How to rescale a object3D to a desired size.
« Reply #5 on: October 04, 2006, 04:55:45 pm »
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

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
How to rescale a object3D to a desired size.
« Reply #7 on: October 04, 2006, 05:37:44 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
How to rescale a object3D to a desired size.
« Reply #8 on: October 17, 2006, 12:32:12 pm »
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...

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
How to rescale a object3D to a desired size.
« Reply #9 on: December 11, 2006, 04:59:55 pm »
I still haven't found the thread :(

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
How to rescale a object3D to a desired size.
« Reply #10 on: December 12, 2006, 09:42:59 pm »
Me too. But it HAS to be here somewhere...it must have a silly topic so that nobody can find it.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
How to rescale a object3D to a desired size.
« Reply #11 on: December 13, 2006, 12:14:24 pm »
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

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
How to rescale a object3D to a desired size.
« Reply #12 on: December 28, 2006, 02:33:56 pm »
single-axis scale matrix... can anyone tell me how to get it?

i can get only translate matrix and rotation matrix from Object3D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
How to rescale a object3D to a desired size.
« Reply #13 on: December 30, 2006, 03:41:23 pm »
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.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
How to rescale a object3D to a desired size.
« Reply #14 on: January 04, 2007, 04:56:19 pm »
Code: [Select]
     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?