mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-28 18:21:20 +00:00
Added support for attaching assets from properties to locator bones in the World Editor
This commit is contained in:
parent
2655f9d3fd
commit
cf84f9909a
@ -194,7 +194,8 @@ HEADERS += \
|
|||||||
Render/CBoneTransformData.h \
|
Render/CBoneTransformData.h \
|
||||||
Resource/CSkin.h \
|
Resource/CSkin.h \
|
||||||
Resource/Factory/CSkinLoader.h \
|
Resource/Factory/CSkinLoader.h \
|
||||||
Render/EDepthGroup.h
|
Render/EDepthGroup.h \
|
||||||
|
Scene/CScriptAttachNode.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -279,4 +280,5 @@ SOURCES += \
|
|||||||
Resource/CAnimation.cpp \
|
Resource/CAnimation.cpp \
|
||||||
Resource/Factory/CAnimationLoader.cpp \
|
Resource/Factory/CAnimationLoader.cpp \
|
||||||
Resource/Factory/CSkinLoader.cpp \
|
Resource/Factory/CSkinLoader.cpp \
|
||||||
Resource/Model/EVertexAttribute.cpp
|
Resource/Model/EVertexAttribute.cpp \
|
||||||
|
Scene/CScriptAttachNode.cpp
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
CAnimationParameters::CAnimationParameters()
|
CAnimationParameters::CAnimationParameters()
|
||||||
: mGame(ePrime)
|
: mGame(ePrime)
|
||||||
, mNodeIndex(0)
|
, mCharIndex(0)
|
||||||
, mUnknown1(0)
|
, mAnimIndex(0)
|
||||||
, mUnknown2(0)
|
, mUnknown2(0)
|
||||||
, mUnknown3(0)
|
, mUnknown3(0)
|
||||||
{
|
{
|
||||||
@ -16,8 +16,8 @@ CAnimationParameters::CAnimationParameters()
|
|||||||
|
|
||||||
CAnimationParameters::CAnimationParameters(EGame Game)
|
CAnimationParameters::CAnimationParameters(EGame Game)
|
||||||
: mGame(Game)
|
: mGame(Game)
|
||||||
, mNodeIndex(0)
|
, mCharIndex(0)
|
||||||
, mUnknown1(0)
|
, mAnimIndex(0)
|
||||||
, mUnknown2(0)
|
, mUnknown2(0)
|
||||||
, mUnknown3(0)
|
, mUnknown3(0)
|
||||||
{
|
{
|
||||||
@ -25,22 +25,22 @@ CAnimationParameters::CAnimationParameters(EGame Game)
|
|||||||
|
|
||||||
CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
||||||
: mGame(Game)
|
: mGame(Game)
|
||||||
, mNodeIndex(0)
|
, mCharIndex(0)
|
||||||
, mUnknown1(0)
|
, mAnimIndex(0)
|
||||||
, mUnknown2(0)
|
, mUnknown2(0)
|
||||||
, mUnknown3(0)
|
, mUnknown3(0)
|
||||||
{
|
{
|
||||||
if (Game <= eEchoes)
|
if (Game <= eEchoes)
|
||||||
{
|
{
|
||||||
mCharacter = CResourceInfo(rSCLY.ReadLong(), "ANCS");
|
mCharacter = CResourceInfo(rSCLY.ReadLong(), "ANCS");
|
||||||
mNodeIndex = rSCLY.ReadLong();
|
mCharIndex = rSCLY.ReadLong();
|
||||||
mUnknown1 = rSCLY.ReadLong();
|
mAnimIndex = rSCLY.ReadLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Game <= eCorruption)
|
else if (Game <= eCorruption)
|
||||||
{
|
{
|
||||||
mCharacter = CResourceInfo(rSCLY.ReadLongLong(), "CHAR");
|
mCharacter = CResourceInfo(rSCLY.ReadLongLong(), "CHAR");
|
||||||
mUnknown1 = rSCLY.ReadLong();
|
mAnimIndex = rSCLY.ReadLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Game == eReturns)
|
else if (Game == eReturns)
|
||||||
@ -50,7 +50,7 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
|||||||
// 0x80 - CharacterAnimationSet is empty.
|
// 0x80 - CharacterAnimationSet is empty.
|
||||||
if (Flags & 0x80)
|
if (Flags & 0x80)
|
||||||
{
|
{
|
||||||
mUnknown1 = -1;
|
mAnimIndex = -1;
|
||||||
mUnknown2 = 0;
|
mUnknown2 = 0;
|
||||||
mUnknown3 = 0;
|
mUnknown3 = 0;
|
||||||
return;
|
return;
|
||||||
@ -60,9 +60,9 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
|||||||
|
|
||||||
// 0x20 - Default Anim is present
|
// 0x20 - Default Anim is present
|
||||||
if (Flags & 0x20)
|
if (Flags & 0x20)
|
||||||
mUnknown1 = rSCLY.ReadLong();
|
mAnimIndex = rSCLY.ReadLong();
|
||||||
else
|
else
|
||||||
mUnknown1 = -1;
|
mAnimIndex = -1;
|
||||||
|
|
||||||
// 0x40 - Two-value struct is present
|
// 0x40 - Two-value struct is present
|
||||||
if (Flags & 0x40)
|
if (Flags & 0x40)
|
||||||
@ -85,8 +85,8 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
|||||||
if (mCharacter.IsValid())
|
if (mCharacter.IsValid())
|
||||||
{
|
{
|
||||||
rSCLY.WriteLong(mCharacter.ID().ToLong());
|
rSCLY.WriteLong(mCharacter.ID().ToLong());
|
||||||
rSCLY.WriteLong(mNodeIndex);
|
rSCLY.WriteLong(mCharIndex);
|
||||||
rSCLY.WriteLong(mUnknown1);
|
rSCLY.WriteLong(mAnimIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
|||||||
if (mCharacter.IsValid())
|
if (mCharacter.IsValid())
|
||||||
{
|
{
|
||||||
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
||||||
rSCLY.WriteLong(mUnknown1);
|
rSCLY.WriteLong(mAnimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -119,14 +119,14 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 Flag = 0;
|
u8 Flag = 0;
|
||||||
if (mUnknown1 != -1) Flag |= 0x20;
|
if (mAnimIndex != -1) Flag |= 0x20;
|
||||||
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
|
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
|
||||||
|
|
||||||
rSCLY.WriteByte(Flag);
|
rSCLY.WriteByte(Flag);
|
||||||
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
||||||
|
|
||||||
if (Flag & 0x20)
|
if (Flag & 0x20)
|
||||||
rSCLY.WriteLong(mUnknown1);
|
rSCLY.WriteLong(mAnimIndex);
|
||||||
|
|
||||||
if (Flag & 0x40)
|
if (Flag & 0x40)
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ CModel* CAnimationParameters::GetCurrentModel(s32 NodeIndex /*= -1*/)
|
|||||||
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
||||||
if (!pSet) return nullptr;
|
if (!pSet) return nullptr;
|
||||||
if (pSet->Type() != eAnimSet) return nullptr;
|
if (pSet->Type() != eAnimSet) return nullptr;
|
||||||
if (NodeIndex == -1) NodeIndex = mNodeIndex;
|
if (NodeIndex == -1) NodeIndex = mCharIndex;
|
||||||
|
|
||||||
if (pSet->NumNodes() <= (u32) NodeIndex) return nullptr;
|
if (pSet->NumNodes() <= (u32) NodeIndex) return nullptr;
|
||||||
return pSet->NodeModel(NodeIndex);
|
return pSet->NodeModel(NodeIndex);
|
||||||
@ -157,7 +157,7 @@ TString CAnimationParameters::GetCurrentCharacterName(s32 NodeIndex /*= -1*/)
|
|||||||
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
||||||
if (!pSet) return "";
|
if (!pSet) return "";
|
||||||
if (pSet->Type() != eAnimSet) return "";
|
if (pSet->Type() != eAnimSet) return "";
|
||||||
if (NodeIndex == -1) NodeIndex = mNodeIndex;
|
if (NodeIndex == -1) NodeIndex = mCharIndex;
|
||||||
|
|
||||||
if (pSet->NumNodes() <= (u32) NodeIndex) return "";
|
if (pSet->NumNodes() <= (u32) NodeIndex) return "";
|
||||||
return pSet->NodeName((u32) NodeIndex);
|
return pSet->NodeName((u32) NodeIndex);
|
||||||
@ -166,9 +166,11 @@ TString CAnimationParameters::GetCurrentCharacterName(s32 NodeIndex /*= -1*/)
|
|||||||
// ************ ACCESSORS ************
|
// ************ ACCESSORS ************
|
||||||
u32 CAnimationParameters::Unknown(u32 Index)
|
u32 CAnimationParameters::Unknown(u32 Index)
|
||||||
{
|
{
|
||||||
|
// mAnimIndex isn't unknown, but I'm too lazy to move it because there's a lot
|
||||||
|
// of UI stuff that depends on these functions atm for accessing and editing parameters.
|
||||||
switch (Index)
|
switch (Index)
|
||||||
{
|
{
|
||||||
case 0: return mUnknown1;
|
case 0: return mAnimIndex;
|
||||||
case 1: return mUnknown2;
|
case 1: return mUnknown2;
|
||||||
case 2: return mUnknown3;
|
case 2: return mUnknown3;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
@ -180,7 +182,7 @@ void CAnimationParameters::SetResource(CResourceInfo Res)
|
|||||||
if (Res.Type() == "ANCS" || Res.Type() == "CHAR")
|
if (Res.Type() == "ANCS" || Res.Type() == "CHAR")
|
||||||
{
|
{
|
||||||
mCharacter = Res;
|
mCharacter = Res;
|
||||||
mNodeIndex = 0;
|
mCharIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::Error("Resource with invalid type passed to CAnimationParameters: " + Res.ToString());
|
Log::Error("Resource with invalid type passed to CAnimationParameters: " + Res.ToString());
|
||||||
@ -190,7 +192,7 @@ void CAnimationParameters::SetUnknown(u32 Index, u32 Value)
|
|||||||
{
|
{
|
||||||
switch (Index)
|
switch (Index)
|
||||||
{
|
{
|
||||||
case 0: mUnknown1 = Value;
|
case 0: mAnimIndex = Value;
|
||||||
case 1: mUnknown2 = Value;
|
case 1: mUnknown2 = Value;
|
||||||
case 2: mUnknown3 = Value;
|
case 2: mUnknown3 = Value;
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ class CAnimationParameters
|
|||||||
EGame mGame;
|
EGame mGame;
|
||||||
CResourceInfo mCharacter;
|
CResourceInfo mCharacter;
|
||||||
|
|
||||||
u32 mNodeIndex;
|
u32 mCharIndex;
|
||||||
u32 mUnknown1;
|
u32 mAnimIndex;
|
||||||
u32 mUnknown2;
|
u32 mUnknown2;
|
||||||
u32 mUnknown3;
|
u32 mUnknown3;
|
||||||
|
|
||||||
@ -29,8 +29,10 @@ public:
|
|||||||
// Accessors
|
// Accessors
|
||||||
inline EGame Version() const { return mGame; }
|
inline EGame Version() const { return mGame; }
|
||||||
inline CAnimSet* AnimSet() const { return (CAnimSet*) mCharacter.Load(); }
|
inline CAnimSet* AnimSet() const { return (CAnimSet*) mCharacter.Load(); }
|
||||||
inline u32 CharacterIndex() { return mNodeIndex; }
|
inline u32 CharacterIndex() const { return mCharIndex; }
|
||||||
inline void SetNodeIndex(u32 Index) { mNodeIndex = Index; }
|
inline u32 AnimIndex() const { return mAnimIndex; }
|
||||||
|
inline void SetCharIndex(u32 Index) { mCharIndex = Index; }
|
||||||
|
inline void SetAnimIndex(u32 Index) { mAnimIndex = Index; }
|
||||||
|
|
||||||
u32 Unknown(u32 Index);
|
u32 Unknown(u32 Index);
|
||||||
void SetResource(CResourceInfo Res);
|
void SetResource(CResourceInfo Res);
|
||||||
@ -41,8 +43,8 @@ public:
|
|||||||
{
|
{
|
||||||
return ( (mGame == rkOther.mGame) &&
|
return ( (mGame == rkOther.mGame) &&
|
||||||
(mCharacter == rkOther.mCharacter) &&
|
(mCharacter == rkOther.mCharacter) &&
|
||||||
(mNodeIndex == rkOther.mNodeIndex) &&
|
(mCharIndex == rkOther.mCharIndex) &&
|
||||||
(mUnknown1 == rkOther.mUnknown1) &&
|
(mAnimIndex == rkOther.mAnimIndex) &&
|
||||||
(mUnknown2 == rkOther.mUnknown2) &&
|
(mUnknown2 == rkOther.mUnknown2) &&
|
||||||
(mUnknown3 == rkOther.mUnknown3) );
|
(mUnknown3 == rkOther.mUnknown3) );
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void CBone::UpdateTransform(CBoneTransformData& rData, const SBoneTransformInfo&
|
|||||||
{
|
{
|
||||||
// Get transform data
|
// Get transform data
|
||||||
SBoneTransformInfo TransformInfo;
|
SBoneTransformInfo TransformInfo;
|
||||||
TransformInfo.Position = mPosition;
|
TransformInfo.Position = mLocalPosition;
|
||||||
|
|
||||||
if (pAnim)
|
if (pAnim)
|
||||||
pAnim->EvaluateTransform(Time, mID, &TransformInfo.Position, &TransformInfo.Rotation, &TransformInfo.Scale);
|
pAnim->EvaluateTransform(Time, mID, &TransformInfo.Position, &TransformInfo.Rotation, &TransformInfo.Scale);
|
||||||
@ -41,7 +41,7 @@ void CBone::UpdateTransform(CBoneTransformData& rData, const SBoneTransformInfo&
|
|||||||
|
|
||||||
CVector3f CBone::TransformedPosition(const CBoneTransformData& rkData) const
|
CVector3f CBone::TransformedPosition(const CBoneTransformData& rkData) const
|
||||||
{
|
{
|
||||||
return rkData[mID] * AbsolutePosition();
|
return rkData[mID] * Position();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBone::IsRoot() const
|
bool CBone::IsRoot() const
|
||||||
@ -77,6 +77,17 @@ CBone* CSkeleton::BoneByID(u32 BoneID) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
|
||||||
|
{
|
||||||
|
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
|
{
|
||||||
|
if (mBones[iBone]->Name() == rkBoneName)
|
||||||
|
return mBones[iBone];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
u32 CSkeleton::MaxBoneID() const
|
u32 CSkeleton::MaxBoneID() const
|
||||||
{
|
{
|
||||||
u32 ID = 0;
|
u32 ID = 0;
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
~CSkeleton();
|
~CSkeleton();
|
||||||
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
|
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
|
||||||
CBone* BoneByID(u32 BoneID) const;
|
CBone* BoneByID(u32 BoneID) const;
|
||||||
|
CBone* BoneByName(const TString& rkBoneName) const;
|
||||||
u32 MaxBoneID() const;
|
u32 MaxBoneID() const;
|
||||||
|
|
||||||
void Draw(FRenderOptions Options, const CBoneTransformData& rkData);
|
void Draw(FRenderOptions Options, const CBoneTransformData& rkData);
|
||||||
@ -55,7 +56,9 @@ class CBone
|
|||||||
std::vector<CBone*> mChildren;
|
std::vector<CBone*> mChildren;
|
||||||
u32 mID;
|
u32 mID;
|
||||||
CVector3f mPosition;
|
CVector3f mPosition;
|
||||||
|
CVector3f mLocalPosition;
|
||||||
CQuaternion mRotation;
|
CQuaternion mRotation;
|
||||||
|
CQuaternion mLocalRotation;
|
||||||
TString mName;
|
TString mName;
|
||||||
CTransform4f mInvBind;
|
CTransform4f mInvBind;
|
||||||
|
|
||||||
@ -72,8 +75,9 @@ public:
|
|||||||
inline CBone* ChildByIndex(u32 Index) const { return mChildren[Index]; }
|
inline CBone* ChildByIndex(u32 Index) const { return mChildren[Index]; }
|
||||||
inline u32 ID() const { return mID; }
|
inline u32 ID() const { return mID; }
|
||||||
inline CVector3f Position() const { return mPosition; }
|
inline CVector3f Position() const { return mPosition; }
|
||||||
inline CVector3f AbsolutePosition() const { return mPosition + (mpParent ? mpParent->AbsolutePosition() : CVector3f::skZero); }
|
inline CVector3f LocalPosition() const { return mLocalPosition; }
|
||||||
inline CQuaternion Rotation() const { return mRotation; }
|
inline CQuaternion Rotation() const { return mRotation; }
|
||||||
|
inline CQuaternion LocalRotation() const { return mLocalRotation; }
|
||||||
inline TString Name() const { return mName; }
|
inline TString Name() const { return mName; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -311,6 +311,21 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
|||||||
pAssets->LinkEndChild(pAsset);
|
pAssets->LinkEndChild(pAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attachments
|
||||||
|
if (!pTemp->mAttachments.empty())
|
||||||
|
{
|
||||||
|
XMLElement *pAttachments = ScriptXML.NewElement("attachments");
|
||||||
|
pEditor->LinkEndChild(pAttachments);
|
||||||
|
|
||||||
|
for (auto it = pTemp->mAttachments.begin(); it != pTemp->mAttachments.end(); it++)
|
||||||
|
{
|
||||||
|
XMLElement *pAttachment = ScriptXML.NewElement("attachment");
|
||||||
|
pAttachment->SetAttribute("propertyID", *it->AttachProperty);
|
||||||
|
pAttachment->SetAttribute("locator", *it->LocatorName);
|
||||||
|
pAttachments->LinkEndChild(pAttachment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Preview Scale
|
// Preview Scale
|
||||||
if (pTemp->mPreviewScale != 1.f)
|
if (pTemp->mPreviewScale != 1.f)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,9 @@ void CSkeletonLoader::SetLocalBoneCoords(CBone *pBone)
|
|||||||
SetLocalBoneCoords(pBone->ChildByIndex(iChild));
|
SetLocalBoneCoords(pBone->ChildByIndex(iChild));
|
||||||
|
|
||||||
if (pBone->mpParent)
|
if (pBone->mpParent)
|
||||||
pBone->mPosition -= pBone->mpParent->mPosition;
|
pBone->mLocalPosition = pBone->mPosition - pBone->mpParent->mPosition;
|
||||||
|
else
|
||||||
|
pBone->mLocalPosition = pBone->mPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSkeletonLoader::CalculateBoneInverseBindMatrices()
|
void CSkeletonLoader::CalculateBoneInverseBindMatrices()
|
||||||
@ -18,7 +20,7 @@ void CSkeletonLoader::CalculateBoneInverseBindMatrices()
|
|||||||
for (u32 iBone = 0; iBone < mpSkeleton->mBones.size(); iBone++)
|
for (u32 iBone = 0; iBone < mpSkeleton->mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
CBone *pBone = mpSkeleton->mBones[iBone];
|
CBone *pBone = mpSkeleton->mBones[iBone];
|
||||||
pBone->mInvBind = CTransform4f::TranslationMatrix(-pBone->AbsolutePosition());
|
pBone->mInvBind = CTransform4f::TranslationMatrix(-pBone->Position());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,8 +52,8 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF)
|
|||||||
BoneInfo[iBone].ParentID = rCINF.ReadLong();
|
BoneInfo[iBone].ParentID = rCINF.ReadLong();
|
||||||
pBone->mPosition = CVector3f(rCINF);
|
pBone->mPosition = CVector3f(rCINF);
|
||||||
|
|
||||||
// Version test. No version number. The next value is the linked bone count in MP1 and the first
|
// Version test. No version number. The next value is the linked bone count in MP1 and the
|
||||||
// skin metric value in MP2. The max bone count is 100 so the linked bone count will not be higher
|
// rotation value in MP2. The max bone count is 100 so the linked bone count will not be higher
|
||||||
// than that. Additionally, every bone links to its parent at least and every skeleton (as far as I
|
// than that. Additionally, every bone links to its parent at least and every skeleton (as far as I
|
||||||
// know) has at least two bones so the linked bone count will never be 0.
|
// know) has at least two bones so the linked bone count will never be 0.
|
||||||
if (Game == eUnknownVersion)
|
if (Game == eUnknownVersion)
|
||||||
@ -62,7 +64,7 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF)
|
|||||||
if (Game == eEchoes)
|
if (Game == eEchoes)
|
||||||
{
|
{
|
||||||
pBone->mRotation = CQuaternion(rCINF);
|
pBone->mRotation = CQuaternion(rCINF);
|
||||||
rCINF.Seek(0x10, SEEK_CUR); // Think this is another quaternion, not sure what for.
|
pBone->mLocalRotation = CQuaternion(rCINF);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 NumLinkedBones = rCINF.ReadLong();
|
u32 NumLinkedBones = rCINF.ReadLong();
|
||||||
|
@ -548,6 +548,34 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attachments
|
||||||
|
XMLElement *pAttachments = pEditor->FirstChildElement("attachments");
|
||||||
|
|
||||||
|
if (pAttachments)
|
||||||
|
{
|
||||||
|
XMLElement *pAttachment = pAttachments->FirstChildElement("attachment");
|
||||||
|
u32 AttachIdx = 0;
|
||||||
|
|
||||||
|
while (pAttachment)
|
||||||
|
{
|
||||||
|
SAttachment Attachment;
|
||||||
|
Attachment.AttachProperty = pAttachment->Attribute("propertyID");
|
||||||
|
Attachment.LocatorName = pAttachment->Attribute("locator");
|
||||||
|
|
||||||
|
// Validate property
|
||||||
|
IPropertyTemplate *pProp = pScript->mpBaseStruct->PropertyByIDString(Attachment.AttachProperty);
|
||||||
|
|
||||||
|
if (!pProp)
|
||||||
|
Log::Error(rkTemplateName + ": Invalid property for attachment " + TString::FromInt32(AttachIdx) + ": " + Attachment.AttachProperty);
|
||||||
|
else if (pProp->Type() != eCharacterProperty && (pProp->Type() != eFileProperty || !static_cast<CFileTemplate*>(pProp)->AcceptsExtension("CMDL")))
|
||||||
|
Log::Error(rkTemplateName + ": Property referred to by attachment " + TString::FromInt32(AttachIdx) + " is not an attachable asset! Must be a file property that accepts CMDLs, or a character property.");
|
||||||
|
else
|
||||||
|
pScript->mAttachments.push_back(Attachment);
|
||||||
|
|
||||||
|
pAttachment = pAttachment->NextSiblingElement("attachment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Preview Scale
|
// Preview Scale
|
||||||
XMLElement *pPreviewScale = pEditor->FirstChildElement("preview_scale");
|
XMLElement *pPreviewScale = pEditor->FirstChildElement("preview_scale");
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "CBasicModel.h"
|
#include "CBasicModel.h"
|
||||||
#include "SSurface.h"
|
#include "SSurface.h"
|
||||||
#include "Core/Resource/CMaterialSet.h"
|
#include "Core/Resource/CMaterialSet.h"
|
||||||
|
#include "Core/Resource/CSkeleton.h"
|
||||||
#include "Core/Resource/CSkin.h"
|
#include "Core/Resource/CSkin.h"
|
||||||
#include "Core/OpenGL/CIndexBuffer.h"
|
#include "Core/OpenGL/CIndexBuffer.h"
|
||||||
#include "Core/OpenGL/GLCommon.h"
|
#include "Core/OpenGL/GLCommon.h"
|
||||||
@ -40,7 +41,7 @@ public:
|
|||||||
bool HasTransparency(u32 MatSet);
|
bool HasTransparency(u32 MatSet);
|
||||||
bool IsSurfaceTransparent(u32 Surface, u32 MatSet);
|
bool IsSurfaceTransparent(u32 Surface, u32 MatSet);
|
||||||
|
|
||||||
bool IsSkinned() const { return (mpSkin != nullptr); }
|
inline bool IsSkinned() const { return (mpSkin != nullptr); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CIndexBuffer* InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive);
|
CIndexBuffer* InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive);
|
||||||
|
@ -9,8 +9,6 @@ CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLa
|
|||||||
, mpLayer(pLayer)
|
, mpLayer(pLayer)
|
||||||
, mVersion(0)
|
, mVersion(0)
|
||||||
, mInstanceID(InstanceID)
|
, mInstanceID(InstanceID)
|
||||||
, mpDisplayModel(nullptr)
|
|
||||||
, mpCollision(nullptr)
|
|
||||||
, mHasInGameModel(false)
|
, mHasInGameModel(false)
|
||||||
, mIsCheckingNearVisibleActivation(false)
|
, mIsCheckingNearVisibleActivation(false)
|
||||||
{
|
{
|
||||||
@ -37,21 +35,14 @@ CScriptObject::~CScriptObject()
|
|||||||
mpScale = mpTemplate->FindScale(mpProperties);
|
mpScale = mpTemplate->FindScale(mpProperties);
|
||||||
mpActive = mpTemplate->FindActive(mpProperties);
|
mpActive = mpTemplate->FindActive(mpProperties);
|
||||||
mpLightParameters = mpTemplate->FindLightParameters(mpProperties);
|
mpLightParameters = mpTemplate->FindLightParameters(mpProperties);
|
||||||
mHasInGameModel = mpTemplate->HasInGameModel(mpProperties);
|
EvaluateDisplayAsset();
|
||||||
EvaluateDisplayModel();
|
|
||||||
EvaluateBillboard();
|
|
||||||
EvaluateCollisionModel();
|
EvaluateCollisionModel();
|
||||||
EvaluateVolume();
|
EvaluateVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptObject::EvaluateDisplayModel()
|
void CScriptObject::EvaluateDisplayAsset()
|
||||||
{
|
{
|
||||||
mpDisplayModel = mpTemplate->FindDisplayModel(mpProperties);
|
mpDisplayAsset = mpTemplate->FindDisplayAsset(mpProperties, mActiveCharIndex, mActiveAnimIndex, mHasInGameModel);
|
||||||
}
|
|
||||||
|
|
||||||
void CScriptObject::EvaluateBillboard()
|
|
||||||
{
|
|
||||||
mpBillboard = mpTemplate->FindBillboardTexture(mpProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptObject::EvaluateCollisionModel()
|
void CScriptObject::EvaluateCollisionModel()
|
||||||
|
@ -38,9 +38,10 @@ class CScriptObject
|
|||||||
TVector3Property *mpScale;
|
TVector3Property *mpScale;
|
||||||
TBoolProperty *mpActive;
|
TBoolProperty *mpActive;
|
||||||
CPropertyStruct *mpLightParameters;
|
CPropertyStruct *mpLightParameters;
|
||||||
TResPtr<CModel> mpDisplayModel;
|
TResPtr<CResource> mpDisplayAsset;
|
||||||
TResPtr<CTexture> mpBillboard;
|
|
||||||
TResPtr<CCollisionMeshGroup> mpCollision;
|
TResPtr<CCollisionMeshGroup> mpCollision;
|
||||||
|
u32 mActiveCharIndex;
|
||||||
|
u32 mActiveAnimIndex;
|
||||||
bool mHasInGameModel;
|
bool mHasInGameModel;
|
||||||
|
|
||||||
EVolumeShape mVolumeShape;
|
EVolumeShape mVolumeShape;
|
||||||
@ -54,8 +55,7 @@ public:
|
|||||||
~CScriptObject();
|
~CScriptObject();
|
||||||
|
|
||||||
void EvaluateProperties();
|
void EvaluateProperties();
|
||||||
void EvaluateDisplayModel();
|
void EvaluateDisplayAsset();
|
||||||
void EvaluateBillboard();
|
|
||||||
void EvaluateCollisionModel();
|
void EvaluateCollisionModel();
|
||||||
void EvaluateVolume();
|
void EvaluateVolume();
|
||||||
bool IsEditorProperty(IProperty *pProp);
|
bool IsEditorProperty(IProperty *pProp);
|
||||||
@ -89,8 +89,9 @@ public:
|
|||||||
bool IsActive() const { return mpActive ? mpActive->Get() : false; }
|
bool IsActive() const { return mpActive ? mpActive->Get() : false; }
|
||||||
bool HasInGameModel() const { return mHasInGameModel; }
|
bool HasInGameModel() const { return mHasInGameModel; }
|
||||||
CPropertyStruct* LightParameters() const { return mpLightParameters; }
|
CPropertyStruct* LightParameters() const { return mpLightParameters; }
|
||||||
CModel* DisplayModel() const { return mpDisplayModel; }
|
CResource* DisplayAsset() const { return mpDisplayAsset; }
|
||||||
CTexture* Billboard() const { return mpBillboard; }
|
u32 ActiveCharIndex() const { return mActiveCharIndex; }
|
||||||
|
u32 ActiveAnimIndex() const { return mActiveAnimIndex; }
|
||||||
CCollisionMeshGroup* Collision() const { return mpCollision; }
|
CCollisionMeshGroup* Collision() const { return mpCollision; }
|
||||||
EVolumeShape VolumeShape() const { return mVolumeShape; }
|
EVolumeShape VolumeShape() const { return mVolumeShape; }
|
||||||
float VolumeScale() const { return mVolumeScale; }
|
float VolumeScale() const { return mVolumeScale; }
|
||||||
|
@ -152,12 +152,14 @@ CPropertyStruct* CScriptTemplate::FindLightParameters(CPropertyStruct *pProperti
|
|||||||
return TFetchProperty<CPropertyStruct*, eStructProperty>(pProperties, mLightParametersIDString);
|
return TFetchProperty<CPropertyStruct*, eStructProperty>(pProperties, mLightParametersIDString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: merge these four functions, they have near-identical code
|
CResource* CScriptTemplate::FindDisplayAsset(CPropertyStruct *pProperties, u32& rOutCharIndex, u32& rOutAnimIndex, bool& rOutIsInGame)
|
||||||
CModel* CScriptTemplate::FindDisplayModel(CPropertyStruct *pProperties)
|
|
||||||
{
|
{
|
||||||
|
rOutCharIndex = -1;
|
||||||
|
rOutAnimIndex = -1;
|
||||||
|
rOutIsInGame = false;
|
||||||
|
|
||||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||||
{
|
{
|
||||||
if ((it->AssetType != SEditorAsset::eModel) && (it->AssetType != SEditorAsset::eAnimParams)) continue;
|
|
||||||
CResource *pRes = nullptr;
|
CResource *pRes = nullptr;
|
||||||
|
|
||||||
// File
|
// File
|
||||||
@ -172,58 +174,34 @@ CModel* CScriptTemplate::FindDisplayModel(CPropertyStruct *pProperties)
|
|||||||
{
|
{
|
||||||
IProperty *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
IProperty *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
||||||
|
|
||||||
if (pProp->Type() == eFileProperty)
|
if (it->AssetType == SEditorAsset::eAnimParams && pProp->Type() == eCharacterProperty)
|
||||||
{
|
{
|
||||||
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
|
TCharacterProperty *pChar = static_cast<TCharacterProperty*>(pProp);
|
||||||
pRes = pFile->Get().Load();
|
pRes = pChar->Get().AnimSet();
|
||||||
|
|
||||||
|
if (pRes)
|
||||||
|
{
|
||||||
|
rOutCharIndex = (it->ForceNodeIndex >= 0 ? it->ForceNodeIndex : pChar->Get().CharacterIndex());
|
||||||
|
rOutAnimIndex = pChar->Get().AnimIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pProp->Type() == eCharacterProperty)
|
else
|
||||||
{
|
|
||||||
TCharacterProperty *pParams = static_cast<TCharacterProperty*>(pProp);
|
|
||||||
pRes = pParams->Get().GetCurrentModel(it->ForceNodeIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify resource exists + is correct type
|
|
||||||
if (pRes && (pRes->Type() == eModel))
|
|
||||||
return static_cast<CModel*>(pRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CTexture* CScriptTemplate::FindBillboardTexture(CPropertyStruct *pProperties)
|
|
||||||
{
|
|
||||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
|
||||||
{
|
|
||||||
if (it->AssetType != SEditorAsset::eBillboard) continue;
|
|
||||||
CResource *pRes = nullptr;
|
|
||||||
|
|
||||||
// File
|
|
||||||
if (it->AssetSource == SEditorAsset::eFile)
|
|
||||||
{
|
|
||||||
TString path = "../resources/" + it->AssetLocation;
|
|
||||||
pRes = gResCache.GetResource(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Property
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IProperty *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
|
||||||
|
|
||||||
if (pProp->Type() == eFileProperty)
|
|
||||||
{
|
{
|
||||||
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
|
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
|
||||||
pRes = pFile->Get().Load();
|
pRes = pFile->Get().Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify resource exists + is correct type
|
// If we have a valid resource, return
|
||||||
if (pRes && (pRes->Type() == eTexture))
|
if (pRes)
|
||||||
return static_cast<CTexture*>(pRes);
|
{
|
||||||
|
rOutIsInGame = (pRes->Type() != eTexture && it->AssetSource == SEditorAsset::eProperty);
|
||||||
|
return pRes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// None are valid - no display asset
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,35 +239,6 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptTemplate::HasInGameModel(CPropertyStruct *pProperties)
|
|
||||||
{
|
|
||||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
|
||||||
{
|
|
||||||
if ((it->AssetType != SEditorAsset::eModel) && (it->AssetType != SEditorAsset::eAnimParams)) continue;
|
|
||||||
if (it->AssetSource == SEditorAsset::eFile) continue;
|
|
||||||
CResource *pRes = nullptr;
|
|
||||||
|
|
||||||
IProperty *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
|
||||||
|
|
||||||
if (pProp->Type() == eFileProperty)
|
|
||||||
{
|
|
||||||
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
|
|
||||||
pRes = pFile->Get().Load();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pProp->Type() == eCharacterProperty)
|
|
||||||
{
|
|
||||||
TCharacterProperty *pParams = static_cast<TCharacterProperty*>(pProp);
|
|
||||||
pRes = pParams->Get().GetCurrentModel(it->ForceNodeIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify resource exists + is correct type
|
|
||||||
if (pRes && (pRes->Type() == eModel))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************ OBJECT TRACKING ************
|
// ************ OBJECT TRACKING ************
|
||||||
u32 CScriptTemplate::NumObjects() const
|
u32 CScriptTemplate::NumObjects() const
|
||||||
|
@ -16,6 +16,12 @@ class CScriptObject;
|
|||||||
|
|
||||||
typedef TString TIDString;
|
typedef TString TIDString;
|
||||||
|
|
||||||
|
struct SAttachment
|
||||||
|
{
|
||||||
|
TIDString AttachProperty; // Must point to a CMDL!
|
||||||
|
TString LocatorName;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CScriptTemplate is a class that encases the data contained in one of the XML templates.
|
* CScriptTemplate is a class that encases the data contained in one of the XML templates.
|
||||||
* It essentially sets the layout of any given script object.
|
* It essentially sets the layout of any given script object.
|
||||||
@ -68,6 +74,7 @@ private:
|
|||||||
TIDString mActiveIDString;
|
TIDString mActiveIDString;
|
||||||
TIDString mLightParametersIDString;
|
TIDString mLightParametersIDString;
|
||||||
std::vector<SEditorAsset> mAssets;
|
std::vector<SEditorAsset> mAssets;
|
||||||
|
std::vector<SAttachment> mAttachments;
|
||||||
|
|
||||||
ERotationType mRotationType;
|
ERotationType mRotationType;
|
||||||
EScaleType mScaleType;
|
EScaleType mScaleType;
|
||||||
@ -99,10 +106,8 @@ public:
|
|||||||
TVector3Property* FindScale(CPropertyStruct *pProperties);
|
TVector3Property* FindScale(CPropertyStruct *pProperties);
|
||||||
TBoolProperty* FindActive(CPropertyStruct *pProperties);
|
TBoolProperty* FindActive(CPropertyStruct *pProperties);
|
||||||
CPropertyStruct* FindLightParameters(CPropertyStruct *pProperties);
|
CPropertyStruct* FindLightParameters(CPropertyStruct *pProperties);
|
||||||
CModel* FindDisplayModel(CPropertyStruct *pProperties);
|
CResource* FindDisplayAsset(CPropertyStruct *pProperties, u32& rOutCharIndex, u32& rOutAnimIndex, bool& rOutIsInGame);
|
||||||
CTexture* FindBillboardTexture(CPropertyStruct *pProperties);
|
|
||||||
CCollisionMeshGroup* FindCollision(CPropertyStruct *pProperties);
|
CCollisionMeshGroup* FindCollision(CPropertyStruct *pProperties);
|
||||||
bool HasInGameModel(CPropertyStruct *pProperties);
|
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CMasterTemplate* MasterTemplate() const { return mpMaster; }
|
inline CMasterTemplate* MasterTemplate() const { return mpMaster; }
|
||||||
@ -114,6 +119,8 @@ public:
|
|||||||
inline bool IsVisible() const { return mVisible; }
|
inline bool IsVisible() const { return mVisible; }
|
||||||
inline TString SourceFile() const { return mSourceFile; }
|
inline TString SourceFile() const { return mSourceFile; }
|
||||||
inline CStructTemplate* BaseStruct() const { return mpBaseStruct; }
|
inline CStructTemplate* BaseStruct() const { return mpBaseStruct; }
|
||||||
|
inline u32 NumAttachments() const { return mAttachments.size(); }
|
||||||
|
const SAttachment& Attachment(u32 Index) const { return mAttachments[Index]; }
|
||||||
|
|
||||||
inline bool HasName() const { return !mNameIDString.IsEmpty(); }
|
inline bool HasName() const { return !mNameIDString.IsEmpty(); }
|
||||||
inline bool HasPosition() const { return !mPositionIDString.IsEmpty(); }
|
inline bool HasPosition() const { return !mPositionIDString.IsEmpty(); }
|
||||||
|
157
src/Core/Scene/CScriptAttachNode.cpp
Normal file
157
src/Core/Scene/CScriptAttachNode.cpp
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
#include "CScriptAttachNode.h"
|
||||||
|
#include "CScriptNode.h"
|
||||||
|
#include "Core/Render/CRenderer.h"
|
||||||
|
#include "Core/Resource/Script/IProperty.h"
|
||||||
|
#include <Common/Assert.h>
|
||||||
|
|
||||||
|
CScriptAttachNode::CScriptAttachNode(CScene *pScene, const TIDString& rkAttachProperty, const TString& rkLocator, CScriptNode *pParent)
|
||||||
|
: CSceneNode(pScene, -1, pParent)
|
||||||
|
, mpScriptNode(pParent)
|
||||||
|
, mLocatorName(rkLocator)
|
||||||
|
{
|
||||||
|
CPropertyStruct *pBaseStruct = pParent->Instance()->Properties();
|
||||||
|
mpAttachAssetProp = pBaseStruct->PropertyByIDString(rkAttachProperty);
|
||||||
|
if (mpAttachAssetProp) AttachPropertyModified();
|
||||||
|
|
||||||
|
ParentDisplayAssetChanged(mpScriptNode->DisplayAsset());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::AttachPropertyModified()
|
||||||
|
{
|
||||||
|
if (mpAttachAssetProp)
|
||||||
|
{
|
||||||
|
if (mpAttachAssetProp->Type() == eFileProperty)
|
||||||
|
mpAttachAsset = TPropCast<TFileProperty>(mpAttachAssetProp)->Get().Load();
|
||||||
|
else if (mpAttachAssetProp->Type() == eCharacterProperty)
|
||||||
|
mpAttachAsset = TPropCast<TCharacterProperty>(mpAttachAssetProp)->Get().AnimSet();
|
||||||
|
|
||||||
|
CModel *pModel = Model();
|
||||||
|
|
||||||
|
if (pModel && pModel->Type() == eModel)
|
||||||
|
mLocalAABox = pModel->AABox();
|
||||||
|
else
|
||||||
|
mLocalAABox = CAABox::skInfinite;
|
||||||
|
|
||||||
|
MarkTransformChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::ParentDisplayAssetChanged(CResource *pNewDisplayAsset)
|
||||||
|
{
|
||||||
|
if (pNewDisplayAsset->Type() == eAnimSet)
|
||||||
|
{
|
||||||
|
CSkeleton *pSkel = mpScriptNode->ActiveSkeleton();
|
||||||
|
mpLocator = pSkel->BoneByName(mLocatorName);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mpLocator = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkTransformChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
CModel* CScriptAttachNode::Model() const
|
||||||
|
{
|
||||||
|
if (mpAttachAsset)
|
||||||
|
{
|
||||||
|
if (mpAttachAsset->Type() == eModel)
|
||||||
|
return static_cast<CModel*>(mpAttachAsset.RawPointer());
|
||||||
|
|
||||||
|
if (mpAttachAsset->Type() == eAnimSet)
|
||||||
|
{
|
||||||
|
TCharacterProperty *pProp = TPropCast<TCharacterProperty>(mpAttachAssetProp);
|
||||||
|
return pProp->Get().GetCurrentModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
|
||||||
|
{
|
||||||
|
CModel *pModel = Model();
|
||||||
|
if (!pModel) return;
|
||||||
|
|
||||||
|
if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||||
|
{
|
||||||
|
if (pModel->HasTransparency(0))
|
||||||
|
AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo);
|
||||||
|
else
|
||||||
|
pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh);
|
||||||
|
|
||||||
|
if (mpParent->IsSelected() && !rkViewInfo.GameMode)
|
||||||
|
pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo)
|
||||||
|
{
|
||||||
|
LoadModelMatrix();
|
||||||
|
mpParent->LoadLights(rkViewInfo);
|
||||||
|
|
||||||
|
CGraphics::SetupAmbientColor();
|
||||||
|
CGraphics::UpdateVertexBlock();
|
||||||
|
|
||||||
|
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(rkViewInfo);
|
||||||
|
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||||
|
CGraphics::UpdatePixelBlock();
|
||||||
|
|
||||||
|
if (ComponentIndex < 0)
|
||||||
|
Model()->Draw(Options, 0);
|
||||||
|
else
|
||||||
|
Model()->DrawSurface(Options, ComponentIndex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::DrawSelection()
|
||||||
|
{
|
||||||
|
LoadModelMatrix();
|
||||||
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
|
Model()->DrawWireframe(eNoRenderOptions, mpParent->WireframeColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptAttachNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& /*rkViewInfo*/)
|
||||||
|
{
|
||||||
|
CModel *pModel = Model();
|
||||||
|
if (!pModel) return;
|
||||||
|
|
||||||
|
const CRay& rkRay = rTester.Ray();
|
||||||
|
std::pair<bool,float> BoxResult = AABox().IntersectsRay(rkRay);
|
||||||
|
|
||||||
|
if (BoxResult.first)
|
||||||
|
rTester.AddNodeModel(this, pModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
SRayIntersection CScriptAttachNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo)
|
||||||
|
{
|
||||||
|
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
||||||
|
|
||||||
|
SRayIntersection Out;
|
||||||
|
Out.pNode = mpParent;
|
||||||
|
Out.ComponentIndex = AssetID;
|
||||||
|
|
||||||
|
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
||||||
|
std::pair<bool,float> Result = Model()->GetSurface(AssetID)->IntersectsRay(TransformedRay, Options.HasFlag(eEnableBackfaceCull));
|
||||||
|
|
||||||
|
if (Result.first)
|
||||||
|
{
|
||||||
|
Out.Hit = true;
|
||||||
|
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
|
||||||
|
CVector3f WorldHitPoint = Transform() * HitPoint;
|
||||||
|
Out.Distance = rkRay.Origin().Distance(WorldHitPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
else Out.Hit = false;
|
||||||
|
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************ PROTECTED ************
|
||||||
|
void CScriptAttachNode::CalculateTransform(CTransform4f& rOut) const
|
||||||
|
{
|
||||||
|
if (mpLocator)
|
||||||
|
rOut = mpScriptNode->BoneTransform(mpLocator->ID(), false);
|
||||||
|
|
||||||
|
CSceneNode::CalculateTransform(rOut);
|
||||||
|
}
|
37
src/Core/Scene/CScriptAttachNode.h
Normal file
37
src/Core/Scene/CScriptAttachNode.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef CSCRIPTATTACHNODE_H
|
||||||
|
#define CSCRIPTATTACHNODE_H
|
||||||
|
|
||||||
|
#include "CSceneNode.h"
|
||||||
|
#include "Core/Resource/Script/IProperty.h"
|
||||||
|
|
||||||
|
class CScriptNode;
|
||||||
|
|
||||||
|
class CScriptAttachNode : public CSceneNode
|
||||||
|
{
|
||||||
|
CScriptNode *mpScriptNode;
|
||||||
|
TResPtr<CResource> mpAttachAsset;
|
||||||
|
IProperty *mpAttachAssetProp;
|
||||||
|
|
||||||
|
TString mLocatorName;
|
||||||
|
CBone *mpLocator;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CScriptAttachNode(CScene *pScene, const TIDString& rkAttachProperty, const TString& rkLocator, CScriptNode *pParent);
|
||||||
|
void AttachPropertyModified();
|
||||||
|
void ParentDisplayAssetChanged(CResource *pNewDisplayAsset);
|
||||||
|
CModel* Model() const;
|
||||||
|
|
||||||
|
ENodeType NodeType() { return eScriptAttachNode; }
|
||||||
|
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
||||||
|
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
||||||
|
void DrawSelection();
|
||||||
|
void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
|
||||||
|
SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo);
|
||||||
|
|
||||||
|
inline IProperty* AttachProperty() const { return mpAttachAssetProp; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void CalculateTransform(CTransform4f& rOut) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSCRIPTATTACHNODE_H
|
@ -7,6 +7,7 @@
|
|||||||
#include "Core/Resource/Script/CMasterTemplate.h"
|
#include "Core/Resource/Script/CMasterTemplate.h"
|
||||||
#include "Core/Resource/Script/CScriptLayer.h"
|
#include "Core/Resource/Script/CScriptLayer.h"
|
||||||
#include "Core/ScriptExtra/CScriptExtra.h"
|
#include "Core/ScriptExtra/CScriptExtra.h"
|
||||||
|
#include <Common/Assert.h>
|
||||||
#include <Math/MathUtil.h>
|
#include <Math/MathUtil.h>
|
||||||
|
|
||||||
CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScriptObject *pInstance)
|
CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScriptObject *pInstance)
|
||||||
@ -15,10 +16,12 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip
|
|||||||
, mpVolumePreviewNode(nullptr)
|
, mpVolumePreviewNode(nullptr)
|
||||||
, mHasVolumePreview(false)
|
, mHasVolumePreview(false)
|
||||||
, mpInstance(pInstance)
|
, mpInstance(pInstance)
|
||||||
, mpBillboard(nullptr)
|
, mpExtra(nullptr)
|
||||||
{
|
{
|
||||||
|
ASSERT(pInstance);
|
||||||
|
|
||||||
// Evaluate instance
|
// Evaluate instance
|
||||||
SetActiveModel(nullptr);
|
SetDisplayAsset(nullptr);
|
||||||
mpCollisionNode = new CCollisionNode(pScene, -1, this);
|
mpCollisionNode = new CCollisionNode(pScene, -1, this);
|
||||||
mpCollisionNode->SetInheritance(true, true, false);
|
mpCollisionNode->SetInheritance(true, true, false);
|
||||||
|
|
||||||
@ -36,8 +39,9 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip
|
|||||||
SetName("[" + pTemp->Name() + "] " + mpInstance->InstanceName());
|
SetName("[" + pTemp->Name() + "] " + mpInstance->InstanceName());
|
||||||
|
|
||||||
// Determine display assets
|
// Determine display assets
|
||||||
SetActiveModel(mpInstance->DisplayModel());
|
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||||
mpBillboard = mpInstance->Billboard();
|
mCharIndex = mpInstance->ActiveCharIndex();
|
||||||
|
mAnimIndex = mpInstance->ActiveAnimIndex();
|
||||||
mpCollisionNode->SetCollision(mpInstance->Collision());
|
mpCollisionNode->SetCollision(mpInstance->Collision());
|
||||||
|
|
||||||
// Create preview volume node
|
// Create preview volume node
|
||||||
@ -54,6 +58,14 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create attachment nodes
|
||||||
|
for (u32 iAttach = 0; iAttach < pTemp->NumAttachments(); iAttach++)
|
||||||
|
{
|
||||||
|
const SAttachment& rkAttach = pTemp->Attachment(iAttach);
|
||||||
|
CScriptAttachNode *pAttach = new CScriptAttachNode(pScene, rkAttach.AttachProperty, rkAttach.LocatorName, this);
|
||||||
|
mAttachments.push_back(pAttach);
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch LightParameters
|
// Fetch LightParameters
|
||||||
mpLightParameters = new CLightParameters(mpInstance->LightParameters(), mpInstance->MasterTemplate()->Game());
|
mpLightParameters = new CLightParameters(mpInstance->LightParameters(), mpInstance->MasterTemplate()->Game());
|
||||||
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
||||||
@ -75,10 +87,12 @@ ENodeType CScriptNode::NodeType()
|
|||||||
|
|
||||||
void CScriptNode::PostLoad()
|
void CScriptNode::PostLoad()
|
||||||
{
|
{
|
||||||
if (mpActiveModel)
|
CModel *pModel = ActiveModel();
|
||||||
|
|
||||||
|
if (pModel)
|
||||||
{
|
{
|
||||||
mpActiveModel->BufferGL();
|
pModel->BufferGL();
|
||||||
mpActiveModel->GenerateMaterialShaders();
|
pModel->GenerateMaterialShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,17 +144,22 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf
|
|||||||
|
|
||||||
if (rkViewInfo.ShowFlags & eShowObjectGeometry || rkViewInfo.GameMode)
|
if (rkViewInfo.ShowFlags & eShowObjectGeometry || rkViewInfo.GameMode)
|
||||||
{
|
{
|
||||||
|
for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++)
|
||||||
|
mAttachments[iAttach]->AddToRenderer(pRenderer, rkViewInfo);
|
||||||
|
|
||||||
if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||||
{
|
{
|
||||||
if (!mpActiveModel)
|
CModel *pModel = ActiveModel();
|
||||||
|
|
||||||
|
if (!pModel)
|
||||||
pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh);
|
pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mpActiveModel->HasTransparency(0))
|
if (!pModel->HasTransparency(0))
|
||||||
pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh);
|
pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh);
|
||||||
else
|
else
|
||||||
AddSurfacesToRenderer(pRenderer, mpActiveModel, 0, rkViewInfo);
|
AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +179,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf
|
|||||||
|
|
||||||
void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo)
|
void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo)
|
||||||
{
|
{
|
||||||
if (!mpInstance) return;
|
if (!mpInstance || !mpDisplayAsset) return;
|
||||||
|
|
||||||
// Draw model
|
// Draw model
|
||||||
if (UsesModel())
|
if (UsesModel())
|
||||||
@ -191,9 +210,11 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
|
|||||||
LoadModelMatrix();
|
LoadModelMatrix();
|
||||||
|
|
||||||
// Draw model if possible!
|
// Draw model if possible!
|
||||||
if (mpActiveModel)
|
CModel *pModel = ActiveModel();
|
||||||
|
|
||||||
|
if (pModel)
|
||||||
{
|
{
|
||||||
if (mpActiveModel->IsSkinned()) CGraphics::LoadIdentityBoneTransforms();
|
if (pModel->IsSkinned()) CGraphics::LoadIdentityBoneTransforms();
|
||||||
|
|
||||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor();
|
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor();
|
||||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
else CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||||
@ -202,9 +223,9 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
|
|||||||
CGraphics::UpdatePixelBlock();
|
CGraphics::UpdatePixelBlock();
|
||||||
|
|
||||||
if (ComponentIndex < 0)
|
if (ComponentIndex < 0)
|
||||||
mpActiveModel->Draw(Options, 0);
|
pModel->Draw(Options, 0);
|
||||||
else
|
else
|
||||||
mpActiveModel->DrawSurface(Options, ComponentIndex, 0);
|
pModel->DrawSurface(Options, ComponentIndex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no model or billboard, default to drawing a purple box
|
// If no model or billboard, default to drawing a purple box
|
||||||
@ -219,9 +240,9 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw billboard
|
// Draw billboard
|
||||||
else if (mpBillboard)
|
else if (mpDisplayAsset->Type() == eTexture)
|
||||||
{
|
{
|
||||||
CDrawUtil::DrawBillboard(mpBillboard, mPosition, BillboardScale(), TintColor(rkViewInfo));
|
CDrawUtil::DrawBillboard(ActiveBillboard(), mPosition, BillboardScale(), TintColor(rkViewInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +254,8 @@ void CScriptNode::DrawSelection()
|
|||||||
// Draw wireframe for models
|
// Draw wireframe for models
|
||||||
if (UsesModel())
|
if (UsesModel())
|
||||||
{
|
{
|
||||||
CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
|
CModel *pModel = ActiveModel();
|
||||||
|
if (!pModel) pModel = CDrawUtil::GetCubeModel();
|
||||||
pModel->DrawWireframe(eNoRenderOptions, WireframeColor());
|
pModel->DrawWireframe(eNoRenderOptions, WireframeColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +331,8 @@ void CScriptNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SVie
|
|||||||
|
|
||||||
if (BoxResult.first)
|
if (BoxResult.first)
|
||||||
{
|
{
|
||||||
if (mpActiveModel) rTester.AddNodeModel(this, mpActiveModel);
|
CModel *pModel = ActiveModel();
|
||||||
|
if (pModel) rTester.AddNodeModel(this, pModel);
|
||||||
else rTester.AddNode(this, 0, BoxResult.second);
|
else rTester.AddNode(this, 0, BoxResult.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,6 +349,12 @@ void CScriptNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SVie
|
|||||||
std::pair<bool,float> BoxResult = BillBox.IntersectsRay(rkRay);
|
std::pair<bool,float> BoxResult = BillBox.IntersectsRay(rkRay);
|
||||||
if (BoxResult.first) rTester.AddNode(this, 0, BoxResult.second);
|
if (BoxResult.first) rTester.AddNode(this, 0, BoxResult.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run ray check on child nodes as well
|
||||||
|
mpCollisionNode->RayAABoxIntersectTest(rTester, rkViewInfo);
|
||||||
|
|
||||||
|
for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++)
|
||||||
|
mAttachments[iAttach]->RayAABoxIntersectTest(rTester, rkViewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo)
|
SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo)
|
||||||
@ -339,7 +368,8 @@ SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetI
|
|||||||
// Model test
|
// Model test
|
||||||
if (UsesModel())
|
if (UsesModel())
|
||||||
{
|
{
|
||||||
CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
|
CModel *pModel = ActiveModel();
|
||||||
|
if (!pModel) pModel = CDrawUtil::GetCubeModel();
|
||||||
|
|
||||||
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
||||||
std::pair<bool,float> Result = pModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & eEnableBackfaceCull) == 0));
|
std::pair<bool,float> Result = pModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & eEnableBackfaceCull) == 0));
|
||||||
@ -385,7 +415,7 @@ SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetI
|
|||||||
// Step 4: look up the hit texel and check whether it's transparent or opaque
|
// Step 4: look up the hit texel and check whether it's transparent or opaque
|
||||||
CVector2f TexCoord = (LocalHitPoint + CVector2f(1.f)) * 0.5f;
|
CVector2f TexCoord = (LocalHitPoint + CVector2f(1.f)) * 0.5f;
|
||||||
TexCoord.X = -TexCoord.X + 1.f;
|
TexCoord.X = -TexCoord.X + 1.f;
|
||||||
float TexelAlpha = mpBillboard->ReadTexelAlpha(TexCoord);
|
float TexelAlpha = ActiveBillboard()->ReadTexelAlpha(TexCoord);
|
||||||
|
|
||||||
if (TexelAlpha < 0.25f)
|
if (TexelAlpha < 0.25f)
|
||||||
Out.Hit = false;
|
Out.Hit = false;
|
||||||
@ -450,24 +480,24 @@ void CScriptNode::PropertyModified(IProperty *pProp)
|
|||||||
// Update resources
|
// Update resources
|
||||||
if (pProp->Type() == eCharacterProperty)
|
if (pProp->Type() == eCharacterProperty)
|
||||||
{
|
{
|
||||||
mpInstance->EvaluateDisplayModel();
|
mpInstance->EvaluateDisplayAsset();
|
||||||
SetActiveModel(mpInstance->DisplayModel());
|
mCharIndex = mpInstance->ActiveCharIndex();
|
||||||
|
mAnimIndex = mpInstance->ActiveAnimIndex();
|
||||||
|
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pProp->Type() == eFileProperty)
|
else if (pProp->Type() == eFileProperty)
|
||||||
{
|
{
|
||||||
CFileTemplate *pFile = static_cast<CFileTemplate*>(pProp->Template());
|
CFileTemplate *pFileTemp = static_cast<CFileTemplate*>(pProp->Template());
|
||||||
|
|
||||||
if (pFile->AcceptsExtension("CMDL") || pFile->AcceptsExtension("ANCS") || pFile->AcceptsExtension("CHAR"))
|
if (pFileTemp->AcceptsExtension("CMDL") || pFileTemp->AcceptsExtension("TXTR") || pFileTemp->AcceptsExtension("ANCS") || pFileTemp->AcceptsExtension("CHAR"))
|
||||||
{
|
{
|
||||||
mpInstance->EvaluateDisplayModel();
|
mpInstance->EvaluateDisplayAsset();
|
||||||
SetActiveModel(mpInstance->DisplayModel());
|
mCharIndex = mpInstance->ActiveCharIndex();
|
||||||
|
mAnimIndex = mpInstance->ActiveAnimIndex();
|
||||||
|
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||||
}
|
}
|
||||||
else if (pFile->AcceptsExtension("TXTR"))
|
else if (pFileTemp->AcceptsExtension("DCLN"))
|
||||||
{
|
|
||||||
mpInstance->EvaluateBillboard();
|
|
||||||
mpBillboard = mpInstance->Billboard();
|
|
||||||
}
|
|
||||||
else if (pFile->AcceptsExtension("DCLN"))
|
|
||||||
{
|
{
|
||||||
mpInstance->EvaluateCollisionModel();
|
mpInstance->EvaluateCollisionModel();
|
||||||
mpCollisionNode->SetCollision(mpInstance->Collision());
|
mpCollisionNode->SetCollision(mpInstance->Collision());
|
||||||
@ -492,11 +522,19 @@ void CScriptNode::PropertyModified(IProperty *pProp)
|
|||||||
mScale = mpInstance->Scale();
|
mScale = mpInstance->Scale();
|
||||||
|
|
||||||
MarkTransformChanged();
|
MarkTransformChanged();
|
||||||
|
|
||||||
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update script extra
|
// Notify attachments
|
||||||
|
for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++)
|
||||||
|
{
|
||||||
|
CScriptAttachNode *pAttach = mAttachments[iAttach];
|
||||||
|
|
||||||
|
if (pAttach->AttachProperty() == pProp)
|
||||||
|
pAttach->AttachPropertyModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify script extra
|
||||||
if (mpExtra) mpExtra->PropertyModified(pProp);
|
if (mpExtra) mpExtra->PropertyModified(pProp);
|
||||||
|
|
||||||
// Update game mode visibility
|
// Update game mode visibility
|
||||||
@ -628,12 +666,43 @@ CScriptExtra* CScriptNode::Extra() const
|
|||||||
|
|
||||||
CModel* CScriptNode::ActiveModel() const
|
CModel* CScriptNode::ActiveModel() const
|
||||||
{
|
{
|
||||||
return mpActiveModel;
|
if (mpDisplayAsset)
|
||||||
|
{
|
||||||
|
if (mpDisplayAsset->Type() == eModel)
|
||||||
|
return static_cast<CModel*>(mpDisplayAsset.RawPointer());
|
||||||
|
else if (mpDisplayAsset->Type() == eAnimSet)
|
||||||
|
return static_cast<CAnimSet*>(mpDisplayAsset.RawPointer())->NodeModel(mCharIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAnimSet* CScriptNode::ActiveAnimSet() const
|
||||||
|
{
|
||||||
|
if (mpDisplayAsset && mpDisplayAsset->Type() == eAnimSet)
|
||||||
|
return static_cast<CAnimSet*>(mpDisplayAsset.RawPointer());
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSkeleton* CScriptNode::ActiveSkeleton() const
|
||||||
|
{
|
||||||
|
CAnimSet *pSet = ActiveAnimSet();
|
||||||
|
if (pSet) return pSet->NodeSkeleton(mCharIndex);
|
||||||
|
else return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTexture* CScriptNode::ActiveBillboard() const
|
||||||
|
{
|
||||||
|
if (mpDisplayAsset && mpDisplayAsset->Type() == eTexture)
|
||||||
|
return static_cast<CTexture*>(mpDisplayAsset.RawPointer());
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptNode::UsesModel() const
|
bool CScriptNode::UsesModel() const
|
||||||
{
|
{
|
||||||
return ((mpActiveModel != nullptr) || (mpBillboard == nullptr));
|
return (mpDisplayAsset == nullptr || ActiveModel() != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptNode::HasPreviewVolume() const
|
bool CScriptNode::HasPreviewVolume() const
|
||||||
@ -655,12 +724,38 @@ CVector2f CScriptNode::BillboardScale() const
|
|||||||
return Out * 0.5f * Template()->PreviewScale();
|
return Out * 0.5f * Template()->PreviewScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ PROTECTED ************
|
CTransform4f CScriptNode::BoneTransform(u32 BoneID, bool Absolute) const
|
||||||
void CScriptNode::SetActiveModel(CModel *pModel)
|
|
||||||
{
|
{
|
||||||
mpActiveModel = pModel;
|
CTransform4f Out;
|
||||||
mLocalAABox = (pModel ? pModel->AABox() : CAABox::skOne);
|
CSkeleton *pSkel = ActiveSkeleton();
|
||||||
MarkTransformChanged();
|
|
||||||
|
if (pSkel)
|
||||||
|
{
|
||||||
|
CBone *pBone = pSkel->BoneByID(BoneID);
|
||||||
|
Out.Translate(pBone->Position());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Absolute) Out = Transform() * Out;
|
||||||
|
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************ PROTECTED ************
|
||||||
|
void CScriptNode::SetDisplayAsset(CResource *pRes)
|
||||||
|
{
|
||||||
|
if (mpDisplayAsset != pRes)
|
||||||
|
{
|
||||||
|
mpDisplayAsset = pRes;
|
||||||
|
CModel *pModel = ActiveModel();
|
||||||
|
mLocalAABox = (pModel ? pModel->AABox() : CAABox::skOne);
|
||||||
|
MarkTransformChanged();
|
||||||
|
|
||||||
|
for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++)
|
||||||
|
mAttachments[iAttach]->ParentDisplayAssetChanged(pRes);
|
||||||
|
|
||||||
|
if (mpExtra)
|
||||||
|
mpExtra->DisplayAssetChanged(pRes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptNode::CalculateTransform(CTransform4f& rOut) const
|
void CScriptNode::CalculateTransform(CTransform4f& rOut) const
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define CSCRIPTNODE_H
|
#define CSCRIPTNODE_H
|
||||||
|
|
||||||
#include "CSceneNode.h"
|
#include "CSceneNode.h"
|
||||||
|
#include "CScriptAttachNode.h"
|
||||||
#include "CModelNode.h"
|
#include "CModelNode.h"
|
||||||
#include "CCollisionNode.h"
|
#include "CCollisionNode.h"
|
||||||
#include "Core/Resource/Script/CScriptObject.h"
|
#include "Core/Resource/Script/CScriptObject.h"
|
||||||
@ -14,9 +15,11 @@ class CScriptNode : public CSceneNode
|
|||||||
CScriptObject *mpInstance;
|
CScriptObject *mpInstance;
|
||||||
CScriptExtra *mpExtra;
|
CScriptExtra *mpExtra;
|
||||||
|
|
||||||
TResPtr<CModel> mpActiveModel;
|
TResPtr<CResource> mpDisplayAsset;
|
||||||
TResPtr<CTexture> mpBillboard;
|
u32 mCharIndex;
|
||||||
|
u32 mAnimIndex;
|
||||||
CCollisionNode *mpCollisionNode;
|
CCollisionNode *mpCollisionNode;
|
||||||
|
std::vector<CScriptAttachNode*> mAttachments;
|
||||||
|
|
||||||
bool mHasValidPosition;
|
bool mHasValidPosition;
|
||||||
bool mHasVolumePreview;
|
bool mHasVolumePreview;
|
||||||
@ -53,14 +56,21 @@ public:
|
|||||||
CScriptObject* Instance() const;
|
CScriptObject* Instance() const;
|
||||||
CScriptTemplate* Template() const;
|
CScriptTemplate* Template() const;
|
||||||
CScriptExtra* Extra() const;
|
CScriptExtra* Extra() const;
|
||||||
CModel* ActiveModel() const;
|
|
||||||
bool UsesModel() const;
|
|
||||||
bool HasPreviewVolume() const;
|
bool HasPreviewVolume() const;
|
||||||
CAABox PreviewVolumeAABox() const;
|
CAABox PreviewVolumeAABox() const;
|
||||||
CVector2f BillboardScale() const;
|
CVector2f BillboardScale() const;
|
||||||
|
CTransform4f BoneTransform(u32 BoneID, bool Absolute) const;
|
||||||
|
|
||||||
|
CModel* ActiveModel() const;
|
||||||
|
CAnimSet* ActiveAnimSet() const;
|
||||||
|
CSkeleton* ActiveSkeleton() const;
|
||||||
|
CTexture* ActiveBillboard() const;
|
||||||
|
bool UsesModel() const;
|
||||||
|
|
||||||
|
inline CResource* DisplayAsset() const { return mpDisplayAsset; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetActiveModel(CModel *pModel);
|
void SetDisplayAsset(CResource *pRes);
|
||||||
void CalculateTransform(CTransform4f& rOut) const;
|
void CalculateTransform(CTransform4f& rOut) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@ enum ENodeType
|
|||||||
eCollisionNode = 0x8,
|
eCollisionNode = 0x8,
|
||||||
eScriptNode = 0x10,
|
eScriptNode = 0x10,
|
||||||
eScriptExtraNode = 0x20,
|
eScriptExtraNode = 0x20,
|
||||||
eLightNode = 0x40,
|
eScriptAttachNode = 0x40,
|
||||||
eAllNodeTypes = 0x7F
|
eLightNode = 0x80,
|
||||||
|
eAllNodeTypes = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_FLAGS(ENodeType, FNodeFlags)
|
DECLARE_FLAGS(ENodeType, FNodeFlags)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "Core/Render/CDrawUtil.h"
|
#include "Core/Render/CDrawUtil.h"
|
||||||
#include "Core/Render/CRenderer.h"
|
#include "Core/Render/CRenderer.h"
|
||||||
|
|
||||||
CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
, mpRenderSideProp(nullptr)
|
, mpRenderSideProp(nullptr)
|
||||||
, mpMat(nullptr)
|
, mpMat(nullptr)
|
||||||
|
@ -31,7 +31,7 @@ class CDamageableTriggerExtra : public CScriptExtra
|
|||||||
float mCachedRayDistance;
|
float mCachedRayDistance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CDamageableTriggerExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CDamageableTriggerExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
~CDamageableTriggerExtra();
|
~CDamageableTriggerExtra();
|
||||||
void CreateMaterial();
|
void CreateMaterial();
|
||||||
void UpdatePlaneTransform();
|
void UpdatePlaneTransform();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "CDoorExtra.h"
|
#include "CDoorExtra.h"
|
||||||
#include "Core/Render/CRenderer.h"
|
#include "Core/Render/CRenderer.h"
|
||||||
|
|
||||||
CDoorExtra::CDoorExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CDoorExtra::CDoorExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
, mpShieldModelProp(nullptr)
|
, mpShieldModelProp(nullptr)
|
||||||
, mpShieldColorProp(nullptr)
|
, mpShieldColorProp(nullptr)
|
||||||
@ -117,22 +117,22 @@ SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID
|
|||||||
{
|
{
|
||||||
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
||||||
|
|
||||||
SRayIntersection out;
|
SRayIntersection Out;
|
||||||
out.pNode = mpParent;
|
Out.pNode = mpParent;
|
||||||
out.ComponentIndex = AssetID;
|
Out.ComponentIndex = AssetID;
|
||||||
|
|
||||||
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
||||||
std::pair<bool,float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & eEnableBackfaceCull) == 0));
|
std::pair<bool,float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & eEnableBackfaceCull) == 0));
|
||||||
|
|
||||||
if (Result.first)
|
if (Result.first)
|
||||||
{
|
{
|
||||||
out.Hit = true;
|
Out.Hit = true;
|
||||||
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
|
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
|
||||||
CVector3f WorldHitPoint = Transform() * HitPoint;
|
CVector3f WorldHitPoint = Transform() * HitPoint;
|
||||||
out.Distance = rkRay.Origin().Distance(WorldHitPoint);
|
Out.Distance = rkRay.Origin().Distance(WorldHitPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
else out.Hit = false;
|
else Out.Hit = false;
|
||||||
|
|
||||||
return out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class CDoorExtra : public CScriptExtra
|
|||||||
CColor mShieldColor;
|
CColor mShieldColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CDoorExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CDoorExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
void PropertyModified(IProperty *pProperty);
|
void PropertyModified(IProperty *pProperty);
|
||||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
||||||
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const CColor CPointOfInterestExtra::skRegularColor = CColor::Integral(0xFF,0x70,0x00);
|
const CColor CPointOfInterestExtra::skRegularColor = CColor::Integral(0xFF,0x70,0x00);
|
||||||
const CColor CPointOfInterestExtra::skImportantColor = CColor::Integral(0xFF,0x00,0x00);
|
const CColor CPointOfInterestExtra::skImportantColor = CColor::Integral(0xFF,0x00,0x00);
|
||||||
|
|
||||||
CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
, mpScanProperty(nullptr)
|
, mpScanProperty(nullptr)
|
||||||
, mpScanData(nullptr)
|
, mpScanData(nullptr)
|
||||||
|
@ -12,7 +12,7 @@ class CPointOfInterestExtra : public CScriptExtra
|
|||||||
TResPtr<CScan> mpScanData;
|
TResPtr<CScan> mpScanData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
void PropertyModified(IProperty* pProperty);
|
void PropertyModified(IProperty* pProperty);
|
||||||
void ModifyTintColor(CColor& Color);
|
void ModifyTintColor(CColor& Color);
|
||||||
CScan* GetScan() const { return mpScanData; }
|
CScan* GetScan() const { return mpScanData; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "Core/Render/CDrawUtil.h"
|
#include "Core/Render/CDrawUtil.h"
|
||||||
#include "Core/Render/CRenderer.h"
|
#include "Core/Render/CRenderer.h"
|
||||||
|
|
||||||
CRadiusSphereExtra::CRadiusSphereExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CRadiusSphereExtra::CRadiusSphereExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
, mpRadius(nullptr)
|
, mpRadius(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ class CRadiusSphereExtra : public CScriptExtra
|
|||||||
TFloatProperty *mpRadius;
|
TFloatProperty *mpRadius;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CRadiusSphereExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CRadiusSphereExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
||||||
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
||||||
CColor Color() const;
|
CColor Color() const;
|
||||||
|
@ -52,9 +52,9 @@ CScriptExtra* CScriptExtra::CreateExtra(CScriptNode *pNode)
|
|||||||
pExtra = new CRadiusSphereExtra(pObj, pNode->Scene(), pNode);
|
pExtra = new CRadiusSphereExtra(pObj, pNode->Scene(), pNode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x53505041: // SplinePath (DKCR)
|
case 0x53505041: // "SPPA" SplinePath (DKCR)
|
||||||
case 0x5043544C: // PathControl (DKCR)
|
case 0x5043544C: // "PCTL" PathControl (DKCR)
|
||||||
case 0x434C5043: // ClingPathControl (DKCR)
|
case 0x434C5043: // "CLPC" ClingPathControl (DKCR)
|
||||||
pExtra = new CSplinePathExtra(pObj, pNode->Scene(), pNode);
|
pExtra = new CSplinePathExtra(pObj, pNode->Scene(), pNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Core/Scene/CSceneNode.h"
|
#include "Core/Scene/CSceneNode.h"
|
||||||
#include "Core/Scene/CScriptNode.h"
|
#include "Core/Scene/CScriptNode.h"
|
||||||
|
#include <Common/Assert.h>
|
||||||
|
|
||||||
/* CScriptExtra is a class that allows for additional coded behavior on any given
|
/* CScriptExtra is a class that allows for additional coded behavior on any given
|
||||||
* script object type. Subclass IScriptExtra, add the new class to CScriptExtra.cpp,
|
* script object type. Subclass IScriptExtra, add the new class to CScriptExtra.cpp,
|
||||||
@ -15,18 +16,20 @@
|
|||||||
class CScriptExtra : public CSceneNode
|
class CScriptExtra : public CSceneNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
CScriptNode *mpScriptNode;
|
||||||
CScriptObject *mpInstance;
|
CScriptObject *mpInstance;
|
||||||
EGame mGame;
|
EGame mGame;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CScriptExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0)
|
explicit CScriptExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0)
|
||||||
: CSceneNode(pScene, -1, pParent),
|
: CSceneNode(pScene, -1, pParent)
|
||||||
mpInstance(pInstance),
|
, mpScriptNode(pParent)
|
||||||
mGame(pInstance->Template()->Game())
|
, mpInstance(pInstance)
|
||||||
|
, mGame(pInstance->Template()->Game())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~CScriptExtra() {}
|
virtual ~CScriptExtra() {}
|
||||||
inline CScriptObject* Instance() const { return mpInstance; }
|
inline CScriptObject* Instance() const { return mpInstance; }
|
||||||
inline EGame Game() const { return mGame; }
|
inline EGame Game() const { return mGame; }
|
||||||
|
|
||||||
@ -43,6 +46,7 @@ public:
|
|||||||
// Virtual CScriptExtra functions
|
// Virtual CScriptExtra functions
|
||||||
virtual void InstanceTransformed() {}
|
virtual void InstanceTransformed() {}
|
||||||
virtual void PropertyModified(IProperty* /*pProperty*/) {}
|
virtual void PropertyModified(IProperty* /*pProperty*/) {}
|
||||||
|
virtual void DisplayAssetChanged(CResource* /*pNewDisplayAsset*/) {}
|
||||||
virtual void LinksModified() {}
|
virtual void LinksModified() {}
|
||||||
virtual bool ShouldDrawNormalAssets() { return true; }
|
virtual bool ShouldDrawNormalAssets() { return true; }
|
||||||
virtual bool ShouldDrawVolume() { return true; }
|
virtual bool ShouldDrawVolume() { return true; }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "CSpacePirateExtra.h"
|
#include "CSpacePirateExtra.h"
|
||||||
|
|
||||||
CSpacePirateExtra::CSpacePirateExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CSpacePirateExtra::CSpacePirateExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene ,pParent)
|
: CScriptExtra(pInstance, pScene ,pParent)
|
||||||
, mpPowerVuln(nullptr)
|
, mpPowerVuln(nullptr)
|
||||||
, mpWaveVuln(nullptr)
|
, mpWaveVuln(nullptr)
|
||||||
|
@ -13,7 +13,7 @@ class CSpacePirateExtra : public CScriptExtra
|
|||||||
TEnumProperty *mpPlasmaVuln;
|
TEnumProperty *mpPlasmaVuln;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSpacePirateExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CSpacePirateExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
CColor TevColor();
|
CColor TevColor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "Core/Resource/Script/CLink.h"
|
#include "Core/Resource/Script/CLink.h"
|
||||||
#include "Core/Scene/CScene.h"
|
#include "Core/Scene/CScene.h"
|
||||||
|
|
||||||
CSplinePathExtra::CSplinePathExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CSplinePathExtra::CSplinePathExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
{
|
{
|
||||||
mpPathColor = TPropCast<TColorProperty>(pInstance->Properties()->PropertyByID(0x00DD86E2));
|
mpPathColor = TPropCast<TColorProperty>(pInstance->Properties()->PropertyByID(0x00DD86E2));
|
||||||
|
@ -15,7 +15,7 @@ class CSplinePathExtra : public CScriptExtra
|
|||||||
std::list<CWaypointExtra*> mWaypoints;
|
std::list<CWaypointExtra*> mWaypoints;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSplinePathExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CSplinePathExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
~CSplinePathExtra() { ClearWaypoints(); }
|
~CSplinePathExtra() { ClearWaypoints(); }
|
||||||
inline CColor PathColor() const { return (mpPathColor ? mpPathColor->Get() : CColor::skBlack); }
|
inline CColor PathColor() const { return (mpPathColor ? mpPathColor->Get() : CColor::skBlack); }
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "Core/Render/CRenderer.h"
|
#include "Core/Render/CRenderer.h"
|
||||||
#include "Core/Scene/CScene.h"
|
#include "Core/Scene/CScene.h"
|
||||||
|
|
||||||
CWaypointExtra::CWaypointExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent)
|
CWaypointExtra::CWaypointExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
|
||||||
: CScriptExtra(pInstance, pScene, pParent)
|
: CScriptExtra(pInstance, pScene, pParent)
|
||||||
, mColor(CColor::skBlack)
|
, mColor(CColor::skBlack)
|
||||||
, mLinksBuilt(false)
|
, mLinksBuilt(false)
|
||||||
|
@ -20,7 +20,7 @@ class CWaypointExtra : public CScriptExtra
|
|||||||
std::vector<SWaypointLink> mLinks;
|
std::vector<SWaypointLink> mLinks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CWaypointExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
|
explicit CWaypointExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0);
|
||||||
~CWaypointExtra();
|
~CWaypointExtra();
|
||||||
void CheckColor();
|
void CheckColor();
|
||||||
void AddToSplinePath(CSplinePathExtra *pPath);
|
void AddToSplinePath(CSplinePathExtra *pPath);
|
||||||
|
@ -655,14 +655,14 @@ void CPropertyDelegate::SetCharacterModelData(QWidget *pEditor, const QModelInde
|
|||||||
{
|
{
|
||||||
Params.SetResource( static_cast<WResourceSelector*>(pEditor)->GetResourceInfo() );
|
Params.SetResource( static_cast<WResourceSelector*>(pEditor)->GetResourceInfo() );
|
||||||
// Reset all other parameters to 0
|
// Reset all other parameters to 0
|
||||||
Params.SetNodeIndex(0);
|
Params.SetCharIndex(0);
|
||||||
for (u32 iUnk = 0; iUnk < 3; iUnk++)
|
for (u32 iUnk = 0; iUnk < 3; iUnk++)
|
||||||
Params.SetUnknown(iUnk, 0);
|
Params.SetUnknown(iUnk, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Type == eEnumProperty)
|
else if (Type == eEnumProperty)
|
||||||
{
|
{
|
||||||
Params.SetNodeIndex( static_cast<QComboBox*>(pEditor)->currentIndex() );
|
Params.SetCharIndex( static_cast<QComboBox*>(pEditor)->currentIndex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Type == eLongProperty)
|
else if (Type == eLongProperty)
|
||||||
|
@ -76,7 +76,7 @@ void WAnimParamsEditor::OnResourceChanged(QString Path)
|
|||||||
|
|
||||||
void WAnimParamsEditor::OnCharacterChanged(int Index)
|
void WAnimParamsEditor::OnCharacterChanged(int Index)
|
||||||
{
|
{
|
||||||
mParams.SetNodeIndex(Index);
|
mParams.SetCharIndex(Index);
|
||||||
emit ParametersChanged(mParams);
|
emit ParametersChanged(mParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
<model source="property">0x06:0x04</model>
|
<model source="property">0x06:0x04</model>
|
||||||
<model source="property">0x0C</model>
|
<model source="property">0x0C</model>
|
||||||
</assets>
|
</assets>
|
||||||
|
<attachments>
|
||||||
|
<attachment propertyID="0x0C" locator="Hive_LCTR"/>
|
||||||
|
</attachments>
|
||||||
<rotation_type>enabled</rotation_type>
|
<rotation_type>enabled</rotation_type>
|
||||||
<scale_type>enabled</scale_type>
|
<scale_type>enabled</scale_type>
|
||||||
</editor>
|
</editor>
|
||||||
|
@ -61,6 +61,9 @@
|
|||||||
<animparams source="property">0x11</animparams>
|
<animparams source="property">0x11</animparams>
|
||||||
<model source="property">0x14</model>
|
<model source="property">0x14</model>
|
||||||
</assets>
|
</assets>
|
||||||
|
<attachments>
|
||||||
|
<attachment propertyID="0x11" locator="grenadeLauncher_LCTR"/>
|
||||||
|
</attachments>
|
||||||
<rotation_type>enabled</rotation_type>
|
<rotation_type>enabled</rotation_type>
|
||||||
<scale_type>enabled</scale_type>
|
<scale_type>enabled</scale_type>
|
||||||
</editor>
|
</editor>
|
||||||
|
@ -65,6 +65,10 @@
|
|||||||
<model source="property">0x14</model>
|
<model source="property">0x14</model>
|
||||||
<model source="property">0x2A</model>
|
<model source="property">0x2A</model>
|
||||||
</assets>
|
</assets>
|
||||||
|
<attachments>
|
||||||
|
<attachment propertyID="0x11" locator="grenadeLauncher_LCTR"/>
|
||||||
|
<attachment propertyID="0x11" locator="grenadeLauncher2_LCTR"/>
|
||||||
|
</attachments>
|
||||||
<rotation_type>enabled</rotation_type>
|
<rotation_type>enabled</rotation_type>
|
||||||
<scale_type>enabled</scale_type>
|
<scale_type>enabled</scale_type>
|
||||||
</editor>
|
</editor>
|
||||||
|
@ -10,20 +10,20 @@
|
|||||||
<struct ID="0x05" name="ActorParameters" template="Structs/ActorParameters.xml"/>
|
<struct ID="0x05" name="ActorParameters" template="Structs/ActorParameters.xml"/>
|
||||||
<property ID="0x06" name="Unknown 1" type="bool"/>
|
<property ID="0x06" name="Unknown 1" type="bool"/>
|
||||||
<property ID="0x07" name="Unknown 2" type="bool"/>
|
<property ID="0x07" name="Unknown 2" type="bool"/>
|
||||||
<property ID="0x08" name="Model 1" type="file" extensions="CMDL"/>
|
<property ID="0x08" name="Rock Weak Point 1 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x09" name="Model 2" type="file" extensions="CMDL"/>
|
<property ID="0x09" name="Rock Weak Point 2 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0A" name="Model 3" type="file" extensions="CMDL"/>
|
<property ID="0x0A" name="Rock Weak Point 3 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0B" name="Model 4" type="file" extensions="CMDL"/>
|
<property ID="0x0B" name="Rock Weak Point 4 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0C" name="Model 5" type="file" extensions="CMDL"/>
|
<property ID="0x0C" name="Rock Weak Point 5 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0D" name="Model 6" type="file" extensions="CMDL"/>
|
<property ID="0x0D" name="Rock Weak Point 6 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0E" name="Model 7" type="file" extensions="CMDL"/>
|
<property ID="0x0E" name="Rock Weak Point 7 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x0F" name="Model 8" type="file" extensions="CMDL"/>
|
<property ID="0x0F" name="Phazon Weak Point 1 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x10" name="Model 9" type="file" extensions="CMDL"/>
|
<property ID="0x10" name="Phazon Weak Point 2 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x11" name="Model 10" type="file" extensions="CMDL"/>
|
<property ID="0x11" name="Phazon Weak Point 3 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x12" name="Model 11" type="file" extensions="CMDL"/>
|
<property ID="0x12" name="Phazon Weak Point 4 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x13" name="Model 12" type="file" extensions="CMDL"/>
|
<property ID="0x13" name="Phazon Weak Point 5 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x14" name="Model 13" type="file" extensions="CMDL"/>
|
<property ID="0x14" name="Phazon Weak Point 6 Model" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x15" name="Model 14" type="file" extensions="CMDL"/>
|
<property ID="0x15" name="Phazon Weak Point 7 Mdoel" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x16" name="Particle 1" type="file" extensions="PART"/>
|
<property ID="0x16" name="Particle 1" type="file" extensions="PART"/>
|
||||||
<property ID="0x17" name="Particle 2" type="file" extensions="PART"/>
|
<property ID="0x17" name="Particle 2" type="file" extensions="PART"/>
|
||||||
<property ID="0x18" name="Particle 3" type="file" extensions="PART"/>
|
<property ID="0x18" name="Particle 3" type="file" extensions="PART"/>
|
||||||
|
@ -243,6 +243,15 @@
|
|||||||
<model source="property">0x91E88D81:0x0CF8C54C:0x37E99C23</model>
|
<model source="property">0x91E88D81:0x0CF8C54C:0x37E99C23</model>
|
||||||
<model source="property">0x91E88D81:0xBBD84681</model>
|
<model source="property">0x91E88D81:0xBBD84681</model>
|
||||||
</assets>
|
</assets>
|
||||||
|
<attachments>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0x07D8CC4F" locator="Head_1"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0xAE30AE06" locator="Spine_6"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0x656C7DA3" locator="Spine_5"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0x78694D1B" locator="Spine_4"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0xB3359EBE" locator="Spine_3"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0x35A1EC10" locator="Spine_2"/>
|
||||||
|
<attachment propertyID="0x91E88D81:0x8B452A19:0xFEFD3FB5" locator="Spine_1"/>
|
||||||
|
</attachments>
|
||||||
<rotation_type>enabled</rotation_type>
|
<rotation_type>enabled</rotation_type>
|
||||||
<scale_type>enabled</scale_type>
|
<scale_type>enabled</scale_type>
|
||||||
</editor>
|
</editor>
|
||||||
|
@ -1,32 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<struct name="SandBossStructA" type="multi">
|
<struct name="SandBossStructA" type="multi">
|
||||||
<properties>
|
<properties>
|
||||||
<property ID="0x07D8CC4F" type="long">
|
<property ID="0x07D8CC4F" type="file" extensions="CMDL"/>
|
||||||
<default>-1</default>
|
<property ID="0xAE30AE06" type="file" extensions="CMDL"/>
|
||||||
</property>
|
<property ID="0x656C7DA3" type="file" extensions="CMDL"/>
|
||||||
<property ID="0xAE30AE06" type="long">
|
<property ID="0x78694D1B" type="file" extensions="CMDL"/>
|
||||||
<default>-1</default>
|
<property ID="0xB3359EBE" type="file" extensions="CMDL"/>
|
||||||
</property>
|
<property ID="0x35A1EC10" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x656C7DA3" type="long">
|
<property ID="0xFEFD3FB5" type="file" extensions="CMDL"/>
|
||||||
<default>-1</default>
|
<property ID="0x37E99C23" type="file" extensions="CMDL"/>
|
||||||
</property>
|
<property ID="0xDCC2BF11" type="file" extensions="CMDL"/>
|
||||||
<property ID="0x78694D1B" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
<property ID="0xB3359EBE" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
<property ID="0x35A1EC10" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
<property ID="0xFEFD3FB5" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
<property ID="0x37E99C23" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
<property ID="0xDCC2BF11" type="long">
|
|
||||||
<default>-1</default>
|
|
||||||
</property>
|
|
||||||
</properties>
|
</properties>
|
||||||
</struct>
|
</struct>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user