Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
# Microsoft Developer Studio Project File - Name="SkinnedMesh" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=SkinnedMesh - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "skinnedmesh.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "skinnedmesh.mak" CFG="SkinnedMesh - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "SkinnedMesh - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "SkinnedMesh - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "SkinnedMesh - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d3dx8.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "SkinnedMesh - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d3dx8dt.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "SkinnedMesh - Win32 Release"
|
||||
# Name "SkinnedMesh - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\directx.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\skinnedmesh.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dapp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dfont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mdraw.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mload.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\skinnedmesh.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SkinnedMesh.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "SkinnedMesh"=.\SkinnedMesh.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define IDC_STATIC -1
|
||||
#include <windows.h>
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINMENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Open...", ID_FILE_OPENMESHHEIRARCHY
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
|
||||
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
END
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "D3D non-indexed", ID_OPTIONS_D3DNONINDEXED
|
||||
, CHECKED
|
||||
MENUITEM "D3D Indexed", ID_OPTIONS_D3DINDEXED
|
||||
MENUITEM "Software Skinning", ID_OPTIONS_SOFTWARESKINNING
|
||||
MENUITEM "D3D Indexed (VS)", ID_OPTIONS_D3DINDEXEDVS
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define IDC_STATIC -1\r\n"
|
||||
"#include <windows.h>\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
VK_F2, IDM_CHANGEDEVICE, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLESTART, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
|
||||
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 138
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Select Device"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
|
||||
LTEXT "&Adapter:",IDC_STATIC,22,17,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Device:",IDC_STATIC,22,32,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
GROUPBOX "Rendering mode",IDC_STATIC,5,52,200,45
|
||||
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,62,85,15
|
||||
CONTROL "&Fullscreen mode:",IDC_FULLSCREEN,"Button",
|
||||
BS_AUTORADIOBUTTON,10,77,75,15
|
||||
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,77,105,204,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
GROUPBOX "Multisample",IDC_STATIC,5,101,200,28
|
||||
LTEXT "&Multisample Type:",IDC_STATIC,22,113,62,10,
|
||||
SS_CENTERIMAGE
|
||||
COMBOBOX IDC_MULTISAMPLE_COMBO,90,111,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "directx.ico"
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
IDD_SHADER1 RCDATA DISCARDABLE "skinmesh1.vsh"
|
||||
IDD_SHADER2 RCDATA DISCARDABLE "skinmesh2.vsh"
|
||||
IDD_SHADER3 RCDATA DISCARDABLE "skinmesh3.vsh"
|
||||
IDD_SHADER4 RCDATA DISCARDABLE "skinmesh4.vsh"
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/directx.ico
Normal file
BIN
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/directx.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
564
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/mdraw.cpp
Normal file
564
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/mdraw.cpp
Normal file
@@ -0,0 +1,564 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: mdraw.cpp
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "SkinnedMesh.h"
|
||||
|
||||
|
||||
HRESULT CMyD3DApplication::DrawMeshContainer(SMeshContainer *pmcMesh)
|
||||
{
|
||||
UINT ipattr;
|
||||
HRESULT hr = S_OK;
|
||||
LPD3DXBONECOMBINATION pBoneComb;
|
||||
DWORD AttribIdPrev;
|
||||
|
||||
if (pmcMesh->m_pSkinMesh)
|
||||
{
|
||||
if (m_method != pmcMesh->m_Method)
|
||||
{
|
||||
GenerateMesh(pmcMesh);
|
||||
}
|
||||
|
||||
if (m_method == D3DNONINDEXED)
|
||||
{
|
||||
AttribIdPrev = UNUSED32;
|
||||
pBoneComb = reinterpret_cast<LPD3DXBONECOMBINATION>(pmcMesh->m_pBoneCombinationBuf->GetBufferPointer());
|
||||
// Draw using default vtx processing of the device (typically HW)
|
||||
for (ipattr = 0; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
DWORD numBlend = 0;
|
||||
for (DWORD i = 0; i < pmcMesh->m_maxFaceInfl; ++i)
|
||||
{
|
||||
if (pBoneComb[ipattr].BoneId[i] != UINT_MAX)
|
||||
{
|
||||
numBlend = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_d3dCaps.MaxVertexBlendMatrices >= numBlend + 1)
|
||||
{
|
||||
for (DWORD i = 0; i < pmcMesh->m_maxFaceInfl; ++i)
|
||||
{
|
||||
DWORD matid = pBoneComb[ipattr].BoneId[i];
|
||||
if (matid != UINT_MAX)
|
||||
{
|
||||
m_pd3dDevice->SetTransform(D3DTS_WORLDMATRIX(i), pmcMesh->m_pBoneMatrix[matid]);
|
||||
m_pd3dDevice->MultiplyTransform(D3DTS_WORLDMATRIX(i), &pmcMesh->m_pBoneOffsetMat[matid]);
|
||||
}
|
||||
}
|
||||
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, numBlend);
|
||||
|
||||
if ((AttribIdPrev != pBoneComb[ipattr].AttribId) || (AttribIdPrev == UNUSED32))
|
||||
{
|
||||
m_pd3dDevice->SetMaterial(&(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId]));
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[pBoneComb[ipattr].AttribId]);
|
||||
AttribIdPrev = pBoneComb[ipattr].AttribId;
|
||||
}
|
||||
|
||||
hr = pmcMesh->pMesh->DrawSubset( ipattr );
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If necessary, draw parts that HW could not handle using SW
|
||||
if (pmcMesh->iAttrSplit < pmcMesh->cpattr)
|
||||
{
|
||||
AttribIdPrev = UNUSED32;
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
|
||||
for (ipattr = pmcMesh->iAttrSplit; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
DWORD numBlend = 0;
|
||||
for (DWORD i = 0; i < pmcMesh->m_maxFaceInfl; ++i)
|
||||
{
|
||||
if (pBoneComb[ipattr].BoneId[i] != UINT_MAX)
|
||||
{
|
||||
numBlend = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_d3dCaps.MaxVertexBlendMatrices < numBlend + 1)
|
||||
{
|
||||
for (DWORD i = 0; i < pmcMesh->m_maxFaceInfl; ++i)
|
||||
{
|
||||
DWORD matid = pBoneComb[ipattr].BoneId[i];
|
||||
if (matid != UINT_MAX)
|
||||
{
|
||||
m_pd3dDevice->SetTransform(D3DTS_WORLDMATRIX(i), pmcMesh->m_pBoneMatrix[matid]);
|
||||
m_pd3dDevice->MultiplyTransform(D3DTS_WORLDMATRIX(i), &pmcMesh->m_pBoneOffsetMat[matid]);
|
||||
}
|
||||
}
|
||||
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, numBlend);
|
||||
|
||||
if ((AttribIdPrev != pBoneComb[ipattr].AttribId) || (AttribIdPrev == UNUSED32))
|
||||
{
|
||||
m_pd3dDevice->SetMaterial(&(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId]));
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[pBoneComb[ipattr].AttribId]);
|
||||
AttribIdPrev = pBoneComb[ipattr].AttribId;
|
||||
}
|
||||
|
||||
hr = pmcMesh->pMesh->DrawSubset( ipattr );
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
|
||||
}
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
|
||||
}
|
||||
else if (m_method == D3DINDEXEDVS)
|
||||
{
|
||||
// Use COLOR instead of UBYTE4 since Geforce3 does not support it
|
||||
// vConst.w should be 3, but due to about hack, mul by 255 and add epsilon
|
||||
D3DXVECTOR4 vConst( 1.0f, 0.0f, 0.0f, 765.01f );
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
LPDIRECT3DINDEXBUFFER8 pIB;
|
||||
|
||||
if (pmcMesh->m_bUseSW)
|
||||
{
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
|
||||
}
|
||||
|
||||
pmcMesh->pMesh->GetVertexBuffer(&pVB);
|
||||
pmcMesh->pMesh->GetIndexBuffer(&pIB);
|
||||
hr = m_pd3dDevice->SetStreamSource(0, pVB, D3DXGetFVFVertexSize(pmcMesh->pMesh->GetFVF()));
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
hr = m_pd3dDevice->SetIndices(pIB, 0);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
pVB->Release();
|
||||
pIB->Release();
|
||||
|
||||
hr = m_pd3dDevice->SetVertexShader(m_dwIndexedVertexShader[pmcMesh->m_maxFaceInfl - 1]);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
|
||||
pBoneComb = reinterpret_cast<LPD3DXBONECOMBINATION>(pmcMesh->m_pBoneCombinationBuf->GetBufferPointer());
|
||||
for (ipattr = 0; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
for (DWORD i = 0; i < pmcMesh->m_paletteSize; ++i)
|
||||
{
|
||||
DWORD matid = pBoneComb[ipattr].BoneId[i];
|
||||
if (matid != UINT_MAX)
|
||||
{
|
||||
D3DXMATRIXA16 mat;
|
||||
D3DXMatrixMultiply(&mat, &pmcMesh->m_pBoneOffsetMat[matid], pmcMesh->m_pBoneMatrix[matid]);
|
||||
D3DXMatrixMultiplyTranspose(&mat, &mat, &m_mView);
|
||||
m_pd3dDevice->SetVertexShaderConstant(i*3 + 9, &mat, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Sum of all ambient and emissive contribution
|
||||
D3DXCOLOR ambEmm;
|
||||
D3DXColorModulate(&ambEmm, &D3DXCOLOR(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId].Ambient),&D3DXCOLOR(.25, .25, .25, 1.0));
|
||||
ambEmm += D3DXCOLOR(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId].Emissive);
|
||||
m_pd3dDevice->SetVertexShaderConstant(8, &(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId].Diffuse), 1);
|
||||
m_pd3dDevice->SetVertexShaderConstant(7, &ambEmm, 1);
|
||||
vConst.y = pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId].Power;
|
||||
m_pd3dDevice->SetVertexShaderConstant(0, &vConst, 1);
|
||||
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[pBoneComb[ipattr].AttribId]);
|
||||
|
||||
hr = m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
||||
pBoneComb[ipattr].VertexStart, pBoneComb[ipattr].VertexCount,
|
||||
pBoneComb[ipattr].FaceStart * 3, pBoneComb[ipattr].FaceCount);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (pmcMesh->m_bUseSW)
|
||||
{
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
|
||||
}
|
||||
}
|
||||
else if (m_method == D3DINDEXED)
|
||||
{
|
||||
if (pmcMesh->m_bUseSW)
|
||||
{
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
|
||||
}
|
||||
|
||||
if (pmcMesh->m_maxFaceInfl == 1)
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS);
|
||||
else
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, pmcMesh->m_maxFaceInfl - 1);
|
||||
if (pmcMesh->m_maxFaceInfl)
|
||||
m_pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, TRUE);
|
||||
pBoneComb = reinterpret_cast<LPD3DXBONECOMBINATION>(pmcMesh->m_pBoneCombinationBuf->GetBufferPointer());
|
||||
for (ipattr = 0; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
for (DWORD i = 0; i < pmcMesh->m_paletteSize; ++i)
|
||||
{
|
||||
DWORD matid = pBoneComb[ipattr].BoneId[i];
|
||||
if (matid != UINT_MAX)
|
||||
{
|
||||
m_pd3dDevice->SetTransform(D3DTS_WORLDMATRIX(i), pmcMesh->m_pBoneMatrix[matid]);
|
||||
m_pd3dDevice->MultiplyTransform(D3DTS_WORLDMATRIX(i), &pmcMesh->m_pBoneOffsetMat[matid]);
|
||||
}
|
||||
}
|
||||
|
||||
m_pd3dDevice->SetMaterial(&(pmcMesh->rgMaterials[pBoneComb[ipattr].AttribId]));
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[pBoneComb[ipattr].AttribId]);
|
||||
|
||||
hr = pmcMesh->pMesh->DrawSubset( ipattr );
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
m_pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
||||
m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
|
||||
|
||||
if (pmcMesh->m_bUseSW)
|
||||
{
|
||||
m_pd3dDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
|
||||
}
|
||||
}
|
||||
else if (m_method == SOFTWARE)
|
||||
{
|
||||
D3DXMATRIX Identity;
|
||||
DWORD cBones = pmcMesh->m_pSkinMesh->GetNumBones();
|
||||
|
||||
// set up bone transforms
|
||||
for (DWORD iBone = 0; iBone < cBones; ++iBone)
|
||||
{
|
||||
D3DXMatrixMultiply
|
||||
(
|
||||
&m_pBoneMatrices[iBone], // output
|
||||
&pmcMesh->m_pBoneOffsetMat[iBone],
|
||||
pmcMesh->m_pBoneMatrix[iBone]
|
||||
);
|
||||
}
|
||||
|
||||
// set world transform
|
||||
D3DXMatrixIdentity(&Identity);
|
||||
hr = m_pd3dDevice->SetTransform(D3DTS_WORLD, &Identity);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
// generate skinned mesh
|
||||
hr = pmcMesh->m_pSkinMesh->UpdateSkinnedMesh(m_pBoneMatrices, NULL, pmcMesh->pMesh);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
for (ipattr = 0; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
m_pd3dDevice->SetMaterial(&(pmcMesh->rgMaterials[pmcMesh->m_pAttrTable[ipattr].AttribId]));
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[pmcMesh->m_pAttrTable[ipattr].AttribId]);
|
||||
hr = pmcMesh->pMesh->DrawSubset(pmcMesh->m_pAttrTable[ipattr].AttribId);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ipattr = 0; ipattr < pmcMesh->cpattr; ipattr++)
|
||||
{
|
||||
m_pd3dDevice->SetMaterial(&(pmcMesh->rgMaterials[ipattr]));
|
||||
m_pd3dDevice->SetTexture(0, pmcMesh->pTextures[ipattr]);
|
||||
hr = pmcMesh->pMesh->DrawSubset( ipattr );
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HRESULT CMyD3DApplication::UpdateFrames(SFrame *pframeCur, D3DXMATRIX &matCur)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
pframeCur->matCombined = matCur;
|
||||
D3DXMatrixMultiply(&pframeCur->matCombined, &pframeCur->matRot, &matCur);
|
||||
D3DXMatrixMultiply(&pframeCur->matCombined, &pframeCur->matCombined, &pframeCur->matTrans );
|
||||
SFrame *pframeChild = pframeCur->pframeFirstChild;
|
||||
while (pframeChild != NULL)
|
||||
{
|
||||
hr = UpdateFrames(pframeChild, pframeCur->matCombined);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
pframeChild = pframeChild->pframeSibling;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HRESULT CMyD3DApplication::DrawFrames(SFrame *pframeCur, UINT &cTriangles)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
SMeshContainer *pmcMesh;
|
||||
SFrame *pframeChild;
|
||||
|
||||
if (pframeCur->pmcMesh != NULL)
|
||||
{
|
||||
hr = m_pd3dDevice->SetTransform(D3DTS_WORLD, &pframeCur->matCombined);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
pmcMesh = pframeCur->pmcMesh;
|
||||
while (pmcMesh != NULL)
|
||||
{
|
||||
hr = DrawMeshContainer(pmcMesh);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
cTriangles += pmcMesh->pMesh->GetNumFaces();
|
||||
|
||||
pmcMesh = pmcMesh->pmcNext;
|
||||
}
|
||||
|
||||
pframeChild = pframeCur->pframeFirstChild;
|
||||
while (pframeChild != NULL)
|
||||
{
|
||||
hr = DrawFrames(pframeChild, cTriangles);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
pframeChild = pframeChild->pframeSibling;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SFrame::SetTime(float fGlobalTime)
|
||||
{
|
||||
UINT iKey;
|
||||
UINT dwp2;
|
||||
UINT dwp3;
|
||||
D3DXMATRIXA16 matResult;
|
||||
D3DXMATRIXA16 matTemp;
|
||||
float fTime1;
|
||||
float fTime2;
|
||||
float fLerpValue;
|
||||
D3DXVECTOR3 vScale;
|
||||
D3DXVECTOR3 vPos;
|
||||
D3DXQUATERNION quat;
|
||||
BOOL bAnimate = false;
|
||||
float fTime;
|
||||
|
||||
if (m_pMatrixKeys )
|
||||
{
|
||||
fTime = (float)fmod(fGlobalTime, m_pMatrixKeys[m_cMatrixKeys-1].dwTime);
|
||||
|
||||
for (iKey = 0 ;iKey < m_cMatrixKeys ; iKey++)
|
||||
{
|
||||
if ((float)m_pMatrixKeys[iKey].dwTime > fTime)
|
||||
{
|
||||
dwp3 = iKey;
|
||||
|
||||
if (iKey > 0)
|
||||
{
|
||||
dwp2= iKey - 1;
|
||||
}
|
||||
else // when iKey == 0, then dwp2 == 0
|
||||
{
|
||||
dwp2 = iKey;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
fTime1 = (float)m_pMatrixKeys[dwp2].dwTime;
|
||||
fTime2 = (float)m_pMatrixKeys[dwp3].dwTime;
|
||||
|
||||
if ((fTime2 - fTime1) ==0)
|
||||
fLerpValue = 0;
|
||||
else
|
||||
fLerpValue = (fTime - fTime1) / (fTime2 - fTime1);
|
||||
|
||||
if (fLerpValue > 0.5)
|
||||
{
|
||||
iKey = dwp3;
|
||||
}
|
||||
else
|
||||
{
|
||||
iKey = dwp2;
|
||||
}
|
||||
|
||||
pframeToAnimate->matRot = m_pMatrixKeys[iKey].mat;
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMatrixIdentity(&matResult);
|
||||
|
||||
if (m_pScaleKeys)
|
||||
{
|
||||
dwp2 = dwp3 = 0;
|
||||
|
||||
fTime = (float)fmod(fGlobalTime, m_pScaleKeys[m_cScaleKeys-1].dwTime);
|
||||
|
||||
for (iKey = 0 ;iKey < m_cScaleKeys ; iKey++)
|
||||
{
|
||||
if ((float)m_pScaleKeys[iKey].dwTime > fTime)
|
||||
{
|
||||
dwp3 = iKey;
|
||||
|
||||
if (iKey > 0)
|
||||
{
|
||||
dwp2= iKey - 1;
|
||||
}
|
||||
else // when iKey == 0, then dwp2 == 0
|
||||
{
|
||||
dwp2 = iKey;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
fTime1 = (float)m_pScaleKeys[dwp2].dwTime;
|
||||
fTime2 = (float)m_pScaleKeys[dwp3].dwTime;
|
||||
|
||||
if ((fTime2 - fTime1) ==0)
|
||||
fLerpValue = 0;
|
||||
else
|
||||
fLerpValue = (fTime - fTime1) / (fTime2 - fTime1);
|
||||
|
||||
D3DXVec3Lerp(&vScale,
|
||||
&m_pScaleKeys[dwp2].vScale,
|
||||
&m_pScaleKeys[dwp3].vScale,
|
||||
fLerpValue);
|
||||
|
||||
|
||||
D3DXMatrixScaling(&matTemp, vScale.x, vScale.y, vScale.z);
|
||||
|
||||
D3DXMatrixMultiply(&matResult, &matResult, &matTemp);
|
||||
|
||||
bAnimate = true;
|
||||
}
|
||||
|
||||
//check rot keys
|
||||
if (m_pRotateKeys )
|
||||
{
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
|
||||
fTime = (float)fmod(fGlobalTime, m_pRotateKeys[m_cRotateKeys-1].dwTime);
|
||||
|
||||
for (iKey = 0 ;iKey < m_cRotateKeys ; iKey++)
|
||||
{
|
||||
if ((float)m_pRotateKeys[iKey].dwTime > fTime)
|
||||
{
|
||||
i1 = (iKey > 0) ? iKey - 1 : 0;
|
||||
i2 = iKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fTime1 = (float)m_pRotateKeys[i1].dwTime;
|
||||
fTime2 = (float)m_pRotateKeys[i2].dwTime;
|
||||
|
||||
if ((fTime2 - fTime1) ==0)
|
||||
fLerpValue = 0;
|
||||
else
|
||||
fLerpValue = (fTime - fTime1) / (fTime2 - fTime1);
|
||||
|
||||
#define USE_SQUAD
|
||||
#ifdef USE_SQUAD
|
||||
int i0 = i1 - 1;
|
||||
int i3 = i2 + 1;
|
||||
|
||||
if(i0 < 0)
|
||||
i0 += m_cRotateKeys;
|
||||
|
||||
if(i3 >= (INT) m_cRotateKeys)
|
||||
i3 -= m_cRotateKeys;
|
||||
|
||||
D3DXQUATERNION qA, qB, qC;
|
||||
D3DXQuaternionSquadSetup(&qA, &qB, &qC,
|
||||
&m_pRotateKeys[i0].quatRotate, &m_pRotateKeys[i1].quatRotate,
|
||||
&m_pRotateKeys[i2].quatRotate, &m_pRotateKeys[i3].quatRotate);
|
||||
|
||||
D3DXQuaternionSquad(&quat, &m_pRotateKeys[i1].quatRotate, &qA, &qB, &qC, fLerpValue);
|
||||
#else
|
||||
D3DXQuaternionSlerp(&quat, &m_pRotateKeys[i1].quatRotate, &m_pRotateKeys[i2].quatRotate, fLerpValue);
|
||||
#endif
|
||||
|
||||
quat.w = -quat.w;
|
||||
D3DXMatrixRotationQuaternion(&matTemp, &quat);
|
||||
D3DXMatrixMultiply(&matResult, &matResult, &matTemp);
|
||||
|
||||
bAnimate = true;
|
||||
}
|
||||
|
||||
if (m_pPositionKeys)
|
||||
{
|
||||
dwp2=dwp3=0;
|
||||
|
||||
fTime = (float)fmod(fGlobalTime, m_pPositionKeys[m_cPositionKeys-1].dwTime);
|
||||
|
||||
for (iKey = 0 ;iKey < m_cPositionKeys ; iKey++)
|
||||
{
|
||||
if ((float)m_pPositionKeys[iKey].dwTime > fTime)
|
||||
{
|
||||
dwp3 = iKey;
|
||||
|
||||
if (iKey > 0)
|
||||
{
|
||||
dwp2= iKey - 1;
|
||||
}
|
||||
else // when iKey == 0, then dwp2 == 0
|
||||
{
|
||||
dwp2 = iKey;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
fTime1 = (float)m_pPositionKeys[dwp2].dwTime;
|
||||
fTime2 = (float)m_pPositionKeys[dwp3].dwTime;
|
||||
|
||||
if ((fTime2 - fTime1) ==0)
|
||||
fLerpValue = 0;
|
||||
else
|
||||
fLerpValue = (fTime - fTime1) / (fTime2 - fTime1);
|
||||
|
||||
|
||||
D3DXVec3Lerp((D3DXVECTOR3*)&vPos,
|
||||
&m_pPositionKeys[dwp2].vPos,
|
||||
&m_pPositionKeys[dwp3].vPos,
|
||||
fLerpValue);
|
||||
|
||||
D3DXMatrixTranslation(&matTemp, vPos.x, vPos.y, vPos.z);
|
||||
|
||||
D3DXMatrixMultiply(&matResult, &matResult, &matTemp);
|
||||
bAnimate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMatrixTranslation(&matTemp, pframeToAnimate->matRotOrig._41, pframeToAnimate->matRotOrig._42, pframeToAnimate->matRotOrig._43);
|
||||
|
||||
D3DXMatrixMultiply(&matResult, &matResult, &matTemp);
|
||||
}
|
||||
|
||||
if (bAnimate)
|
||||
{
|
||||
pframeToAnimate->matRot = matResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1224
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/mload.cpp
Normal file
1224
Library/dxx8/samples/Multimedia/Direct3D/SkinnedMesh/mload.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by SkinnedMesh.rc
|
||||
//
|
||||
#define IDI_MAIN_ICON 101
|
||||
#define IDR_MAIN_ACCEL 113
|
||||
#define IDR_MAINMENU 141
|
||||
#define IDD_SELECTDEVICE 144
|
||||
#define IDD_SHADER1 154
|
||||
#define IDD_SHADER2 155
|
||||
#define IDD_SHADER3 156
|
||||
#define IDD_SHADER4 157
|
||||
#define IDC_DEVICE_COMBO 1000
|
||||
#define IDC_MODE_COMBO 1001
|
||||
#define IDC_ADAPTER_COMBO 1002
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003
|
||||
#define IDC_MULTISAMPLE_COMBO 1005
|
||||
#define IDC_WINDOWED_CHECKBOX 1012
|
||||
#define IDC_FULLSCREEN_TEXT 1014
|
||||
#define IDC_WINDOW 1016
|
||||
#define IDC_FULLSCREEN 1018
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
#define ID_FILE_OPENMESHHEIRARCHY 40008
|
||||
#define ID_OPTIONS_D3DNONINDEXED 40009
|
||||
#define ID_OPTIONS_D3DINDEXED 40010
|
||||
#define ID_OPTIONS_SOFTWARESKINNING 40011
|
||||
#define ID_OPTIONS_D3DINDEXEDVS 40012
|
||||
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 158
|
||||
#define _APS_NEXT_COMMAND_VALUE 40104
|
||||
#define _APS_NEXT_CONTROL_VALUE 1019
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
vs.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; v0 = position
|
||||
; v1 = blend weights
|
||||
; v2 = blend indices
|
||||
; v3 = normal
|
||||
; v4 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; r0.w = Last blend weight
|
||||
; r1 = Blend indices
|
||||
; r2 = Temp position
|
||||
; r3 = Temp normal
|
||||
; r4 = Blended position in camera space
|
||||
; r5 = Blended normal in camera space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app;
|
||||
;
|
||||
; c9-c95 = world-view matrix palette
|
||||
; c8 = diffuse * light.diffuse
|
||||
; c7 = ambient color
|
||||
; c2-c5 = projection matrix
|
||||
; c1 = light direction
|
||||
; c0 = {1, power, 0, 1020.01};
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; oPos = Output position
|
||||
; oD0 = Diffuse
|
||||
; oD1 = Specular
|
||||
; oT0 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
// Compensate for lack of UBYTE4 on Geforce3
|
||||
mul r1,v2.zyxw,c0.wwww
|
||||
//mul r1,v2,c0.wwww
|
||||
|
||||
|
||||
//Set 1
|
||||
mov a0.x,r1.x
|
||||
m4x3 r4,v0,c[a0.x + 9];
|
||||
m3x3 r5,v3,c[a0.x + 9];
|
||||
|
||||
//compute position
|
||||
mov r4.w,c0.x
|
||||
m4x4 oPos,r4,c2
|
||||
|
||||
// normalize normals
|
||||
dp3 r5.w, r5, r5;
|
||||
rsq r5.w, r5.w;
|
||||
mul r5, r5, r5.w;
|
||||
|
||||
; Do the lighting calculation
|
||||
dp3 r1.x, r5, c1 ; normal dot light
|
||||
lit r1, r1
|
||||
mul r0, r1.y, c8 ; Multiply with diffuse
|
||||
add r0, r0, c7 ; Add in ambient
|
||||
min oD0, r0, c0.x ; clamp if > 1
|
||||
mov oD1, c0.zzzz ; output specular
|
||||
|
||||
; Copy texture coordinate
|
||||
mov oT0, v4
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
|
||||
vs.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; v0 = position
|
||||
; v1 = blend weights
|
||||
; v2 = blend indices
|
||||
; v3 = normal
|
||||
; v4 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; r0.w = Last blend weight
|
||||
; r1 = Blend indices
|
||||
; r2 = Temp position
|
||||
; r3 = Temp normal
|
||||
; r4 = Blended position in camera space
|
||||
; r5 = Blended normal in camera space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app;
|
||||
;
|
||||
; c9-c95 = world-view matrix palette
|
||||
; c8 = diffuse * light.diffuse
|
||||
; c7 = ambient color
|
||||
; c2-c5 = projection matrix
|
||||
; c1 = light direction
|
||||
; c0 = {1, power, 0, 1020.01};
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; oPos = Output position
|
||||
; oD0 = Diffuse
|
||||
; oD1 = Specular
|
||||
; oT0 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
// Compensate for lack of UBYTE4 on Geforce3
|
||||
mul r1,v2.zyxw,c0.wwww
|
||||
//mul r1,v2,c0.wwww
|
||||
|
||||
|
||||
//first compute the last blending weight
|
||||
dp3 r0.w,v1.xyz,c0.xzz;
|
||||
add r0.w,-r0.w,c0.x
|
||||
|
||||
//Set 1
|
||||
mov a0.x,r1.x
|
||||
m4x3 r4,v0,c[a0.x + 9];
|
||||
m3x3 r5,v3,c[a0.x + 9];
|
||||
|
||||
//blend them
|
||||
mul r4,r4,v1.xxxx
|
||||
mul r5,r5,v1.xxxx
|
||||
|
||||
//Set 2
|
||||
mov a0.x,r1.y
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,r0.wwww,r4;
|
||||
mad r5,r3,r0.wwww,r5;
|
||||
|
||||
//compute position
|
||||
mov r4.w,c0.x
|
||||
m4x4 oPos,r4,c2
|
||||
|
||||
// normalize normals
|
||||
dp3 r5.w, r5, r5;
|
||||
rsq r5.w, r5.w;
|
||||
mul r5, r5, r5.w;
|
||||
|
||||
; Do the lighting calculation
|
||||
dp3 r1.x, r5, c1 ; normal dot light
|
||||
lit r1, r1
|
||||
mul r0, r1.y, c8 ; Multiply with diffuse
|
||||
add r0, r0, c7 ; Add in ambient
|
||||
min oD0, r0, c0.x ; clamp if > 1
|
||||
mov oD1, c0.zzzz ; output specular
|
||||
|
||||
; Copy texture coordinate
|
||||
mov oT0, v4
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
vs.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; v0 = position
|
||||
; v1 = blend weights
|
||||
; v2 = blend indices
|
||||
; v3 = normal
|
||||
; v4 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; r0.w = Last blend weight
|
||||
; r1 = Blend indices
|
||||
; r2 = Temp position
|
||||
; r3 = Temp normal
|
||||
; r4 = Blended position in camera space
|
||||
; r5 = Blended normal in camera space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app;
|
||||
;
|
||||
; c9-c95 = world-view matrix palette
|
||||
; c8 = diffuse * light.diffuse
|
||||
; c7 = ambient color
|
||||
; c2-c5 = projection matrix
|
||||
; c1 = light direction
|
||||
; c0 = {1, power, 0, 1020.01};
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; oPos = Output position
|
||||
; oD0 = Diffuse
|
||||
; oD1 = Specular
|
||||
; oT0 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
// Compensate for lack of UBYTE4 on Geforce3
|
||||
mul r1,v2.zyxw,c0.wwww
|
||||
//mul r1,v2,c0.wwww
|
||||
|
||||
|
||||
//first compute the last blending weight
|
||||
dp3 r0.w,v1.xyz,c0.xxz;
|
||||
add r0.w,-r0.w,c0.x
|
||||
|
||||
//Set 1
|
||||
mov a0.x,r1.x
|
||||
m4x3 r4,v0,c[a0.x + 9];
|
||||
m3x3 r5,v3,c[a0.x + 9];
|
||||
|
||||
//blend them
|
||||
mul r4,r4,v1.xxxx
|
||||
mul r5,r5,v1.xxxx
|
||||
|
||||
//Set 2
|
||||
mov a0.x,r1.y
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,v1.yyyy,r4;
|
||||
mad r5,r3,v1.yyyy,r5;
|
||||
|
||||
//Set 3
|
||||
mov a0.x,r1.z
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,r0.wwww,r4;
|
||||
mad r5,r3,r0.wwww,r5;
|
||||
|
||||
//compute position
|
||||
mov r4.w,c0.x
|
||||
m4x4 oPos,r4,c2
|
||||
|
||||
// normalize normals
|
||||
dp3 r5.w, r5, r5;
|
||||
rsq r5.w, r5.w;
|
||||
mul r5, r5, r5.w;
|
||||
|
||||
; Do the lighting calculation
|
||||
dp3 r1.x, r5, c1 ; normal dot light
|
||||
lit r1, r1
|
||||
mul r0, r1.y, c8 ; Multiply with diffuse
|
||||
add r0, r0, c7 ; Add in ambient
|
||||
min oD0, r0, c0.x ; clamp if > 1
|
||||
mov oD1, c0.zzzz ; output specular
|
||||
|
||||
; Copy texture coordinate
|
||||
mov oT0, v4
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
|
||||
vs.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; v0 = position
|
||||
; v1 = blend weights
|
||||
; v2 = blend indices
|
||||
; v3 = normal
|
||||
; v4 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; r0.w = Last blend weight
|
||||
; r1 = Blend indices
|
||||
; r2 = Temp position
|
||||
; r3 = Temp normal
|
||||
; r4 = Blended position in camera space
|
||||
; r5 = Blended normal in camera space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app;
|
||||
;
|
||||
; c9-c95 = world-view matrix palette
|
||||
; c8 = diffuse * light.diffuse
|
||||
; c7 = ambient color
|
||||
; c2-c5 = projection matrix
|
||||
; c1 = light direction
|
||||
; c0 = {1, power, 0, 1020.01};
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; oPos = Output position
|
||||
; oD0 = Diffuse
|
||||
; oD1 = Specular
|
||||
; oT0 = texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
// Compensate for lack of UBYTE4 on Geforce3
|
||||
mul r1,v2.zyxw,c0.wwww
|
||||
//mul r1,v2,c0.wwww
|
||||
|
||||
|
||||
//first compute the last blending weight
|
||||
dp3 r0.w,v1.xyz,c0.xxx;
|
||||
add r0.w,-r0.w,c0.x
|
||||
|
||||
//Set 1
|
||||
mov a0.x,r1.x
|
||||
m4x3 r4,v0,c[a0.x + 9];
|
||||
m3x3 r5,v3,c[a0.x + 9];
|
||||
|
||||
//blend them
|
||||
mul r4,r4,v1.xxxx
|
||||
mul r5,r5,v1.xxxx
|
||||
|
||||
//Set 2
|
||||
mov a0.x,r1.y
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,v1.yyyy,r4;
|
||||
mad r5,r3,v1.yyyy,r5;
|
||||
|
||||
//Set 3
|
||||
mov a0.x,r1.z
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,v1.zzzz,r4;
|
||||
mad r5,r3,v1.zzzz,r5;
|
||||
|
||||
//Set 4
|
||||
mov a0.x,r1.w
|
||||
m4x3 r2,v0,c[a0.x + 9];
|
||||
m3x3 r3,v3,c[a0.x + 9];
|
||||
|
||||
//add them in
|
||||
mad r4,r2,r0.wwww,r4;
|
||||
mad r5,r3,r0.wwww,r5;
|
||||
|
||||
//compute position
|
||||
mov r4.w,c0.x
|
||||
m4x4 oPos,r4,c2
|
||||
|
||||
// normalize normals
|
||||
dp3 r5.w, r5, r5;
|
||||
rsq r5.w, r5.w;
|
||||
mul r5, r5, r5.w;
|
||||
|
||||
; Do the lighting calculation
|
||||
dp3 r1.x, r5, c1 ; normal dot light
|
||||
lit r1, r1
|
||||
mul r0, r1.y, c8 ; Multiply with diffuse
|
||||
add r0, r0, c7 ; Add in ambient
|
||||
min oD0, r0, c0.x ; clamp if > 1
|
||||
mov oD1, c0.zzzz ; output specular
|
||||
|
||||
; Copy texture coordinate
|
||||
mov oT0, v4
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on SkinnedMesh.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=SkinnedMesh - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to SkinnedMesh - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "SkinnedMesh - Win32 Release" && "$(CFG)" != "SkinnedMesh - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "SkinnedMesh.mak" CFG="SkinnedMesh - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "SkinnedMesh - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "SkinnedMesh - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "SkinnedMesh - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\SkinnedMesh.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\mdraw.obj"
|
||||
-@erase "$(INTDIR)\mload.obj"
|
||||
-@erase "$(INTDIR)\skinnedmesh.obj"
|
||||
-@erase "$(INTDIR)\skinnedmesh.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\SkinnedMesh.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\skinnedmesh.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\SkinnedMesh.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d3dx8.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\SkinnedMesh.pdb" /machine:I386 /out:"$(OUTDIR)\SkinnedMesh.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\mdraw.obj" \
|
||||
"$(INTDIR)\mload.obj" \
|
||||
"$(INTDIR)\skinnedmesh.obj" \
|
||||
"$(INTDIR)\skinnedmesh.res"
|
||||
|
||||
"$(OUTDIR)\SkinnedMesh.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "SkinnedMesh - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\SkinnedMesh.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\mdraw.obj"
|
||||
-@erase "$(INTDIR)\mload.obj"
|
||||
-@erase "$(INTDIR)\skinnedmesh.obj"
|
||||
-@erase "$(INTDIR)\skinnedmesh.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\SkinnedMesh.exe"
|
||||
-@erase "$(OUTDIR)\SkinnedMesh.ilk"
|
||||
-@erase "$(OUTDIR)\SkinnedMesh.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\skinnedmesh.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\SkinnedMesh.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d3dx8dt.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\SkinnedMesh.pdb" /debug /machine:I386 /out:"$(OUTDIR)\SkinnedMesh.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\mdraw.obj" \
|
||||
"$(INTDIR)\mload.obj" \
|
||||
"$(INTDIR)\skinnedmesh.obj" \
|
||||
"$(INTDIR)\skinnedmesh.res"
|
||||
|
||||
"$(OUTDIR)\SkinnedMesh.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("SkinnedMesh.dep")
|
||||
!INCLUDE "SkinnedMesh.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "SkinnedMesh.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "SkinnedMesh - Win32 Release" || "$(CFG)" == "SkinnedMesh - Win32 Debug"
|
||||
SOURCE=.\skinnedmesh.rc
|
||||
|
||||
"$(INTDIR)\skinnedmesh.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
|
||||
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
|
||||
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
|
||||
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\mdraw.cpp
|
||||
|
||||
"$(INTDIR)\mdraw.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\mload.cpp
|
||||
|
||||
"$(INTDIR)\mload.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\skinnedmesh.cpp
|
||||
|
||||
"$(INTDIR)\skinnedmesh.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,604 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: SkinnedMesh.cpp
|
||||
//
|
||||
// Desc: Example code showing how to use animated models with skinning.
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <commdlg.h>
|
||||
#include <tchar.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include "resource.h"
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "SkinnedMesh.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("Skinned Mesh");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bShowCursorWhenFullscreen = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
|
||||
m_pmcSelectedMesh = NULL;
|
||||
m_pframeSelected = NULL;
|
||||
m_pdeHead = NULL;
|
||||
m_pdeSelected = NULL;
|
||||
|
||||
m_dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL | D3DFVF_TEX1;
|
||||
|
||||
m_method = D3DNONINDEXED;
|
||||
|
||||
m_pBoneMatrices = NULL;
|
||||
m_maxBones = 0;
|
||||
|
||||
m_szPath[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
// This sample wants mixed vertex processing rather than hardware
|
||||
// vertex processing so it can fallback to sw processing if the
|
||||
// device supports fewer than three matrices when skinning.
|
||||
if( dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
// Set cursor to indicate that user can move the object with the mouse
|
||||
#ifdef _WIN64
|
||||
SetClassLongPtr( m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor( NULL, IDC_SIZEALL ) );
|
||||
#else
|
||||
SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)LoadCursor( NULL, IDC_SIZEALL ) );
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
SDrawElement *pdeCur;
|
||||
SFrame *pframeCur;
|
||||
|
||||
pdeCur = m_pdeHead;
|
||||
while (pdeCur != NULL)
|
||||
{
|
||||
pdeCur->fCurTime += m_fElapsedTime * 4800;
|
||||
if (pdeCur->fCurTime > 1.0e15f)
|
||||
pdeCur->fCurTime = 0;
|
||||
|
||||
pframeCur = pdeCur->pframeAnimHead;
|
||||
while (pframeCur != NULL)
|
||||
{
|
||||
pframeCur->SetTime(pdeCur->fCurTime);
|
||||
pframeCur = pframeCur->pframeAnimNext;
|
||||
}
|
||||
|
||||
pdeCur = pdeCur->pdeNext;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Render()
|
||||
// Desc: Called once per frame, the call is the entry point for 3d
|
||||
// rendering. This function sets up render states, clears the
|
||||
// viewport, and renders the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::Render()
|
||||
{
|
||||
// Set up viewing postion from ArcBall
|
||||
SDrawElement *pdeCur;
|
||||
D3DXMATRIXA16 mat;
|
||||
pdeCur = m_pdeHead;
|
||||
while (pdeCur != NULL)
|
||||
{
|
||||
pdeCur->pframeRoot->matRot = *m_ArcBall.GetRotationMatrix();
|
||||
pdeCur->pframeRoot->matTrans = *m_ArcBall.GetTranslationMatrix();
|
||||
pdeCur = pdeCur->pdeNext;
|
||||
}
|
||||
|
||||
// Clear the viewport
|
||||
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(89,135,179), 1.0f, 0 );
|
||||
|
||||
if (m_pdeHead == NULL)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Begin the scene
|
||||
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
UINT cTriangles = 0;
|
||||
HRESULT hr;
|
||||
SDrawElement *pdeCur;
|
||||
D3DXMATRIXA16 mCur;
|
||||
D3DXVECTOR3 vTemp;
|
||||
|
||||
D3DXMatrixTranslation(&m_mView, 0, 0, -m_pdeSelected->fRadius * 2.8f);
|
||||
|
||||
hr = m_pd3dDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&m_mView);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
|
||||
pdeCur = m_pdeHead;
|
||||
while (pdeCur != NULL)
|
||||
{
|
||||
D3DXMatrixIdentity(&mCur);
|
||||
|
||||
hr = UpdateFrames(pdeCur->pframeRoot, mCur);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
hr = DrawFrames(pdeCur->pframeRoot, cTriangles);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
pdeCur = pdeCur->pdeNext;
|
||||
}
|
||||
|
||||
// Show frame rate
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// Restore the fonts
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// if no filename, use the default
|
||||
if (m_szPath[0] == '\0')
|
||||
{
|
||||
DXUtil_FindMediaFile( m_szPath, _T("tiny.x") );
|
||||
}
|
||||
|
||||
LoadMeshHierarchy();
|
||||
|
||||
if( m_pdeHead != NULL)
|
||||
m_ArcBall.SetRadius( m_pdeHead->fRadius );
|
||||
m_ArcBall.SetRightHanded( TRUE );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
// Restore the fonts
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
D3DLIGHT8 light;
|
||||
|
||||
m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 2.0f );
|
||||
|
||||
if (m_pdeSelected != NULL)
|
||||
SetProjectionMatrix();
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_COLORVERTEX, FALSE );
|
||||
|
||||
// Create vertex shader for the indexed skinning
|
||||
DWORD dwIndexedVertexDecl1[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position of first mesh
|
||||
D3DVSD_REG( 2, D3DVSDT_D3DCOLOR ), // Blend indices
|
||||
// D3DVSD_REG( 2, D3DVSDT_UBYTE4 ), // Blend indices
|
||||
D3DVSD_REG( 3, D3DVSDT_FLOAT3 ), // Normal
|
||||
D3DVSD_REG( 4, D3DVSDT_FLOAT2 ), // Tex coords
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
DWORD dwIndexedVertexDecl2[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position of first mesh
|
||||
D3DVSD_REG( 1, D3DVSDT_FLOAT1 ), // Blend weights
|
||||
D3DVSD_REG( 2, D3DVSDT_D3DCOLOR ), // Blend indices
|
||||
// D3DVSD_REG( 2, D3DVSDT_UBYTE4 ), // Blend indices
|
||||
D3DVSD_REG( 3, D3DVSDT_FLOAT3 ), // Normal
|
||||
D3DVSD_REG( 4, D3DVSDT_FLOAT2 ), // Tex coords
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
DWORD dwIndexedVertexDecl3[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position of first mesh
|
||||
D3DVSD_REG( 1, D3DVSDT_FLOAT2 ), // Blend weights
|
||||
D3DVSD_REG( 2, D3DVSDT_D3DCOLOR ), // Blend indices
|
||||
// D3DVSD_REG( 2, D3DVSDT_UBYTE4 ), // Blend indices
|
||||
D3DVSD_REG( 3, D3DVSDT_FLOAT3 ), // Normal
|
||||
D3DVSD_REG( 4, D3DVSDT_FLOAT2 ), // Tex coords
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
DWORD dwIndexedVertexDecl4[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position of first mesh
|
||||
D3DVSD_REG( 1, D3DVSDT_FLOAT3 ), // Blend weights
|
||||
D3DVSD_REG( 2, D3DVSDT_D3DCOLOR ), // Blend indices
|
||||
// D3DVSD_REG( 2, D3DVSDT_UBYTE4 ), // Blend indices
|
||||
D3DVSD_REG( 3, D3DVSDT_FLOAT3 ), // Normal
|
||||
D3DVSD_REG( 4, D3DVSDT_FLOAT2 ), // Tex coords
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
DWORD* dwIndexedVertexDecl[] = {dwIndexedVertexDecl1, dwIndexedVertexDecl2, dwIndexedVertexDecl3, dwIndexedVertexDecl4};
|
||||
|
||||
LPD3DXBUFFER pCode;
|
||||
|
||||
DWORD bUseSW = D3DUSAGE_SOFTWAREPROCESSING;
|
||||
if (m_d3dCaps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
|
||||
{
|
||||
bUseSW = 0;
|
||||
}
|
||||
|
||||
for (DWORD i = 0; i < 4; ++i)
|
||||
{
|
||||
// Assemble the vertex shader file
|
||||
if( FAILED( hr = D3DXAssembleShaderFromResource(NULL, MAKEINTRESOURCE(IDD_SHADER1 + i), 0, NULL, &pCode, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
// Create the vertex shader
|
||||
if( FAILED( hr = m_pd3dDevice->CreateVertexShader( dwIndexedVertexDecl[i],
|
||||
(DWORD*)pCode->GetBufferPointer(),
|
||||
&(m_dwIndexedVertexShader[i]) , bUseSW ) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
pCode->Release();
|
||||
}
|
||||
|
||||
ZeroMemory( &light, sizeof(light) );
|
||||
light.Type = D3DLIGHT_DIRECTIONAL;
|
||||
|
||||
light.Diffuse.r = 1.0;
|
||||
light.Diffuse.g = 1.0;
|
||||
light.Diffuse.b = 1.0;
|
||||
light.Specular.r = 0;
|
||||
light.Specular.g = 0;
|
||||
light.Specular.b = 0;
|
||||
light.Ambient.r = 0.25;
|
||||
light.Ambient.g = 0.25;
|
||||
light.Ambient.b = 0.25;
|
||||
|
||||
light.Direction = D3DXVECTOR3( 0.0f, 0.0f, -1.0f);
|
||||
|
||||
hr = m_pd3dDevice->SetLight(0, &light );
|
||||
if (FAILED(hr))
|
||||
return E_FAIL;
|
||||
|
||||
hr = m_pd3dDevice->LightEnable(0, TRUE);
|
||||
if (FAILED(hr))
|
||||
return E_FAIL;
|
||||
|
||||
// Set Light for vertex shader
|
||||
D3DXVECTOR4 vLightDir( 0.0f, 0.0f, 1.0f, 0.0f );
|
||||
m_pd3dDevice->SetVertexShaderConstant(1, &vLightDir, 1);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ReleaseDeviceDependentMeshes()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReleaseDeviceDependentMeshes(SFrame* pframe)
|
||||
{
|
||||
if (pframe->pmcMesh != NULL)
|
||||
{
|
||||
for (SMeshContainer* pmcCurr = pframe->pmcMesh; pmcCurr != NULL; pmcCurr = pmcCurr->pmcNext)
|
||||
{
|
||||
if (pmcCurr->m_pSkinMesh != NULL)
|
||||
{
|
||||
GXRELEASE(pmcCurr->pMesh);
|
||||
|
||||
pmcCurr->m_Method = NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pframe->pframeFirstChild != NULL)
|
||||
ReleaseDeviceDependentMeshes(pframe->pframeFirstChild);
|
||||
|
||||
if (pframe->pframeSibling != NULL)
|
||||
ReleaseDeviceDependentMeshes(pframe->pframeSibling);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
|
||||
|
||||
for (SDrawElement* pdeCurr = m_pdeHead; pdeCurr != NULL; pdeCurr = pdeCurr->pdeNext)
|
||||
{
|
||||
ReleaseDeviceDependentMeshes(pdeCurr->pframeRoot);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
|
||||
if( m_pdeSelected == m_pdeHead )
|
||||
m_pdeSelected = NULL;
|
||||
|
||||
delete m_pdeHead;
|
||||
m_pdeHead = NULL;
|
||||
|
||||
delete [] m_pBoneMatrices;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
// Pass mouse messages to the ArcBall so it can build internal matrices
|
||||
m_ArcBall.HandleMouseMessages( hWnd, uMsg, wParam, lParam );
|
||||
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if ( 0 == HIWORD(wParam) )
|
||||
{
|
||||
switch ( LOWORD(wParam) )
|
||||
{
|
||||
case ID_FILE_OPENMESHHEIRARCHY:
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
memset( &ofn, 0, sizeof(ofn) );
|
||||
static TCHAR file[256];
|
||||
static TCHAR szFilepath[256];
|
||||
static TCHAR fileTitle[256];
|
||||
static TCHAR filter[] =
|
||||
TEXT("X files (*.x)\0*.x\0")
|
||||
TEXT("All Files (*.*)\0*.*\0");
|
||||
_tcscpy( file, TEXT(""));
|
||||
_tcscpy( fileTitle, TEXT(""));
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = m_hWnd;
|
||||
ofn.hInstance = NULL;//m_hInstance;
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrCustomFilter = NULL;
|
||||
ofn.nMaxCustFilter = 0L;
|
||||
ofn.nFilterIndex = 1L;
|
||||
ofn.lpstrFile = file;
|
||||
ofn.nMaxFile = sizeof(file);
|
||||
ofn.lpstrFileTitle = fileTitle;
|
||||
ofn.nMaxFileTitle = sizeof(fileTitle);
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.nFileOffset = 0;
|
||||
ofn.nFileExtension = 0;
|
||||
ofn.lpstrDefExt = TEXT("*.x");
|
||||
ofn.lCustData = 0;
|
||||
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
if ( ! GetOpenFileName( &ofn) )
|
||||
{
|
||||
TCHAR s[40];
|
||||
DWORD dwErr = CommDlgExtendedError();
|
||||
if ( 0 != dwErr )
|
||||
{
|
||||
wsprintf( s, "GetOpenFileName failed with %x", dwErr );
|
||||
MessageBox( m_hWnd, s, "TexWin", MB_OK | MB_SYSTEMMODAL );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
lstrcpy(m_szPath, ofn.lpstrFile);
|
||||
HRESULT hr = LoadMeshHierarchy();
|
||||
if (FAILED(hr))
|
||||
MessageBox(NULL, "Could not open file or incorrect file type", "Error loading file", MB_OK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case ID_OPTIONS_D3DINDEXED:
|
||||
{
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_CHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED);
|
||||
m_method = D3DINDEXED;
|
||||
break;
|
||||
}
|
||||
case ID_OPTIONS_D3DINDEXEDVS:
|
||||
{
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_CHECKED);
|
||||
m_method = D3DINDEXEDVS;
|
||||
break;
|
||||
}
|
||||
case ID_OPTIONS_D3DNONINDEXED:
|
||||
{
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_CHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED);
|
||||
m_method = D3DNONINDEXED;
|
||||
break;
|
||||
}
|
||||
case ID_OPTIONS_SOFTWARESKINNING:
|
||||
{
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_CHECKED);
|
||||
CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED);
|
||||
m_method = SOFTWARE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: SetProjectionMatrix()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::SetProjectionMatrix()
|
||||
{
|
||||
D3DXMATRIX mat;
|
||||
|
||||
if (m_pdeHead == NULL)
|
||||
return S_OK;
|
||||
|
||||
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
|
||||
D3DXMatrixPerspectiveFovRH(&mat, 0.25f*3.141592654f, fAspect, m_pdeSelected->fRadius / 64, m_pdeSelected->fRadius * 200);
|
||||
HRESULT hr = m_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)&mat );
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
// Set Projection Matrix for vertex shader
|
||||
D3DXMatrixTranspose(&mat, &mat);
|
||||
return m_pd3dDevice->SetVertexShaderConstant(2, &mat, 4);
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __MVIEW_H__
|
||||
#define __MVIEW_H__
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// File: mview.h
|
||||
//
|
||||
// Copyright (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
#define GXRELEASE(_p) do { if ((_p) != NULL) {(_p)->Release(); (_p) = NULL;} } while (0)
|
||||
|
||||
enum METHOD {
|
||||
D3DNONINDEXED,
|
||||
D3DINDEXED,
|
||||
SOFTWARE,
|
||||
D3DINDEXEDVS,
|
||||
NONE
|
||||
};
|
||||
|
||||
struct SMeshContainer
|
||||
{
|
||||
ID3DXMesh *pMesh;
|
||||
D3DMATERIAL8 *rgMaterials;
|
||||
LPDIRECT3DTEXTURE8 *pTextures;
|
||||
DWORD cpattr;
|
||||
DWORD cMaterials;
|
||||
DWORD iAttrSplit;
|
||||
|
||||
SMeshContainer *pmcNext;
|
||||
|
||||
char *szName;
|
||||
|
||||
// Skin info
|
||||
LPD3DXSKINMESH m_pSkinMesh;
|
||||
D3DXATTRIBUTERANGE *m_pAttrTable;
|
||||
D3DXMATRIX** m_pBoneMatrix;
|
||||
LPD3DXBUFFER m_pBoneNamesBuf;
|
||||
LPD3DXBUFFER m_pBoneOffsetBuf;
|
||||
D3DXMATRIX* m_pBoneOffsetMat;
|
||||
DWORD* m_rgiAdjacency;
|
||||
DWORD m_numBoneComb;
|
||||
DWORD m_maxFaceInfl;
|
||||
LPD3DXBUFFER m_pBoneCombinationBuf;
|
||||
METHOD m_Method;
|
||||
DWORD m_paletteSize;
|
||||
BOOL m_bUseSW;
|
||||
|
||||
SMeshContainer()
|
||||
:pMesh(NULL),
|
||||
rgMaterials(NULL),
|
||||
pTextures(NULL),
|
||||
cpattr(0),
|
||||
iAttrSplit(0),
|
||||
cMaterials(0),
|
||||
pmcNext(NULL),
|
||||
szName(NULL),
|
||||
m_pSkinMesh(NULL),
|
||||
m_pAttrTable(NULL),
|
||||
m_pBoneMatrix(NULL),
|
||||
m_pBoneNamesBuf(NULL),
|
||||
m_pBoneOffsetBuf(NULL),
|
||||
m_pBoneOffsetMat(NULL),
|
||||
m_rgiAdjacency(NULL),
|
||||
m_numBoneComb(0),
|
||||
m_maxFaceInfl(0),
|
||||
m_pBoneCombinationBuf(NULL),
|
||||
m_Method(NONE),
|
||||
m_paletteSize(0),
|
||||
m_bUseSW(FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
~SMeshContainer()
|
||||
{
|
||||
delete []rgMaterials;
|
||||
|
||||
if (pTextures)
|
||||
{
|
||||
for (DWORD i = 0; i < cMaterials; ++i)
|
||||
{
|
||||
GXRELEASE(pTextures[i]);
|
||||
}
|
||||
delete []pTextures;
|
||||
}
|
||||
|
||||
GXRELEASE(pMesh);
|
||||
GXRELEASE(m_pSkinMesh);
|
||||
GXRELEASE(m_pBoneNamesBuf);
|
||||
GXRELEASE(m_pBoneOffsetBuf);
|
||||
GXRELEASE(m_pBoneCombinationBuf);
|
||||
|
||||
delete[] m_pBoneMatrix;
|
||||
|
||||
delete[] m_pAttrTable;
|
||||
|
||||
delete []szName;
|
||||
|
||||
delete[] m_rgiAdjacency;
|
||||
|
||||
delete pmcNext;
|
||||
}
|
||||
};
|
||||
|
||||
// X File formation rotate key
|
||||
struct SRotateKeyXFile
|
||||
{
|
||||
DWORD dwTime;
|
||||
DWORD dwFloats;
|
||||
float w;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
struct SScaleKeyXFile
|
||||
{
|
||||
DWORD dwTime;
|
||||
DWORD dwFloats;
|
||||
D3DXVECTOR3 vScale;
|
||||
};
|
||||
|
||||
|
||||
struct SPositionKeyXFile
|
||||
{
|
||||
DWORD dwTime;
|
||||
DWORD dwFloats;
|
||||
D3DXVECTOR3 vPos;
|
||||
};
|
||||
|
||||
struct SMatrixKeyXFile
|
||||
{
|
||||
DWORD dwTime;
|
||||
DWORD dwFloats;
|
||||
D3DXMATRIX mat;
|
||||
};
|
||||
|
||||
// in memory versions
|
||||
|
||||
struct SRotateKey
|
||||
{
|
||||
DWORD dwTime;
|
||||
D3DXQUATERNION quatRotate;
|
||||
};
|
||||
|
||||
struct SPositionKey
|
||||
{
|
||||
DWORD dwTime;
|
||||
D3DXVECTOR3 vPos;
|
||||
};
|
||||
|
||||
struct SScaleKey
|
||||
{
|
||||
DWORD dwTime;
|
||||
D3DXVECTOR3 vScale;
|
||||
};
|
||||
|
||||
struct SMatrixKey
|
||||
{
|
||||
DWORD dwTime;
|
||||
D3DXMATRIXA16 mat;
|
||||
};
|
||||
|
||||
struct SFrame
|
||||
{
|
||||
SMeshContainer *pmcMesh;
|
||||
D3DXMATRIXA16 matRot;
|
||||
D3DXMATRIXA16 matTrans;
|
||||
D3DXMATRIXA16 matRotOrig;
|
||||
D3DXMATRIXA16 matCombined;
|
||||
|
||||
// animation information
|
||||
SPositionKey *m_pPositionKeys;
|
||||
UINT m_cPositionKeys;
|
||||
SRotateKey *m_pRotateKeys;
|
||||
UINT m_cRotateKeys;
|
||||
SScaleKey *m_pScaleKeys;
|
||||
UINT m_cScaleKeys;
|
||||
SMatrixKey *m_pMatrixKeys;
|
||||
UINT m_cMatrixKeys;
|
||||
|
||||
SFrame *pframeAnimNext;
|
||||
SFrame *pframeToAnimate;
|
||||
|
||||
SFrame *pframeSibling;
|
||||
SFrame *pframeFirstChild;
|
||||
|
||||
bool bAnimationFrame;
|
||||
char *szName;
|
||||
|
||||
SFrame()
|
||||
:
|
||||
pmcMesh(NULL),
|
||||
m_pPositionKeys(NULL),
|
||||
m_cPositionKeys(0),
|
||||
m_pScaleKeys(NULL),
|
||||
m_cScaleKeys(0),
|
||||
m_pRotateKeys(NULL),
|
||||
m_cRotateKeys(0),
|
||||
m_pMatrixKeys(NULL),
|
||||
m_cMatrixKeys(0),
|
||||
pframeAnimNext(NULL),
|
||||
pframeToAnimate(NULL),
|
||||
pframeSibling(NULL),
|
||||
pframeFirstChild(NULL),
|
||||
bAnimationFrame(false),
|
||||
szName(NULL)
|
||||
{
|
||||
D3DXMatrixIdentity(&matRot);
|
||||
D3DXMatrixIdentity(&matRotOrig);
|
||||
D3DXMatrixIdentity(&matTrans);
|
||||
}
|
||||
|
||||
~SFrame()
|
||||
{
|
||||
delete []szName;
|
||||
delete pmcMesh;
|
||||
delete pframeFirstChild;
|
||||
delete pframeSibling;
|
||||
|
||||
delete []m_pPositionKeys;
|
||||
delete []m_pRotateKeys;
|
||||
delete []m_pScaleKeys;
|
||||
delete []m_pMatrixKeys;
|
||||
|
||||
// do NOT delete pframeAnimNext
|
||||
// do NOT delete pframeToAnimate
|
||||
}
|
||||
|
||||
void SetTime(float fTime);
|
||||
|
||||
SFrame *FindFrame(char *szFrame)
|
||||
{
|
||||
SFrame *pframe;
|
||||
|
||||
if ((szName != NULL) && (strcmp(szName, szFrame) == 0))
|
||||
return this;
|
||||
|
||||
if (pframeFirstChild != NULL)
|
||||
{
|
||||
pframe = pframeFirstChild->FindFrame(szFrame);
|
||||
if (pframe != NULL)
|
||||
return pframe;
|
||||
}
|
||||
|
||||
if (pframeSibling != NULL)
|
||||
{
|
||||
pframe = pframeSibling->FindFrame(szFrame);
|
||||
if (pframe != NULL)
|
||||
return pframe;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ResetMatrix()
|
||||
{
|
||||
matRot = matRotOrig;
|
||||
D3DXMatrixIdentity(&matTrans);
|
||||
|
||||
if (pframeFirstChild != NULL)
|
||||
{
|
||||
pframeFirstChild->ResetMatrix();
|
||||
}
|
||||
|
||||
if (pframeSibling != NULL)
|
||||
{
|
||||
pframeSibling->ResetMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void AddFrame(SFrame *pframe)
|
||||
{
|
||||
if (pframeFirstChild == NULL)
|
||||
{
|
||||
pframeFirstChild = pframe;
|
||||
}
|
||||
else
|
||||
{
|
||||
pframe->pframeSibling = pframeFirstChild->pframeSibling;
|
||||
pframeFirstChild->pframeSibling = pframe;
|
||||
}
|
||||
}
|
||||
|
||||
void AddMesh(SMeshContainer *pmc)
|
||||
{
|
||||
pmc->pmcNext = pmcMesh;
|
||||
pmcMesh = pmc;
|
||||
}
|
||||
};
|
||||
|
||||
struct SDrawElement
|
||||
{
|
||||
SFrame *pframeRoot;
|
||||
|
||||
D3DXVECTOR3 vCenter;
|
||||
float fRadius;
|
||||
|
||||
// name of element for selection purposes
|
||||
char *szName;
|
||||
|
||||
// animation list
|
||||
SFrame *pframeAnimHead;
|
||||
|
||||
// next element in list
|
||||
SDrawElement *pdeNext;
|
||||
|
||||
float fCurTime;
|
||||
float fMaxTime;
|
||||
|
||||
SDrawElement()
|
||||
:vCenter(0.0,0.0,0.0),
|
||||
fRadius(1.0),
|
||||
szName(NULL),
|
||||
pframeRoot(NULL),
|
||||
pframeAnimHead(NULL),
|
||||
pdeNext(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~SDrawElement()
|
||||
{
|
||||
delete pframeRoot;
|
||||
delete pdeNext;
|
||||
delete [] szName;
|
||||
|
||||
// do NOT delete pframeAnimHead;
|
||||
}
|
||||
|
||||
void AddAnimationFrame(SFrame *pframeAnim)
|
||||
{
|
||||
pframeAnim->pframeAnimNext = pframeAnimHead;
|
||||
pframeAnimHead = pframeAnim;
|
||||
}
|
||||
|
||||
SFrame *FindFrame(char *szName)
|
||||
{
|
||||
if (pframeRoot == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return pframeRoot->FindFrame(szName);
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT CalculateBoundingSphere(SDrawElement *pdeCur);
|
||||
|
||||
|
||||
|
||||
extern DWORD g_dwNumDeviceTypes;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMyD3DApplication
|
||||
// Desc: Application class. The base class (CD3DApplication) provides the
|
||||
// generic functionality needed in all Direct3D samples. CMyD3DApplication
|
||||
// adds functionality specific to this sample program.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMyD3DApplication : public CD3DApplication
|
||||
{
|
||||
CD3DFont* m_pFont;
|
||||
|
||||
METHOD m_method;
|
||||
|
||||
DWORD m_dwFVF;
|
||||
|
||||
CD3DArcBall m_ArcBall;
|
||||
|
||||
SMeshContainer *m_pmcSelectedMesh;
|
||||
SFrame *m_pframeSelected;
|
||||
SDrawElement *m_pdeSelected;
|
||||
SDrawElement *m_pdeHead;
|
||||
|
||||
TCHAR m_szPath[MAX_PATH];
|
||||
LPD3DXMATRIXA16 m_pBoneMatrices;
|
||||
DWORD m_maxBones;
|
||||
DWORD m_dwIndexedVertexShader[4];
|
||||
D3DXMATRIXA16 m_mView;
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT ConfirmDevice(D3DCAPS8*,DWORD,D3DFORMAT);
|
||||
|
||||
HRESULT FindBones(SFrame *pframeCur, SDrawElement *pde);
|
||||
HRESULT LoadMeshHierarchy();
|
||||
HRESULT LoadAnimationSet(LPDIRECTXFILEDATA pxofobjCur, SDrawElement *pde,
|
||||
DWORD options, DWORD fvf, LPDIRECT3DDEVICE8 pD3DDevice,
|
||||
SFrame *pframeParent);
|
||||
HRESULT LoadAnimation(LPDIRECTXFILEDATA pxofobjCur, SDrawElement *pde,
|
||||
DWORD options, DWORD fvf, LPDIRECT3DDEVICE8 pD3DDevice,
|
||||
SFrame *pframeParent);
|
||||
HRESULT LoadFrames(LPDIRECTXFILEDATA pxofobjCur, SDrawElement *pde,
|
||||
DWORD options, DWORD fvf, LPDIRECT3DDEVICE8 pD3DDevice,
|
||||
SFrame *pframeParent);
|
||||
HRESULT LoadMesh(LPDIRECTXFILEDATA pxofobjCur,
|
||||
DWORD options, DWORD fvf, LPDIRECT3DDEVICE8 pD3DDevice,
|
||||
SFrame *pframeParent);
|
||||
HRESULT SetProjectionMatrix();
|
||||
HRESULT DeleteSelectedMesh();
|
||||
HRESULT DrawMeshContainer(SMeshContainer *pmcMesh);
|
||||
HRESULT UpdateFrames(SFrame *pframeCur, D3DXMATRIX &matCur);
|
||||
HRESULT GenerateMesh(SMeshContainer* pmcMesh);
|
||||
HRESULT DrawFrames(SFrame *pframeCur, UINT &cTriangles);
|
||||
|
||||
public:
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
CMyD3DApplication();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user