Jump to content

Recommended Posts

Posted

Good evening all,

 

I've been looking into block animation with the help of a Fast TESR, putting together a simple stone pillar rotating smoothly around its axis.

The underlying TileEntity has a speed value, which is supposed to affect the visual rotation speed of the model.

This is the relevant snippet of renderTileEntityFast() in its current state:

[...]

final BlockPos pos = te.getPos();
final IBlockState state = te.getBlockState();
float time = Animation.getWorldTime(getWorld(), partialTicks);
		
// Rotation matrix based on rotation speed
Matrix4f rot = new Matrix4f();
rot.setIdentity();
rot.rotY((float) ((time * speed % 360) * Math.PI / 180));
		
// Bake rotated model
TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(rot));
IBakedModel model = this.model.bake(modelGetter, textureGetter, transform, false, DefaultVertexFormats.BLOCK);
		
// Render it
buffer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockModelRenderer.renderModel(this.getWorld(), model, state, pos, buffer, true, new Random(), 42);

 

It's not far off, however the rotation doesn't quite work out the way you'd expect it to:

https://i.imgur.com/GXLP0Cn.gifv

It appears the faces are locked into being orthogonal to the main axes.

I would like to ask if anyone here has solved this with a Fast TESR before, knows a better way to approach this, or knows of a good place to look further. 

Any suggestions are welcome, thanks a lot!~

Posted (edited)
  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Thank you Cadiboo, I appreciate the help.

 

The Issue seemed to arise from trying to bake models with rotations other than 0, 90, 180 and -90. 

My current approach uses a wrapped IBakedModel that modifies getQuads() in such a way that it rotates the individual quads of the original model before passing them over.

This works fantastically, but the performance is questionable - about 150 of these lowered my FPS from ~320 to ~70 and it only gets worse from there.

I'm still open to suggestions for performance improvements, but consider the original problem solved. ?

 

Cheers!~

Posted

You definitely shouldn’t be rebaking the model each frame

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Very true, the baked model stays the same but transforms its quads every frame. I wonder if caching the rotated quads for each angle would be sensible...

Edit: In fact, not only for every frame but for each instance as well, as they can have different rotation speeds. This is probably why it scales so badly.

Edited by simicats

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.