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