Fixed grid drawing at incorrect depth, fixed MP2 areas not loading correctly with the AnimSet loader changes
This commit is contained in:
parent
c4268746f2
commit
7f3929d4ca
|
@ -298,47 +298,50 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Animation Set
|
if (Loader.mVersion <= ePrime)
|
||||||
u32 SetStart = rANCS.Tell();
|
|
||||||
SetStart = SetStart;
|
|
||||||
u16 InfoCount = rANCS.ReadShort();
|
|
||||||
u32 NumAnims = rANCS.ReadLong();
|
|
||||||
|
|
||||||
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
|
|
||||||
Loader.LoadAnimation(rANCS);
|
|
||||||
|
|
||||||
u32 NumTransitions = rANCS.ReadLong();
|
|
||||||
|
|
||||||
for (u32 iTrans = 0; iTrans < NumTransitions; iTrans++)
|
|
||||||
Loader.LoadTransition(rANCS);
|
|
||||||
Loader.LoadMetaTransition(rANCS);
|
|
||||||
|
|
||||||
u32 NumAdditiveAnims = rANCS.ReadLong();
|
|
||||||
|
|
||||||
for (u32 iAnim = 0; iAnim < NumAdditiveAnims; iAnim++)
|
|
||||||
Loader.LoadAdditiveAnimation(rANCS);
|
|
||||||
|
|
||||||
rANCS.Seek(0x8, SEEK_CUR);
|
|
||||||
|
|
||||||
if (InfoCount > 2)
|
|
||||||
{
|
{
|
||||||
u32 NumHalfTransitions = rANCS.ReadLong();
|
// Load Animation Set
|
||||||
|
u32 SetStart = rANCS.Tell();
|
||||||
|
SetStart = SetStart;
|
||||||
|
u16 InfoCount = rANCS.ReadShort();
|
||||||
|
u32 NumAnims = rANCS.ReadLong();
|
||||||
|
|
||||||
for (u32 iHalf = 0; iHalf < NumHalfTransitions; iHalf++)
|
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
|
||||||
Loader.LoadHalfTransition(rANCS);
|
Loader.LoadAnimation(rANCS);
|
||||||
}
|
|
||||||
|
|
||||||
// Add anims to set
|
u32 NumTransitions = rANCS.ReadLong();
|
||||||
for (u32 iPrim = 0; iPrim < Loader.mAnimPrimitives.size(); iPrim++)
|
|
||||||
{
|
|
||||||
SPrimitive& rPrim = Loader.mAnimPrimitives[iPrim];
|
|
||||||
|
|
||||||
if (rPrim.Loaded)
|
for (u32 iTrans = 0; iTrans < NumTransitions; iTrans++)
|
||||||
|
Loader.LoadTransition(rANCS);
|
||||||
|
Loader.LoadMetaTransition(rANCS);
|
||||||
|
|
||||||
|
u32 NumAdditiveAnims = rANCS.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iAnim = 0; iAnim < NumAdditiveAnims; iAnim++)
|
||||||
|
Loader.LoadAdditiveAnimation(rANCS);
|
||||||
|
|
||||||
|
rANCS.Seek(0x8, SEEK_CUR);
|
||||||
|
|
||||||
|
if (InfoCount > 2)
|
||||||
{
|
{
|
||||||
CAnimSet::SAnimation Anim;
|
u32 NumHalfTransitions = rANCS.ReadLong();
|
||||||
Anim.Name = rPrim.Name;
|
|
||||||
Anim.pAnim = gResCache.GetResource(rPrim.AnimID, "ANIM");
|
for (u32 iHalf = 0; iHalf < NumHalfTransitions; iHalf++)
|
||||||
Loader.pSet->mAnims.push_back(Anim);
|
Loader.LoadHalfTransition(rANCS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add anims to set
|
||||||
|
for (u32 iPrim = 0; iPrim < Loader.mAnimPrimitives.size(); iPrim++)
|
||||||
|
{
|
||||||
|
SPrimitive& rPrim = Loader.mAnimPrimitives[iPrim];
|
||||||
|
|
||||||
|
if (rPrim.Loaded)
|
||||||
|
{
|
||||||
|
CAnimSet::SAnimation Anim;
|
||||||
|
Anim.Name = rPrim.Name;
|
||||||
|
Anim.pAnim = gResCache.GetResource(rPrim.AnimID, "ANIM");
|
||||||
|
Loader.pSet->mAnims.push_back(Anim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -464,16 +464,6 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL)
|
||||||
{
|
{
|
||||||
Loader.mMaterials[iSet] = CMaterialLoader::LoadMaterialSet(rCMDL, Loader.mVersion);
|
Loader.mMaterials[iSet] = CMaterialLoader::LoadMaterialSet(rCMDL, Loader.mVersion);
|
||||||
|
|
||||||
// Toggle skinning on materials
|
|
||||||
if (Loader.mFlags.HasAnyFlags(eSkinnedModel))
|
|
||||||
{
|
|
||||||
for (u32 iMat = 0; iMat < Loader.mMaterials[iSet]->NumMaterials(); iMat++)
|
|
||||||
{
|
|
||||||
CMaterial *pMat = Loader.mMaterials[iSet]->MaterialByIndex(iMat);
|
|
||||||
pMat->SetVertexDescription(pMat->VtxDesc() | FVertexDescription(eBoneIndices | eBoneWeights));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.mVersion < eCorruptionProto)
|
if (Loader.mVersion < eCorruptionProto)
|
||||||
Loader.mpSectionMgr->ToNextSection();
|
Loader.mpSectionMgr->ToNextSection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
|
||||||
SSurface *pSurf = mSurfaces[Surface];
|
SSurface *pSurf = mSurfaces[Surface];
|
||||||
CMaterial *pMat = mMaterialSets[MatSet]->MaterialByIndex(pSurf->MaterialID);
|
CMaterial *pMat = mMaterialSets[MatSet]->MaterialByIndex(pSurf->MaterialID);
|
||||||
|
|
||||||
if ((!(Options & eEnableOccluders)) && (pMat->Options() & CMaterial::eOccluder))
|
if (!Options.HasFlag(eEnableOccluders) && pMat->Options().HasFlag(CMaterial::eOccluder))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pMat->SetCurrent(Options);
|
pMat->SetCurrent(Options);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef CGRIDRENDERABLE
|
||||||
|
#define CGRIDRENDERABLE
|
||||||
|
|
||||||
|
#include <Core/Render/CRenderer.h>
|
||||||
|
#include <Core/Render/IRenderable.h>
|
||||||
|
|
||||||
|
// Tiny helper to make sure the grid draws at the correct depth.
|
||||||
|
class CGridRenderable : public IRenderable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
|
||||||
|
{
|
||||||
|
pRenderer->AddMesh(this, 0, CAABox::skOne, false, eDrawMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw(FRenderOptions, int, const SViewInfo&)
|
||||||
|
{
|
||||||
|
CDrawUtil::DrawGrid();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CGRIDRENDERABLE
|
||||||
|
|
|
@ -49,14 +49,14 @@ void CCharacterEditorViewport::Paint()
|
||||||
{
|
{
|
||||||
mpRenderer->BeginFrame();
|
mpRenderer->BeginFrame();
|
||||||
mCamera.LoadMatrices();
|
mCamera.LoadMatrices();
|
||||||
CDrawUtil::DrawGrid();
|
mGrid.AddToRenderer(mpRenderer, mViewInfo);
|
||||||
|
|
||||||
if (mpCharNode)
|
if (mpCharNode)
|
||||||
{
|
{
|
||||||
mpCharNode->AddToRenderer(mpRenderer, mViewInfo);
|
mpCharNode->AddToRenderer(mpRenderer, mViewInfo);
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
mpRenderer->EndFrame();
|
mpRenderer->EndFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CCHARACTEREDITORVIEWPORT_H
|
#define CCHARACTEREDITORVIEWPORT_H
|
||||||
|
|
||||||
#include "Editor/CBasicViewport.h"
|
#include "Editor/CBasicViewport.h"
|
||||||
|
#include "Editor/CGridRenderable.h"
|
||||||
#include <Core/Scene/CCharacterNode.h>
|
#include <Core/Scene/CCharacterNode.h>
|
||||||
|
|
||||||
class CCharacterEditorViewport : public CBasicViewport
|
class CCharacterEditorViewport : public CBasicViewport
|
||||||
|
@ -9,6 +10,7 @@ class CCharacterEditorViewport : public CBasicViewport
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CCharacterNode *mpCharNode;
|
CCharacterNode *mpCharNode;
|
||||||
|
CGridRenderable mGrid;
|
||||||
CRenderer *mpRenderer;
|
CRenderer *mpRenderer;
|
||||||
u32 mHoverBone;
|
u32 mHoverBone;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,8 @@ HEADERS += \
|
||||||
WorldEditor/CRepackInfoDialog.h \
|
WorldEditor/CRepackInfoDialog.h \
|
||||||
CAboutDialog.h \
|
CAboutDialog.h \
|
||||||
CharacterEditor/CCharacterEditor.h \
|
CharacterEditor/CCharacterEditor.h \
|
||||||
CharacterEditor/CCharacterEditorViewport.h
|
CharacterEditor/CCharacterEditorViewport.h \
|
||||||
|
CGridRenderable.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|
|
@ -56,13 +56,15 @@ void CModelEditorViewport::Paint()
|
||||||
if (!mpModelNode->Model())
|
if (!mpModelNode->Model())
|
||||||
{
|
{
|
||||||
if (mGridEnabled)
|
if (mGridEnabled)
|
||||||
CDrawUtil::DrawGrid();
|
mGrid.AddToRenderer(mpRenderer, mViewInfo);
|
||||||
|
|
||||||
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mMode == eDrawMesh)
|
else if (mMode == eDrawMesh)
|
||||||
{
|
{
|
||||||
if (mGridEnabled)
|
if (mGridEnabled)
|
||||||
CDrawUtil::DrawGrid();
|
mGrid.AddToRenderer(mpRenderer, mViewInfo);
|
||||||
|
|
||||||
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
|
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CMODELEDITORVIEWPORT_H
|
#define CMODELEDITORVIEWPORT_H
|
||||||
|
|
||||||
#include "Editor/CBasicViewport.h"
|
#include "Editor/CBasicViewport.h"
|
||||||
|
#include "Editor/CGridRenderable.h"
|
||||||
#include <Core/Scene/CModelNode.h>
|
#include <Core/Scene/CModelNode.h>
|
||||||
|
|
||||||
class CModelEditorViewport : public CBasicViewport
|
class CModelEditorViewport : public CBasicViewport
|
||||||
|
@ -13,6 +14,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EDrawMode mMode;
|
EDrawMode mMode;
|
||||||
|
CGridRenderable mGrid;
|
||||||
CModelNode *mpModelNode;
|
CModelNode *mpModelNode;
|
||||||
CMaterial *mpActiveMaterial;
|
CMaterial *mpActiveMaterial;
|
||||||
CRenderer *mpRenderer;
|
CRenderer *mpRenderer;
|
||||||
|
|
Loading…
Reference in New Issue