-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: skeleton and bones + refactored header 2 state
- Loading branch information
jvenin
committed
Mar 10, 2024
1 parent
f82bd34
commit 26c372a
Showing
11 changed files
with
1,540 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; | ||
|
||
class BindPose extends GsfPart { | ||
late final Standard4BytesData<double> float1To1; | ||
late final Standard4BytesData<double> float1To2; | ||
late final Standard4BytesData<double> float1To3; | ||
late final Standard4BytesData<double> float1To4; | ||
late final Standard4BytesData<double> float2To1; | ||
late final Standard4BytesData<double> float2To2; | ||
late final Standard4BytesData<double> float2To3; | ||
late final Standard4BytesData<double> float2To4; | ||
late final Standard4BytesData<double> float3To1; | ||
late final Standard4BytesData<double> float3To2; | ||
late final Standard4BytesData<double> float3To3; | ||
late final Standard4BytesData<double> float3To4; | ||
late final Standard4BytesData<double> float4To1; | ||
late final Standard4BytesData<double> float4To2; | ||
late final Standard4BytesData<double> float4To3; | ||
late final Standard4BytesData<double> float4To4; | ||
|
||
|
||
@override | ||
String get label => 'Bind Pose'; | ||
|
||
BindPose.fromBytes(Uint8List bytes, int offset) : super(offset: offset) { | ||
float1To1 = Standard4BytesData( | ||
position: 0, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float1To2 = Standard4BytesData( | ||
position: float1To1.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float1To3 = Standard4BytesData( | ||
position: float1To2.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float1To4 = Standard4BytesData( | ||
position: float1To3.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float2To1 = Standard4BytesData( | ||
position: float1To4.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float2To2 = Standard4BytesData( | ||
position: float2To1.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float2To3 = Standard4BytesData( | ||
position: float2To2.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float2To4 = Standard4BytesData( | ||
position: float2To3.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float3To1 = Standard4BytesData( | ||
position: float2To4.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float3To2 = Standard4BytesData( | ||
position: float3To1.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float3To3 = Standard4BytesData( | ||
position: float3To2.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float3To4 = Standard4BytesData( | ||
position: float3To3.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float4To1 = Standard4BytesData( | ||
position: float3To4.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float4To2 = Standard4BytesData( | ||
position: float4To1.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float4To3 = Standard4BytesData( | ||
position: float4To2.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
float4To4 = Standard4BytesData( | ||
position: float4To3.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
} | ||
|
||
@override | ||
int getEndOffset() => float4To4.offsettedLength; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; | ||
|
||
class Bone extends GsfPart { | ||
late final Standard4BytesData<int> guid; | ||
late final Standard4BytesData<int> flags; | ||
late final Standard4BytesData<double> animPositionX; | ||
late final Standard4BytesData<double> animPositionY; | ||
late final Standard4BytesData<double> animPositionZ; | ||
late final Standard4BytesData<double> scaleX; | ||
late final Standard4BytesData<double> scaleY; | ||
late final Standard4BytesData<double> scaleZ; | ||
late final Standard4BytesData<double> quaternionL; | ||
late final Standard4BytesData<double> quaternionI; | ||
late final Standard4BytesData<double> quaternionJ; | ||
late final Standard4BytesData<double> quaternionK; | ||
late final Standard4BytesData<int> bonesCount; | ||
late final Standard4BytesData<int> nextBoneOffset; | ||
late final Standard4BytesData<int> bonesCount2; | ||
|
||
@override | ||
String get label => 'Bone $guid'; | ||
|
||
Bone.fromBytes(Uint8List bytes, int offset) : super(offset: offset) { | ||
guid = Standard4BytesData( | ||
position: 0, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
flags = Standard4BytesData( | ||
position: guid.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
animPositionX = Standard4BytesData( | ||
position: flags.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
animPositionY = Standard4BytesData( | ||
position: animPositionX.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
animPositionZ = Standard4BytesData( | ||
position: animPositionY.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
scaleX = Standard4BytesData( | ||
position: animPositionZ.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
scaleY = Standard4BytesData( | ||
position: scaleX.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
scaleZ = Standard4BytesData( | ||
position: scaleY.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionL = Standard4BytesData( | ||
position: scaleZ.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionI = Standard4BytesData( | ||
position: quaternionL.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionJ = Standard4BytesData( | ||
position: quaternionI.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionK = Standard4BytesData( | ||
position: quaternionJ.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
bonesCount = Standard4BytesData( | ||
position: quaternionK.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
nextBoneOffset = Standard4BytesData( | ||
position: bonesCount.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
bonesCount2 = Standard4BytesData( | ||
position: nextBoneOffset.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
} | ||
|
||
@override | ||
int getEndOffset() { | ||
return bonesCount2.offsettedLength; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:paraworld_gsf_viewer/classes/gsf/header2/chunks/chunk.dart'; | ||
import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; | ||
|
||
class BoneLinkChunk extends Chunk { | ||
late final Standard4BytesData<int> attributes; | ||
late final Standard4BytesData<int> guid; | ||
late final Standard4BytesData<int> positionX; | ||
late final Standard4BytesData<int> positionY; | ||
late final Standard4BytesData<int> positionZ; | ||
late final Standard4BytesData<int> quaternionL; | ||
late final Standard4BytesData<int> quaternionI; | ||
late final Standard4BytesData<int> quaternionJ; | ||
late final Standard4BytesData<int> quaternionK; | ||
late final Standard4BytesData<StringNoZero> fourccLink; | ||
late final Standard4BytesData<int> skeletonIndex; | ||
late final Standard4BytesData<UnknowData> boneIds; | ||
late final Standard4BytesData<UnknowData> boneWeights; | ||
|
||
@override | ||
String get label => 'BoneLink 0x${guid.value.toRadixString(16)}'; | ||
|
||
BoneLinkChunk.fromBytes(Uint8List bytes, int offset) | ||
: super(offset: offset, type: ChunkType.boneLink) { | ||
attributes = Standard4BytesData( | ||
position: 0, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
guid = Standard4BytesData( | ||
position: attributes.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
positionX = Standard4BytesData( | ||
position: guid.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
positionY = Standard4BytesData( | ||
position: positionX.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
positionZ = Standard4BytesData( | ||
position: positionY.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionL = Standard4BytesData( | ||
position: positionZ.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionI = Standard4BytesData( | ||
position: quaternionL.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionJ = Standard4BytesData( | ||
position: quaternionI.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
quaternionK = Standard4BytesData( | ||
position: quaternionJ.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
fourccLink = Standard4BytesData( | ||
position: quaternionK.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
skeletonIndex = Standard4BytesData( | ||
position: fourccLink.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
boneIds = Standard4BytesData( | ||
position: skeletonIndex.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
boneWeights = Standard4BytesData( | ||
position: boneIds.relativeEnd, | ||
bytes: bytes, | ||
offset: offset, | ||
); | ||
} | ||
|
||
@override | ||
int getEndOffset() { | ||
return boneWeights.offsettedLength; | ||
} | ||
} |
Oops, something went wrong.