#include "stdafx.h" #include "DiffuseOpacityMaterial_Skinned.h" DiffuseOpacityMaterial_Skinned::DiffuseOpacityMaterial_Skinned(): Material(L"Effects/PosNormTex3D_OpacitySkinned.fx") { } void DiffuseOpacityMaterial_Skinned::SetDiffuseTexture(const std::wstring& assetFile) { m_pDiffuseTexture = ContentManager::Load(assetFile); SetVariable_Texture(L"gDiffuseMap", m_pDiffuseTexture); } void DiffuseOpacityMaterial_Skinned::SetOpacityTexture(const std::wstring& assetFile) { m_pOpacityTexture = ContentManager::Load(assetFile); SetVariable_Texture(L"gOpacityMap", m_pOpacityTexture); } TextureData* DiffuseOpacityMaterial_Skinned::GetOpacityTexture() { return m_pOpacityTexture; } void DiffuseOpacityMaterial_Skinned::SetIgnoreLightDirection(bool ignoreLightDir) { SetVariable_Scalar(L"gIgnoreLightDirection", ignoreLightDir); } void DiffuseOpacityMaterial_Skinned::InitializeEffectVariables() { } void DiffuseOpacityMaterial_Skinned::OnUpdateModelVariables(const SceneContext& sceneContext, const ModelComponent* pModel) const { //Update the Light Direction (retrieve the direction from the LightManager > sceneContext) XMFLOAT4 lightDir = sceneContext.pLights->GetDirectionalLight().direction; SetVariable_Vector(L"gLightDirection", XMFLOAT3{ lightDir.x, lightDir.y, lightDir.z }); //Retrieve The Animator from the ModelComponent ModelAnimator* pAnimator = pModel->GetAnimator(); //Make sure the animator is not NULL (ASSERT_NULL_) ASSERT_NULL_(pAnimator); //Retrieve the BoneTransforms from the Animator std::vector boneTransforms = pAnimator->GetBoneTransforms(); //Set the 'gBones' variable of the effect (MatrixArray) > BoneTransforms SetVariable_MatrixArray(L"gBones", reinterpret_cast(boneTransforms.data()), UINT(boneTransforms.size())); }