I'm trying to make a custom mob that can change its pitch and yaw, and I want players who ride it to stay on its back by rotating with it.
I can use GlStateManager#rotate in rotateCorpse to rotate the mob; first around the y axis, then around the x axis.
However when I try to use GlStateManager#rotate with the same angles when handling RenderPlayerEvent.Pre, not only do
I have to divide the angles by two to fit the mob, but when I try two directions at the same time, it rotates off the mob.
I'm quite new to OpenGL and rusty with matrices, but I think I've gathered the current matrices just before I start my transformations. The matrices differed in the middle two values of row 4: does this cause the problem, and if so what can I do about it? Or is there something else I'm missing?
Thanks for reading.
Edit: Removed an extra transformation and got better results
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
it seems as though you are not pushing&popping (save&load) the transformation matrix. (in future you can post your code with pastebin or github so we don't have to guess)
I would also suggest using GlStateManager.pushAttrib() / GlStateManager.popAttrib() to save and load the settings for OpenGL. This is only necessary if you change settings like the color, alpha, lighting and so on ...
it seems as though you are not pushing&popping (save&load) the transformation matrix. (in future you can post your code with pastebin or github so we don't have to guess)
Sorry about not posting the code; I just assumed my whole method was wrong. Here's the rider code: http://pastebin.com/42CqhPUu (the -1.0 on line 11 should be a 1.0).
I would also suggest using GlStateManager.pushAttrib() / GlStateManager.popAttrib() to save and load the settings for OpenGL. This is only necessary if you change settings like the color, alpha, lighting and so on ...
Thank you for the tip; I will keep that in mind.
Rollback Post to RevisionRollBack
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
Huh.... I am not sure what is wrong! Everything seems ok!
Now I have a couple of suggestions. Replace the -1 with 1 on line 11 and negate the angle. (or even better use something like this so you don't have to fiddle around with the rotation vectors)
Instead of checking if player riding you can simply make a private boolean in event class called something like prePlayerRotated and set it to true in pre when rotating and in post check for prePlayerRotated and if it's true then pop matrix and set prePlayerRotated to false. This will increase your performance a bit and simplify the code. (what can never be a bad thing)
Other than that I my biggest suspect is that you may be rotating in wrong order. (because existing rotation in matrix effects new rotations) Try flipping line 10 and 11.
Also in this kind of graphical debugging screenshots/unlisted youtube videos/gifs (or any way for us to see what is going on) are extremely useful.
Other than that I my biggest suspect is that you may be rotating in wrong order
Sadly, this just made things wrong in a different way. My next step is to rotate around the vector you get when you rotate around (0.0, 1.0, 0.0) - not sure if it's possible (or makes sense) though.
Also in this kind of graphical debugging screenshots/unlisted youtube videos/gifs (or any way for us to see what is going on) are extremely useful.
Yeah, a video or gif would be useful but my laptop has trouble doing screencaps so I just try to explain :/
Rollback Post to RevisionRollBack
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
I needed to change it to 1 but leave the angle, because I negated some other rendering numbers and forgot to change that one.
Heh no need to excuse your derps. I am not going to give you a grade! xD
Yeah, a video or gif would be useful but my laptop has trouble doing screencaps so I just try to explain :/
Hmmm... A couple of images a couple of examples with the problem and an example of how it should be, or 5sec video would be extremely useful. You can make it really easy wth software like https://www.bandicam.com/free-screen-recorder/ and https://support.microsoft.com/en-us/help/14220/windows-movie-maker-download I mean something like this. The point is that an image tells 100 words and a video 1000.
If you your laptop can't take screenshots than try softvare like https://app.prntscr.com or if that does not work than you can even take the "screenshot" with your phone and quality it will not be an issue because the transformation issues or overall scenario can be seen really easy so I can emulate the scenario in my workspace and give you working code/instructions.
I meant I can do screenshots but video capture is unwatchable, so here are 200 words...
This is the correct pitch, but I have to disable the yaw rotation to get it. Squid yaw: approx. 0; pitch: approx: 0.75PI.
With the yaw rotation enabled, the player rotates in the same direction as the squid, but around the black line instead of the red line (which the squid rotates around).
Squid yaw: approx. 0; pitch: approx. 0.
I have the code for translating the player to stay on the squid's back, by the way.
It looks to me like after the yaw rotation, asking it to rotate around (1, 0, 0) makes it rotate around (1, 1, 0) or (1, -1, 0) instead. So while I wait for your reply I will try asking it to rotate around these vectors instead.
Rollback Post to RevisionRollBack
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
Thank you for the code, but sadly using this code as-is doesn't work for me. My model must be different to the original in some way, so please could you try and tell me in general terms what adjustments to make and I can try and adapt them to my model?
As for your tip, I'm just making a small fun mod but yeah, that head rotation is a little too "The Exorcist" for my liking.
Also, shouldn't popping the matrix have lowest priority? Surely with highest priority you might pop someone else's matrix that they added after you?
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
Thank you for the code, but sadly using this code as-is doesn't work for me. My model must be different to the original in some way, so please could you try and tell me in general terms what adjustments to make and I can try and adapt them to my model?
As for your tip, I'm just making a small fun mod but yeah, that head rotation is a little too "The Exorcist" for my liking.
Also, shouldn't popping the matrix have lowest priority? Surely with highest priority you might pop someone else's matrix that they added after you?
Thanks! The pc is ok. (as you can see from the fact that I am posting xD)
Well it's a matter or trial and error when it comes to this kind of transforming. Or you should look how you are rendering the squid thingy and replicate that on the player render event.
Oh ok I thought it was a "serious" mod.
Lowest priority? Yeah! You are right! Never thought about that.
Rollback Post to RevisionRollBack
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
I found it easier to set the rider's yaw via the applyOrientationToEntity method, and only rotate the player around one axis which is calculated from the squid's rotation. Thanks for the help anyway!
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
Hi,
I'm trying to make a custom mob that can change its pitch and yaw, and I want players who ride it to stay on its back by rotating with it.
I can use GlStateManager#rotate in rotateCorpse to rotate the mob; first around the y axis, then around the x axis.
However when I try to use GlStateManager#rotate with the same angles when handling RenderPlayerEvent.Pre, not only do
I have to divide the angles by two to fit the mob, but when I try two directions at the same time, it rotates off the mob.
I'm quite new to OpenGL and rusty with matrices, but I think I've gathered the current matrices just before I start my transformations. The matrices differed in the middle two values of row 4: does this cause the problem, and if so what can I do about it? Or is there something else I'm missing?
Thanks for reading.
Edit: Removed an extra transformation and got better results
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here
it seems as though you are not pushing&popping (save&load) the transformation matrix. (in future you can post your code with pastebin or github so we don't have to guess)
This is how you should usually transform a model:
Gl11.glPushMatrix(); (or GlStateManager.pushMatrix())
do your transformation here (translate, scale, rotate)
renderModel/s();
Gl11.glPopMatrix(); (or GlStateManager.popMatrix())
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
I would also suggest using GlStateManager.pushAttrib() / GlStateManager.popAttrib() to save and load the settings for OpenGL. This is only necessary if you change settings like the color, alpha, lighting and so on ...
For example:
GlStateManager.pushAttrib();
{
// Do your settings
GlStateManager.pushMatix();
{
// Do your transformation
// Render your model
}
}
GlStateManager.popMatrix();
GlStateManager.popAttrib();
Nice Greetings
TechMage66
Sorry about not posting the code; I just assumed my whole method was wrong. Here's the rider code: http://pastebin.com/42CqhPUu (the -1.0 on line 11 should be a 1.0).
Thank you for the tip; I will keep that in mind.
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here
Huh.... I am not sure what is wrong! Everything seems ok!
Now I have a couple of suggestions. Replace the -1 with 1 on line 11 and negate the angle. (or even better use something like this so you don't have to fiddle around with the rotation vectors)
Instead of checking if player riding you can simply make a private boolean in event class called something like prePlayerRotated and set it to true in pre when rotating and in post check for prePlayerRotated and if it's true then pop matrix and set prePlayerRotated to false. This will increase your performance a bit and simplify the code. (what can never be a bad thing)
Other than that I my biggest suspect is that you may be rotating in wrong order. (because existing rotation in matrix effects new rotations) Try flipping line 10 and 11.
Also in this kind of graphical debugging screenshots/unlisted youtube videos/gifs (or any way for us to see what is going on) are extremely useful.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Well at least I'm going about it the right way!
I needed to change it to 1 but leave the angle, because I negated some other rendering numbers and forgot to change that one.
Thanks for this; entity stuff seems a bit calculation-intensive so every little helps!
Sadly, this just made things wrong in a different way. My next step is to rotate around the vector you get when you rotate around (0.0, 1.0, 0.0) - not sure if it's possible (or makes sense) though.
Yeah, a video or gif would be useful but my laptop has trouble doing screencaps so I just try to explain :/
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here
Heh no need to excuse your derps. I am not going to give you a grade! xD
Hmmm... A couple of images a couple of examples with the problem and an example of how it should be, or 5sec video would be extremely useful. You can make it really easy wth software like https://www.bandicam.com/free-screen-recorder/ and https://support.microsoft.com/en-us/help/14220/windows-movie-maker-download I mean something like this. The point is that an image tells 100 words and a video 1000.
If you your laptop can't take screenshots than try softvare like https://app.prntscr.com or if that does not work than you can even take the "screenshot" with your phone and quality it will not be an issue because the transformation issues or overall scenario can be seen really easy so I can emulate the scenario in my workspace and give you working code/instructions.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
I meant I can do screenshots but video capture is unwatchable, so here are 200 words...
This is the correct pitch, but I have to disable the yaw rotation to get it. Squid yaw: approx. 0; pitch: approx: 0.75PI.
With the yaw rotation enabled, the player rotates in the same direction as the squid, but around the black line instead of the red line (which the squid rotates around).
Squid yaw: approx. 0; pitch: approx. 0.
I have the code for translating the player to stay on the squid's back, by the way.
It looks to me like after the yaw rotation, asking it to rotate around (1, 0, 0) makes it rotate around (1, 1, 0) or (1, -1, 0) instead. So while I wait for your reply I will try asking it to rotate around these vectors instead.
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here
Ok I get it. Hang on. I'll make the transformation.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Hello! I am back! (my pc broke while I was testing the transformation )
Here is the code for rotating a player with a squid (as that is pretty much what you are using).
Tip: you may need to lock player head rotation and stuff like that because it's really broken with extra transformation to player.
Feel free to copy functions from my code if you don't have your equivalent.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Hi again! I hope your computer is ok.
Thank you for the code, but sadly using this code as-is doesn't work for me. My model must be different to the original in some way, so please could you try and tell me in general terms what adjustments to make and I can try and adapt them to my model?
As for your tip, I'm just making a small fun mod but yeah, that head rotation is a little too "The Exorcist" for my liking.
Also, shouldn't popping the matrix have lowest priority? Surely with highest priority you might pop someone else's matrix that they added after you?
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here
Thanks! The pc is ok. (as you can see from the fact that I am posting xD)
Well it's a matter or trial and error when it comes to this kind of transforming. Or you should look how you are rendering the squid thingy and replicate that on the player render event.
Oh ok I thought it was a "serious" mod.
Lowest priority? Yeah! You are right! Never thought about that.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
I don't know why, but this works.
I found it easier to set the rider's yaw via the applyOrientationToEntity method, and only rotate the player around one axis which is calculated from the squid's rotation. Thanks for the help anyway!
For anyone in a similar situation, here's my current code: http://pastebin.com/BCvWT6BE
I have made an unofficial port of the spectacular ExRollerCoaster mod, updated for Minecraft 1.12.2.
Build wonderful roller coasters which can go in ANY direction, and the camera will twist and turn with you.
I'm not releasing it through the usual channels but I hope four years on this site makes me a trustworthy modder.
Links:
original mod homepage
source code of my port
download mod jar here