www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Melssj5 on May 07, 2006, 11:56:08 pm

Title: How to rescale a object3D to a desired size.
Post by: Melssj5 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.
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen 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.
Title: How to rescale a object3D to a desired size.
Post by: Melssj5 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.
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen 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).
Title: How to rescale a object3D to a desired size.
Post by: eye1 on October 04, 2006, 04:45:23 pm
Hello

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

Thanks
Title: How to rescale a object3D to a desired size.
Post by: Melssj5 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.
Title: How to rescale a object3D to a desired size.
Post by: eye1 on October 04, 2006, 05:07:37 pm
http://www.jpct.net/forum/viewtopic.php?t=59&start=0&postdays=0&postorder=asc&highlight=scale

is this still the only solution :?:
Title: How to rescale a object3D to a desired size.
Post by: Melssj5 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.
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen 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...
Title: How to rescale a object3D to a desired size.
Post by: eye1 on December 11, 2006, 04:59:55 pm
I still haven't found the thread :(
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen 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.
Title: How to rescale a object3D to a desired size.
Post by: eye1 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
Title: How to rescale a object3D to a desired size.
Post by: eye1 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
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen 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.
Title: How to rescale a object3D to a desired size.
Post by: eye1 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?
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen on January 04, 2007, 05:46:49 pm
No, there isn't. If you want some things not to be set, reset them after cloning. About the scale-thing: As long as it works, all is fine!
Title: How to rescale a object3D to a desired size.
Post by: eye1 on January 05, 2007, 04:03:30 pm
Another question?

When I merge two objects into one. How do I position them before merging them?
Title: How to rescale a object3D to a desired size.
Post by: EgonOlsen on January 05, 2007, 05:15:21 pm
Merging in done in object space, so transformations in world space don't apply here. If you need an offset, you have to make the translation permanent in object space by using Object3D.translateMesh();