Jump to content

Recommended Posts

Posted

Hello! I'm currently working on a custom entity that can hold items in their hands, but I'm somewhat confused as to how to properly align the rendered item to model's arms. My model is somewhat different than the vanilla mobs, so I take it that I had to create a custom render layer for this. I've looked through both the normal HeldItemLayer and the Fox's implementation on how this was done to get some hints on how this was done, (since the fox is somewhat similar to my model in that they both hold the items on their "heads"), and the part I'm stuck at are the two methods of the MatrixStack I assume are used to align the item correctly: mulPose and translate.

I would love some sort of guidance on how these two work, since I couldn't find a good explanation of them.

From what I achieved so far, I (believe) I managed to align the item to the model's arms, but because of how the model is structured, (the arms of the entity are on its head, which also serve as its body), it creates some issues whenever the entity turns and moves its head. For a clearer understanding of this problem, here are some images:

6635617a7a.png

when idle, the entity has the item aligned properly, (but not perfect)

 

ed5cc93f4f.gif

a small gif showcasing the weird rotational movement. I would assume this is caused by my improper implementation of the mulPose and translate methods. a weird quirk to note about this issue is that it seems to be influenced by his legs, which is something I would need to address as well.

 

If you would like to see the files, here are some links in the Github to the important files:

Github

Renderer

HeldItemLayer Implementation

Model

 

Thank you for taking your time to look at this!

 

Posted

looks like you're applying yaw and pitch swapped during partial ticks. That is, you're applying a large yaw change to the pitch angle and a small pitch change to the yaw angle.

As for how the matrix works, you'll want to read up on projection matricies:
https://jsantell.com/3d-projection/

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
2 hours ago, Draco18s said:

looks like you're applying yaw and pitch swapped during partial ticks. That is, you're applying a large yaw change to the pitch angle and a small pitch change to the yaw angle.

As for how the matrix works, you'll want to read up on projection matricies:
https://jsantell.com/3d-projection/

thank you for the quick response! I'll definitely look into that.

Posted

There's probably better resources, but I skimmed that one, and it had some interactive graphics that explain what goes on.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.