diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 41108ace0..6fbcddf39 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -2718,20 +2718,13 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) - { - send(std::make_shared(packet->textureName, pbData, dwBytes, pDLCSkinFile)); - } - else - { - send(std::make_shared(packet->textureName, pbData, dwBytes)); - } + send(std::make_shared(packet->textureName, pbData, dwBytes, pDLCSkinFile)); } else { unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask)); + send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), app.GetSkinAdjustments(packet->dwSkinID), uiAnimOverrideBitmask)); } } } @@ -2748,6 +2741,11 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrdwSkinID,packet->BoxDataA,packet->dwBoxC); } + // Add the offet data + if(packet->dwOffsetC!=0) + { + app.SetSkinAdjustments(packet->dwSkinID,packet->OffsetDataA,packet->dwOffsetC); + } // Add the anim override app.SetAnimOverrideBitmask(packet->dwSkinID,packet->uiAnimOverrideBitmask); diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 72e68a971..b4d28b6c1 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -197,6 +197,7 @@ CMinecraftApp::CMinecraftApp() InitializeCriticalSection(&csTMSPPDownloadQueue); InitializeCriticalSection(&csAdditionalModelParts); InitializeCriticalSection(&csAdditionalSkinBoxes); + InitializeCriticalSection(&csSkinAdjustments); InitializeCriticalSection(&csAnimOverrideBitmask); InitializeCriticalSection(&csMemFilesLock); InitializeCriticalSection(&csMemTPDLock); @@ -9289,7 +9290,7 @@ bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType) void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC) { EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - Model *pModel = renderer->getModel(); + Model *pModel = renderer->getModel(Player::GetModelTypeFromAnimBitmask(GetAnimOverrideBitmask(dwSkinID))); vector *pvModelPart = new vector; vector *pvSkinBoxes = new vector; @@ -9318,10 +9319,30 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D } +void CMinecraftApp::SetSkinAdjustments(DWORD dwSkinID, SKIN_OFFSET *SkinAdjustmentA, DWORD dwSkinAdjustmentC) +{ + vector *pvSkinAdjustment = new vector; + + EnterCriticalSection( &csSkinAdjustments ); + + app.DebugPrintf("*** SetSkinAdjustments - Adding skin adjustments for skin %d from array of Skin Offsets\n",dwSkinID&0x0FFFFFFF); + + for(unsigned int i=0;ipush_back(&SkinAdjustmentA[i]); + } + + + m_SkinAdjustments.insert( std::pair *>(dwSkinID, pvSkinAdjustment) ); + + LeaveCriticalSection( &csSkinAdjustments ); + +} + vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vector *pvSkinBoxA) { EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - Model *pModel = renderer->getModel(); + Model *pModel = renderer->getModel(Player::GetModelTypeFromAnimBitmask(GetAnimOverrideBitmask(dwSkinID))); vector *pvModelPart = new vector; EnterCriticalSection( &csAdditionalModelParts ); @@ -9346,6 +9367,24 @@ vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect return pvModelPart; } +vector * CMinecraftApp::SetSkinAdjustments(DWORD dwSkinID, vector *pvSkinAdjustmentA) +{ + vector *pvSkinAdjustment = new vector; + + EnterCriticalSection( &csSkinAdjustments ); + app.DebugPrintf("*** SetSkinAdjustments - Inserting skin adjustments for skin %d from array of Skin Offsets\n",dwSkinID&0x0FFFFFFF); + + for( auto& it : *pvSkinAdjustmentA ) + { + pvSkinAdjustment->push_back(it); + } + + m_SkinAdjustments.emplace(dwSkinID, pvSkinAdjustmentA); + + LeaveCriticalSection( &csSkinAdjustments ); + return pvSkinAdjustment; +} + vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) { @@ -9381,6 +9420,23 @@ vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) return pvSkinBoxes; } +vector *CMinecraftApp::GetSkinAdjustments(DWORD dwSkinID) +{ + EnterCriticalSection( &csSkinAdjustments ); + vector *pvSkinAdjustments=nullptr; + if(m_SkinAdjustments.size()>0) + { + auto it = m_SkinAdjustments.find(dwSkinID); + if(it!=m_SkinAdjustments.end()) + { + pvSkinAdjustments = (*it).second; + } + } + + LeaveCriticalSection( &csSkinAdjustments ); + return pvSkinAdjustments; +} + unsigned int CMinecraftApp::GetAnimOverrideBitmask(DWORD dwSkinID) { EnterCriticalSection( &csAnimOverrideBitmask ); diff --git a/Minecraft.Client/Common/Consoles_App.h b/Minecraft.Client/Common/Consoles_App.h index 6401c8395..d8912798b 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -21,6 +21,7 @@ using namespace std; #include "./GameRules/ConsoleGameRulesConstants.h" #include "./GameRules/GameRuleManager.h" #include "../SkinBox.h" +#include "../SkinOffset.h" #include "../ArchiveFile.h" typedef struct _JoinFromInviteData @@ -826,6 +827,7 @@ private: CRITICAL_SECTION csTMSPPDownloadQueue; CRITICAL_SECTION csAdditionalModelParts; CRITICAL_SECTION csAdditionalSkinBoxes; + CRITICAL_SECTION csSkinAdjustments; CRITICAL_SECTION csAnimOverrideBitmask; bool m_bCorruptSaveDeleted; @@ -847,6 +849,9 @@ public: vector * SetAdditionalSkinBoxes(DWORD dwSkinID, vector *pvSkinBoxA); vector *GetAdditionalModelParts(DWORD dwSkinID); vector *GetAdditionalSkinBoxes(DWORD dwSkinID); + void SetSkinAdjustments(DWORD dwSkinID, SKIN_OFFSET *SkinAdjustmentA, DWORD dwSkinAdjustmentC); + vector * SetSkinAdjustments(DWORD dwSkinID, vector *pvSkinAdjustmentA); + vector *GetSkinAdjustments(DWORD dwSkinID); void SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOverrideBitmask); unsigned int GetAnimOverrideBitmask(DWORD dwSkinID); @@ -877,6 +882,7 @@ private: // vector of additional skin model parts, indexed by the skin texture id unordered_map *> m_AdditionalModelParts; unordered_map *> m_AdditionalSkinBoxes; + unordered_map *> m_SkinAdjustments; unordered_map m_AnimOverrides; diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 8f35b1d1f..01196b25b 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -24,6 +24,7 @@ const WCHAR *DLCManager::wchTypeNamesA[]= L"ENCHANTTEXTFOCUSCOLOUR", L"DATAPATH", L"PACKVERSION", + L"OFFSET", }; DLCManager::DLCManager() diff --git a/Minecraft.Client/Common/DLC/DLCManager.h b/Minecraft.Client/Common/DLC/DLCManager.h index f114bd075..a51160d77 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.h +++ b/Minecraft.Client/Common/DLC/DLCManager.h @@ -45,6 +45,7 @@ public: e_DLCParamType_EnchantmentTextFocusColour, e_DLCParamType_DataPath, e_DLCParamType_PackVersion, + e_DLCParamType_Offset, e_DLCParamType_Max, diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp index d6ba11d58..eec95c1db 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp @@ -116,9 +116,9 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring #ifdef __PS3__ // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. - swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f", wchBodyPart, + swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f%f%f%f", wchBodyPart, #else - swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart,10, + swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f%f%f%f", wchBodyPart,10, #endif &pSkinBox->fX, &pSkinBox->fY, @@ -127,7 +127,10 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, - &pSkinBox->fV); + &pSkinBox->fV, + &pSkinBox->fA, + &pSkinBox->fM, + &pSkinBox->fS); if(wcscmp(wchBodyPart,L"HEAD")==0) { @@ -153,11 +156,216 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring { pSkinBox->ePart=eBodyPart_Leg1; } + else if(wcscmp(wchBodyPart,L"HEADWEAR")==0) + { + pSkinBox->ePart=eBodyPart_Headwear; + } + else if(wcscmp(wchBodyPart,L"JACKET")==0) + { + pSkinBox->ePart=eBodyPart_Jacket; + } + else if(wcscmp(wchBodyPart,L"SLEEVE0")==0) + { + pSkinBox->ePart=eBodyPart_Sleeve0; + } + else if(wcscmp(wchBodyPart,L"SLEEVE1")==0) + { + pSkinBox->ePart=eBodyPart_Sleeve1; + } + else if(wcscmp(wchBodyPart,L"PANTS0")==0) + { + pSkinBox->ePart=eBodyPart_Pants0; + } + else if(wcscmp(wchBodyPart,L"PANTS1")==0) + { + pSkinBox->ePart=eBodyPart_Pants1; + } + else if(wcscmp(wchBodyPart,L"WAIST")==0) + { + pSkinBox->ePart=eBodyPart_Waist; + } + else if(wcscmp(wchBodyPart,L"LEGGING0")==0) + { + pSkinBox->ePart=eBodyPart_Legging0; + } + else if(wcscmp(wchBodyPart,L"LEGGING1")==0) + { + pSkinBox->ePart=eBodyPart_Legging1; + } + else if(wcscmp(wchBodyPart,L"SOCK0")==0) + { + pSkinBox->ePart=eBodyPart_Sock0; + } + else if(wcscmp(wchBodyPart,L"SOCK1")==0) + { + pSkinBox->ePart=eBodyPart_Sock1; + } + else if(wcscmp(wchBodyPart,L"BOOT0")==0) + { + pSkinBox->ePart=eBodyPart_Boot0; + } + else if(wcscmp(wchBodyPart,L"BOOT1")==0) + { + pSkinBox->ePart=eBodyPart_Boot1; + } + else if(wcscmp(wchBodyPart,L"ARMARMOR0")==0) + { + pSkinBox->ePart=eBodyPart_ArmArmor0; + } + else if(wcscmp(wchBodyPart,L"ARMARMOR1")==0) + { + pSkinBox->ePart=eBodyPart_ArmArmor1; + } + else if(wcscmp(wchBodyPart,L"BODYARMOR")==0) + { + pSkinBox->ePart=eBodyPart_BodyArmor; + } + else if(wcscmp(wchBodyPart,L"BELT")==0) + { + pSkinBox->ePart=eBodyPart_Belt; + } // add this to the skin's vector of parts m_AdditionalBoxes.push_back(pSkinBox); } break; + case DLCManager::e_DLCParamType_Offset: + { + WCHAR wchBodyPart[10]; + wchar_t wchDirection[2]; + SKIN_OFFSET *pSkinOffset = new SKIN_OFFSET; + ZeroMemory(pSkinOffset,sizeof(SKIN_OFFSET)); + +#ifdef __PS3__ + // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. + swscanf(value.c_str(), L"%10ls%2ls%f", wchBodyPart, +#else + swscanf_s(value.c_str(), L"%9ls%2ls%f", wchBodyPart,10, wchDirection,2, +#endif + &pSkinOffset->fO); + + if(wcscmp(wchDirection,L"X")==0) + { + pSkinOffset->fD=eOffsetDirection_X; + } + else if (wcscmp(wchDirection,L"Y")==0) + { + pSkinOffset->fD=eOffsetDirection_Y; + } + else if(wcscmp(wchDirection,L"Z")==0) + { + pSkinOffset->fD=eOffsetDirection_Z; + } + + if(wcscmp(wchBodyPart,L"HEAD")==0) + { + pSkinOffset->ePart=eBodyOffset_Head; + } + else if(wcscmp(wchBodyPart,L"BODY")==0) + { + pSkinOffset->ePart=eBodyOffset_Body; + } + else if(wcscmp(wchBodyPart,L"ARM0")==0) + { + pSkinOffset->ePart=eBodyOffset_Arm0; + } + else if(wcscmp(wchBodyPart,L"ARM1")==0) + { + pSkinOffset->ePart=eBodyOffset_Arm1; + } + else if(wcscmp(wchBodyPart,L"LEG0")==0) + { + pSkinOffset->ePart=eBodyOffset_Leg0; + } + else if(wcscmp(wchBodyPart,L"LEG1")==0) + { + pSkinOffset->ePart=eBodyOffset_Leg1; + } + else if(wcscmp(wchBodyPart,L"HEADWEAR")==0) + { + pSkinOffset->ePart=eBodyOffset_Headwear; + } + else if(wcscmp(wchBodyPart,L"JACKET")==0) + { + pSkinOffset->ePart=eBodyOffset_Jacket; + } + else if(wcscmp(wchBodyPart,L"SLEEVE0")==0) + { + pSkinOffset->ePart=eBodyOffset_Sleeve0; + } + else if(wcscmp(wchBodyPart,L"SLEEVE1")==0) + { + pSkinOffset->ePart=eBodyOffset_Sleeve1; + } + else if(wcscmp(wchBodyPart,L"PANTS0")==0) + { + pSkinOffset->ePart=eBodyOffset_Pants0; + } + else if(wcscmp(wchBodyPart,L"PANTS1")==0) + { + pSkinOffset->ePart=eBodyOffset_Pants1; + } + else if(wcscmp(wchBodyPart,L"HELMET")==0) + { + pSkinOffset->ePart=eBodyOffset_Helmet; + } + else if(wcscmp(wchBodyPart,L"WAIST")==0) + { + pSkinOffset->ePart=eBodyOffset_Waist; + } + else if(wcscmp(wchBodyPart,L"LEGGING0")==0) + { + pSkinOffset->ePart=eBodyOffset_Legging0; + } + else if(wcscmp(wchBodyPart,L"LEGGING1")==0) + { + pSkinOffset->ePart=eBodyOffset_Legging1; + } + else if(wcscmp(wchBodyPart,L"SOCK0")==0) + { + pSkinOffset->ePart=eBodyOffset_Sock0; + } + else if(wcscmp(wchBodyPart,L"SOCK1")==0) + { + pSkinOffset->ePart=eBodyOffset_Sock1; + } + else if(wcscmp(wchBodyPart,L"BOOT0")==0) + { + pSkinOffset->ePart=eBodyOffset_Boot0; + } + else if(wcscmp(wchBodyPart,L"BOOT1")==0) + { + pSkinOffset->ePart=eBodyOffset_Boot1; + } + else if(wcscmp(wchBodyPart,L"ARMARMOR1")==0) + { + pSkinOffset->ePart=eBodyOffset_ArmArmor1; + } + else if(wcscmp(wchBodyPart,L"ARMARMOR0")==0) + { + pSkinOffset->ePart=eBodyOffset_ArmArmor0; + } + else if(wcscmp(wchBodyPart,L"BODYARMOR")==0) + { + pSkinOffset->ePart=eBodyOffset_BodyArmor; + } + else if(wcscmp(wchBodyPart,L"BELT")==0) + { + pSkinOffset->ePart=eBodyOffset_Belt; + } + else if(wcscmp(wchBodyPart,L"TOOL0")==0) + { + pSkinOffset->ePart=eBodyOffset_Tool0; + } + else if(wcscmp(wchBodyPart,L"TOOL1")==0) + { + pSkinOffset->ePart=eBodyOffset_Tool1; + } + + // add this to the skin's vector of offsets + m_Offsets.push_back(pSkinOffset); + } + break; case DLCManager::e_DLCParamType_Anim: #ifdef __PS3__ // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. @@ -185,6 +393,15 @@ vector *DLCSkinFile::getAdditionalBoxes() return &m_AdditionalBoxes; } +int DLCSkinFile::getOffsetsCount() +{ + return static_cast(m_Offsets.size()); +} +vector *DLCSkinFile::getOffsets() +{ + return &m_Offsets; +} + wstring DLCSkinFile::getParameterAsString(DLCManager::EDLCParameterType type) { switch(type) diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.h b/Minecraft.Client/Common/DLC/DLCSkinFile.h index 1645fb2a5..d8392d930 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.h +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.h @@ -12,6 +12,7 @@ private: unsigned int m_uiAnimOverrideBitmask; bool m_bIsFree; vector m_AdditionalBoxes; + vector m_Offsets; public: @@ -24,6 +25,8 @@ public: bool getParameterAsBool(DLCManager::EDLCParameterType type) override; vector *getAdditionalBoxes(); int getAdditionalBoxesCount(); + vector *getOffsets(); + int getOffsetsCount(); unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask;} bool isFree() {return m_bIsFree;} }; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp index cbffa662f..5fab00633 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -56,6 +56,7 @@ UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview() m_framesAnimatingRotation = 0; m_bAnimatingToFacing = false; m_pvAdditionalModelParts=nullptr; + m_pvSkinAdjustments=nullptr; m_uiAnimOverrideBitmask=0L; } @@ -132,6 +133,7 @@ void UIControl_PlayerSkinPreview::SetTexture(const wstring &url, TEXTURE_NAME ba } m_pvAdditionalModelParts=app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl)); + m_pvSkinAdjustments=app.GetSkinAdjustments(app.getSkinIdFromPath(m_customTextureUrl)); } void UIControl_PlayerSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAnimate /*= false*/) @@ -257,7 +259,8 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou glPushMatrix(); glDisable(GL_CULL_FACE); - HumanoidModel *model = static_cast(renderer->getModel()); + Textures *t = Minecraft::GetInstance()->textures; + HumanoidModel *model = static_cast(renderer->getModel(Player::GetModelTypeFromTextureId(t->loadMemTexture(m_customTextureUrl, m_backupTexture))+Player::GetModelTypeFromAnimBitmask(m_uiAnimOverrideBitmask))); //getAttackAnim(mob, a); //if (armor != nullptr) armor->attackTime = model->attackTime; @@ -357,7 +360,8 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou glEnable(GL_ALPHA_TEST); //model->prepareMobModel(mob, wp, ws, a); - model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true); + // Using a modified version of the render function to render offsts is skin select menu + model->renderUIAdjustments(wp, ws, bob, headRot - bodyRot, headRotx, _scale, true, m_pvSkinAdjustments); /*for (int i = 0; i < MAX_ARMOR_LAYERS; i++) { if (prepareArmor(mob, i, a)) diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h index 974e5924b..042e962f9 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h @@ -53,6 +53,7 @@ private: ESkinPreviewAnimations m_currentAnimation; //vector *m_pvAdditionalBoxes; vector *m_pvAdditionalModelParts; + vector *m_pvSkinAdjustments; public: enum ESkinPreviewFacing { diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index daf78083c..26bf90426 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -24,6 +24,16 @@ const WCHAR *UIScene_SkinSelectMenu::wchDefaultNamesA[]= L"Prisoner Steve", L"Cyclist Steve", L"Boxer Steve", + L"Alex", + L"Tennis Alex", + L"Tuxedo Alex", + L"Athlete Alex", + L"Swedish Alex", + L"Prisoner Alex", + L"Cyclist Alex", + L"Boxer Alex", + L"Developer Alex", + L"Developer Steve", }; UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) @@ -49,6 +59,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer m_selectedSkinPath = L""; m_selectedCapePath = L""; m_vAdditionalSkinBoxes = nullptr; + m_vSkinAdjustments = nullptr; m_bSlidingSkins = false; m_bAnimatingMove = false; @@ -652,6 +663,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = skinFile->getPath(); m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + m_vSkinAdjustments = skinFile->getOffsets(); skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); @@ -674,6 +686,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = L""; m_selectedCapePath = L""; m_vAdditionalSkinBoxes = nullptr; + m_vSkinAdjustments = nullptr; switch(m_packIndex) { @@ -716,6 +729,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = skinFile->getPath(); m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + m_vSkinAdjustments = skinFile->getOffsets(); skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); @@ -763,6 +777,17 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),m_vAdditionalSkinBoxes); } } + + if(m_vSkinAdjustments && m_vSkinAdjustments->size()!=0) + { + // add the skin adjustments to the humanoid model, but only if we've not done this already + + vector *pSkinAdjustments = app.GetSkinAdjustments(skinFile->getSkinID()); + if(pSkinAdjustments==nullptr) + { + pSkinAdjustments = app.SetSkinAdjustments(skinFile->getSkinID(),m_vSkinAdjustments); + } + } if(skinFile!=nullptr) { @@ -780,6 +805,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() wstring otherSkinPath = L""; wstring otherCapePath = L""; vector *othervAdditionalSkinBoxes=nullptr; + vector *othervSkinAdjustments=nullptr; wchar_t chars[256]; // turn off all displays @@ -834,6 +860,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinAdjustments = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } else @@ -841,6 +868,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = L""; otherCapePath = L""; othervAdditionalSkinBoxes=nullptr; + othervSkinAdjustments=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -860,6 +888,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinAdjustments = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } } @@ -877,6 +906,14 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } + if(othervSkinAdjustments && othervSkinAdjustments->size()!=0) + { + vector *pSkinAdjustments = app.GetSkinAdjustments(skinFile->getSkinID()); + if(pSkinAdjustments==nullptr) + { + pSkinAdjustments = app.SetSkinAdjustments(skinFile->getSkinID(),othervSkinAdjustments); + } + } // 4J-PB - anim override needs set before SetTexture if(skinFile!=nullptr) { @@ -905,6 +942,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinAdjustments = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } else @@ -912,6 +950,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = L""; otherCapePath = L""; othervAdditionalSkinBoxes=nullptr; + othervSkinAdjustments=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -931,6 +970,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinAdjustments = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } } @@ -948,6 +988,14 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } + if(othervSkinAdjustments && othervSkinAdjustments->size()!=0) + { + vector *pSkinAdjustments = app.GetSkinAdjustments(skinFile->getSkinID()); + if(pSkinAdjustments==nullptr) + { + pSkinAdjustments = app.SetSkinAdjustments(skinFile->getSkinID(),othervSkinAdjustments); + } + } // 4J-PB - anim override needs set before SetTexture if(skinFile) { @@ -993,6 +1041,36 @@ TEXTURE_NAME UIScene_SkinSelectMenu::getTextureId(int skinIndex) case eDefaultSkins_Skin7: texture = TN_MOB_CHAR7; break; + case eDefaultSkins_Skin8: + texture = TN_MOB_ALEX; + break; + case eDefaultSkins_Skin9: + texture = TN_MOB_ALEX1; + break; + case eDefaultSkins_Skin10: + texture = TN_MOB_ALEX2; + break; + case eDefaultSkins_Skin11: + texture = TN_MOB_ALEX3; + break; + case eDefaultSkins_Skin12: + texture = TN_MOB_ALEX4; + break; + case eDefaultSkins_Skin13: + texture = TN_MOB_ALEX5; + break; + case eDefaultSkins_Skin14: + texture = TN_MOB_ALEX6; + break; + case eDefaultSkins_Skin15: + texture = TN_MOB_ALEX7; + break; + case eDefaultSkins_Skin16: + texture = TN_MOB_DEVALEX; + break; + case eDefaultSkins_Skin17: + texture = TN_MOB_DEVSTEVE; + break; }; return texture; diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h index f6922230a..eb0ccb5b8 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h @@ -104,6 +104,7 @@ private: DWORD m_originalSkinId; wstring m_currentSkinPath, m_selectedSkinPath, m_selectedCapePath; vector *m_vAdditionalSkinBoxes; + vector *m_vSkinAdjustments; bool m_bSlidingSkins, m_bAnimatingMove; ESkinSelectNavigation m_currentNavigation; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp index 3206185f6..fe52d9663 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp @@ -63,6 +63,7 @@ CXuiCtrlMinecraftSkinPreview::CXuiCtrlMinecraftSkinPreview() : m_framesAnimatingRotation = 0; m_bAnimatingToFacing = false; m_pvAdditionalModelParts=nullptr; + m_pvSkinAdjustments=nullptr; m_uiAnimOverrideBitmask=0L; } @@ -102,6 +103,7 @@ void CXuiCtrlMinecraftSkinPreview::SetTexture(const wstring &url, TEXTURE_NAME b app.DebugPrintf("+++ SetTexture - %d, %8x\n",app.getSkinIdFromPath(m_customTextureUrl)&0xFFFFFFF,m_uiAnimOverrideBitmask); m_pvAdditionalModelParts=app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl)); + m_pvSkinAdjustments=app.GetSkinAdjustments(app.getSkinIdFromPath(m_customTextureUrl)); } void CXuiCtrlMinecraftSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAnimate /*= false*/) @@ -294,7 +296,8 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do glPushMatrix(); glDisable(GL_CULL_FACE); - HumanoidModel *model = static_cast(renderer->getModel()); + Textures *t = Minecraft::GetInstance()->textures; + HumanoidModel *model = static_cast(renderer->getModel(Player::GetModelTypeFromTextureId(t->loadMemTexture(m_customTextureUrl, m_backupTexture))+Player::GetModelTypeFromAnimBitmask(m_uiAnimOverrideBitmask))); //getAttackAnim(mob, a); //if (armor != nullptr) armor->attackTime = model->attackTime; @@ -389,7 +392,7 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do glEnable(GL_ALPHA_TEST); //model->prepareMobModel(mob, wp, ws, a); - model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true); + model->renderUIAdjustments(wp, ws, bob, headRot - bodyRot, headRotx, _scale, true, m_pvSkinAdjustments); /*for (int i = 0; i < MAX_ARMOR_LAYERS; i++) { if (prepareArmor(mob, i, a)) diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h index 254bc0432..12ca26ed2 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h @@ -5,6 +5,7 @@ #include "../../Textures.h" //#include "../../Xbox/DLC/DLCSkinFile.h" #include "../../Model.h" +#include "../../SkinOffset.h" using namespace std; @@ -103,4 +104,5 @@ private: ESkinPreviewAnimations m_currentAnimation; //vector *m_pvAdditionalBoxes; vector *m_pvAdditionalModelParts; + vector *m_pvSkinAdjustments; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/res/1_2_2/mob/DevAlex.png b/Minecraft.Client/Common/res/1_2_2/mob/DevAlex.png new file mode 100644 index 000000000..9db32e3d8 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/DevAlex.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/DevSteve.png b/Minecraft.Client/Common/res/1_2_2/mob/DevSteve.png new file mode 100644 index 000000000..652a7c427 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/DevSteve.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex.png b/Minecraft.Client/Common/res/1_2_2/mob/alex.png new file mode 100644 index 000000000..b643fe2d0 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex1.png b/Minecraft.Client/Common/res/1_2_2/mob/alex1.png new file mode 100644 index 000000000..3f6abf7e0 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex1.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex2.png b/Minecraft.Client/Common/res/1_2_2/mob/alex2.png new file mode 100644 index 000000000..6f42db335 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex2.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex3.png b/Minecraft.Client/Common/res/1_2_2/mob/alex3.png new file mode 100644 index 000000000..a67a3c823 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex3.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex4.png b/Minecraft.Client/Common/res/1_2_2/mob/alex4.png new file mode 100644 index 000000000..a73a9314a Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex4.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex5.png b/Minecraft.Client/Common/res/1_2_2/mob/alex5.png new file mode 100644 index 000000000..a81c05fcc Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex5.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex6.png b/Minecraft.Client/Common/res/1_2_2/mob/alex6.png new file mode 100644 index 000000000..eed411793 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex6.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/alex7.png b/Minecraft.Client/Common/res/1_2_2/mob/alex7.png new file mode 100644 index 000000000..cb20ba3aa Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/alex7.png differ diff --git a/Minecraft.Client/EntityRenderer.cpp b/Minecraft.Client/EntityRenderer.cpp index b7abf91f3..f0096f7a9 100644 --- a/Minecraft.Client/EntityRenderer.cpp +++ b/Minecraft.Client/EntityRenderer.cpp @@ -19,6 +19,8 @@ ResourceLocation EntityRenderer::SHADOW_LOCATION = ResourceLocation(TN__CLAMP__M EntityRenderer::EntityRenderer() { model = nullptr; + modelWide = nullptr; + modelSlim = nullptr; tileRenderer = new TileRenderer(); shadowRadius = 0; shadowStrength = 1.0f; @@ -407,4 +409,11 @@ void EntityRenderer::registerTerrainTextures(IconRegister *iconRegister) ResourceLocation *EntityRenderer::getTextureLocation(shared_ptr mob) { return nullptr; +} + +Model *EntityRenderer::getModel(int modelType) +{ + if (modelType == 2) return modelSlim; + else if (modelType == 1) return modelWide; + else return model; } \ No newline at end of file diff --git a/Minecraft.Client/EntityRenderer.h b/Minecraft.Client/EntityRenderer.h index ef3b63bdc..779f1b7b3 100644 --- a/Minecraft.Client/EntityRenderer.h +++ b/Minecraft.Client/EntityRenderer.h @@ -30,6 +30,8 @@ private: protected: Model *model; // TODO 4J: Check why exactly this is here, it seems to get shadowed by classes inheriting from this by their own + Model *modelWide; + Model *modelSlim; protected: TileRenderer *tileRenderer; // 4J - changed to protected so derived classes can use instead of shadowing their own @@ -67,6 +69,6 @@ public: public: // 4J Added - virtual Model *getModel() { return model; } + virtual Model *getModel(int modelType = 0); virtual void SetItemFrame(bool bSet) {} }; diff --git a/Minecraft.Client/HumanoidModel.cpp b/Minecraft.Client/HumanoidModel.cpp index a120ed055..3f754b931 100644 --- a/Minecraft.Client/HumanoidModel.cpp +++ b/Minecraft.Client/HumanoidModel.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "HumanoidModel.h" #include "../Minecraft.World/Mth.h" -#include "../Minecraft.World/Entity.h" +#include "../Minecraft.World/Player.h" #include "ModelPart.h" // 4J added @@ -9,6 +9,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) { ModelPart *pAttachTo=nullptr; + float scale=0; switch(pBox->ePart) { @@ -30,7 +31,65 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) case eBodyPart_Leg1: pAttachTo=leg1; break; + case eBodyPart_Headwear: + pAttachTo=hair; + break; + case eBodyPart_Jacket: + pAttachTo=jacket; + scale=0.25; + break; + case eBodyPart_Sleeve0: + pAttachTo=sleeve0; + scale=0.25; + break; + case eBodyPart_Sleeve1: + pAttachTo=sleeve1; + scale=0.25; + break; + case eBodyPart_Pants0: + pAttachTo=pants0; + scale=0.25; + break; + case eBodyPart_Pants1: + pAttachTo=pants1; + scale=0.25; + break; + case eBodyPart_Waist: + pAttachTo=waist; + break; + case eBodyPart_Belt: + pAttachTo=belt; + break; + case eBodyPart_BodyArmor: + pAttachTo=bodyArmor; + break; + case eBodyPart_ArmArmor0: + pAttachTo=armArmor0; + break; + case eBodyPart_ArmArmor1: + pAttachTo=armArmor1; + break; + case eBodyPart_Legging0: + pAttachTo=legging0; + break; + case eBodyPart_Legging1: + pAttachTo=legging1; + break; + case eBodyPart_Sock0: + pAttachTo=sock0; + break; + case eBodyPart_Sock1: + pAttachTo=sock1; + break; + case eBodyPart_Boot0: + pAttachTo=boot0; + break; + case eBodyPart_Boot1: + pAttachTo=boot1; + break; } + // check if this box has a declared scale then add it + if (pBox->fS != 0) scale = pBox->fS; // first check this box doesn't already exist ModelPart *pNewBox = pAttachTo->retrieveChild(pBox); @@ -49,7 +108,9 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) pNewBox = new ModelPart(this, static_cast(pBox->fU), static_cast(pBox->fV)); pNewBox->visible=false; - pNewBox->addHumanoidBox(pBox->fX, pBox->fY, pBox->fZ, pBox->fW, pBox->fH, pBox->fD, 0); + if (pBox->fM > 0) pNewBox->bMirror = true; // check if this box has the mirror flag + pNewBox->hideWithArmor = (unsigned int)pBox->fA; // add the "hide when armor is worn" bit flags + pNewBox->addHumanoidBox(pBox->fX, pBox->fY, pBox->fZ, pBox->fW, pBox->fH, pBox->fD, scale); // 4J-PB - don't compile here, since the lighting isn't set up. It'll be compiled on first use. //pNewBox->compile(1.0f/16.0f); pAttachTo->addChild(pNewBox); @@ -58,47 +119,156 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) return pNewBox; } -void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight) +void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight, bool slim, bool isArmor) { this->texWidth = texWidth; this->texHeight = texHeight; + jacket = nullptr; + sleeve0 = nullptr; + sleeve1 = nullptr; + pants0 = nullptr; + pants1 = nullptr; + + waist = nullptr; + belt = nullptr; + bodyArmor = nullptr; + armArmor0 = nullptr; + armArmor1 = nullptr; + legging0 = nullptr; + legging1 = nullptr; + sock0 = nullptr; + sock1 = nullptr; + boot0 = nullptr; + boot1 = nullptr; + m_fYOffset=yOffset; - cloak = new ModelPart(this, 0, 0); - cloak->addHumanoidBox(-5, -0, -1, 10, 16, 1, g); // Cloak + cloak = new ModelPart(this, 0, 0); + cloak->addHumanoidBox(-5, -0, -1, 10, 16, 1, g); // Cloak - ear = new ModelPart(this, 24, 0); - ear->addHumanoidBox(-3, -6, -1, 6, 6, 1, g); // Ear - - head = new ModelPart(this, 0, 0); - head->addHumanoidBox(-4, -8, -4, 8, 8, 8, g); // Head - head->setPos(0, 0 + yOffset, 0); + ear = new ModelPart(this, 24, 0); + ear->addHumanoidBox(-3, -6, -1, 6, 6, 1, g); // Ear + + head = new ModelPart(this, 0, 0); + head->addHumanoidBox(-4, -8, -4, 8, 8, 8, g); // Head + head->setPos(0, 0 + yOffset, 0); - hair = new ModelPart(this, 32, 0); - hair->addHumanoidBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head - hair->setPos(0, 0 + yOffset, 0); + hair = new ModelPart(this, 32, 0); + hair->addHumanoidBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head + hair->setPos(0, 0 + yOffset, 0); - body = new ModelPart(this, 16, 16); - body->addHumanoidBox(-4, 0, -2, 8, 12, 4, g); // Body - body->setPos(0, 0 + yOffset, 0); + body = new ModelPart(this, 16, 16); + body->addHumanoidBox(-4, 0, -2, 8, 12, 4, g); // Body + body->setPos(0, 0 + yOffset, 0); - arm0 = new ModelPart(this, 24 + 16, 16); - arm0->addHumanoidBox(-3, -2, -2, 4, 12, 4, g); // Arm0 - arm0->setPos(-5, 2 + yOffset, 0); + if (texHeight == 64) + { + jacket = new ModelPart(this, 16, 32); + jacket->addHumanoidBox(-4, 0, -2, 8, 12, 4, g + 0.25); // Jacket + jacket->setPos(0, 0 + yOffset, 0); - arm1 = new ModelPart(this, 24 + 16, 16); - arm1->bMirror = true; - arm1->addHumanoidBox(-1, -2, -2, 4, 12, 4, g); // Arm1 - arm1->setPos(5, 2 + yOffset, 0); + waist = new ModelPart(this, 0, 0); + waist->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Waist + waist->setPos(0, 0 + yOffset, 0); + belt = new ModelPart(this, 0, 0); + belt->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Belt + belt->setPos(0, 0 + yOffset, 0); + bodyArmor = new ModelPart(this, 0, 0); + bodyArmor->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // BodyArmor + bodyArmor->setPos(0, 0 + yOffset, 0); + armArmor0 = new ModelPart(this, 0, 0); + armArmor0->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // ArmArmor0 + armArmor0->setPos(-5, 2 + yOffset, 0); + armArmor1 = new ModelPart(this, 0, 0); + armArmor1->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // ArmArmor1 + armArmor1->setPos(5, 2 + yOffset, 0); + legging0 = new ModelPart(this, 0, 0); + legging0->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Legging0 + legging0->setPos(-1.9, 12 + yOffset, 0); + legging1 = new ModelPart(this, 0, 0); + legging1->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Legging1 + legging1->setPos(1.9, 12 + yOffset, 0); + sock0 = new ModelPart(this, 0, 0); + sock0->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Sock0 + sock0->setPos(-1.9, 12 + yOffset, 0); + sock1 = new ModelPart(this, 0, 0); + sock1->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Sock1 + sock1->setPos(1.9, 12 + yOffset, 0); + boot0 = new ModelPart(this, 0, 0); + boot0->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Boot0 + boot0->setPos(-1.9, 12 + yOffset, 0); + boot1 = new ModelPart(this, 0, 0); + boot1->addHumanoidBox(0, 0, 0, 0, 0, 0, g); // Boot1 + boot1->setPos(1.9, 12 + yOffset, 0); + } - leg0 = new ModelPart(this, 0, 16); - leg0->addHumanoidBox(-2, 0, -2, 4, 12, 4, g); // Leg0 - leg0->setPos(-1.9, 12 + yOffset, 0); + if (texHeight == 64) + { + arm0 = new ModelPart(this, 24 + 16, 16); + arm1 = new ModelPart(this, 16 + 16, 48); - leg1 = new ModelPart(this, 0, 16); - leg1->bMirror = true; - leg1->addHumanoidBox(-2, 0, -2, 4, 12, 4, g); // Leg1 - leg1->setPos(1.9, 12 + yOffset, 0); + sleeve0 = new ModelPart(this, 24 + 16, 32); + sleeve1 = new ModelPart(this, 32 + 16, 48); + + if (!slim) + { + sleeve0->addHumanoidBox(-3, -2, -2, 4, 12, 4, g + 0.25); // Sleeve0 + sleeve1->addHumanoidBox(-1, -2, -2, 4, 12, 4, g + 0.25); // Sleeve1 + } + else if (slim) + { + sleeve0->addHumanoidBox(-2, -2, -2, 3, 12, 4, g + 0.25); // Sleeve0 Slim + sleeve1->addHumanoidBox(-1, -2, -2, 3, 12, 4, g + 0.25); // Sleeve1 Slim + } + + sleeve0->setPos(-5, 2 + yOffset, 0); + sleeve1->setPos(5, 2 + yOffset, 0); + } + else if (texHeight == 32) + { + arm0 = new ModelPart(this, 24 + 16, 16); + arm1 = new ModelPart(this, 24 + 16, 16); + arm1->bMirror = true; + } + + if (!slim) + { + arm0->addHumanoidBox(-3, -2, -2, 4, 12, 4, g); // Arm0 + arm1->addHumanoidBox(-1, -2, -2, 4, 12, 4, g); // Arm1 + } + else if (slim) + { + arm0->addHumanoidBox(-2, -2, -2, 3, 12, 4, g); // Arm0 Slim + arm1->addHumanoidBox(-1, -2, -2, 3, 12, 4, g); // Arm1 Slim + } + + arm0->setPos(-5, 2 + yOffset, 0); + arm1->setPos(5, 2 + yOffset, 0); + + leg0 = new ModelPart(this, 0, 16); + if (texHeight == 64) + { + leg1 = new ModelPart(this, 16, 48); + + pants0 = new ModelPart(this, 0, 32); + pants0->addHumanoidBox(-2, 0, -2, 4, 12, 4, g + 0.25); // Pants0 + pants0->setPos(-1.9, 12 + yOffset, 0); + + pants1 = new ModelPart(this, 0, 48); + pants1->addHumanoidBox(-2, 0, -2, 4, 12, 4, g + 0.25); // Pants1 + pants1->setPos(1.9, 12 + yOffset, 0); + } + else if (texHeight == 32) + { + leg1 = new ModelPart(this, 0, 16); + leg1->bMirror = true; + } + + leg0->addHumanoidBox(-2, 0, -2, 4, 12, 4, g); // Leg0 + leg0->setPos(-1.9, 12 + yOffset, 0); + + leg1->addHumanoidBox(-2, 0, -2, 4, 12, 4, g); // Leg1 + leg1->setPos(1.9, 12 + yOffset, 0); // 4J added - compile now to avoid random performance hit first time cubes are rendered // 4J Stu - Not just performance, but alpha+depth tests don't work right unless we compile here @@ -112,6 +282,39 @@ void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight) leg1->compile(1.0f/16.0f); hair->compile(1.0f/16.0f); + if (jacket != 0) + jacket->compile(1.0f/16.0f); + if (sleeve0 != 0) + sleeve0->compile(1.0f/16.0f); + if (sleeve1 != 0) + sleeve1->compile(1.0f/16.0f); + if (pants0 != 0) + pants0->compile(1.0f/16.0f); + if (pants1 != 0) + pants1->compile(1.0f/16.0f); + if (waist != 0) + waist->compile(1.0f/16.0f); + if (belt != 0) + belt->compile(1.0f/16.0f); + if (bodyArmor != 0) + bodyArmor->compile(1.0f/16.0f); + if (armArmor0 != 0) + armArmor0->compile(1.0f/16.0f); + if (armArmor1 != 0) + armArmor1->compile(1.0f/16.0f); + if (legging0 != 0) + legging0->compile(1.0f/16.0f); + if (legging1 != 0) + legging1->compile(1.0f/16.0f); + if (sock0 != 0) + sock0->compile(1.0f/16.0f); + if (sock1 != 0) + sock1->compile(1.0f/16.0f); + if (boot0 != 0) + boot0->compile(1.0f/16.0f); + if (boot1 != 0) + boot1->compile(1.0f/16.0f); + holdingLeftHand=0; holdingRightHand=0; sneaking=false; @@ -123,25 +326,36 @@ void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight) eating_t = 0.0f; eating_swing = 0.0f; m_uiAnimOverrideBitmask = 0L; + m_isArmor = isArmor; } HumanoidModel::HumanoidModel() : Model() { - _init(0, 0, 64, 32); + _init(0, 0, 64, 32, false, false); } HumanoidModel::HumanoidModel(float g) : Model() { - _init(g, 0, 64, 32); + _init(g, 0, 64, 32, false, false); +} + +HumanoidModel::HumanoidModel(float g, bool isArmor) : Model() +{ + _init(g, 0, 64, 32, false, isArmor); } HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight) : Model() { - _init(g,yOffset,texWidth,texHeight); + _init(g,yOffset,texWidth,texHeight, false, false); +} + +HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight, bool slim) : Model() +{ + _init(g,yOffset,texWidth,texHeight, slim, false); } void HumanoidModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) -{ +{ if(entity != nullptr) { m_uiAnimOverrideBitmask=entity->getAnimOverrideBitmask(); @@ -170,21 +384,500 @@ void HumanoidModel::render(shared_ptr entity, float time, float r, float } else { - head->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); - body->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); - arm0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); - arm1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); - leg0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); - leg1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + shared_ptr player = dynamic_pointer_cast(entity); + vector headOffsets = {0, 0, 0}; + vector bodyOffsets = {0, 0, 0}; + vector arm0Offsets = {0, 0, 0}; + vector arm1Offsets = {0, 0, 0}; + vector leg0Offsets = {0, 0, 0}; + vector leg1Offsets = {0, 0, 0}; + vector* pSkinAdjustments = nullptr; + if (player != nullptr) + pSkinAdjustments = player->GetSkinAdjustments(); + if (pSkinAdjustments != nullptr) + { + for( SKIN_OFFSET *pSkinAdjustment : *pSkinAdjustments ) + { + switch (pSkinAdjustment->ePart) + { + case eBodyOffset_Head: + if(pSkinAdjustment->fD == 1) + headOffsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + headOffsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + headOffsets[2] += pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Body: + if(pSkinAdjustment->fD == 1) + bodyOffsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + bodyOffsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + bodyOffsets[2] += pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Arm0: + if(pSkinAdjustment->fD == 1) + arm0Offsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + arm0Offsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + arm0Offsets[2] += pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Arm1: + if(pSkinAdjustment->fD == 1) + arm1Offsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + arm1Offsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + arm1Offsets[2] += pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Leg0: + if(pSkinAdjustment->fD == 1) + leg0Offsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + leg0Offsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + leg0Offsets[2] += pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Leg1: + if(pSkinAdjustment->fD == 1) + leg1Offsets[0] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + leg1Offsets[1] += pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + leg1Offsets[2] += pSkinAdjustment->fO / 16.0f; + break; + } + } + } + + glPushMatrix(); + glTranslatef(headOffsets[0], headOffsets[1], headOffsets[2]); + head->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + body->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + arm0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + arm1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + leg0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + leg1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(headOffsets[0], headOffsets[1], headOffsets[2]); hair->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + if (jacket != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + jacket->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (sleeve0 != 0) + { + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + sleeve0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (sleeve1 != 0) + { + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + sleeve1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (pants0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + pants0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (pants1 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + pants1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (waist != 0) + waist->render(scale, usecompiled); + if (belt != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + belt->render(scale, usecompiled); + glPopMatrix(); + } + if (bodyArmor != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + bodyArmor->render(scale, usecompiled); + glPopMatrix(); + } + if (armArmor0 != 0) + { + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + armArmor0->render(scale, usecompiled); + glPopMatrix(); + } + if (armArmor1 != 0) + { + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + armArmor1->render(scale, usecompiled); + glPopMatrix(); + } + if (legging0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + legging0->render(scale, usecompiled); + glPopMatrix(); + } + if (legging1 != 0) + { + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + legging1->render(scale, usecompiled); + glPopMatrix(); + } + if (sock0 != 0) + sock0->render(scale, usecompiled); + if (sock1 != 0) + sock1->render(scale, usecompiled); + if (boot0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + boot0->render(scale, usecompiled); + glPopMatrix(); + } + if (boot1 != 0) + { + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + boot1->render(scale, usecompiled); + glPopMatrix(); + } } } +// This code is the same as above but allows for skin offsets to work in the skin select menu - Langtanium +void HumanoidModel::renderUIAdjustments(float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled, vector *skinAdjustments) +{ + setupAnim(time, r, bob, yRot, xRot, scale, nullptr, m_uiAnimOverrideBitmask); + + vector headOffsets = {0, 0, 0}; + vector bodyOffsets = {0, 0, 0}; + vector arm0Offsets = {0, 0, 0}; + vector arm1Offsets = {0, 0, 0}; + vector leg0Offsets = {0, 0, 0}; + vector leg1Offsets = {0, 0, 0}; + vector* pSkinAdjustments = nullptr; + if (skinAdjustments != nullptr) + pSkinAdjustments = skinAdjustments; + if (pSkinAdjustments != nullptr) + { + for( SKIN_OFFSET *pSkinAdjustment : *pSkinAdjustments ) + { + switch (pSkinAdjustment->ePart) + { + case eBodyOffset_Head: + if(pSkinAdjustment->fD == 1) + headOffsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + headOffsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + headOffsets[2] = pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Body: + if(pSkinAdjustment->fD == 1) + bodyOffsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + bodyOffsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + bodyOffsets[2] = pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Arm0: + if(pSkinAdjustment->fD == 1) + arm0Offsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + arm0Offsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + arm0Offsets[2] = pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Arm1: + if(pSkinAdjustment->fD == 1) + arm1Offsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + arm1Offsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + arm1Offsets[2] = pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Leg0: + if(pSkinAdjustment->fD == 1) + leg0Offsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + leg0Offsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + leg0Offsets[2] = pSkinAdjustment->fO / 16.0f; + break; + case eBodyOffset_Leg1: + if(pSkinAdjustment->fD == 1) + leg1Offsets[0] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 2) + leg1Offsets[1] = pSkinAdjustment->fO / 16.0f; + else if(pSkinAdjustment->fD == 3) + leg1Offsets[2] = pSkinAdjustment->fO / 16.0f; + break; + } + } + } + + glPushMatrix(); + glTranslatef(headOffsets[0], headOffsets[1], headOffsets[2]); + head->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + body->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + arm0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + arm1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + leg0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + leg1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(headOffsets[0], headOffsets[1], headOffsets[2]); + hair->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + if (jacket != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + jacket->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (sleeve0 != 0) + { + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + sleeve0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (sleeve1 != 0) + { + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + sleeve1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (pants0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + pants0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (pants1 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + pants1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + glPopMatrix(); + } + if (waist != 0) + waist->render(scale, usecompiled); + if (belt != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + belt->render(scale, usecompiled); + glPopMatrix(); + } + if (bodyArmor != 0) + { + glPushMatrix(); + glTranslatef(bodyOffsets[0], bodyOffsets[1], bodyOffsets[2]); + bodyArmor->render(scale, usecompiled); + glPopMatrix(); + } + if (armArmor0 != 0) + { + glPushMatrix(); + glTranslatef(arm0Offsets[0], arm0Offsets[1], arm0Offsets[2]); + armArmor0->render(scale, usecompiled); + glPopMatrix(); + } + if (armArmor1 != 0) + { + glPushMatrix(); + glTranslatef(arm1Offsets[0], arm1Offsets[1], arm1Offsets[2]); + armArmor1->render(scale, usecompiled); + glPopMatrix(); + } + if (legging0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + legging0->render(scale, usecompiled); + glPopMatrix(); + } + if (legging1 != 0) + { + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + legging1->render(scale, usecompiled); + glPopMatrix(); + } + if (sock0 != 0) + sock0->render(scale, usecompiled); + if (sock1 != 0) + sock1->render(scale, usecompiled); + if (boot0 != 0) + { + glPushMatrix(); + glTranslatef(leg0Offsets[0], leg0Offsets[1], leg0Offsets[2]); + boot0->render(scale, usecompiled); + glPopMatrix(); + } + if (boot1 != 0) + { + glPushMatrix(); + glTranslatef(leg1Offsets[0], leg1Offsets[1], leg1Offsets[2]); + boot1->render(scale, usecompiled); + glPopMatrix(); + } + +} + void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { //bool bIsAttacking = (attackTime > -9990.0f); { + /* Code to get armor offsets, not fully implemented yet. Directly applying the offsets + causes the armor pivot points to not aline with the player model pivot points. Some math + is requied to properly rotate the armor pivot points around the player model pivot points - Langtanium*/ + vector headOffsets = {0, 0, 0}; + vector bodyOffsets = {0, 0, 0}; + vector arm0Offsets = {0, 0, 0}; + vector arm1Offsets = {0, 0, 0}; + vector leg0Offsets = {0, 0, 0}; + vector leg1Offsets = {0, 0, 0}; + if (m_isArmor) + { + shared_ptr player = dynamic_pointer_cast(entity); + vector* pSkinAdjustments = nullptr; + if (player != nullptr) + pSkinAdjustments = player->GetSkinAdjustments(); + if (pSkinAdjustments != nullptr) + { + for( SKIN_OFFSET *pSkinAdjustment : *pSkinAdjustments ) + { + switch (pSkinAdjustment->ePart) + { + case eBodyOffset_Helmet: + if(pSkinAdjustment->fD == 1) + headOffsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + headOffsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + headOffsets[2] += pSkinAdjustment->fO; + case eBodyOffset_Belt: + if (!body->isArmorPart1) + { + if(pSkinAdjustment->fD == 1) + bodyOffsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + bodyOffsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + bodyOffsets[2] += pSkinAdjustment->fO; + } + break; + case eBodyOffset_BodyArmor: + if (body->isArmorPart1) + { + if(pSkinAdjustment->fD == 1) + bodyOffsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + bodyOffsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + bodyOffsets[2] += pSkinAdjustment->fO; + } + break; + case eBodyOffset_ArmArmor0: + if(pSkinAdjustment->fD == 1) + arm0Offsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + arm0Offsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + arm0Offsets[2] += pSkinAdjustment->fO; + break; + case eBodyOffset_ArmArmor1: + if(pSkinAdjustment->fD == 1) + arm1Offsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + arm1Offsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + arm1Offsets[2] += pSkinAdjustment->fO; + break; + case eBodyOffset_Boot0: + if (leg0->isArmorPart1) + { + if(pSkinAdjustment->fD == 1) + leg0Offsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + leg0Offsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + leg0Offsets[2] += pSkinAdjustment->fO; + } + break; + case eBodyOffset_Boot1: + if (leg1->isArmorPart1) + { + if(pSkinAdjustment->fD == 1) + leg1Offsets[0] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 2) + leg1Offsets[1] += pSkinAdjustment->fO; + else if(pSkinAdjustment->fD == 3) + leg1Offsets[2] += pSkinAdjustment->fO; + } + break; + } + } + } + } + head->yRot = yRot / (float) (180.0f / PI); head->xRot = xRot / (float) (180.0f / PI); hair->yRot = head->yRot; @@ -199,7 +892,6 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float arm1->xRot=0.0f; arm0->zRot = 0.0f; arm1->zRot = 0.0f; - } else if(uiBitmaskOverrideAnim&(1<zRot = 0.0f; arm1->zRot = 0.0f; } - // arm0.zRot = ((float) (util.Mth.cos(time * 0.2312f) + 1) * 1) * r; + // arm0.zRot = ((float) (util.Mth.cos(time * 0.2312f) + 1) * 1) * r; - // arm1.zRot = ((float) (util.Mth.cos(time * 0.2812f) - 1) * 1) * r; + // arm1.zRot = ((float) (util.Mth.cos(time * 0.2812f) - 1) * 1) * r; leg0->yRot = 0.0f; @@ -272,7 +964,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float leg1->xRot=0.0f; leg1->zRot=0.0f; leg0->yRot = 0.0f; - leg1->yRot = 0.0f; + leg1->yRot = 0.0f; } else if(uiBitmaskOverrideAnim&(1<yRot = 0.0f; arm1->yRot = 0.0f; + if (attackTime > -9990.0f) { float swing = attackTime; @@ -316,7 +1009,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float float aa = Mth::sin(swing * PI); float bb = Mth::sin(attackTime * PI) * -(head->xRot - 0.7f) * 0.75f; arm0->xRot -= aa * 1.2f + bb; // 4J - changed 1.2 -> 1.2f - arm0->yRot += body->yRot * 2.0f; + arm0->yRot += body->yRot * 2.0f; if((uiBitmaskOverrideAnim&(1<xRot = - Mth::abs(Mth::cos(eating_t / 4.0f * PI) * 0.1f) * (eating_swing > 0.2 ? 1.0f : 0.0f) * 2.0f; // This factor is the chomping bit (conditional factor is so that he doesn't eat whilst the food is being pulled away at the end) arm0->yRot -= iss * 0.5f; // This factor and the following to the general arm movement through the life of the swing arm0->xRot -= iss * 1.2f; - } if (sneaking) @@ -410,6 +1102,13 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float body->y = 0.0f; arm0->y = 2.0f; arm1->y = 2.0f; + /*if (m_isArmor) // If armor apply helmet offset using some math, needs to be refined - Langtanium + { + head->x = headOffsets[1] * sin(yRot / (float) (180.0f / PI)) * sin(xRot / (float) (180.0f / PI)); + head->y = headOffsets[1] * cos(xRot / (float) (180.0f / PI)); + head->z = headOffsets[1] * sin(xRot / (float) (180.0f / PI)) - headOffsets[1] * abs(sin(yRot / (float) (180.0f / PI))) * sin(xRot / (float) (180.0f / PI)); + } + else*/ head->y = 0.0f; hair->y = 0.0f; ear->y = 1.0f; @@ -441,23 +1140,164 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float arm0->xRot += ((float) (Mth::sin(bob * 0.067f)) * 0.05f); arm1->xRot -= ((float) (Mth::sin(bob * 0.067f)) * 0.05f); } + + if (jacket != 0) + { + jacket->x = body->x; + jacket->y = body->y; + jacket->z = body->z; + jacket->xRot = body->xRot; + jacket->yRot = body->yRot; + } + if (sleeve0 != 0) + { + sleeve0->x = arm0->x; + sleeve0->y = arm0->y; + sleeve0->z = arm0->z; + sleeve0->xRot = arm0->xRot; + sleeve0->yRot = arm0->yRot; + sleeve0->zRot = arm0->zRot; + } + if (sleeve1 != 0) + { + sleeve1->x = arm1->x; + sleeve1->y = arm1->y; + sleeve1->z = arm1->z; + sleeve1->xRot = arm1->xRot; + sleeve1->yRot = arm1->yRot; + sleeve1->zRot = arm1->zRot; + } + if (pants0 != 0) + { + pants0->x = leg0->x; + pants0->y = leg0->y; + pants0->z = leg0->z; + pants0->xRot = leg0->xRot; + pants0->yRot = leg0->yRot; + pants0->zRot = leg0->zRot; + } + if (pants1 != 0) + { + pants1->x = leg1->x; + pants1->y = leg1->y; + pants1->z = leg1->z; + pants1->xRot = leg1->xRot; + pants1->yRot = leg1->yRot; + pants1->zRot = leg1->zRot; + } + if (waist != 0) + { + waist->x = body->x; + waist->y = body->y; + waist->z = body->z; + waist->xRot = body->xRot; + waist->yRot = body->yRot; + } + if (belt != 0) + { + belt->x = body->x; + belt->y = body->y; + belt->z = body->z; + belt->xRot = body->xRot; + belt->yRot = body->yRot; + } + if (bodyArmor != 0) + { + bodyArmor->x = body->x; + bodyArmor->y = body->y; + bodyArmor->z = body->z; + bodyArmor->xRot = body->xRot; + bodyArmor->yRot = body->yRot; + } + if (armArmor0 != 0) + { + armArmor0->x = arm0->x; + armArmor0->y = arm0->y; + armArmor0->z = arm0->z; + armArmor0->xRot = arm0->xRot; + armArmor0->yRot = arm0->yRot; + armArmor0->zRot = arm0->zRot; + } + if (armArmor1 != 0) + { + armArmor1->x = arm1->x; + armArmor1->y = arm1->y; + armArmor1->z = arm1->z; + armArmor1->xRot = arm1->xRot; + armArmor1->yRot = arm1->yRot; + armArmor1->zRot = arm1->zRot; + } + if (legging0 != 0) + { + legging0->x = leg0->x; + legging0->y = leg0->y; + legging0->z = leg0->z; + legging0->xRot = leg0->xRot; + legging0->yRot = leg0->yRot; + legging0->zRot = leg0->zRot; + } + if (legging1 != 0) + { + legging1->x = leg1->x; + legging1->y = leg1->y; + legging1->z = leg1->z; + legging1->xRot = leg1->xRot; + legging1->yRot = leg1->yRot; + legging1->zRot = leg1->zRot; + } + if (sock0 != 0) + { + sock0->x = leg0->x; + sock0->y = leg0->y; + sock0->z = leg0->z; + sock0->xRot = leg0->xRot; + sock0->yRot = leg0->yRot; + sock0->zRot = leg0->zRot; + } + if (sock1 != 0) + { + sock1->x = leg1->x; + sock1->y = leg1->y; + sock1->z = leg1->z; + sock1->xRot = leg1->xRot; + sock1->yRot = leg1->yRot; + sock1->zRot = leg1->zRot; + } + if (boot0 != 0) + { + boot0->x = leg0->x; + boot0->y = leg0->y; + boot0->z = leg0->z; + boot0->xRot = leg0->xRot; + boot0->yRot = leg0->yRot; + boot0->zRot = leg0->zRot; + } + if (boot1 != 0) + { + boot1->x = leg1->x; + boot1->y = leg1->y; + boot1->z = leg1->z; + boot1->xRot = leg1->xRot; + boot1->yRot = leg1->yRot; + boot1->zRot = leg1->zRot; + } } } void HumanoidModel::renderHair(float scale,bool usecompiled) { - hair->yRot = head->yRot; - hair->xRot = head->xRot; - hair->render(scale,usecompiled); + hair->yRot = head->yRot; + hair->xRot = head->xRot; + hair->render(scale,usecompiled); } void HumanoidModel::renderEars(float scale,bool usecompiled) { - ear->yRot = head->yRot; - ear->xRot = head->xRot; - ear->x=0; - ear->y=0; - ear->render(scale,usecompiled); + ear->yRot = head->yRot; + ear->xRot = head->xRot; + ear->x=0; + ear->y=0; + ear->render(scale,usecompiled); } void HumanoidModel::renderCloak(float scale,bool usecompiled) @@ -467,25 +1307,46 @@ void HumanoidModel::renderCloak(float scale,bool usecompiled) void HumanoidModel::render(HumanoidModel *model, float scale, bool usecompiled) { - head->yRot = model->head->yRot; - head->y = model->head->y; - head->xRot = model->head->xRot; - hair->y = head->y; - hair->yRot = head->yRot; - hair->xRot = head->xRot; + head->yRot = model->head->yRot; + head->y = model->head->y; + head->xRot = model->head->xRot; + hair->y = head->y; + hair->yRot = head->yRot; + hair->xRot = head->xRot; - body->yRot = model->body->yRot; - - arm0->xRot = model->arm0->xRot; - arm0->yRot = model->arm0->yRot; - arm0->zRot = model->arm0->zRot; - - arm1->xRot = model->arm1->xRot; - arm1->yRot = model->arm1->yRot; - arm1->zRot = model->arm1->zRot; - - leg0->xRot = model->leg0->xRot; - leg1->xRot = model->leg1->xRot; + body->yRot = model->body->yRot; + + if (jacket != 0) + jacket->yRot = model->body->yRot; + + arm0->xRot = model->arm0->xRot; + arm0->yRot = model->arm0->yRot; + arm0->zRot = model->arm0->zRot; + + if (sleeve0 != 0) + { + sleeve0->xRot = model->arm0->xRot; + sleeve0->yRot = model->arm0->yRot; + sleeve0->zRot = model->arm0->zRot; + } + + arm1->xRot = model->arm1->xRot; + arm1->yRot = model->arm1->yRot; + arm1->zRot = model->arm1->zRot; + + if (sleeve1 != 0) + { + sleeve1->xRot = model->arm1->xRot; + sleeve1->yRot = model->arm1->yRot; + sleeve1->zRot = model->arm1->zRot; + } + + leg0->xRot = model->leg0->xRot; + if (pants0 != 0) + pants0->xRot = model->leg0->xRot; + leg1->xRot = model->leg1->xRot; + if (pants1 != 0) + pants1->xRot = model->leg1->xRot; head->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); body->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); @@ -494,4 +1355,14 @@ void HumanoidModel::render(HumanoidModel *model, float scale, bool usecompiled) leg0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); leg1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); hair->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + if (jacket != 0) + jacket->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + if (sleeve0 != 0) + sleeve0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + if (sleeve1 != 0) + sleeve1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + if (pants0 != 0) + pants0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); + if (pants1 != 0) + pants1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); } diff --git a/Minecraft.Client/HumanoidModel.h b/Minecraft.Client/HumanoidModel.h index 52f9d98e1..5b8531ea5 100644 --- a/Minecraft.Client/HumanoidModel.h +++ b/Minecraft.Client/HumanoidModel.h @@ -1,10 +1,16 @@ #pragma once #include "Model.h" +#include "SkinOffset.h" class HumanoidModel : public Model { public: + // Base geometry ModelPart *head, *hair, *body, *arm0, *arm1, *leg0, *leg1, *ear, *cloak; + // Second layer/64x64 skin geometry + ModelPart *jacket, *sleeve0, *sleeve1, *pants0, *pants1; + // Extra geometry for DLC skins + ModelPart *waist, *belt, *bodyArmor, *armArmor0, *armArmor1, *legging0, *legging1, *sock0, *sock1, *boot0, *boot1; //ModelPart *hat; int holdingLeftHand; @@ -17,6 +23,7 @@ public: float eating_swing; // 4J added unsigned int m_uiAnimOverrideBitmask; // 4J added float m_fYOffset; // 4J added + bool m_isArmor; enum animbits { eAnim_ArmsDown =0, @@ -37,7 +44,22 @@ public: eAnim_DisableRenderLeg0, eAnim_DisableRenderLeg1, eAnim_DisableRenderHair, - eAnim_SmallModel // Maggie Simpson for riding horse, etc + eAnim_SmallModel, // Maggie Simpson for riding horse, etc + eAnim_WideModel, + eAnim_SlimModel, + // Hide overlay/second layer on 64x64 skins + eAnim_DisableRenderSleeve1, + eAnim_DisableRenderSleeve0, + eAnim_DisableRenderPants1, + eAnim_DisableRenderPants0, + eAnim_DisableRenderJacket, + eAnim_RenderArmorHead, + eAnim_RenderArmorArm0, + eAnim_RenderArmorArm1, + eAnim_RenderArmorTorso, + eAnim_RenderArmorLeg0, + eAnim_RenderArmorLeg1, + eAnim_Dinnerbone }; @@ -47,14 +69,22 @@ public: (1< entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled); + virtual void renderUIAdjustments(float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled, vector *skinAdjustments); virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr entity, unsigned int uiBitmaskOverrideAnim = 0); void renderHair(float scale, bool usecompiled); void renderEars(float scale, bool usecompiled); diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index 034498cf5..c4161c0ab 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -9,15 +9,22 @@ #include "../Minecraft.World/Mth.h" #include "../Minecraft.World/Player.h" - ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION = ResourceLocation(TN__BLUR__MISC_GLINT); int LivingEntityRenderer::MAX_ARMOR_LAYERS = 4; -LivingEntityRenderer::LivingEntityRenderer(Model *model, float shadow) +LivingEntityRenderer::LivingEntityRenderer(Model *model, float shadow, bool isPlayer) { this->model = model; + + if (isPlayer) + { + this->modelWide = new HumanoidModel(0, 0, 64, 64, false); + this->modelSlim = new HumanoidModel(0, 0, 64, 64, true); + } + shadowRadius = shadow; armor = nullptr; + resModel = model; } void LivingEntityRenderer::setArmor(Model *armor) @@ -25,6 +32,11 @@ void LivingEntityRenderer::setArmor(Model *armor) this->armor = armor; } +void LivingEntityRenderer::setPlayerModelType(Model *humanoidModel) +{ + resModel = humanoidModel; +} + float LivingEntityRenderer::rotlerp(float from, float to, float a) { float diff = to - from; @@ -52,12 +64,12 @@ void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, d glPushMatrix(); glDisable(GL_CULL_FACE); - model->attackTime = getAttackAnim(mob, a); - if (armor != nullptr) armor->attackTime = model->attackTime; - model->riding = mob->isRiding(); - if (armor != nullptr) armor->riding = model->riding; - model->young = mob->isBaby(); - if (armor != nullptr) armor->young = model->young; + resModel->attackTime = getAttackAnim(mob, a); + if (armor != nullptr) armor->attackTime = resModel->attackTime; + resModel->riding = mob->isRiding(); + if (armor != nullptr) armor->riding = resModel->riding; + resModel->young = mob->isBaby(); + if (armor != nullptr) armor->young = resModel->young; /*try*/ { @@ -103,7 +115,7 @@ void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, d if (ws > 1) ws = 1; glEnable(GL_ALPHA_TEST); - model->prepareMobModel(mob, wp, ws, a); + resModel->prepareMobModel(mob, wp, ws, a); renderModel(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale); for (int i = 0; i < MAX_ARMOR_LAYERS; i++) @@ -187,7 +199,7 @@ void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, d if (mob->hurtTime > 0 || mob->deathTime > 0) { glColor4f(br, 0, 0, 0.4f); - model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale, false); + resModel->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale, false); for (int i = 0; i < MAX_ARMOR_LAYERS; i++) { if (prepareArmorOverlay(mob, i, a) >= 0) @@ -205,7 +217,7 @@ void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, d float b = ((overlayColor) & 0xff) / 255.0f; float aa = ((overlayColor >> 24) & 0xff) / 255.0f; glColor4f(r, g, b, aa); - model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale, false); + resModel->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale, false); for (int i = 0; i < MAX_ARMOR_LAYERS; i++) { if (prepareArmorOverlay(mob, i, a) >= 0) @@ -245,7 +257,7 @@ void LivingEntityRenderer::renderModel(shared_ptr mob, float wp, f bindTexture(mob); if (!mob->isInvisible()) { - model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); + resModel->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); } else if(!mob->isInvisibleTo(dynamic_pointer_cast(Minecraft::GetInstance()->player))) { @@ -255,7 +267,7 @@ void LivingEntityRenderer::renderModel(shared_ptr mob, float wp, f glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 1.0f / 255.0f); - model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); + resModel->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); glDisable(GL_BLEND); glAlphaFunc(GL_GREATER, .1f); glPopMatrix(); @@ -263,7 +275,7 @@ void LivingEntityRenderer::renderModel(shared_ptr mob, float wp, f } else { - model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale, mob); + resModel->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale, mob); } } @@ -285,7 +297,7 @@ void LivingEntityRenderer::setupRotations(shared_ptr mob, float bo else { wstring name = mob->getAName(); - if (name == L"Dinnerbone" || name == L"Grumm") + if (name == L"Dinnerbone" || name == L"Grumm" || mob->getAnimOverrideBitmask()&(1<instanceof(eTYPE_PLAYER) || !dynamic_pointer_cast(mob)->isCapeHidden() ) { @@ -314,6 +326,7 @@ void LivingEntityRenderer::additionalRendering(shared_ptr mob, flo void LivingEntityRenderer::renderArrows(shared_ptr mob, float a) { int arrowCount = mob->getArrowCount(); + if (arrowCount > 0) { shared_ptr arrow = std::make_shared(mob->level, mob->x, mob->y, mob->z); @@ -322,7 +335,10 @@ void LivingEntityRenderer::renderArrows(shared_ptr mob, float a) for (int i = 0; i < arrowCount; i++) { glPushMatrix(); - ModelPart *modelPart = model->getRandomModelPart(random); + + ModelPart *modelPart; + modelPart = resModel->getRandomModelPart(random); + Cube *cube = modelPart->cubes[random.nextInt(modelPart->cubes.size())]; modelPart->translateTo(1 / 16.0f); float xd = random.nextFloat(); diff --git a/Minecraft.Client/LivingEntityRenderer.h b/Minecraft.Client/LivingEntityRenderer.h index 8a9cbcdd1..5c564e374 100644 --- a/Minecraft.Client/LivingEntityRenderer.h +++ b/Minecraft.Client/LivingEntityRenderer.h @@ -17,11 +17,13 @@ class LivingEntityRenderer : public EntityRenderer protected: //Model *model; // 4J Stu - This shadows the one in EntityRenderer Model *armor; + Model *resModel; public: - LivingEntityRenderer(Model *model, float shadow); + LivingEntityRenderer(Model *model, float shadow, bool isPlayer = false); virtual void render(shared_ptr mob, double x, double y, double z, float rot, float a); virtual void setArmor(Model *armor); + virtual void setPlayerModelType(Model *humanoidModel); private: float rotlerp(float from, float to, float a); diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index f1e5a17b5..cd7dd889b 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -1696,3 +1696,7 @@ void LocalPlayer::SetPlayerAdditionalModelParts(vectorpAdditionalMo { m_pAdditionalModelParts=pAdditionalModelParts; } +void LocalPlayer::SetPlayerModelOffsets(vectorpModelOffsets) +{ + m_pModelOffsets=pModelOffsets; +} diff --git a/Minecraft.Client/LocalPlayer.h b/Minecraft.Client/LocalPlayer.h index de832c853..b27e29155 100644 --- a/Minecraft.Client/LocalPlayer.h +++ b/Minecraft.Client/LocalPlayer.h @@ -211,9 +211,11 @@ public: virtual void handleCollectItem(shared_ptr item); void SetPlayerAdditionalModelParts(vectorpAdditionalModelParts); + void SetPlayerModelOffsets(vectorpModelOffsets); private: vector m_pAdditionalModelParts; + vector m_pModelOffsets; }; diff --git a/Minecraft.Client/ModelPart.cpp b/Minecraft.Client/ModelPart.cpp index e423a4ae2..ac081f78b 100644 --- a/Minecraft.Client/ModelPart.cpp +++ b/Minecraft.Client/ModelPart.cpp @@ -13,6 +13,8 @@ void ModelPart::_init() compiled=false; bMirror = false; visible = true; + hideWithArmor = 0L; + isArmorPart1 = false; neverRender = false; x=y=z = 0.0f; xRot=yRot=zRot = 0.0f; diff --git a/Minecraft.Client/ModelPart.h b/Minecraft.Client/ModelPart.h index da78e5437..df3b1e8b0 100644 --- a/Minecraft.Client/ModelPart.h +++ b/Minecraft.Client/ModelPart.h @@ -16,6 +16,8 @@ public: float xRot, yRot, zRot; bool bMirror; bool visible; + unsigned int hideWithArmor; + bool isArmorPart1; bool neverRender; vector cubes; vector children; diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index bdb66f6ea..96e128d7b 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -885,22 +885,16 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) - { - send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pDLCSkinFile)); - } - else - { - send(std::make_shared(packet->textureName, pbData, dwTextureBytes)); - } + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pDLCSkinFile)); } else { // we don't have the dlc skin, so retrieve the data from the app store vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID); + vector *pvSkinAdjustments = app.GetSkinAdjustments(packet->dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, pvSkinAdjustments, uiAnimOverrideBitmask)); } } else @@ -924,6 +918,14 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrdwSkinID,packet->BoxDataA,packet->dwBoxC); } + // add the offsets to the app list + if(packet->dwOffsetC!=0) + { +#ifndef _CONTENT_PACKAGE + wprintf(L"Adding skin offsets for skin id %X, offset count %d\n",packet->dwSkinID,packet->dwOffsetC); +#endif + app.SetSkinAdjustments(packet->dwSkinID,packet->OffsetDataA,packet->dwOffsetC); + } // Add the anim override app.SetAnimOverrideBitmask(packet->dwSkinID,packet->uiAnimOverrideBitmask); @@ -973,9 +975,10 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa // get the data from the app DWORD dwSkinID = app.getSkinIdFromPath(textureName); vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); + vector *pvSkinOffsets = app.GetSkinAdjustments(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); - send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); + send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, pvSkinOffsets, uiAnimOverrideBitmask)); } m_texturesRequested.erase(it); } diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 634a6b5e8..a9ff00fcb 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -55,12 +55,21 @@ static unsigned int nametagColorForIndex(int index) ResourceLocation PlayerRenderer::DEFAULT_LOCATION = ResourceLocation(TN_MOB_CHAR); -PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0.5f ) +PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0.5f, true ) { - humanoidModel = static_cast(model); + humanoidModel = static_cast(model); + humanoidModelWide = static_cast(modelWide); + humanoidModelSlim = static_cast(modelSlim); - armorParts1 = new HumanoidModel(1.0f); - armorParts2 = new HumanoidModel(0.5f); + armorParts1 = new HumanoidModel(1.0f, true); + armorParts2 = new HumanoidModel(0.5f, true); +} + +void PlayerRenderer::setModelType(shared_ptr player) +{ + if (Player::GetModelTypeFromTextureId(player->getCustomSkin()) == 1 || Player::GetModelTypeFromAnimBitmask(player->getAnimOverrideBitmask()) == 1) resModel = humanoidModelWide; + else if (Player::GetModelTypeFromTextureId(player->getCustomSkin()) == 2 || Player::GetModelTypeFromAnimBitmask(player->getAnimOverrideBitmask()) == 2) resModel = humanoidModelSlim; + else resModel = humanoidModel; } unsigned int PlayerRenderer::getNametagColour(int index) @@ -74,6 +83,7 @@ int PlayerRenderer::prepareArmor(shared_ptr _player, int layer, fl { // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr player = dynamic_pointer_cast(_player); + setModelType(player); // 4J-PB - need to disable rendering armour for some special skins (Daleks) unsigned int uiAnimOverrideBitmask=player->getAnimOverrideBitmask(); @@ -101,10 +111,18 @@ int PlayerRenderer::prepareArmor(shared_ptr _player, int layer, fl armor->leg0->visible = layer == 2 || layer == 3; armor->leg1->visible = layer == 2 || layer == 3; + armor->head->isArmorPart1 = layer == 0; + armor->hair->isArmorPart1 = layer == 0; + armor->body->isArmorPart1 = layer == 1; + armor->arm0->isArmorPart1 = layer == 1; + armor->arm1->isArmorPart1 = layer == 1; + armor->leg0->isArmorPart1 = layer == 3; + armor->leg1->isArmorPart1 = layer == 3; + setArmor(armor); - if (armor != nullptr) armor->attackTime = model->attackTime; - if (armor != nullptr) armor->riding = model->riding; - if (armor != nullptr) armor->young = model->young; + if (armor != nullptr) armor->attackTime = resModel->attackTime; + if (armor != nullptr) armor->riding = resModel->riding; + if (armor != nullptr) armor->young = resModel->young; float brightness = SharedConstants::TEXTURE_LIGHTING ? 1 : player->getBrightness(a); if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) @@ -164,8 +182,13 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double if(mob == nullptr) return; if(mob->hasInvisiblePrivilege()) return; + setModelType(mob); + setPlayerModelType(resModel); + shared_ptr item = mob->inventory->getSelected(); - armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != nullptr ? 1 : 0; + + armorParts1->holdingRightHand = armorParts2->holdingRightHand = resModel->holdingRightHand = item != nullptr ? 1 : 0; + if (item != nullptr) { if (mob->getUseItemDuration() > 0) @@ -173,11 +196,11 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double UseAnim anim = item->getUseAnimation(); if (anim == UseAnim_block) { - armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = 3; + armorParts1->holdingRightHand = armorParts2->holdingRightHand = resModel->holdingRightHand = 3; } else if (anim == UseAnim_bow) { - armorParts1->bowAndArrow = armorParts2->bowAndArrow = humanoidModel->bowAndArrow = true; + armorParts1->bowAndArrow = armorParts2->bowAndArrow = resModel->bowAndArrow = true; } } } @@ -187,17 +210,17 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double // These factors are largely lifted from ItemInHandRenderer to try and keep the 3rd person eating animation as similar as possible float t = (mob->getUseItemDuration() - a + 1); float swing = 1 - (t / item->getUseDuration()); - armorParts1->eating = armorParts2->eating = humanoidModel->eating = true; - armorParts1->eating_t = armorParts2->eating_t = humanoidModel->eating_t = t; - armorParts1->eating_swing = armorParts2->eating_swing = humanoidModel->eating_swing = swing; + + armorParts1->eating = armorParts2->eating = resModel->eating = true; + armorParts1->eating_t = armorParts2->eating_t = resModel->eating_t = t; + armorParts1->eating_swing = armorParts2->eating_swing = resModel->eating_swing = swing; } else { - armorParts1->eating = armorParts2->eating = humanoidModel->eating = false; + armorParts1->eating = armorParts2->eating = resModel->eating = false; } - armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = mob->isSneaking(); - + armorParts1->sneaking = armorParts2->sneaking = resModel->sneaking = mob->isSneaking(); double yp = y - mob->heightOffset; if (mob->isSneaking()) { @@ -224,24 +247,30 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double { if(mob->isIdle()) { - humanoidModel->idle=true; + resModel->idle=true; armorParts1->idle=true; armorParts2->idle=true; } else { - humanoidModel->idle=false; + resModel->idle=false; armorParts1->idle=false; armorParts2->idle=false; } } else { - humanoidModel->idle=false; + resModel->idle=false; armorParts1->idle=false; armorParts2->idle=false; } + // Get armor in armor slot so we can hide the armor layer of the skin - Langtanium + shared_ptr itemHelmet = mob->inventory->getArmor(3); + shared_ptr itemChestplate = mob->inventory->getArmor(2); + shared_ptr itemLeggings = mob->inventory->getArmor(1); + shared_ptr itemBoots = mob->inventory->getArmor(0); + // 4J-PB - any additional parts to turn on for this player (skin dependent) vector *pAdditionalModelParts=mob->GetAdditionalModelParts(); //turn them on @@ -249,7 +278,16 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double { for(ModelPart *pModelPart : *pAdditionalModelParts) { - pModelPart->visible=true; + if (itemHelmet != nullptr && pModelPart->hideWithArmor&(1<<0)) // Hide the skin boxes that have the "hide when helmet is worn" bit flag - Langtanium + pModelPart->visible=false; + else if (itemChestplate != nullptr && pModelPart->hideWithArmor&(1<<1)) // Hide the skin boxes that have the "hide when chestplate is worn" bit flag - Langtanium + pModelPart->visible=false; + else if (itemLeggings != nullptr && pModelPart->hideWithArmor&(1<<2)) // Hide the skin boxes that have the "hide when leggings are worn" bit flag - Langtanium + pModelPart->visible=false; + else if (itemBoots != nullptr && pModelPart->hideWithArmor&(1<<3)) // Hide the skin boxes that have the "hide when boots are worn" bit flag - Langtanium + pModelPart->visible=false; + else + pModelPart->visible=true; } } @@ -263,10 +301,10 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double pModelPart->visible=false; } } - armorParts1->bowAndArrow = armorParts2->bowAndArrow = humanoidModel->bowAndArrow = false; - armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = false; - armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = 0; + armorParts1->bowAndArrow = armorParts2->bowAndArrow = resModel->bowAndArrow = false; + armorParts1->sneaking = armorParts2->sneaking = resModel->sneaking = false; + armorParts1->holdingRightHand = armorParts2->holdingRightHand = resModel->holdingRightHand = 0; } void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) @@ -279,6 +317,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr mob = dynamic_pointer_cast(_mob); + setModelType(mob); shared_ptr headGear = mob->inventory->getArmor(3); if (headGear != nullptr) @@ -289,7 +328,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) if((uiAnimOverrideBitmask&(1<head->translateTo(1 / 16.0f); + resModel->head->translateTo(1 / 16.0f); if(headGear->getItem()->id < 256) { @@ -337,7 +376,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) float s = 8 / 6.0f; glScalef(s, s, s); - humanoidModel->renderEars(1 / 16.0f,true); + resModel->renderEars(1 / 16.0f,true); glPopMatrix(); } } @@ -383,7 +422,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) glRotatef(lean2 / 2, 0, 0, 1); glRotatef(-lean2 / 2, 0, 1, 0); glRotatef(180, 0, 1, 0); - humanoidModel->renderCloak(1 / 16.0f,true); + humanoidModel->renderCloak(1 / 16.0f,true); glPopMatrix(); } @@ -392,7 +431,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) if (item != nullptr) { glPushMatrix(); - humanoidModel->arm0->translateTo(1 / 16.0f); + resModel->arm0->translateTo(1 / 16.0f); glTranslatef(-1 / 16.0f, 7 / 16.0f, 1 / 16.0f); if (mob->fishing != nullptr) @@ -522,30 +561,50 @@ void PlayerRenderer::scale(shared_ptr player, float a) void PlayerRenderer::renderHand() { + shared_ptr player = dynamic_pointer_cast(Minecraft::GetInstance()->player); + setModelType(player); + float brightness = 1; glColor3f(brightness, brightness, brightness); - humanoidModel->m_uiAnimOverrideBitmask = Minecraft::GetInstance()->player->getAnimOverrideBitmask(); - armorParts1->eating = armorParts2->eating = humanoidModel->eating = humanoidModel->idle = false; - humanoidModel->attackTime = 0; - humanoidModel->setupAnim(0, 0, 0, 0, 0, 1 / 16.0f, Minecraft::GetInstance()->player); + resModel->m_uiAnimOverrideBitmask = player->getAnimOverrideBitmask(); + armorParts1->eating = armorParts2->eating = resModel->eating = resModel->idle = false; + resModel->attackTime = 0; + resModel->setupAnim(0, 0, 0, 0, 0, 1 / 16.0f, Minecraft::GetInstance()->player); // 4J-PB - does this skin have its arm0 disabled? (Dalek, etc) - if((humanoidModel->m_uiAnimOverrideBitmask&(1<arm0->render(1 / 16.0f,true); - } - - + if((resModel->m_uiAnimOverrideBitmask&(1<arm0->render(1 / 16.0f,true); + // Does this skin have its sleeve0 disabled? + if((resModel->m_uiAnimOverrideBitmask&(1<sleeve0!=nullptr) + resModel->sleeve0->render(1 / 16.0f,true); + //Render custom skin boxes on viewmodel - Botch - vector* additionalModelParts = Minecraft::GetInstance()->player->GetAdditionalModelParts(); + vector* additionalModelParts = player->GetAdditionalModelParts(); if (!additionalModelParts) return; //If there are no custom boxes, return. This fixes bug where the game will crash if you select a skin with no additional boxes. - vector armchildren = humanoidModel->arm0->children; std::unordered_set additionalModelPartSet(additionalModelParts->begin(), additionalModelParts->end()); + vector armchildren = resModel->arm0->children; for (const auto& x : armchildren) { - if (x) { - if (additionalModelPartSet.find(x) != additionalModelPartSet.end()) { //This is to verify box is still actually on current skin - Botch + if (x && additionalModelPartSet.find(x) != additionalModelPartSet.end()) //This is to verify box is still actually on current skin - Botch + { + glPushMatrix(); + //We need to transform to match offset of arm - Botch + glTranslatef(-5 * 0.0625f, 2 * 0.0625f, 0); + glRotatef(0.1 * (180.0f / PI), 0, 0, 1); + x->visible = true; + x->render(1.0f / 16.0f, true); + x->visible = false; + glPopMatrix(); + } + } + //Render custom skin boxes on viewmodel for sleeve0 + if (resModel->sleeve0!=nullptr) + { + vector sleevechildren = resModel->sleeve0->children; + for (const auto& x : sleevechildren) { + if (x && additionalModelPartSet.find(x) != additionalModelPartSet.end()) //This is to verify box is still actually on current skin + { glPushMatrix(); - //We need to transform to match offset of arm - Botch + //We need to transform to match offset of arm/sleeve glTranslatef(-5 * 0.0625f, 2 * 0.0625f, 0); glRotatef(0.1 * (180.0f / PI), 0, 0, 1); x->visible = true; @@ -555,8 +614,6 @@ void PlayerRenderer::renderHand() } } } - - } void PlayerRenderer::setupPosition(shared_ptr _mob, double x, double y, double z) diff --git a/Minecraft.Client/PlayerRenderer.h b/Minecraft.Client/PlayerRenderer.h index c5ae8250e..7086193ff 100644 --- a/Minecraft.Client/PlayerRenderer.h +++ b/Minecraft.Client/PlayerRenderer.h @@ -14,6 +14,10 @@ public: private: HumanoidModel *humanoidModel; + HumanoidModel *humanoidModelWide; + HumanoidModel *humanoidModelSlim; + HumanoidModel *resModel; + HumanoidModel *armorParts1; HumanoidModel *armorParts2; @@ -26,6 +30,7 @@ private: static const wstring MATERIAL_NAMES[5]; protected: + virtual void setModelType(shared_ptr player); virtual int prepareArmor(shared_ptr _player, int layer, float a); virtual void prepareSecondPassArmor(shared_ptr mob, int layer, float a); diff --git a/Minecraft.Client/SkinBox.h b/Minecraft.Client/SkinBox.h index 827e4447c..d82a790da 100644 --- a/Minecraft.Client/SkinBox.h +++ b/Minecraft.Client/SkinBox.h @@ -9,11 +9,28 @@ enum eBodyPart eBodyPart_Arm1, eBodyPart_Leg0, eBodyPart_Leg1, + eBodyPart_Headwear, + eBodyPart_Jacket, + eBodyPart_Sleeve0, + eBodyPart_Sleeve1, + eBodyPart_Pants0, + eBodyPart_Pants1, + eBodyPart_Waist, + eBodyPart_Legging0, + eBodyPart_Legging1, + eBodyPart_Sock0, + eBodyPart_Sock1, + eBodyPart_Boot0, + eBodyPart_Boot1, + eBodyPart_ArmArmor0, + eBodyPart_ArmArmor1, + eBodyPart_BodyArmor, + eBodyPart_Belt }; typedef struct { eBodyPart ePart; - float fX,fY,fZ,fW,fH,fD,fU,fV; + float fX,fY,fZ,fW,fH,fD,fU,fV,fA,fM,fS; } SKIN_BOX; diff --git a/Minecraft.Client/SkinOffset.h b/Minecraft.Client/SkinOffset.h new file mode 100644 index 000000000..79d39cac3 --- /dev/null +++ b/Minecraft.Client/SkinOffset.h @@ -0,0 +1,48 @@ +#pragma once + +enum eBodyOffset +{ + eBodyOffset_Unknown=0, + eBodyOffset_Head, + eBodyOffset_Body, + eBodyOffset_Arm0, + eBodyOffset_Arm1, + eBodyOffset_Leg0, + eBodyOffset_Leg1, + eBodyOffset_Headwear, + eBodyOffset_Jacket, + eBodyOffset_Sleeve0, + eBodyOffset_Sleeve1, + eBodyOffset_Pants0, + eBodyOffset_Pants1, + eBodyOffset_Helmet, + eBodyOffset_Waist, + eBodyOffset_Legging0, + eBodyOffset_Legging1, + eBodyOffset_Sock0, + eBodyOffset_Sock1, + eBodyOffset_Boot0, + eBodyOffset_Boot1, + eBodyOffset_ArmArmor1, + eBodyOffset_ArmArmor0, + eBodyOffset_BodyArmor, + eBodyOffset_Belt, + eBodyOffset_Tool0, + eBodyOffset_Tool1 + +}; + +enum eOffsetDirection +{ + eOffsetDirection_Unknown=0, + eOffsetDirection_X, + eOffsetDirection_Y, + eOffsetDirection_Z +}; + +typedef struct +{ + eBodyOffset ePart; + float fD, fO; +} +SKIN_OFFSET; diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index 778f00ccb..5476d7b97 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -72,6 +72,16 @@ const wchar_t *Textures::preLoaded[TN_COUNT] = L"mob/char5", L"mob/char6", L"mob/char7", + L"mob/alex", + L"mob/alex1", + L"mob/alex2", + L"mob/alex3", + L"mob/alex4", + L"mob/alex5", + L"mob/alex6", + L"mob/alex7", + L"mob/DevAlex", + L"mob/DevSteve", L"terrain/moon", L"terrain/sun", L"armor/power", diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index 11c3014f3..aac6bed66 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -63,6 +63,16 @@ typedef enum _TEXTURE_NAME TN_MOB_CHAR5, TN_MOB_CHAR6, TN_MOB_CHAR7, + TN_MOB_ALEX, + TN_MOB_ALEX1, + TN_MOB_ALEX2, + TN_MOB_ALEX3, + TN_MOB_ALEX4, + TN_MOB_ALEX5, + TN_MOB_ALEX6, + TN_MOB_ALEX7, + TN_MOB_DEVALEX, + TN_MOB_DEVSTEVE, TN_TERRAIN_MOON, TN_TERRAIN_SUN, TN_POWERED_CREEPER, diff --git a/Minecraft.World/Definitions.h b/Minecraft.World/Definitions.h index d338019db..f45252f5b 100644 --- a/Minecraft.World/Definitions.h +++ b/Minecraft.World/Definitions.h @@ -35,6 +35,16 @@ enum EDefaultSkins eDefaultSkins_Skin5, eDefaultSkins_Skin6, eDefaultSkins_Skin7, + eDefaultSkins_Skin8, + eDefaultSkins_Skin9, + eDefaultSkins_Skin10, + eDefaultSkins_Skin11, + eDefaultSkins_Skin12, + eDefaultSkins_Skin13, + eDefaultSkins_Skin14, + eDefaultSkins_Skin15, + eDefaultSkins_Skin16, + eDefaultSkins_Skin17, eDefaultSkins_Count, }; \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 2942d7ef0..ee280873e 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -2132,7 +2132,12 @@ unsigned int Entity::getAnimOverrideBitmask() (1<SetAdditionalModelParts(nullptr); + this->SetSkinAdjustments(nullptr); } @@ -759,6 +765,12 @@ unsigned int Player::getSkinAnimOverrideBitmask(DWORD skinId) return bitmask; } +vector *Player::getSkinAdjustments(DWORD skinId) +{ + vector *skinAdjustments = app.GetSkinAdjustments(skinId); + return skinAdjustments; +} + void Player::setXuid(PlayerUID xuid) { m_xuid = xuid; @@ -2706,6 +2718,26 @@ int Player::getTexture() return TN_MOB_CHAR6; // 4J - was L"/mob/char6.png"; case eDefaultSkins_Skin7: return TN_MOB_CHAR7; // 4J - was L"/mob/char7.png"; + case eDefaultSkins_Skin8: + return TN_MOB_ALEX; // 4J - was L"/mob/alex.png"; + case eDefaultSkins_Skin9: + return TN_MOB_ALEX1; // 4J - was L"/mob/alex1.png"; + case eDefaultSkins_Skin10: + return TN_MOB_ALEX2; // 4J - was L"/mob/alex2.png"; + case eDefaultSkins_Skin11: + return TN_MOB_ALEX3; // 4J - was L"/mob/alex3.png"; + case eDefaultSkins_Skin12: + return TN_MOB_ALEX4; // 4J - was L"/mob/alex4.png"; + case eDefaultSkins_Skin13: + return TN_MOB_ALEX5; // 4J - was L"/mob/alex5.png"; + case eDefaultSkins_Skin14: + return TN_MOB_ALEX6; // 4J - was L"/mob/alex6.png"; + case eDefaultSkins_Skin15: + return TN_MOB_ALEX7; // 4J - was L"/mob/alex7.png"; + case eDefaultSkins_Skin16: + return TN_MOB_DEVALEX; // 4J - was L"/mob/DevAlex.png"; + case eDefaultSkins_Skin17: + return TN_MOB_DEVSTEVE; // 4J - was L"/mob/DevSteve.png"; default: return TN_MOB_CHAR; // 4J - was L"/mob/char.png"; @@ -3132,11 +3164,73 @@ vector *Player::GetAdditionalModelParts() return m_ppAdditionalModelParts; } +vector *Player::GetSkinAdjustments() +{ + if(m_ppSkinAdjustments==nullptr && !m_bCheckedForSkinAdjustments) + { + bool hasCustomTexture = !customTextureUrl.empty(); + bool customTextureIsDefaultSkin = customTextureUrl.substr(0,3).compare(L"def") == 0; + + // see if we can find the parts + m_ppSkinAdjustments=app.GetSkinAdjustments(m_dwSkinId); + + // If it's a default texture (which has no parts), we have the parts, or we already have the texture (in which case we should have parts if there are any) then we are done + if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppSkinAdjustments != nullptr || app.IsFileInMemoryTextures(customTextureUrl)) + { + m_bCheckedForSkinAdjustments=true; + } + if(m_ppSkinAdjustments == nullptr && !m_bCheckedDLCForSkinAdjustments) + { + m_bCheckedDLCForSkinAdjustments = true; + + // we don't have the data from the dlc skin yet + app.DebugPrintf("m_bCheckedForModelOffsets Couldn't get skin adjustments for skin %X\n",m_dwSkinId); + + // do we have it from the DLC pack? + DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); + + if(pDLCSkinFile!=nullptr) + { + DWORD dwOffsetC=pDLCSkinFile->getOffsetsCount(); + if(dwOffsetC!=0) + { + app.DebugPrintf("m_bCheckedForSkinAdjustments Got skin adjustments from DLCskin for skin %X\n",m_dwSkinId); + m_ppSkinAdjustments=app.SetSkinAdjustments(m_dwSkinId,pDLCSkinFile->getOffsets()); + } + + m_bCheckedForSkinAdjustments=true; + } + } + } + return m_ppSkinAdjustments; +} + +int Player::GetModelTypeFromAnimBitmask(unsigned int uiAnimOverrideBitmask) +{ + if (uiAnimOverrideBitmask&(1< 8 && textureId < 18) return 2; + else if (textureId == 18) return 1; + else if (textureId > 44 && textureId < 54) return 2; + else if (textureId == 54) return 1; + else return 0; +} + void Player::SetAdditionalModelParts(vector *ppAdditionalModelParts) { m_ppAdditionalModelParts=ppAdditionalModelParts; } +void Player::SetSkinAdjustments(vector *ppSkinAdjustments) +{ + m_ppSkinAdjustments=ppSkinAdjustments; +} + #if defined(__PS3__) || defined(__ORBIS__) Player::ePlayerNameValidState Player::GetPlayerNameValidState(void) diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 2e223a1e5..4ee19ccbe 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -411,6 +411,7 @@ public: static DWORD getCapeIdFromPath(const wstring &cape); static wstring getCapePathFromId(DWORD capeId); static unsigned int getSkinAnimOverrideBitmask(DWORD skinId); + vector *getSkinAdjustments(DWORD skinId); // 4J Added void setXuid(PlayerUID xuid); @@ -520,6 +521,10 @@ public: vector *GetAdditionalModelParts(); void SetAdditionalModelParts(vector *ppAdditionalModelParts); + vector *GetSkinAdjustments(); + void SetSkinAdjustments(vector *ppSkinAdjustments); + static int GetModelTypeFromAnimBitmask(unsigned int uiAnimOverrideBitmask); + static int GetModelTypeFromTextureId(int textureId); #if defined(__PS3__) || defined(__ORBIS__) enum ePlayerNameValidState @@ -536,6 +541,9 @@ private: vector *m_ppAdditionalModelParts; bool m_bCheckedForModelParts; bool m_bCheckedDLCForModelParts; + vector *m_ppSkinAdjustments; + bool m_bCheckedForSkinAdjustments; + bool m_bCheckedDLCForSkinAdjustments; #if defined(__PS3__) || defined(__ORBIS__) ePlayerNameValidState m_ePlayerNameValidState; // 4J-PB - to ensure we have the characters for this name in our font, or display a player number instead diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp index 1c920ee7a..44309caa3 100644 --- a/Minecraft.World/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/TextureAndGeometryPacket.cpp @@ -12,7 +12,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket() this->dwTextureBytes = 0; this->pbData = nullptr; this->dwBoxC = 0; + this->dwOffsetC = 0; this->BoxDataA = nullptr; + this->OffsetDataA = nullptr; uiAnimOverrideBitmask=0; } @@ -43,7 +45,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->dwBoxC = 0; + this->dwOffsetC = 0; this->BoxDataA=nullptr; + this->OffsetDataA=nullptr; this->uiAnimOverrideBitmask=0; } @@ -62,6 +66,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->dwTextureBytes = dwBytes; this->uiAnimOverrideBitmask = pDLCSkinFile->getAnimOverrideBitmask(); this->dwBoxC = pDLCSkinFile->getAdditionalBoxesCount(); + this->dwOffsetC = pDLCSkinFile->getOffsetsCount(); if(this->dwBoxC!=0) { this->BoxDataA= new SKIN_BOX [this->dwBoxC]; @@ -77,9 +82,24 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P { this->BoxDataA=nullptr; } + if(this->dwOffsetC!=0) + { + this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC]; + vector *pSkinOffsets=pDLCSkinFile->getOffsets(); + int iCount=0; + + for(auto& pSkinOffset : *pSkinOffsets) + { + this->OffsetDataA[iCount++]=*pSkinOffset; + } + } + else + { + this->OffsetDataA=nullptr; + } } -TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes,vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask) +TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask) { this->textureName = textureName; @@ -109,6 +129,22 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->BoxDataA[iCount++]=*pSkinBox; } } + if(pvSkinOffsets==nullptr) + { + this->dwOffsetC=0; + this->OffsetDataA=nullptr; + } + else + { + this->dwOffsetC = static_cast(pvSkinOffsets->size()); + this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC]; + int iCount=0; + + for(auto& pSkinOffset : *pvSkinOffsets) + { + this->OffsetDataA[iCount++]=*pSkinOffset; + } + } } @@ -148,6 +184,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException uiAnimOverrideBitmask = dis->readInt(); short rawBoxC = dis->readShort(); + short rawOffsetC = dis->readShort(); if (rawBoxC <= 0) { dwBoxC = 0; @@ -160,11 +197,27 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException dwBoxC = 0; // sane limit for skin boxes } } + if (rawOffsetC <= 0) + { + dwOffsetC = 0; + } + else + { + dwOffsetC = (DWORD)(unsigned short)rawOffsetC; + if (dwOffsetC > 256) + { + dwOffsetC = 0; // sane limit for skin offsets + } + } if(dwBoxC>0) { this->BoxDataA= new SKIN_BOX [dwBoxC]; } + if(dwOffsetC>0) + { + this->OffsetDataA= new SKIN_OFFSET [dwOffsetC]; + } for(DWORD i=0;iBoxDataA[i].fD = dis->readFloat(); this->BoxDataA[i].fU = dis->readFloat(); this->BoxDataA[i].fV = dis->readFloat(); + this->BoxDataA[i].fA = dis->readFloat(); + this->BoxDataA[i].fM = dis->readFloat(); + this->BoxDataA[i].fS = dis->readFloat(); + } + for(DWORD i=0;iOffsetDataA[i].ePart = static_cast(dis->readShort()); + this->OffsetDataA[i].fD = dis->readFloat(); + this->OffsetDataA[i].fO = dis->readFloat(); } } -void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException +void __fastcall TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); dos->writeInt(dwSkinID); @@ -203,6 +265,17 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException dos->writeFloat(this->BoxDataA[i].fD); dos->writeFloat(this->BoxDataA[i].fU); dos->writeFloat(this->BoxDataA[i].fV); + dos->writeFloat(this->BoxDataA[i].fA); + dos->writeFloat(this->BoxDataA[i].fM); + dos->writeFloat(this->BoxDataA[i].fS); + } + + dos->writeShort(static_cast(dwOffsetC)); + for(DWORD i=0;iwriteShort(static_cast(this->OffsetDataA[i].ePart)); + dos->writeFloat(this->OffsetDataA[i].fD); + dos->writeFloat(this->OffsetDataA[i].fO); } } diff --git a/Minecraft.World/TextureAndGeometryPacket.h b/Minecraft.World/TextureAndGeometryPacket.h index fa0a5837b..245edd2af 100644 --- a/Minecraft.World/TextureAndGeometryPacket.h +++ b/Minecraft.World/TextureAndGeometryPacket.h @@ -4,6 +4,7 @@ using namespace std; #include "Packet.h" #include "../Minecraft.Client/Model.h" #include "../Minecraft.Client/SkinBox.h" +#include "../Minecraft.Client/SkinOffset.h" class DLCSkinFile; @@ -15,14 +16,16 @@ public: PBYTE pbData; DWORD dwTextureBytes; SKIN_BOX *BoxDataA; + SKIN_OFFSET *OffsetDataA; DWORD dwBoxC; + DWORD dwOffsetC; unsigned int uiAnimOverrideBitmask; TextureAndGeometryPacket(); ~TextureAndGeometryPacket(); TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes); TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile); - TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask); + TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis);