Skip to content

Commit

Permalink
Merge branch 'pr/30' into Version0.73
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeqMacaw committed Jan 4, 2023
2 parents 20f77ff + 157c204 commit ce3ef3c
Show file tree
Hide file tree
Showing 29 changed files with 2,720 additions and 1,205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Public Class SourceMdlActivityModifier

Public nameOffset As Integer

' V53/V52 has an int here that needs to be read for proper output. 0 or 1.
Public unk As Integer

Public theName As String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ Public Class SourceMdlAnimation
' short nextoffset;
Public nextSourceMdlAnimationOffset As Short

'MDL 53 stuff
Public positionScale As Double
Public unk As Short
'Public OffsetX As Short
'Public OffsetY As Short
'Public OffsetZ As Short
'Public OffsetL As Short
Public PosX As SourceFloat16bits
Public PosY As SourceFloat16bits
Public PosZ As SourceFloat16bits
Public ScaleX As SourceFloat16bits
Public ScaleY As SourceFloat16bits
Public ScaleZ As SourceFloat16bits
Public nextTitanfall2MdlAnimationOffset As Integer


' Values for the field, flags:
'#define STUDIO_ANIM_RAWPOS 0x01 // Vector48
Expand All @@ -47,6 +62,20 @@ Public Class SourceMdlAnimation
Public Const STUDIO_ANIM_DELTA As Integer = &H10
Public Const STUDIO_ANIM_RAWROT2 As Integer = &H20

' MDL 53 values for flags:
'#define STUDIO_ANIM_DELTA_53 0x01 // this appears to be delta until proven otherwise
'// These work as toggles, flag enabled is raw data, flag disabled is pointers, see 'STUDIO_ANIM_READBONE_53' for exception.
'#define STUDIO_ANIM_RAWPOS_53 0x02 // Vector48
'#define STUDIO_ANIM_RAWROT_53 0x04 // Quaternion48
'#define STUDIO_ANIM_RAWSCALE_53 0x08 // Vector48
'// if above flag is disabled and below is enabled there is special exceptions
'#define STUDIO_ANIM_READBONE_53 0x10 // read bone data if any Of the above are disabled, only observed For rotation
Public Const STUDIO_ANIM_DELTA_53 As Integer = &H1
Public Const STUDIO_ANIM_RAWPOS_53 As Integer = &H2
Public Const STUDIO_ANIM_RAWROT_53 As Integer = &H4
Public Const STUDIO_ANIM_RAWSCALE_53 As Integer = &H8
Public Const STUDIO_ANIM_UNKFLAG_53 As Integer = &H10


' Do not use union, because it will have to rely on size of a .NET Framework data type.
'<StructLayout(LayoutKind.Explicit)> _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Public Class SourceMdlBone
'#define BONE_HAS_SAVEFRAME_ROT 0x00400000
Public Const BONE_SCREEN_ALIGN_SPHERE As Integer = &H8
Public Const BONE_SCREEN_ALIGN_CYLINDER As Integer = &H10
Public Const BONE_WORLD_ALIGN As Integer = &H20
Public Const BONE_USED_BY_VERTEX_LOD0 As Integer = &H400
Public Const BONE_USED_BY_VERTEX_LOD1 As Integer = &H800
Public Const BONE_USED_BY_VERTEX_LOD2 As Integer = &H1000
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
35 changes: 35 additions & 0 deletions Crowbar/Core/GameModel/SourceModel49/SourceQcFile49.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3973,6 +3973,8 @@ Public Class SourceQcFile49
Me.WriteBoneMergeCommand()
Me.WriteLimitRotationCommand()

Me.WriteWorldAlignCommand()

Me.WriteProceduralBonesCommand()
Me.WriteJiggleBoneCommand()
End Sub
Expand Down Expand Up @@ -4180,6 +4182,39 @@ Public Class SourceQcFile49
End If
End Sub

Private Sub WriteWorldAlignCommand()
Dim line As String = ""

' used in CS:GO
'$worldalign "ValveBiped.Bip01_R_Hand"
If Me.theMdlFileData.theBones IsNot Nothing Then
Dim aBone As SourceMdlBone
Dim emptyLineIsAlreadyWritten As Boolean

emptyLineIsAlreadyWritten = False
For i As Integer = 0 To Me.theMdlFileData.theBones.Count - 1
aBone = Me.theMdlFileData.theBones(i)

If (aBone.flags And SourceMdlBone.BONE_WORLD_ALIGN) > 0 Then
If Not emptyLineIsAlreadyWritten Then
Me.theOutputFileStreamWriter.WriteLine()
emptyLineIsAlreadyWritten = True
End If

If TheApp.Settings.DecompileQcUseMixedCaseForKeywordsIsChecked Then
line = "$WorldAlign "
Else
line = "$worldalign "
End If
line += """"
line += aBone.theName
line += """"
Me.theOutputFileStreamWriter.WriteLine(line)
End If
Next
End If
End Sub

Private Sub WriteJiggleBoneCommand()
If Me.theMdlFileData.theBones Is Nothing Then
Return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Public Class SourceAniFrameAnim52
Public constantsOffset As Integer
Public frameOffset As Integer
Public frameLength As Integer
Public unused(2) As Integer
Public oldBoneFlags As Integer
Public unkDataIndex As Integer
Public unused As Integer


'NOTE: These are indexed by global bone index.
Expand All @@ -34,26 +36,12 @@ Public Class SourceAniFrameAnim52
'NOTE: This is indexed by frame index and global bone index.
Public theBoneFrameDataInfos As List(Of List(Of BoneFrameDataInfo49))

'FROM: AlienSwarm_source\src\public\studio.h
' Values for the field, theBoneFlags:
'#define STUDIO_FRAME_RAWPOS 0x01 // Vector48 in constants
'#define STUDIO_FRAME_RAWROT 0x02 // Quaternion48 in constants
'#define STUDIO_FRAME_ANIMPOS 0x04 // Vector48 in framedata
'#define STUDIO_FRAME_ANIMROT 0x08 // Quaternion48 in framedata
'#define STUDIO_FRAME_FULLANIMPOS 0x10 // Vector in framedata
' In V52 they added scale tracks and redid how these work
Public Const STUDIO_FRAME_RAWPOS As Integer = &H1
Public Const STUDIO_FRAME_RAWROT As Integer = &H2
Public Const STUDIO_FRAME_ANIMPOS As Integer = &H4
Public Const STUDIO_FRAME_ANIMROT As Integer = &H8
Public Const STUDIO_FRAME_FULLANIMPOS As Integer = &H10

'Public Const STUDIO_FRAME_UNKNOWN01 As Integer = &H40 ' Seems to be 6 rotation bytes in constants based on tests. New format that is not Quaternion48. Maybe Quaternion48Smallest3?
'Public Const STUDIO_FRAME_UNKNOWN02 As Integer = &H80 ' Seems to be 6 rotation bytes in framedata based on tests. New format that is not Quaternion48. Maybe Quaternion48Smallest3?
'FROM: Kerry at Valve via Splinks on 24-Apr-2017
'#define STUDIO_FRAME_CONST_ROT2 0x40 // Quaternion48S in constants
'#define STUDIO_FRAME_ANIM_ROT2 0x80 // Quaternion48S in framedata
Public Const STUDIO_FRAME_CONST_ROT2 As Integer = &H40
Public Const STUDIO_FRAME_ANIM_ROT2 As Integer = &H80

Public Const STUDIO_FRAME_RAWSCALE As Integer = &H4
Public Const STUDIO_FRAME_ANIMPOS As Integer = &H8
Public Const STUDIO_FRAME_ANIMROT As Integer = &H10
Public Const STUDIO_FRAME_ANIMSCALE As Integer = &H20

End Class
Loading

0 comments on commit ce3ef3c

Please sign in to comment.