Advertisement
expired6978

TintMaskOnBody

Aug 19th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 KB | None | 0 0
  1. TESNPC * actorBase = DYNAMIC_CAST(thisObj->baseForm, TESForm, TESNPC);
  2.     if(actorBase) {
  3.         TESRace * race = actorBase->race.race;
  4.         UInt8 gender = CALL_MEMBER_FN(actorBase, GetSex)();
  5.         auto chargenData = race->chargenData[gender];
  6.         NiNode * root = thisObj->GetObjectRootNode();
  7.         VisitObjects(root, [&](NiAVObject* object) {
  8.             BSTriShape * trishape = object->GetAsBSTriShape();
  9.             if(trishape) {
  10.                 BSLightingShaderProperty * lightingShader = ni_cast(trishape->shaderProperty, BSLightingShaderProperty);
  11.                 if(lightingShader) {
  12.                     BSLightingShaderMaterialBase * material = static_cast<BSLightingShaderMaterialBase *>(lightingShader->shaderMaterial);
  13.                     if(material->GetType() == BSLightingShaderMaterialBase::kType_SkinTint) {
  14.                         BSLightingShaderMaterialFace * faceMaterial = static_cast<BSLightingShaderMaterialFace*>(CreateShaderMaterialByType(BSLightingShaderMaterialBase::kType_Face));
  15.                         CALL_MEMBER_FN(faceMaterial, Copy)(material);
  16.                         CALL_MEMBER_FN(lightingShader, SetFlag)(21, false); // Turn off SkinTint
  17.                         CALL_MEMBER_FN(lightingShader, SetFlag)(9, true); // Turn on FaceTint
  18.  
  19.                         faceMaterial->baseDiffuse = material->spDiffuseTexture;
  20.  
  21.                         tArray<BGSCharacterTint::Entry*> tempTints;
  22.                         CopyCharacterTints(&tempTints, actorBase->tints);
  23.                         FillTintTemplates(&tempTints, chargenData);
  24.                         MergeTintTextures(actorBase, &tempTints, (*g_faceGenManager)->unk3478, (*g_faceGenManager)->unk3230, 1, 0);
  25.  
  26.                         CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(16);
  27.                         CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(17);
  28.                         CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(18);
  29.  
  30.                         NiPointer<NiTexture> diffuse = CreateTexture("FaceCustomizationDiffuse", 1);
  31.                         diffuse->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(16, 1, 1, 0);
  32.                         faceMaterial->spDiffuseTexture = diffuse;
  33.  
  34.                         NiPointer<NiTexture> normal = CreateTexture("FaceCustomizationNormals", 0);
  35.                         normal->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(17, 1, 1, 0);
  36.                         faceMaterial->spNormalTexture = normal;
  37.  
  38.                         NiPointer<NiTexture> spec = CreateTexture("FaceCustomizationSmoothSpec", 0);
  39.                         spec->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(18, 1, 1, 0);
  40.                         faceMaterial->spSmoothnessSpecMaskTexture = spec;
  41.  
  42.                         CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(16);
  43.                         CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(17);
  44.                         CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(18);
  45.  
  46.                         CALL_MEMBER_FN(lightingShader, SetMaterial)(faceMaterial, true);
  47.                     }
  48.                 }
  49.             }
  50.             return false;
  51.         });
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement