the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 94 lines 3.7 kB view raw
1#include "stdafx.h" 2#include "..\..\Minecraft.h" 3#include "..\..\ScreenSizeCalculator.h" 4#include "..\..\EntityRenderDispatcher.h" 5#include "..\..\PlayerRenderer.h" 6#include "..\..\HumanoidModel.h" 7#include "..\..\Lighting.h" 8#include "..\..\ModelPart.h" 9#include "..\..\Options.h" 10#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h" 11#include "..\..\MultiplayerLocalPlayer.h" 12#include "UI.h" 13#include "UIControl_MinecraftPlayer.h" 14 15UIControl_MinecraftPlayer::UIControl_MinecraftPlayer() 16{ 17 UIControl::setControlType(UIControl::eMinecraftPlayer); 18 19 Minecraft *pMinecraft=Minecraft::GetInstance(); 20 21 ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); 22 m_fScreenWidth=(float)pMinecraft->width_phys; 23 m_fRawWidth=(float)ssc.rawWidth; 24 m_fScreenHeight=(float)pMinecraft->height_phys; 25 m_fRawHeight=(float)ssc.rawHeight; 26} 27 28void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion *region) 29{ 30 Minecraft *pMinecraft = Minecraft::GetInstance(); 31 glEnable(GL_RESCALE_NORMAL); 32 glEnable(GL_COLOR_MATERIAL); 33 glPushMatrix(); 34 35 float width = region->x1 - region->x0; 36 float height = region->y1 - region->y0; 37 float xo = width/2; 38 float yo = height; 39 40 // dynamic y offset according to region height 41 glTranslatef(xo, yo - (height / 9.0f), 50.0f); 42 43 float ss; 44 45 // Base scale on height of this control 46 // Potentially we might want separate x & y scales here 47 ss = width / (m_fScreenWidth / m_fScreenHeight); 48 49 glScalef(-ss, ss, ss); 50 glRotatef(180, 0, 0, 1); 51 52 UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu *)m_parentScene; 53 54 float oybr = pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot; 55 float oyr = pMinecraft->localplayers[containerMenu->getPad()]->yRot; 56 float oxr = pMinecraft->localplayers[containerMenu->getPad()]->xRot; 57 float oyhr = pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot; 58 59 //float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x; 60 float xd = (m_x + m_width/2) - containerMenu->m_pointerPos.x; 61 62 // Need to base Y on head position, not centre of mass 63 //float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) - m_pointerPos.y; 64 float yd = (m_y + m_height/2 - 40) - containerMenu->m_pointerPos.y; 65 66 glRotatef(45 + 90, 0, 1, 0); 67 Lighting::turnOn(); 68 glRotatef(-45 - 90, 0, 1, 0); 69 70 glRotatef(-(float) atan(yd / 40.0f) * 20, 1, 0, 0); 71 72 pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot = (float) atan(xd / 40.0f) * 20; 73 pMinecraft->localplayers[containerMenu->getPad()]->yRot = (float) atan(xd / 40.0f) * 40; 74 pMinecraft->localplayers[containerMenu->getPad()]->xRot = -(float) atan(yd / 40.0f) * 20; 75 pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot = pMinecraft->localplayers[containerMenu->getPad()]->yRot; 76 //pMinecraft->localplayers[m_iPad]->glow = 1; 77 glTranslatef(0, pMinecraft->localplayers[containerMenu->getPad()]->heightOffset, 0); 78 EntityRenderDispatcher::instance->playerRotY = 180; 79 80 // 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen 81 bool wasHidingGui = pMinecraft->options->hideGui; 82 pMinecraft->options->hideGui = true; 83 EntityRenderDispatcher::instance->render(pMinecraft->localplayers[containerMenu->getPad()], 0, 0, 0, 0, 1, false, false); 84 pMinecraft->options->hideGui = wasHidingGui; 85 //pMinecraft->localplayers[m_iPad]->glow = 0; 86 87 pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot = oybr; 88 pMinecraft->localplayers[containerMenu->getPad()]->yRot = oyr; 89 pMinecraft->localplayers[containerMenu->getPad()]->xRot = oxr; 90 pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot = oyhr; 91 glPopMatrix(); 92 Lighting::turnOff(); 93 glDisable(GL_RESCALE_NORMAL); 94}