Posted April 19, 20196 yr 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!~
April 20, 20196 yr Here’s an example (in 1.12.2) https://github.com/Cadiboo/Example-Mod/blob/5fe80fde8a41cd571593c02897b06b5822e9a738/src/main/java/io/github/cadiboo/examplemod/client/render/tileentity/RenderExampleTileEntity.java Edited April 20, 20196 yr by Cadiboo Made link a permalink About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
April 21, 20196 yr Author 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!~
April 21, 20196 yr You definitely shouldn’t be rebaking the model each frame About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
April 21, 20196 yr Author 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 April 21, 20196 yr 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.