Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge into pre merger #7

Merged
merged 8 commits into from
Sep 3, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Public Class SourceMdlAnimation
Public Const STUDIO_ANIM_ANIMROT As Integer = &H8
Public Const STUDIO_ANIM_DELTA As Integer = &H10
Public Const STUDIO_ANIM_RAWROT2 As Integer = &H20
'MDL 53 values for flags:
Public Const MDL53_ANIM_TRANSLATION As Integer = &H2
Public Const MDL53_ANIM_ROTATION As Integer = &H4


' Do not use union, because it will have to rely on size of a .NET Framework data type.
Expand Down
18 changes: 18 additions & 0 deletions Crowbar/Core/GameModel/SourceGlobal/SourceQuaternion64bits.vb
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,22 @@ Public Class SourceQuaternion64bits
<FieldOffset(0)> Public s As Single
End Structure

Public ReadOnly Property XOffset() As UInt16
Get
Return BitConverter.ToUInt16(Me.theBytes, 0)
End Get
End Property

Public ReadOnly Property YOffset() As UInt16
Get
Return BitConverter.ToUInt16(Me.theBytes, 2)
End Get
End Property

Public ReadOnly Property ZOffset() As UInt16
Get
Return BitConverter.ToUInt16(Me.theBytes, 4)
End Get
End Property

End Class
6 changes: 4 additions & 2 deletions Crowbar/Core/GameModel/SourceModel52/SourceMdlFile52.vb
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ Public Class SourceMdlFile52
aBone.rotation.x = Me.theInputFileReader.ReadSingle()
aBone.rotation.y = Me.theInputFileReader.ReadSingle()
aBone.rotation.z = Me.theInputFileReader.ReadSingle()

aBone.positionScale = New SourceVector()
aBone.positionScale.x = Me.theInputFileReader.ReadSingle()
aBone.positionScale.y = Me.theInputFileReader.ReadSingle()
aBone.positionScale.z = Me.theInputFileReader.ReadSingle()

aBone.rotationScale = New SourceVector()
aBone.rotationScale.x = Me.theInputFileReader.ReadSingle()
aBone.rotationScale.y = Me.theInputFileReader.ReadSingle()
Expand Down Expand Up @@ -459,8 +461,6 @@ Public Class SourceMdlFile52
aBone.contents = Me.theInputFileReader.ReadInt32()
aBone.surfacepropLookup = Me.theInputFileReader.ReadInt32()

'If Me.theMdlFileData.version <> 2531 Then

aBone.unkVector = New SourceVector()
aBone.unkVector.x = Me.theInputFileReader.ReadSingle()
aBone.unkVector.y = Me.theInputFileReader.ReadSingle()
Expand Down Expand Up @@ -995,6 +995,8 @@ Public Class SourceMdlFile52

anAnimationDesc.ikRuleZeroFrameOffset = Me.theInputFileReader.ReadInt32()

anAnimationDesc.compressedIkErrorOffset = Me.theInputFileReader.ReadInt32()

For x As Integer = 0 To anAnimationDesc.unused1.Length - 1
anAnimationDesc.unused1(x) = Me.theInputFileReader.ReadInt32()
Next
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ Public Class SourceMdlAnimationDesc52
' mstudioikrulezeroframe_t *pIKRuleZeroFrame( int i ) const { if (ikrulezeroframeindex) return (mstudioikrulezeroframe_t *)(((byte *)this) + ikrulezeroframeindex) + i; else return NULL; };
Public ikRuleZeroFrameOffset As Integer

Public compressedIkErrorOffset As Integer

' int unused1[5]; // remove as appropriate (and zero if loading older versions)
Public unused1(4) As Integer
Public unused1(3) As Integer

' int animblock;
Public animBlock As Integer
Expand Down
454 changes: 186 additions & 268 deletions Crowbar/Core/GameModel/SourceModel53/SourceMdlFile53.vb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ Public Class SourceMdlAnimationDesc53
' mstudioikrulezeroframe_t *pIKRuleZeroFrame( int i ) const { if (ikrulezeroframeindex) return (mstudioikrulezeroframe_t *)(((byte *)this) + ikrulezeroframeindex) + i; else return NULL; };
'Public ikRuleZeroFrameOffset As Integer

' int unused1[5]; // remove as appropriate (and zero if loading older versions)
'Public unused1(4) As Integer

' int animblock;
Public animBlock As Integer
'Public animBlock As Integer

Public compressedIkErrorOffset As Integer

' int animindex; // non-zero when anim data isn't in sections
Public animOffset As Integer
' mstudioanim_t *pAnimBlock( int block, int index ) const; // returns pointer to a specific anim block (local or external)
Expand All @@ -102,8 +108,6 @@ Public Class SourceMdlAnimationDesc53
' int ikruleindex; // non-zero when IK data is stored in the mdl
Public ikRuleOffset As Integer
' int animblockikruleindex; // non-zero when IK data is stored in animblock file
Public animblockIkRuleOffset As Integer
' mstudioikrule_t *pIKRule( int i ) const;

' int numlocalhierarchy;
Public localHierarchyCount As Integer
Expand All @@ -127,16 +131,15 @@ Public Class SourceMdlAnimationDesc53
' mutable float zeroframestalltime; // saved during read stalls
Public spanStallTime As Single

' int unused1[5]; // remove as appropriate (and zero if loading older versions)
Public unused1(3) As Integer
Public unused1(4) As Integer

' Moved to SourceMdlAnimationDescBase
'' inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
'Public theName As String

Public theSectionsOfAnimations As List(Of List(Of SourceMdlAnimation53))
Public theSectionsOfAnimations As List(Of List(Of SourceMdlAnimation))
Public theSectionsOfFrameAnim As List(Of SourceAniFrameAnim52)
Public theIkRules As List(Of SourceMdlIkRule)
Public theIkRules As List(Of SourceMdlIkRule53)
Public theSections As List(Of SourceMdlAnimationSection)
Public theMovements As List(Of SourceMdlMovement)
Public theLocalHierarchies As List(Of SourceMdlLocalHierarchy)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Public Class SourceMdlIkRule53

'FROM: SourceEngine2006+_source\public\studio.h
'struct mstudioikrule_t
'{
' DECLARE_BYTESWAP_DATADESC();
' int index;

' int type;
' int chain;

' int bone;

' int slot; // iktarget slot. Usually same as chain.
' float height;
' float radius;
' float floor;
' Vector pos;
' Quaternion q;

' int compressedikerrorindex;
' inline mstudiocompressedikerror_t *pCompressedError() const { return (mstudiocompressedikerror_t *)(((byte *)this) + compressedikerrorindex); };
' int unused2;

' int iStart;
' int ikerrorindex;
' inline mstudioikerror_t *pError( int i ) const { return (ikerrorindex) ? (mstudioikerror_t *)(((byte *)this) + ikerrorindex) + (i - iStart) : NULL; };

' float start; // beginning of influence
' float peak; // start of full influence
' float tail; // end of full influence
' float end; // end of all influence

' float unused3; //
' float contact; // frame footstep makes ground concact
' float drop; // how far down the foot should drop when reaching for IK
' float top; // top of the foot box

' int unused6;
' int unused7;
' int unused8;

' int szattachmentindex; // name of world attachment
' inline char * const pszAttachment( void ) const { return ((char *)this) + szattachmentindex; }

' int unused[7];

' mstudioikrule_t() {}

'private:
' // No copy constructors allowed
' mstudioikrule_t(const mstudioikrule_t& vOther);
'};



Public index As Integer
Public type As Integer
Public chain As Integer
Public bone As Integer

Public slot As Integer
Public height As Double
Public radius As Double
Public floor As Double
Public pos As SourceVector
Public q As SourceQuaternion

Public compressedIkErrorOffset As Integer

Public ikErrorIndexStart As Integer
Public ikErrorOffset As Integer

Public influenceStart As Double
Public influencePeak As Double
Public influenceTail As Double
Public influenceEnd As Double

Public contact As Double
Public drop As Double
Public top As Double

Public attachmentNameOffset As Integer

Public unused(8) As Integer



Public theAttachmentName As String
Public theCompressedIkError As SourceMdlCompressedIkError



' For the 'type' field:
'FROM: se2007_src\src_main\public\studio.h
'#define IK_SELF 1
'#define IK_WORLD 2
'#define IK_GROUND 3
'#define IK_RELEASE 4
'#define IK_ATTACHMENT 5
'#define IK_UNLATCH 6
Public Const IK_SELF As Integer = 1
Public Const IK_WORLD As Integer = 2
Public Const IK_GROUND As Integer = 3
Public Const IK_RELEASE As Integer = 4
Public Const IK_ATTACHMENT As Integer = 5
Public Const IK_UNLATCH As Integer = 6

End Class
14 changes: 7 additions & 7 deletions Crowbar/Core/GameModel/SourceModel53/SourceQcFile53.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2488,36 +2488,36 @@ Public Class SourceQcFile53
Dim line As String = ""

If anAnimationDesc.theIkRules IsNot Nothing Then
For Each anIkRule As SourceMdlIkRule In anAnimationDesc.theIkRules
For Each anIkRule As SourceMdlIkRule53 In anAnimationDesc.theIkRules
line = vbTab
line += "ikrule"
line += " """
line += Me.theMdlFileData.theIkChains(anIkRule.chain).theName
line += """"
If anIkRule.type = SourceMdlIkRule.IK_SELF Then
If anIkRule.type = SourceMdlIkRule53.IK_SELF Then
line += " "
line += "touch"
line += " """
If anIkRule.bone >= 0 Then
line += Me.theMdlFileData.theBones(anIkRule.bone).theName
End If
line += """"
'ElseIf anIkRule.type = SourceMdlIkRule.IK_WORLD Then
'ElseIf anIkRule.type = SourceMdlIkRule53.IK_WORLD Then
'line += " "
'line += "world"
ElseIf anIkRule.type = SourceMdlIkRule.IK_GROUND Then
ElseIf anIkRule.type = SourceMdlIkRule53.IK_GROUND Then
line += " "
line += "footstep"
ElseIf anIkRule.type = SourceMdlIkRule.IK_RELEASE Then
ElseIf anIkRule.type = SourceMdlIkRule53.IK_RELEASE Then
line += " "
line += "release"
ElseIf anIkRule.type = SourceMdlIkRule.IK_ATTACHMENT Then
ElseIf anIkRule.type = SourceMdlIkRule53.IK_ATTACHMENT Then
line += " "
line += "attachment"
line += " """
line += anIkRule.theAttachmentName
line += """"
ElseIf anIkRule.type = SourceMdlIkRule.IK_UNLATCH Then
ElseIf anIkRule.type = SourceMdlIkRule53.IK_UNLATCH Then
line += " "
line += "unlatch"
End If
Expand Down
Loading