A call for cuboids (a.k.a. rectangles)

Started by LeoMaheo, March 22, 2009, 10:21:41 PM

Previous topic - Next topic

LeoMaheo

Hi!

I use JBullet to simulate walking ragdolls. Their body parts are cuboids.

I wish jPCT provided "native" cuboid support.
(Axis aligned cuboids I'd suggest :-))

(To some people: Some people refer to cuboids as rectangles.
Rectangles are however 2 dimensional and cuboids 3 dimensional.)

Kind regards,
Magnus


LeoMaheo

But isn't then width = depth? I don't want that.
(Perhaps I can modify the rotation matrix so it stretches the box?)

EgonOlsen

#3
Quote from: LeoMaheo on March 22, 2009, 10:28:34 PM
But isn't then width = depth? I don't want that.
(Perhaps I can modify the rotation matrix so it stretches the box?)
Yes, that's true. You can modify the rotation matrix on your own to flatten the box, apply a rotateMesh() and reset the matrix. That should give you the desired 3d-rectangle.

Edit: Or just write your own cuboid-method...it shouldn't be too hard and it ensures that the cubs are really axis-aligned (i'm not sure that jPCT's lathe boxes are...).

Edit_2: Don't get me wrong. I'm not against adding this or something, but i'm busy right now with other things. So if you don't want to wait, you may be better off writing your own method. If you want to post it and it fits, i would be more than happy to add it to jPCT.

LeoMaheo

Now I've modified the rotation matrix to scale a cube into a cuboid. Below code works for me.

(I currently use no textures though;
perhaps texture coordinates are affected in some (inappropriate) manner. (?))

Thanks Egon for your quick reply :-)


box = Primitives.getCube(1f);
box.rotateY(Util.PI / 4); // cancel jPCT's default rotation around Y
Matrix scaler = new Matrix();
scaler.setDump(new float[]{
halfExtents.x, 0, 0, 0,
0, halfExtents.y, 0, 0,
0, 0, halfExtents.z, 0,
0, 0, 0, 1 });
box.getRotationMatrix().matMul(scaler);
box.rotateMesh();
box.build();
// Reset rotation matrix so above scaling is not applied twice:
box.getRotationMatrix().setIdentity();


EgonOlsen

Quote from: LeoMaheo on March 23, 2009, 04:40:10 AM
(I currently use no textures though;
perhaps texture coordinates are affected in some (inappropriate) manner. (?))
The lathe objects that Primitives creates (except for the plane...) have no texture coordinates anyway... ;)