Jump to content

Recommended Posts

Posted (edited)

Hey, I've been recently playing a lot with TRSRTransformation class and I realized that it could probably be easier to use a builder for it rather than passing a million arguments (I know it's just 4, but it looks neater).

Let me show you what I mean.

 

First, a few arguments why I even created a TRSR Util class:

1) I didn't know that there were cornerToCenter and centerToCorner methods and at first, they confused me since any rotation I do happens around the center of the block. (I think the majority of modders want it like that).

2) Quaternions. I don't think anybody uses quaternions to in their head to picture a rotation. I know that there are static methods in the TRSRTransformation class to get a quaternion from XYZ degrees, but that makes a horrible mess.

3) Readability. Tell me what is easier to read:

    

TRSRTransformation tr = new TRSRTransformation(new Vector3f(0, 10F, 0), new Quat4f(0, 0.125F, 1, 0), new Vector3f(1, 1.25F, 1), null);

VS

TRSRTransformation tr = new TRSRTransformation.Builder()
	.translate(0.125F, 0, 0)
	.rotate(0, 90, 0)
	.scale(2, 2, 2)
	.postRotate(90, 0, 0)
	.build()

 

You could even specify in the Builder's constructor if you want to use the corner or center version as a boolean variable (true - center, false - corner).

 

And then, the Builder would do all the messy work, while you would just move on with your life. I can even provide a working Builder class I made myself if you all think that this would be a great addition, no matter how small it is, it would help modders a lot.

Edited by TheTrollguy_
Spelling mistakes
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.