none
DirectXTK Skeletal Animation Update

    General discussion

  • I managed to get pretty far modifying the code to build the skinned models

    pch.h

    #pragma once
    
    #include <wrl.h>
    #include <wrl/client.h>
    #include <dxgi1_4.h>
    #include <d3d11_3.h>
    #include <d2d1_3.h>
    #include <d2d1effects_2.h>
    #include <d3d10shader.h>
    #include <d3d10effect.h>
    #include <dwrite_3.h>
    #include <wincodec.h>
    #include <DirectXColors.h>
    #include <DirectXMath.h>
    #include <memory>
    #include <agile.h>
    #include <concrt.h>
    #include "Audio.h"
    #include "CommonStates.h"
    #include "DDSTextureLoader.h"
    #include "DirectXHelpers.h"
    #include "Effects.h"
    #include "GamePad.h"
    #include "GeometricPrimitive.h"
    #include "GraphicsMemory.h"
    #include "Keyboard.h"
    #include "Model.h"
    #include "Mouse.h"
    #include "PostProcess.h"
    #include "PrimitiveBatch.h"
    #include "ScreenGrab.h"
    #include "SimpleMath.h"
    #include "SpriteBatch.h"
    #include "SpriteFont.h"
    #include "VertexTypes.h"
    #include "WICTextureLoader.h"
    #include <DirectXMath.h>
    #include <DirectXCollision.h>
    #include <vector>
    #include "Common/DeviceResources.h"
    #include <d3d11.h>
    #include <d3d11_1.h>
    #include <d3d11_2.h>
    #include <d3d11_3.h>
    #include <d3d11_4.h>
    #include <NuiApi.h>
    #include "Mechanics/PlayerCallbackHandler.h"
    #include "Mechanics/GameEngine.h"
    #include "Mechanics/GameState.h"
    
    
    
    using namespace std;
    using namespace DirectX;
    using namespace DirectX::SimpleMath;
    
    
    using Microsoft::WRL::ComPtr;
    
    
    
    
    typedef struct D3DXFRAME {
    	LPSTR               Name;
    	XMMATRIX            TransformationMatrix;
    	LPD3DXMESHCONTAINER pMeshContainer;
    	D3DXFRAME           *pFrameSibling;
    	D3DXFRAME           *pFrameFirstChild;
    } D3DXFRAME, *LPD3DXFRAME;
    
    struct FrameEx : public D3DXFRAME 
    { 
    	XMMATRIX combinedTransform;
    };
    
    typedef struct LPD3DXMATERIAL
    {
    	D3DCOLORVALUE  Diffuse;
    	D3DCOLORVALUE  Ambient;
    	D3DCOLORVALUE  Specular;
    	D3DCOLORVALUE  Emissive;
    	D3DCOLORVALUE  Power;
    }LPD3DXMATERIAL, *LPD3DMATERIAL;
    
    typedef struct ID3DXSKININFO *LPD3DXSKININFO;
    
    typedef enum D3DXMESH {
    	D3DXMESH_32BIT = 0x001,
    	D3DXMESH_DONOTCLIP = 0x002,
    	D3DXMESH_POINTS = 0x004,
    	D3DXMESH_RTPATCHES = 0x008,
    	D3DXMESH_NPATCHES = 0x4000,
    	D3DXMESH_VB_SYSTEMMEM = 0x010,
    	D3DXMESH_VB_MANAGED = 0x020,
    	D3DXMESH_VB_WRITEONLY = 0x040,
    	D3DXMESH_VB_DYNAMIC = 0x080,
    	D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000,
    	D3DXMESH_IB_SYSTEMMEM = 0x100,
    	D3DXMESH_IB_MANAGED = 0x200,
    	D3DXMESH_IB_WRITEONLY = 0x400,
    	D3DXMESH_IB_DYNAMIC = 0x800,
    	D3DXMESH_IB_SOFTWAREPROCESSING = 0x10000,
    	D3DXMESH_VB_SHARE = 0x1000,
    	D3DXMESH_USEHWONLY = 0x2000,
    	D3DXMESH_SYSTEMMEM = 0x110,
    	D3DXMESH_MANAGED = 0x220,
    	D3DXMESH_WRITEONLY = 0x440,
    	D3DXMESH_DYNAMIC = 0x880,
    	D3DXMESH_SOFTWAREPROCESSING = 0x18000
    } D3DXMESH, *LPD3DXMESH;
    
    
    typedef interface ID3DXAnimationSet ID3DXAnimationSet;
    typedef interface ID3DXAnimationSet *LPD3DXANIMATIONSET;
    
    typedef interface ID3DXKeyframedAnimationSet ID3DXKeyframedAnimationSet;
    typedef interface ID3DXKeyframedAnimationSet *LPD3DXKEYFRAMEDANIMATIONSET;
    
    typedef interface ID3DXBuffer ID3DXBuffer;
    typedef interface ID3DXBuffer *LPD3DXBUFFER;
    
    typedef interface ID3DXEffect ID3DXEffect;
    typedef interface ID3DXEffect *LPD3DXEFFECT;
    
    HRESULT SetCallbackKey(
    	[in]  UINT               Animation,
    	[out] LPD3DXKEY_CALLBACK pCallbackKeys
    );
    
    typedef interface ID3DXCompressedAnimationSet ID3DXCompressedAnimationSet;
    typedef interface ID3DXCompressedAnimationSet *LPD3DXCOMPRESSEDANIMATIONSET;
    
    HRESULT D3DXCreateCompressedAnimationSet(
    	_In_        LPCSTR                       pName,
    	_In_        DOUBLE                       TicksPerSecond,
    	_In_        D3DXPLAYBACK_TYPE            Playback,
    	_In_        LPD3DXBUFFER                 pCompressedData,
    	_In_        UINT                         NumCallbackKeys,
    	_In_  const LPD3DXKEY_CALLBACK           *pCallKeys,
    	_Out_       LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet
    );
    
    typedef struct D3DMATERIAL9 {
    	D3DCOLORVALUE Diffuse;
    	D3DCOLORVALUE Ambient;
    	D3DCOLORVALUE Specular;
    	D3DCOLORVALUE Emissive;
    	float         Power;
    } D3DMATERIAL9, *LPD3DMATERIAL9;
    
    typedef enum D3DXPLAYBACK_TYPE {
    	D3DXPLAY_LOOP = 0,
    	D3DXPLAY_ONCE = 1,
    	D3DXPLAY_PINGPONG = 2,
    	D3DXPLAY_FORCE_DWORD = 0x7fffffff
    } D3DXPLAYBACK_TYPE, *LPD3DXPLAYBACK_TYPE;
    
    typedef struct D3DXKEY_CALLBACK {
    	FLOAT  Time;
    	LPVOID pCallbackData;
    } D3DXKEY_CALLBACK, *LPD3DXKEY_CALLBACK;
    
    typedef enum D3DXEFFECTDEFAULTTYPE {
    	D3DXEDT_STRING = 1,
    	D3DXEDT_FLOATS = 2,
    	D3DXEDT_DWORD = 3,
    	D3DXEDT_FORCEDWORD = 0x7fffffff
    } D3DXEFFECTDEFAULTTYPE, *LPD3DXEFFECTDEFAULTTYPE;
    
    typedef struct D3DXEFFECTINSTANCE {
    	LPSTR               pEffectFilename;
    	DWORD               NumDefaults;
    	LPD3DXEFFECTDEFAULT pDefaults;
    } D3DXEFFECTINSTANCE, *LPD3DXEFFECTINSTANCE;
    
    typedef struct D3DXEFFECTDEFAULT {
    	LPSTR                 pParamName;
    	D3DXEFFECTDEFAULTTYPE Type;
    	DWORD                 NumBytes;
    	LPVOID                pValue;
    } D3DXEFFECTDEFAULT, *LPD3DXEFFECTDEFAULT;
    
    typedef enum D3DXEFFECTDEFAULTTYPE {
    	D3DXEDT_STRING = 1,
    	D3DXEDT_FLOATS = 2,
    	D3DXEDT_DWORD = 3,
    	D3DXEDT_FORCEDWORD = 0x7fffffff
    } D3DXEFFECTDEFAULTTYPE, *LPD3DXEFFECTDEFAULTTYPE;
    
    typedef enum D3DXMESHDATATYPE 
    {
    	D3DXMESHTYPE_MESH = 0x001,
    	D3DXMESHTYPE_PATCHMESH = 0x003,
    	D3DXMESHTYPE_FORCE_DWORD = 0x7fffffff
    } D3DXMESHDATATYPE, *LPD3DXMESHDATATYPE;
    
    typedef struct _D3DXMESHCONTAINER 
    { 
    	LPSTR Name;    
    	ModelMesh MeshData;    
    	LPD3DXMATERIAL pMaterials;    
    	LPD3DXEFFECTINSTANCE pEffects;     
    	DWORD NumMaterials;    
    	DWORD *pAdjacency;     
    	LPD3DXSKININFO pSkinInfo;     
    	struct _D3DXMESHCONTAINER *pNextMeshContainer; 
    } 
    D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER;
    
    HRESULT SetMatrixArray(
    	float *pData,
    	UINT  Offset,
    	UINT  Count
    );
    
    LPCSTR GetBoneName(
    	[in] DWORD Bone
    );
    
    LPD3DXFRAME D3DXFrameFind(
    	_In_ const D3DXFRAME *pFrameRoot,
    	_In_       LPCSTR    Name
    );
    
    struct Keyframe 
    { 
    	float time;     
    	Quaternion R;
    	Vector3    S;
    	Vector3    T; 
    };
    
    struct FrameEx : public D3DXFRAME
    
    { 
    	XMMATRIX combinedTransform;
    };
    
    void CombineTransforms(FrameEx* frame, XMMATRIX& P)
    // parent's combined transform
    {    
    	// Save some references to economize line space.    
    	XMMATRIX& L = frame->TransformationMatrix;
    	XMMATRIX& C = frame->combinedTransform;
    C = L * P;
    FrameEx* sibling = (FrameEx*)frame->pFrameSibling;    
    FrameEx* firstChild = (FrameEx*)frame->pFrameFirstChild;
    // Recurse down siblings. 
    if( sibling )   combineTransforms(sibling, P); 
    // Recurse to first child. 
    if( firstChild )  
    combineTransforms(firstChild , C); 
    }
    
    
    
    void interpolateBone(Keyframe& K0, Keyframe& K1, XMMATRIX& L)
    {    
    	// Transform to [0, 1]     
    	float t0 = K0.time;     
    	float t1 = K1.time;    
    	float lerpTime = (t - t0) / (t1 - t0);  
    																	 
    	// Compute interpolated RST-values.     
    	Vector3 lerpedT;     
    	Vector3 lerpedS;
    	Quaternion lerpedR;
    	XMVectorLerp(       &lerpedT, &K0.T, &K1.T, lerpTime);     
    	XMVectorLerp(       &lerpedS, &K0.S, &K1.S, lerpTime);    
    	XMQuaternionSlerp(&lerpedR, &K0.R, &K1.R, lerpTime); 
    
    	
    
    	// Build and return the interpolated local     
    	// transformation matrix for this bone.     
    	XMMATRIX T, S, R;    
    	XMMatrixTranslation(&T, lerpedT.x, lerpedT.y, lerpedT.z); 
    	XMMatrixScaling(&S, lerpedS.x, lerpedS.y, lerpedS.z);    
    	XMMatrixRotationQuaternion(&R, &lerpedQ);
    	L = R * S * T;
    }
    
    void RecursRender(D3DXFRAME* node, XMMATRIX& parentTransform) {
    	XMMATRIX C = node->TransformationMatrix * parentTransform;
    	_device->SetTransform(D3DTS_WORLD, &C);     
    	for (uint32 i = 0; i < node->pMeshContainer->NumMaterials; ++i) {
    		D3DXMESHCONTAINER* mc = node->pMeshContainer; 
    		D3DMATERIAL9& mtrl = mc->pMaterials[i].MatD3D;  _device->SetMaterial(&mtrl);
    			node->pMeshContainer->MeshData.pMesh->DrawSubset(i);
    	}
    	if (node->pFrameSibling)  recursRender(node->pFrameSibling, parentTransform);
    	if (node->pFrameFirstChild)  recursRender(node->pFrameFirstChild, C);
    }
    
    
    
    
    DirectX::SimpleMath::Matrix                           m_world;
    DirectX::SimpleMath::Matrix                           m_view;
    DirectX::SimpleMath::Matrix                           m_proj;
    DirectX::SimpleMath::Matrix                           _hWorldViewProj;
    
    std::unique_ptr<DirectX::SpriteFont>                  m_font;
    DirectX::SimpleMath::Vector2                          m_fontPos;
    std::unique_ptr<DirectX::SpriteBatch>                 m_spriteBatch;
    
    std::unique_ptr<DirectX::GamePad>                     m_gamePad;
    DirectX::GamePad::ButtonStateTracker                  m_buttons;
    
    std::unique_ptr<DX::DeviceResources>                  m_deviceResources;
    
    std::unique_ptr<DirectX::Model>                       m_model;
    
    std::unique_ptr<DirectX::EffectFactory>               m_fxFactory;
    std::unique_ptr<DirectX::CommonStates>                m_states;
    
    DirectX::SimpleMath::Vector2 m_screenPos;
    DirectX::SimpleMath::Vector2 m_origin;
    
    Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>      m_texture;

    PlayerCallbackHandler.h

    #pragma once
    
    #include "pch.h"
    
    
    class PlayerCallbackHandler : public ID3DXAnimationCallbackHandler
    {
    public:
    	HRESULT CALLBACK HandleCallback(THIS_ UINT Track, LPVOID pCallbackData);
    }

    #include "Mechanics/PlayerCallbackHandler .h"
    
    
    HRESULT BoxerCallbackHandler::HandleCallback(UINT Track, LPVOID pCallbackData)
    {    
    	// Given your callback data, execute any desired code.    
    	PlayerCallbackInfo* data = (PlayerCallbackInfo*)pCallbackData;
    																					
    	// rotate camera 90 degrees    
    	*(data->theta) += D3DX_PI * 0.5f;  
    	return D3D_OK;
    }

    SkinnedMesh.h

    #pragma once
    
    #include "pch.h"
    
    
    public class SkinnedMesh
    {
    public:
    	SkinnedMesh();
    	~SkinnedMesh();
    
    	D3DXFRAME * findNodeWithMesh(D3DXFRAME * frame);
    
    	void buildSkinnedMesh(ModelMesh * mesh);
    
    	void buildCombinedTransforms();
    
    	void frameMove(float deltaTime, XMMATRIX & worldViewProj);
    
    	void render();
    
    private:
    
    	ID3DXEffect                      _effect;
    
    };


    SkinnedMesh.cpp

    #include "Mechanics/SkinnedMesh.h"
    #include "SkinnedMesh.h"
    
    
    SkinnedMesh::SkinnedMesh()
    {
    }
    
    SkinnedMesh::~SkinnedMesh()
    {
    }
    
    D3DXFRAME* SkinnedMesh::findNodeWithMesh(D3DXFRAME* frame)
    {
    	if (frame->pMeshContainer) 
    		if (frame->pMeshContainer->MeshData.meshParts != 0)    
    		return frame;
    	D3DXFRAME* f = 0;  
    	if (frame->pFrameSibling)   
    		if (f = findNodeWithMesh(frame->pFrameSibling))     
    			return f;
    	if (frame->pFrameFirstChild)   
    		if (f = findNodeWithMesh(frame->pFrameFirstChild))    
    			return f;
    	return 0;
    }
    
    void SkinnedMesh::buildSkinnedMesh(ModelMesh* mesh) 
    {
    	DWORD        numBoneComboEntries = 0;  
    	ID3DXBuffer* boneComboTable = 0;
    	THROW_DXERR(_skinInfo->ConvertToIndexedBlendedMesh(mesh, D3DXMESH_MANAGED | D3DXMESH_WRITEONLY, SkinnedMesh::MAX_NUM_BONES_SUPPORTED, 
    		0, // ignore adjacency in   
    		0, // ignore adjacency out   
    		0, // ignore face remap   
    		0, // ignore vertex remap   
    		&_maxVertInfluences,   
    		&numBoneComboEntries,   
    		&boneComboTable,  
    		&_skinnedMesh) ) 
    																																			 
    		// We do not need the bone table, so just release it.  
    		ReleaseCOM(boneComboTable); 
    } 
    
    void SkinnedMesh::buildCombinedTransforms() 
    {
    	for (UINT i = 0; i < _numBones; ++i) {        
    		// Find the frame that corresponds with the ith          
    		// bone offset matrix.         
    		const char* boneName = _skinInfo->GetBoneName(i);        
    		D3DXFRAME* frame = D3DXFrameFind(_root, boneName);         
    		if( frame )         {            
    			FrameEx* frameEx = static_cast<FrameEx*>( frame );            
    		_combinedTransforms[i] = &frameEx->combinedTransform;        
    		}    
    	}
    } 
    
    void SkinnedMesh::frameMove(float deltaTime, XMMATRIX& worldViewProj) {
    	_animCtrl->AdvanceTime(deltaTime, 0);
    	XMMATRIX identity;
    	XMMatrixIdentity();  
    	combineTransforms(static_cast<FrameEx*>(_root), identity);
    	XMMATRIX offsetTemp, combinedTemp;
    	for (UINT i = 0; i < _numBones; ++i) 
    	{ 
    		offsetTemp = *_skinInfo->GetBoneOffsetMatrix(i);   
    	combinedTemp = *_combinedTransforms[i];  
    	_finalTransforms[i] = offsetTemp * combinedTemp; 
    	}
    	_effect->SetMatrix(_hWorldViewProj, &worldViewProj);
    
    	_effect->SetMatrixArray(_hFinalTransforms, &_finalTransforms[0], _finalTransforms.size());
    }
    
    void SkinnedMesh::render() {
    	_effect->SetTechnique(_hTech);  
    	UINT numPasses = 0; 
    	_effect->Begin(&numPasses, 0);
    	for (UINT i = 0; i < numPasses; ++i) {
    		_effect->BeginPass(i);
    		// Draw the one and only subset.   _skinnedMesh->DrawSubset(0); 
    		_effect->EndPass();
    	}  _effect->End();
    }


    Player.h

    #pragma once
    
    #include "pch.h"
    
    
    enum ANIMATIONSET_INDEX
    {
    	Idle = 0,
    
    };
    
    
    
    class Player{
    
    
    
    
    public:
    	Player();
    
    	void LoadContent();
    
    
    
    	void Update();
    
    	void ProcessInput();
    
    	void setupCallbackKeyframes(float * theta);
    
    
    
    	void Render();
    
    	int maxHealth = 100;
    
    	float currentHealth = maxHealth;
    
    	void Idle();
    
    	void Damage(float damage);
    
    	void Health();
    
    	 float light;
    
    private:
    
    
    	float ratio;
    
    
    	std::unique_ptr<DirectX::ModelMesh>  m_modelMesh;
    
    
    
    };

    Player.cpp

    #include "Player.h"
    
    
    //4 weights and indices per vertex
    #define BONE_WEIGHTS_SIZE 4
    
    #define MAX_BONES 60
    
    
    
    //----------------------------------------------------------------------
    
    Player::Player()
    {
    
    }
    
    //----------------------------------------------------------------------
    
    void Player::LoadContent()
    {
    	auto device = m_deviceResources->GetD3DDevice();
    	m_states = std::make_unique<CommonStates>(device);
    
    	m_fxFactory = std::make_unique<EffectFactory>(device);
    
    	m_model = Model::CreateFromCMO((device), L"GaryTurbo.cmo", *m_fxFactory);
    
    	m_model->UpdateEffects([](IEffect* effect)
    	{
    		auto lights = dynamic_cast<IEffectLights*>(effect);
    		if (lights)
    		{
    			lights->SetLightingEnabled(true);
    			lights->SetPerPixelLighting(true);
    			lights->SetLightEnabled(0, true);
    			lights->SetLightDiffuseColor(0, Colors::Gold);
    			lights->SetLightEnabled(1, false);
    			lights->SetLightEnabled(2, false);
    		}
    
    		auto fog = dynamic_cast<IEffectFog*>(effect);
    		if (fog)
    		{
    			fog->SetFogEnabled(true);
    			fog->SetFogColor(Colors::CornflowerBlue);
    			fog->SetFogStart(3.f);
    			fog->SetFogEnd(4.f);
    		}
    	});
    	
    
    
    	m_world = Matrix::Identity;
    
    }
    
    void Player::Update()
    {
    
    	
    }
    
    void Player::ProcessInput()
    {
    	auto state = m_gamePad->GetState(0);
    
    	if (state.IsConnected())
    	{
    
    
    		float forward = (state.IsLeftThumbStickUp()) ? 1.f : 0;
    		float backward = (state.IsLeftThumbStickDown()) ? 1.f : 0;
    		float leftturn = (state.IsLeftThumbStickLeft()) ? 1.f : 0;
    		float rightturn = (state.IsLeftThumbStickRight()) ? 1.f : 0;
    		float punch = (state.IsRightThumbStickUp()) ? 1.f : 0;
    		float uppercut = (state.IsRightThumbStickDown()) ? 1.f : 0;
    		float lefthook = (state.IsRightThumbStickLeft()) ? 1.f : 0;
    		float righthook = (state.IsRightThumbStickRight()) ? 1.f : 0;
    
    		m_buttons.Update(state);
    		if (m_buttons.a == GamePad::ButtonStateTracker::PRESSED)
    		{
    			// A was up last frame, it just went down this frame
    		}
    		if (m_buttons.b == GamePad::ButtonStateTracker::RELEASED)
    		{
    			// B was down last frame, it just went up this frame
    		}
    	}
    
    
    	
    
    
    
    }
    
    void Player::setupCallbackKeyframes(float* theta)
    {  // Remark: ‘theta’ is a pointer to the camera’s theta  // coordinate. 
       // Grab the current animation set for 'tiny.x'   
       // (we know there is only one.)  
    	ID3DXKeyframedAnimationSet* animSetTemp = 0; 
    	_animCtrl->GetAnimationSet(   0, (ID3DXAnimationSet**)&animSetTemp); 
       // Compress it.  
    	ID3DXBuffer* compressedInfo = 0;  
    	animSetTemp->Compress(compress,    0.5f, 0, &compressedInfo); 
       // Setup two callback keys.  
    	UINT numCallbacks = 2;  
    	D3DXKEY_CALLBACK keys[2]; 
       // Make static so it does not pop off the stack.  
    	static BoxerCallbackInfo CallbackData; 
    
    	CallbackData.theta = theta;
    	// GetSourceTicksPerSecond() returns the number of  
    	// animation key frame ticks that occur per second.  
    	// Callback keyframe times are tick based. 
    		double ticks = animSetTemp->GetSourceTicksPerSecond(); 
    	// Set the first callback key to trigger a callback  
    	// half way through the animation sequence.    
    		keys[0].Time = float(animSetTemp->GetPeriod()/2.0f*ticks);  
    		keys[0].pCallbackData = (void*)&CallbackData;    
    		// Set the second callback key to trigger a callback  
    		// at the end of the animation sequence.  
    		keys[1].Time = animSetTemp->GetPeriod()*ticks;  keys[1].pCallbackData = (void*)&CallbackData; 
    	// Create the ID3DXCompressedAnimationSet interface   
    	// with the callback keys.  
    		ID3DXCompressedAnimationSet* compressedAnimSet = 0;  
    		D3DXCreateCompressedAnimationSet(animSetTemp->GetName(),   
    			animSetTemp->GetSourceTicksPerSecond(),   
    			animSetTemp->GetPlaybackType(), compressedInfo,   numCallbacks, keys, &compressedAnimSet); 
    	compressedInfo->Release();    
    	// Remove the old (non compressed) animation set.  
    	_animCtrl->UnregisterAnimationSet(animSetTemp);  
    	animSetTemp->Release(); 
    	// Add the new (compressed) animation set. 
    	_animCtrl->RegisterAnimationSet(compressedAnimSet);   
    	// Hook up the animation set to the first track.  
    	_animCtrl->SetTrackAnimationSet(0, compressedAnimSet);  
    	compressedAnimSet->Release(); 
    } 
    
    void Player::Render()
    {
    	// Clear the views
    	auto context = m_deviceResources->GetD3DDeviceContext();
    	m_model->Draw(context, *m_states, m_world, m_view, m_proj);
    }
    
    void Player::Idle()
    {
    	ANIMATIONSET_INDEX* idle = 0;
    	_animCtrl->GetAnimationSet(LOITER_INDEX, &idle);
    	_animCtrl->SetTrackAnimationSet(0, idle);
    	_animCtrl->ResetTime();
    }
    
    void Player::Damage(float damage)
    {
    	currentHealth -= damage;
    }
    
    void Player::Health()
    {
    
    }
    
    void Attack()
    {
    
    
    
    	switch (switch_on)
    	
    	{
    		case Head:
    
    			break;
    		case Torso:
    
    			break;
    	}
    }

    It still have errors which I keep having problems with


    Tuesday, September 11, 2018 1:54 AM

All replies

  • I been having touble with this:

    SkinnedMesh.h

    	ID3DXEffect                      _effect;
    	int                              _finalTransforms;
    	int                             _combinedTransforms;

    SkinnedMesh.cpp

    void SkinnedMesh::buildCombinedTransforms()

    {

    for(UINTi = 0; i < _numBones; ++i) {       

    // Find the frame that corresponds with the ith         


    // bone offset matrix.        


    constchar* boneName = _skinInfo->GetBoneName(i);       

    D3DXFRAME* frame = D3DXFrameFind(_root, boneName);        

    if( frame )         {           

    FrameEx* frameEx = static_cast<FrameEx*>( frame );           

    _combinedTransforms[i] = &frameEx->combinedTransform;       

    }   

    }

    }

    void SkinnedMesh::frameMove(float deltaTime, XMMATRIX& worldViewProj) { _animCtrl->AdvanceTime(deltaTime, 0); XMMATRIX identity; XMMatrixIdentity(); combineTransforms(static_cast<FrameEx*>(_root), identity); XMMATRIX offsetTemp, combinedTemp; for (UINT i = 0; i < _numBones; ++i) { offsetTemp = *_skinInfo->GetBoneOffsetMatrix(i); combinedTemp = *_combinedTransforms[i]; _finalTransforms[i] = offsetTemp * combinedTemp; } _effect->SetMatrix(_hWorldViewProj, &worldViewProj); _effect->SetMatrixArray(_hFinalTransforms, &_finalTransforms[0], _finalTransforms.size()); }


    The _finalTransforms and _combinedTransforms have this error


    Severity


    Code


    Description


    Project


    File


    Line


    Suppression State


    Error (active)


    E2242


    expression must have pointer-to-object or handle-to-C++/CX mapping-array type


    Beatdown


    c:\Users\garre\Documents\Visual Studio 2017\Projects\Beatdown\Beatdown\SkinnedMesh.cpp


    72

    Sunday, September 23, 2018 3:38 AM
  • I found out how to fix the SkinnedMesh script

    void SkinnedMesh::render() {
    	_effect->SetTechnique(_hTech);  
    	UINT numPasses = 0;  
    	_effect->Begin(&numPasses, 0);
    	for (UINT i = 0; i < numPasses; ++i) 
    	{
    		_effect->BeginPass(i);
    		// Draw the one and only subset.   _skinnedMesh->DrawSubset(0); 
    		_effect->EndPass();
    	}  
    	_effect->End();
    }

    I tried BasicEffect, EffectFactory, SkinnedEffectetc and it all don't work


    Monday, October 22, 2018 4:06 AM