@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
if (ModularBosses.instance.playerTarget != null && MBExtendedPlayer.get((EntityPlayer) event.entity).knockdownTime > 0) {
EntityPlayer player = event.entityPlayer;
GL11.glPushMatrix();
GL11.glTranslatef(0, 0.15f, 0);
GL11.glRotatef(-90, 1, 0, 0);
GL11.glRotatef(-player.rotationYaw, 0, 0, 1);
GL11.glRotatef(player.rotationYaw, 0, 1, 0);
player.motionX = player.motionY = player.motionZ = 0;
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Post event) {
if (ModularBosses.instance.playerTarget != null && MBExtendedPlayer.get((EntityPlayer) event.entity).knockdownTime > 0) {
GL11.glPopMatrix();
}
}
Issues with Push and Pop Matrix
I am trying to rotate a player model in by 90 degrees
I do this in a pre and post render event
Problem is now when a spectator views the playor being affected, the affected player is moving all backwards in relation to the spectator.
Here is a video of the issue
Affected player is on the left and the spectator is on the right.
What can I add to the pre render event to counteract the odd movement on the spectator side. I can check if the client is spectator or affected so I just need to know how to translate the push matrix to look normal for the spectators.
Any help is appreciated.
Thank you,
If you want to use push/pop matrix, you should do it for each object you render like this
pushMatrix
do transformation
render
popMatrix
Don't mix this like this:
Call pre-render-event for all objects
Render all objects
Call post-render-event for all objects
The latter will not work.
But, the modern way don't use push/pop matrix at all. Today you have some matrix attached to the object representing its orientation and you do one of the following things:
1. (old way): glLoadMatrix to upload the model matrix
2. (better): upload the matrix as uniform to your shader
3. (even better): upload the matrix to uniform block/memory
The easiest way would be glLoadMatrix, as it seems that you are using ancient OpenGL (Version 1.1) now.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement