vertex load

This commit is contained in:
VitalyR 2025-06-17 12:31:53 +08:00 committed by VitalyR
parent fdb780b50d
commit 16e70b469d
8 changed files with 6050 additions and 25 deletions

801
assets/models/cube_anim.fbx Normal file
View File

@ -0,0 +1,801 @@
; FBX 7.7.0 project file
; ----------------------------------------------------
FBXHeaderExtension: {
FBXHeaderVersion: 1004
FBXVersion: 7700
CreationTimeStamp: {
Version: 1000
Year: 2023
Month: 9
Day: 7
Hour: 22
Minute: 17
Second: 31
Millisecond: 940
}
Creator: "FBX SDK/FBX Plugins version 2020.3"
OtherFlags: {
TCDefinition: 127
}
SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
Type: "UserData"
Version: 100
MetaData: {
Version: 100
Title: ""
Subject: ""
Author: ""
Keywords: ""
Revision: ""
Comment: ""
}
Properties70: {
P: "DocumentUrl", "KString", "Url", "", "D:\Dev\clean\ufbx-rust\tests\data\cube_anim.fbx"
P: "SrcDocumentUrl", "KString", "Url", "", "D:\Dev\clean\ufbx-rust\tests\data\cube_anim.fbx"
P: "Original", "Compound", "", ""
P: "Original|ApplicationVendor", "KString", "", "", "Autodesk"
P: "Original|ApplicationName", "KString", "", "", "Maya"
P: "Original|ApplicationVersion", "KString", "", "", "2023"
P: "Original|DateTime_GMT", "DateTime", "", "", "07/09/2023 19:17:31.937"
P: "Original|FileName", "KString", "", "", "D:\Dev\clean\ufbx-rust\tests\data\cube_anim.fbx"
P: "LastSaved", "Compound", "", ""
P: "LastSaved|ApplicationVendor", "KString", "", "", "Autodesk"
P: "LastSaved|ApplicationName", "KString", "", "", "Maya"
P: "LastSaved|ApplicationVersion", "KString", "", "", "2023"
P: "LastSaved|DateTime_GMT", "DateTime", "", "", "07/09/2023 19:17:31.937"
P: "Original|ApplicationActiveProject", "KString", "", "", "D:\Dev\clean\ufbx-rust\tests\data"
}
}
}
GlobalSettings: {
Version: 1000
Properties70: {
P: "UpAxis", "int", "Integer", "",1
P: "UpAxisSign", "int", "Integer", "",1
P: "FrontAxis", "int", "Integer", "",2
P: "FrontAxisSign", "int", "Integer", "",1
P: "CoordAxis", "int", "Integer", "",0
P: "CoordAxisSign", "int", "Integer", "",1
P: "OriginalUpAxis", "int", "Integer", "",1
P: "OriginalUpAxisSign", "int", "Integer", "",1
P: "UnitScaleFactor", "double", "Number", "",1
P: "OriginalUnitScaleFactor", "double", "Number", "",1
P: "AmbientColor", "ColorRGB", "Color", "",0,0,0
P: "DefaultCamera", "KString", "", "", "Producer Perspective"
P: "TimeMode", "enum", "", "",11
P: "TimeProtocol", "enum", "", "",2
P: "SnapOnFrameMode", "enum", "", "",0
P: "TimeSpanStart", "KTime", "Time", "",0
P: "TimeSpanStop", "KTime", "Time", "",192442325000
P: "CustomFrameRate", "double", "Number", "",-1
P: "TimeMarker", "Compound", "", ""
P: "CurrentTimeMarker", "int", "Integer", "",-1
}
}
; Documents Description
;------------------------------------------------------------------
Documents: {
Count: 1
Document: 2244722366480, "", "Scene" {
Properties70: {
P: "SourceObject", "object", "", ""
P: "ActiveAnimStackName", "KString", "", "", "Take 001"
}
RootNode: 0
}
}
; Document References
;------------------------------------------------------------------
References: {
}
; Object definitions
;------------------------------------------------------------------
Definitions: {
Version: 100
Count: 24
ObjectType: "GlobalSettings" {
Count: 1
}
ObjectType: "AnimationStack" {
Count: 1
PropertyTemplate: "FbxAnimStack" {
Properties70: {
P: "Description", "KString", "", "", ""
P: "LocalStart", "KTime", "Time", "",0
P: "LocalStop", "KTime", "Time", "",0
P: "ReferenceStart", "KTime", "Time", "",0
P: "ReferenceStop", "KTime", "Time", "",0
}
}
}
ObjectType: "AnimationLayer" {
Count: 1
PropertyTemplate: "FbxAnimLayer" {
Properties70: {
P: "Weight", "Number", "", "A",100
P: "Mute", "bool", "", "",0
P: "Solo", "bool", "", "",0
P: "Lock", "bool", "", "",0
P: "Color", "ColorRGB", "Color", "",0.8,0.8,0.8
P: "BlendMode", "enum", "", "",0
P: "RotationAccumulationMode", "enum", "", "",0
P: "ScaleAccumulationMode", "enum", "", "",0
P: "BlendModeBypass", "ULongLong", "", "",0
}
}
}
ObjectType: "Geometry" {
Count: 1
PropertyTemplate: "FbxMesh" {
Properties70: {
P: "Color", "ColorRGB", "Color", "",0.8,0.8,0.8
P: "BBoxMin", "Vector3D", "Vector", "",0,0,0
P: "BBoxMax", "Vector3D", "Vector", "",0,0,0
P: "Primary Visibility", "bool", "", "",1
P: "Casts Shadows", "bool", "", "",1
P: "Receive Shadows", "bool", "", "",1
}
}
}
ObjectType: "Material" {
Count: 1
PropertyTemplate: "FbxSurfaceLambert" {
Properties70: {
P: "ShadingModel", "KString", "", "", "Lambert"
P: "MultiLayer", "bool", "", "",0
P: "EmissiveColor", "Color", "", "A",0,0,0
P: "EmissiveFactor", "Number", "", "A",1
P: "AmbientColor", "Color", "", "A",0.2,0.2,0.2
P: "AmbientFactor", "Number", "", "A",1
P: "DiffuseColor", "Color", "", "A",0.8,0.8,0.8
P: "DiffuseFactor", "Number", "", "A",1
P: "Bump", "Vector3D", "Vector", "",0,0,0
P: "NormalMap", "Vector3D", "Vector", "",0,0,0
P: "BumpFactor", "double", "Number", "",1
P: "TransparentColor", "Color", "", "A",0,0,0
P: "TransparencyFactor", "Number", "", "A",0
P: "DisplacementColor", "ColorRGB", "Color", "",0,0,0
P: "DisplacementFactor", "double", "Number", "",1
P: "VectorDisplacementColor", "ColorRGB", "Color", "",0,0,0
P: "VectorDisplacementFactor", "double", "Number", "",1
}
}
}
ObjectType: "AnimationCurveNode" {
Count: 5
PropertyTemplate: "FbxAnimCurveNode" {
Properties70: {
P: "d", "Compound", "", ""
}
}
}
ObjectType: "AnimationCurve" {
Count: 13
}
ObjectType: "Model" {
Count: 1
PropertyTemplate: "FbxNode" {
Properties70: {
P: "QuaternionInterpolate", "enum", "", "",0
P: "RotationOffset", "Vector3D", "Vector", "",0,0,0
P: "RotationPivot", "Vector3D", "Vector", "",0,0,0
P: "ScalingOffset", "Vector3D", "Vector", "",0,0,0
P: "ScalingPivot", "Vector3D", "Vector", "",0,0,0
P: "TranslationActive", "bool", "", "",0
P: "TranslationMin", "Vector3D", "Vector", "",0,0,0
P: "TranslationMax", "Vector3D", "Vector", "",0,0,0
P: "TranslationMinX", "bool", "", "",0
P: "TranslationMinY", "bool", "", "",0
P: "TranslationMinZ", "bool", "", "",0
P: "TranslationMaxX", "bool", "", "",0
P: "TranslationMaxY", "bool", "", "",0
P: "TranslationMaxZ", "bool", "", "",0
P: "RotationOrder", "enum", "", "",0
P: "RotationSpaceForLimitOnly", "bool", "", "",0
P: "RotationStiffnessX", "double", "Number", "",0
P: "RotationStiffnessY", "double", "Number", "",0
P: "RotationStiffnessZ", "double", "Number", "",0
P: "AxisLen", "double", "Number", "",10
P: "PreRotation", "Vector3D", "Vector", "",0,0,0
P: "PostRotation", "Vector3D", "Vector", "",0,0,0
P: "RotationActive", "bool", "", "",0
P: "RotationMin", "Vector3D", "Vector", "",0,0,0
P: "RotationMax", "Vector3D", "Vector", "",0,0,0
P: "RotationMinX", "bool", "", "",0
P: "RotationMinY", "bool", "", "",0
P: "RotationMinZ", "bool", "", "",0
P: "RotationMaxX", "bool", "", "",0
P: "RotationMaxY", "bool", "", "",0
P: "RotationMaxZ", "bool", "", "",0
P: "InheritType", "enum", "", "",0
P: "ScalingActive", "bool", "", "",0
P: "ScalingMin", "Vector3D", "Vector", "",0,0,0
P: "ScalingMax", "Vector3D", "Vector", "",1,1,1
P: "ScalingMinX", "bool", "", "",0
P: "ScalingMinY", "bool", "", "",0
P: "ScalingMinZ", "bool", "", "",0
P: "ScalingMaxX", "bool", "", "",0
P: "ScalingMaxY", "bool", "", "",0
P: "ScalingMaxZ", "bool", "", "",0
P: "GeometricTranslation", "Vector3D", "Vector", "",0,0,0
P: "GeometricRotation", "Vector3D", "Vector", "",0,0,0
P: "GeometricScaling", "Vector3D", "Vector", "",1,1,1
P: "MinDampRangeX", "double", "Number", "",0
P: "MinDampRangeY", "double", "Number", "",0
P: "MinDampRangeZ", "double", "Number", "",0
P: "MaxDampRangeX", "double", "Number", "",0
P: "MaxDampRangeY", "double", "Number", "",0
P: "MaxDampRangeZ", "double", "Number", "",0
P: "MinDampStrengthX", "double", "Number", "",0
P: "MinDampStrengthY", "double", "Number", "",0
P: "MinDampStrengthZ", "double", "Number", "",0
P: "MaxDampStrengthX", "double", "Number", "",0
P: "MaxDampStrengthY", "double", "Number", "",0
P: "MaxDampStrengthZ", "double", "Number", "",0
P: "PreferedAngleX", "double", "Number", "",0
P: "PreferedAngleY", "double", "Number", "",0
P: "PreferedAngleZ", "double", "Number", "",0
P: "LookAtProperty", "object", "", ""
P: "UpVectorProperty", "object", "", ""
P: "Show", "bool", "", "",1
P: "NegativePercentShapeSupport", "bool", "", "",1
P: "DefaultAttributeIndex", "int", "Integer", "",-1
P: "Freeze", "bool", "", "",0
P: "LODBox", "bool", "", "",0
P: "Lcl Translation", "Lcl Translation", "", "A",0,0,0
P: "Lcl Rotation", "Lcl Rotation", "", "A",0,0,0
P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
P: "Visibility", "Visibility", "", "A",1
P: "Visibility Inheritance", "Visibility Inheritance", "", "",1
}
}
}
}
; Object properties
;------------------------------------------------------------------
Objects: {
Geometry: 2245309148656, "Geometry::", "Mesh" {
Vertices: *24 {
a: -0.5,-0.5,0.5,0.5,-0.5,0.5,-0.5,0.5,0.5,0.5,0.5,0.5,-0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5
}
PolygonVertexIndex: *24 {
a: 0,1,3,-3,2,3,5,-5,4,5,7,-7,6,7,1,-1,1,7,5,-4,6,0,2,-5
}
Edges: *12 {
a: 0,2,6,10,3,1,7,5,11,9,15,13
}
GeometryVersion: 124
LayerElementNormal: 0 {
Version: 102
Name: ""
MappingInformationType: "ByPolygonVertex"
ReferenceInformationType: "Direct"
Normals: *72 {
a: 0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0
}
NormalsW: *24 {
a: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
}
}
LayerElementBinormal: 0 {
Version: 102
Name: "map1"
MappingInformationType: "ByPolygonVertex"
ReferenceInformationType: "Direct"
Binormals: *72 {
a: 0,1,-0,0,1,-0,0,1,-0,0,1,-0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,-0,1,0,-0,1,0,0,1,-0,-0,1,0,0,1,0,0,1,0,0,1,0,0,1,0
}
BinormalsW: *24 {
a: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
}
}
LayerElementTangent: 0 {
Version: 102
Name: "map1"
MappingInformationType: "ByPolygonVertex"
ReferenceInformationType: "Direct"
Tangents: *72 {
a: 1,-0,-0,1,-0,0,1,-0,0,1,-0,0,1,-0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,-0,1,0,-0,1,0,-0,1,0,-0,0,0,-1,0,0,-1,0,-0,-1,0,0,-1,0,-0,1,0,-0,1,0,-0,1,0,-0,1
}
TangentsW: *24 {
a: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
}
}
LayerElementUV: 0 {
Version: 101
Name: "map1"
MappingInformationType: "ByPolygonVertex"
ReferenceInformationType: "IndexToDirect"
UV: *28 {
a: 0.375,0,0.625,0,0.375,0.25,0.625,0.25,0.375,0.5,0.625,0.5,0.375,0.75,0.625,0.75,0.375,1,0.625,1,0.875,0,0.875,0.25,0.125,0,0.125,0.25
}
UVIndex: *24 {
a: 0,1,3,2,2,3,5,4,4,5,7,6,6,7,9,8,1,10,11,3,12,0,2,13
}
}
LayerElementMaterial: 0 {
Version: 101
Name: ""
MappingInformationType: "AllSame"
ReferenceInformationType: "IndexToDirect"
Materials: *1 {
a: 0
}
}
Layer: 0 {
Version: 100
LayerElement: {
Type: "LayerElementNormal"
TypedIndex: 0
}
LayerElement: {
Type: "LayerElementBinormal"
TypedIndex: 0
}
LayerElement: {
Type: "LayerElementTangent"
TypedIndex: 0
}
LayerElement: {
Type: "LayerElementMaterial"
TypedIndex: 0
}
LayerElement: {
Type: "LayerElementUV"
TypedIndex: 0
}
}
}
Model: 2244692774032, "Model::pCube1", "Mesh" {
Version: 232
Properties70: {
P: "RotationActive", "bool", "", "",1
P: "InheritType", "enum", "", "",1
P: "ScalingMax", "Vector3D", "Vector", "",0,0,0
P: "DefaultAttributeIndex", "int", "Integer", "",0
P: "Lcl Translation", "Lcl Translation", "", "A+",0,0.518518518518518,0
P: "Lcl Rotation", "Lcl Rotation", "", "A+",11.6666666666667,11.6666666666667,0
P: "Lcl Scaling", "Lcl Scaling", "", "A+",1.05185185185185,1.1037037037037,1.15555555555556
P: "currentUVSet", "KString", "", "U", "map1"
}
Shading: T
Culling: "CullingOff"
}
Material: 2242872361376, "Material::lambert1", "" {
Version: 102
ShadingModel: "lambert"
MultiLayer: 0
Properties70: {
P: "AmbientColor", "Color", "", "A",0,0,0
P: "DiffuseColor", "Color", "", "A+",0.740740716457367,0.259259253740311,0
P: "DiffuseFactor", "Number", "", "A",0.800000011920929
P: "TransparencyFactor", "Number", "", "A",1
P: "Emissive", "Vector3D", "Vector", "",0,0,0
P: "Ambient", "Vector3D", "Vector", "",0,0,0
P: "Diffuse", "Vector3D", "Vector", "",0.592592581996211,0.20740740608286,0
P: "Opacity", "double", "Number", "",1
}
}
AnimationStack: 2243155095872, "AnimStack::Take 001", "" {
Properties70: {
P: "LocalStop", "KTime", "Time", "",38488465000
P: "ReferenceStop", "KTime", "Time", "",38488465000
}
}
AnimationCurve: 2243096615744, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 1,0
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096607744, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,1
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096613984, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,0
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096609024, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 1,1
}
;KeyAttrFlags: Constant|ConstantStandard, Constant|ConstantStandard
KeyAttrFlags: *2 {
a: 2,2
}
;KeyAttrDataFloat: RightSlope:0, NextLeftSlope:0, RightWeight:0.333333, NextLeftWeight:0.333333, RightVelocity:0, NextLeftVelocity:0; RightSlope:0, NextLeftSlope:0, RightWeight:0.333333, NextLeftWeight:0.333333, RightVelocity:0, NextLeftVelocity:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096609184, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,0
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096614944, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,2
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096614304, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,0
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096609824, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 1,1.2
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096613504, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 1,1.4
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096615424, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 1,1.6
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096609344, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,45
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096607264, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,45
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurve: 2243096615104, "AnimCurve::", "" {
Default: 0
KeyVer: 4009
KeyTime: *2 {
a: 0,23093079000
}
KeyValueFloat: *2 {
a: 0,0
}
;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive, Cubic|TangeantAuto|GenericTimeIndependent|GenericClampProgressive
KeyAttrFlags: *2 {
a: 24840,24840
}
;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightAuto:0, NextLeftAuto:0
KeyAttrDataFloat: *8 {
a: 0,0,218434821,0,0,0,218434821,0
}
KeyAttrRefCount: *2 {
a: 1,1
}
}
AnimationCurveNode: 2243155097120, "AnimCurveNode::DiffuseColor", "" {
Properties70: {
P: "d|X", "Number", "", "A",0.740740716457367
P: "d|Y", "Number", "", "A",0.259259253740311
P: "d|Z", "Number", "", "A",0
}
}
AnimationCurveNode: 2243155095456, "AnimCurveNode::Visibility", "" {
Properties70: {
P: "d|Visibility", "Visibility", "", "A",1
}
}
AnimationCurveNode: 2243155095040, "AnimCurveNode::T", "" {
Properties70: {
P: "d|X", "Number", "", "A",0
P: "d|Y", "Number", "", "A",0.518518518518518
P: "d|Z", "Number", "", "A",0
}
}
AnimationCurveNode: 2243155095248, "AnimCurveNode::S", "" {
Properties70: {
P: "d|X", "Number", "", "A",1.05185185185185
P: "d|Y", "Number", "", "A",1.1037037037037
P: "d|Z", "Number", "", "A",1.15555555555556
}
}
AnimationCurveNode: 2243155089008, "AnimCurveNode::R", "" {
Properties70: {
P: "d|X", "Number", "", "A",11.6666666666667
P: "d|Y", "Number", "", "A",11.6666666666667
P: "d|Z", "Number", "", "A",0
}
}
AnimationLayer: 2245017641168, "AnimLayer::BaseLayer", "" {
}
}
; Object connections
;------------------------------------------------------------------
Connections: {
;Model::pCube1, Model::RootNode
C: "OO",2244692774032,0
;AnimLayer::BaseLayer, AnimStack::Take 001
C: "OO",2245017641168,2243155095872
;AnimCurveNode::DiffuseColor, AnimLayer::BaseLayer
C: "OO",2243155097120,2245017641168
;AnimCurveNode::Visibility, AnimLayer::BaseLayer
C: "OO",2243155095456,2245017641168
;AnimCurveNode::T, AnimLayer::BaseLayer
C: "OO",2243155095040,2245017641168
;AnimCurveNode::S, AnimLayer::BaseLayer
C: "OO",2243155095248,2245017641168
;AnimCurveNode::R, AnimLayer::BaseLayer
C: "OO",2243155089008,2245017641168
;AnimCurveNode::DiffuseColor, Material::lambert1
C: "OP",2243155097120,2242872361376, "DiffuseColor"
;AnimCurve::, AnimCurveNode::DiffuseColor
C: "OP",2243096615744,2243155097120, "d|X"
;AnimCurve::, AnimCurveNode::DiffuseColor
C: "OP",2243096607744,2243155097120, "d|Y"
;AnimCurve::, AnimCurveNode::DiffuseColor
C: "OP",2243096613984,2243155097120, "d|Z"
;Geometry::, Model::pCube1
C: "OO",2245309148656,2244692774032
;Material::lambert1, Model::pCube1
C: "OO",2242872361376,2244692774032
;AnimCurveNode::T, Model::pCube1
C: "OP",2243155095040,2244692774032, "Lcl Translation"
;AnimCurveNode::R, Model::pCube1
C: "OP",2243155089008,2244692774032, "Lcl Rotation"
;AnimCurveNode::S, Model::pCube1
C: "OP",2243155095248,2244692774032, "Lcl Scaling"
;AnimCurveNode::Visibility, Model::pCube1
C: "OP",2243155095456,2244692774032, "Visibility"
;AnimCurve::, AnimCurveNode::Visibility
C: "OP",2243096609024,2243155095456, "d|Visibility"
;AnimCurve::, AnimCurveNode::T
C: "OP",2243096609184,2243155095040, "d|X"
;AnimCurve::, AnimCurveNode::T
C: "OP",2243096614944,2243155095040, "d|Y"
;AnimCurve::, AnimCurveNode::T
C: "OP",2243096614304,2243155095040, "d|Z"
;AnimCurve::, AnimCurveNode::S
C: "OP",2243096609824,2243155095248, "d|X"
;AnimCurve::, AnimCurveNode::S
C: "OP",2243096613504,2243155095248, "d|Y"
;AnimCurve::, AnimCurveNode::S
C: "OP",2243096615424,2243155095248, "d|Z"
;AnimCurve::, AnimCurveNode::R
C: "OP",2243096609344,2243155089008, "d|X"
;AnimCurve::, AnimCurveNode::R
C: "OP",2243096607264,2243155089008, "d|Y"
;AnimCurve::, AnimCurveNode::R
C: "OP",2243096615104,2243155089008, "d|Z"
}
;Takes section
;----------------------------------------------------
Takes: {
Current: "Take 001"
Take: "Take 001" {
FileName: "Take_001.tak"
LocalTime: 0,38488465000
ReferenceTime: 0,38488465000
}
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,354 @@
; FBX 7.7.0 project file
; ----------------------------------------------------
FBXHeaderExtension: {
FBXHeaderVersion: 1004
FBXVersion: 7700
CreationTimeStamp: {
Version: 1000
Year: 2023
Month: 9
Day: 7
Hour: 23
Minute: 0
Second: 12
Millisecond: 549
}
Creator: "FBX SDK/FBX Plugins version 2020.3"
OtherFlags: {
TCDefinition: 127
}
SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
Type: "UserData"
Version: 100
MetaData: {
Version: 100
Title: ""
Subject: ""
Author: ""
Keywords: ""
Revision: ""
Comment: ""
}
Properties70: {
P: "DocumentUrl", "KString", "Url", "", "D:\Dev\clean\ufbx-rust\tests\data\nurbs_saddle.fbx"
P: "SrcDocumentUrl", "KString", "Url", "", "D:\Dev\clean\ufbx-rust\tests\data\nurbs_saddle.fbx"
P: "Original", "Compound", "", ""
P: "Original|ApplicationVendor", "KString", "", "", "Autodesk"
P: "Original|ApplicationName", "KString", "", "", "Maya"
P: "Original|ApplicationVersion", "KString", "", "", "2023"
P: "Original|DateTime_GMT", "DateTime", "", "", "07/09/2023 20:00:12.548"
P: "Original|FileName", "KString", "", "", "D:\Dev\clean\ufbx-rust\tests\data\nurbs_saddle.fbx"
P: "LastSaved", "Compound", "", ""
P: "LastSaved|ApplicationVendor", "KString", "", "", "Autodesk"
P: "LastSaved|ApplicationName", "KString", "", "", "Maya"
P: "LastSaved|ApplicationVersion", "KString", "", "", "2023"
P: "LastSaved|DateTime_GMT", "DateTime", "", "", "07/09/2023 20:00:12.548"
P: "Original|ApplicationActiveProject", "KString", "", "", "D:\Dev\clean\ufbx-rust\tests\data"
}
}
}
GlobalSettings: {
Version: 1000
Properties70: {
P: "UpAxis", "int", "Integer", "",1
P: "UpAxisSign", "int", "Integer", "",1
P: "FrontAxis", "int", "Integer", "",2
P: "FrontAxisSign", "int", "Integer", "",1
P: "CoordAxis", "int", "Integer", "",0
P: "CoordAxisSign", "int", "Integer", "",1
P: "OriginalUpAxis", "int", "Integer", "",1
P: "OriginalUpAxisSign", "int", "Integer", "",1
P: "UnitScaleFactor", "double", "Number", "",1
P: "OriginalUnitScaleFactor", "double", "Number", "",1
P: "AmbientColor", "ColorRGB", "Color", "",0,0,0
P: "DefaultCamera", "KString", "", "", "Producer Perspective"
P: "TimeMode", "enum", "", "",11
P: "TimeProtocol", "enum", "", "",2
P: "SnapOnFrameMode", "enum", "", "",0
P: "TimeSpanStart", "KTime", "Time", "",0
P: "TimeSpanStop", "KTime", "Time", "",192442325000
P: "CustomFrameRate", "double", "Number", "",-1
P: "TimeMarker", "Compound", "", ""
P: "CurrentTimeMarker", "int", "Integer", "",-1
}
}
; Documents Description
;------------------------------------------------------------------
Documents: {
Count: 1
Document: 2244722434576, "", "Scene" {
Properties70: {
P: "SourceObject", "object", "", ""
P: "ActiveAnimStackName", "KString", "", "", "Take 001"
}
RootNode: 0
}
}
; Document References
;------------------------------------------------------------------
References: {
}
; Object definitions
;------------------------------------------------------------------
Definitions: {
Version: 100
Count: 6
ObjectType: "GlobalSettings" {
Count: 1
}
ObjectType: "AnimationStack" {
Count: 1
PropertyTemplate: "FbxAnimStack" {
Properties70: {
P: "Description", "KString", "", "", ""
P: "LocalStart", "KTime", "Time", "",0
P: "LocalStop", "KTime", "Time", "",0
P: "ReferenceStart", "KTime", "Time", "",0
P: "ReferenceStop", "KTime", "Time", "",0
}
}
}
ObjectType: "AnimationLayer" {
Count: 1
PropertyTemplate: "FbxAnimLayer" {
Properties70: {
P: "Weight", "Number", "", "A",100
P: "Mute", "bool", "", "",0
P: "Solo", "bool", "", "",0
P: "Lock", "bool", "", "",0
P: "Color", "ColorRGB", "Color", "",0.8,0.8,0.8
P: "BlendMode", "enum", "", "",0
P: "RotationAccumulationMode", "enum", "", "",0
P: "ScaleAccumulationMode", "enum", "", "",0
P: "BlendModeBypass", "ULongLong", "", "",0
}
}
}
ObjectType: "Geometry" {
Count: 1
PropertyTemplate: "FbxNurbsSurface" {
Properties70: {
P: "Color", "ColorRGB", "Color", "",0.8,0.8,0.8
P: "BBoxMin", "Vector3D", "Vector", "",0,0,0
P: "BBoxMax", "Vector3D", "Vector", "",0,0,0
P: "Primary Visibility", "bool", "", "",1
P: "Casts Shadows", "bool", "", "",1
P: "Receive Shadows", "bool", "", "",1
}
}
}
ObjectType: "Model" {
Count: 1
PropertyTemplate: "FbxNode" {
Properties70: {
P: "QuaternionInterpolate", "enum", "", "",0
P: "RotationOffset", "Vector3D", "Vector", "",0,0,0
P: "RotationPivot", "Vector3D", "Vector", "",0,0,0
P: "ScalingOffset", "Vector3D", "Vector", "",0,0,0
P: "ScalingPivot", "Vector3D", "Vector", "",0,0,0
P: "TranslationActive", "bool", "", "",0
P: "TranslationMin", "Vector3D", "Vector", "",0,0,0
P: "TranslationMax", "Vector3D", "Vector", "",0,0,0
P: "TranslationMinX", "bool", "", "",0
P: "TranslationMinY", "bool", "", "",0
P: "TranslationMinZ", "bool", "", "",0
P: "TranslationMaxX", "bool", "", "",0
P: "TranslationMaxY", "bool", "", "",0
P: "TranslationMaxZ", "bool", "", "",0
P: "RotationOrder", "enum", "", "",0
P: "RotationSpaceForLimitOnly", "bool", "", "",0
P: "RotationStiffnessX", "double", "Number", "",0
P: "RotationStiffnessY", "double", "Number", "",0
P: "RotationStiffnessZ", "double", "Number", "",0
P: "AxisLen", "double", "Number", "",10
P: "PreRotation", "Vector3D", "Vector", "",0,0,0
P: "PostRotation", "Vector3D", "Vector", "",0,0,0
P: "RotationActive", "bool", "", "",0
P: "RotationMin", "Vector3D", "Vector", "",0,0,0
P: "RotationMax", "Vector3D", "Vector", "",0,0,0
P: "RotationMinX", "bool", "", "",0
P: "RotationMinY", "bool", "", "",0
P: "RotationMinZ", "bool", "", "",0
P: "RotationMaxX", "bool", "", "",0
P: "RotationMaxY", "bool", "", "",0
P: "RotationMaxZ", "bool", "", "",0
P: "InheritType", "enum", "", "",0
P: "ScalingActive", "bool", "", "",0
P: "ScalingMin", "Vector3D", "Vector", "",0,0,0
P: "ScalingMax", "Vector3D", "Vector", "",1,1,1
P: "ScalingMinX", "bool", "", "",0
P: "ScalingMinY", "bool", "", "",0
P: "ScalingMinZ", "bool", "", "",0
P: "ScalingMaxX", "bool", "", "",0
P: "ScalingMaxY", "bool", "", "",0
P: "ScalingMaxZ", "bool", "", "",0
P: "GeometricTranslation", "Vector3D", "Vector", "",0,0,0
P: "GeometricRotation", "Vector3D", "Vector", "",0,0,0
P: "GeometricScaling", "Vector3D", "Vector", "",1,1,1
P: "MinDampRangeX", "double", "Number", "",0
P: "MinDampRangeY", "double", "Number", "",0
P: "MinDampRangeZ", "double", "Number", "",0
P: "MaxDampRangeX", "double", "Number", "",0
P: "MaxDampRangeY", "double", "Number", "",0
P: "MaxDampRangeZ", "double", "Number", "",0
P: "MinDampStrengthX", "double", "Number", "",0
P: "MinDampStrengthY", "double", "Number", "",0
P: "MinDampStrengthZ", "double", "Number", "",0
P: "MaxDampStrengthX", "double", "Number", "",0
P: "MaxDampStrengthY", "double", "Number", "",0
P: "MaxDampStrengthZ", "double", "Number", "",0
P: "PreferedAngleX", "double", "Number", "",0
P: "PreferedAngleY", "double", "Number", "",0
P: "PreferedAngleZ", "double", "Number", "",0
P: "LookAtProperty", "object", "", ""
P: "UpVectorProperty", "object", "", ""
P: "Show", "bool", "", "",1
P: "NegativePercentShapeSupport", "bool", "", "",1
P: "DefaultAttributeIndex", "int", "Integer", "",-1
P: "Freeze", "bool", "", "",0
P: "LODBox", "bool", "", "",0
P: "Lcl Translation", "Lcl Translation", "", "A",0,0,0
P: "Lcl Rotation", "Lcl Rotation", "", "A",0,0,0
P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
P: "Visibility", "Visibility", "", "A",1
P: "Visibility Inheritance", "Visibility Inheritance", "", "",1
}
}
}
ObjectType: "Material" {
Count: 1
PropertyTemplate: "FbxSurfaceLambert" {
Properties70: {
P: "ShadingModel", "KString", "", "", "Lambert"
P: "MultiLayer", "bool", "", "",0
P: "EmissiveColor", "Color", "", "A",0,0,0
P: "EmissiveFactor", "Number", "", "A",1
P: "AmbientColor", "Color", "", "A",0.2,0.2,0.2
P: "AmbientFactor", "Number", "", "A",1
P: "DiffuseColor", "Color", "", "A",0.8,0.8,0.8
P: "DiffuseFactor", "Number", "", "A",1
P: "Bump", "Vector3D", "Vector", "",0,0,0
P: "NormalMap", "Vector3D", "Vector", "",0,0,0
P: "BumpFactor", "double", "Number", "",1
P: "TransparentColor", "Color", "", "A",0,0,0
P: "TransparencyFactor", "Number", "", "A",0
P: "DisplacementColor", "ColorRGB", "Color", "",0,0,0
P: "DisplacementFactor", "double", "Number", "",1
P: "VectorDisplacementColor", "ColorRGB", "Color", "",0,0,0
P: "VectorDisplacementFactor", "double", "Number", "",1
}
}
}
}
; Object properties
;------------------------------------------------------------------
Objects: {
Geometry: 2244661497968, "Geometry::", "NurbsSurface" {
Type: "NurbsSurface"
NurbsSurfaceVersion: 100
SurfaceDisplay: 4,4,4
NurbsSurfaceOrder: 4,4
Dimensions: 4,4
Step: 4,4
Form: "Open", "Open"
Points: *64 {
a: -0.5,3.02450737408863e-16,0.5,1,-0.166666666666667,1,0.5,1,0.166666666666667,1,0.5,1,0.5,1.91428434946347e-16,0.5,1,-0.5,-1.02053899928946e-17,0.166666666666667,1,-0.166666666666667,-1.02053899928946e-17,0.166666666666667,1,0.166666666666667,-1.02053899928946e-17,0.166666666666667,1,0.5,-1.02053899928946e-17,0.166666666666667,1,-0.5,1.02053899928946e-17,-0.166666666666667,1,-0.166666666666667,1.02053899928946e-17,-0.166666666666667,1,0.166666666666667,1.02053899928946e-17,-0.166666666666667,1,0.5,1.02053899928946e-17,-0.166666666666667,1,-0.5,-3.02450737408863e-16,-0.5,1,-0.166666666666667,1,-0.5,1,0.166666666666667,1,-0.5,1,0.5,-4.13473039871379e-16,-0.5,1
}
KnotVectorU: *8 {
a: 0,0,0,0,1,1,1,1
}
KnotVectorV: *8 {
a: 0,0,0,0,1,1,1,1
}
GeometryVersion: 124
LayerElementMaterial: 0 {
Version: 101
Name: ""
MappingInformationType: "AllSame"
ReferenceInformationType: "IndexToDirect"
Materials: *1 {
a: 0
}
}
Layer: 0 {
Version: 100
LayerElement: {
Type: "LayerElementMaterial"
TypedIndex: 0
}
}
FlipNormals: 0
}
Model: 2244692783312, "Model::nurbsPlane1", "NurbsSurface" {
Version: 232
Properties70: {
P: "RotationActive", "bool", "", "",1
P: "InheritType", "enum", "", "",1
P: "ScalingMax", "Vector3D", "Vector", "",0,0,0
P: "DefaultAttributeIndex", "int", "Integer", "",0
}
Shading: T
Culling: "CullingOff"
}
Material: 2245206607712, "Material::lambert1", "" {
Version: 102
ShadingModel: "lambert"
MultiLayer: 0
Properties70: {
P: "AmbientColor", "Color", "", "A",0,0,0
P: "DiffuseColor", "Color", "", "A",0.5,0.5,0.5
P: "DiffuseFactor", "Number", "", "A",0.800000011920929
P: "TransparencyFactor", "Number", "", "A",1
P: "Emissive", "Vector3D", "Vector", "",0,0,0
P: "Ambient", "Vector3D", "Vector", "",0,0,0
P: "Diffuse", "Vector3D", "Vector", "",0.400000005960464,0.400000005960464,0.400000005960464
P: "Opacity", "double", "Number", "",1
}
}
AnimationStack: 2245342457680, "AnimStack::Take 001", "" {
Properties70: {
P: "LocalStop", "KTime", "Time", "",38488465000
P: "ReferenceStop", "KTime", "Time", "",38488465000
}
}
AnimationLayer: 2244690764464, "AnimLayer::BaseLayer", "" {
}
}
; Object connections
;------------------------------------------------------------------
Connections: {
;Model::nurbsPlane1, Model::RootNode
C: "OO",2244692783312,0
;AnimLayer::BaseLayer, AnimStack::Take 001
C: "OO",2244690764464,2245342457680
;Geometry::, Model::nurbsPlane1
C: "OO",2244661497968,2244692783312
;Material::lambert1, Model::nurbsPlane1
C: "OO",2245206607712,2244692783312
}
;Takes section
;----------------------------------------------------
Takes: {
Current: "Take 001"
Take: "Take 001" {
FileName: "Take_001.tak"
LocalTime: 0,38488465000
ReferenceTime: 0,38488465000
}
}

View File

@ -19,6 +19,8 @@ pub enum FbxAssetLabel {
Skeleton(usize),
/// `Node{}`: Individual FBX node in the scene hierarchy
Node(usize),
/// `Skin{}`: FBX skin for skeletal animation
Skin(usize),
/// `Light{}`: FBX light definition
Light(usize),
/// `Camera{}`: FBX camera definition
@ -43,6 +45,7 @@ impl core::fmt::Display for FbxAssetLabel {
FbxAssetLabel::AnimationStack(index) => f.write_str(&format!("AnimationStack{index}")),
FbxAssetLabel::Skeleton(index) => f.write_str(&format!("Skeleton{index}")),
FbxAssetLabel::Node(index) => f.write_str(&format!("Node{index}")),
FbxAssetLabel::Skin(index) => f.write_str(&format!("Skin{index}")),
FbxAssetLabel::Light(index) => f.write_str(&format!("Light{index}")),
FbxAssetLabel::Camera(index) => f.write_str(&format!("Camera{index}")),
FbxAssetLabel::Texture(index) => f.write_str(&format!("Texture{index}")),

View File

@ -15,7 +15,8 @@ use bevy_asset::{
io::Reader, Asset, AssetApp, AssetLoader, Handle, LoadContext, RenderAssetUsages,
};
use bevy_ecs::prelude::*;
use bevy_mesh::{Indices, Mesh, PrimitiveTopology};
use bevy_mesh::{Indices, Mesh, PrimitiveTopology, VertexAttributeValues};
use bevy_mesh::skinning::SkinnedMeshInverseBindposes;
use bevy_pbr::{MeshMaterial3d, StandardMaterial};
use bevy_platform::collections::HashMap;
@ -255,7 +256,7 @@ pub struct FbxSkin {
/// All the nodes that form this skin.
pub joints: Vec<Handle<FbxNode>>,
/// Inverse-bind matrices of this skin.
pub inverse_bind_matrices: Handle<bevy_mesh::skinning::SkinnedMeshInverseBindposes>,
pub inverse_bind_matrices: Handle<SkinnedMeshInverseBindposes>,
}
/// Animation stack representing a timeline.
@ -472,6 +473,58 @@ impl AssetLoader for FbxLoader {
bevy_mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs);
}
// Process skinning data if available
if mesh.skin_deformers.len() > 0 {
let skin_deformer = &mesh.skin_deformers[0];
// Extract joint indices and weights
let mut joint_indices = vec![[0u16; 4]; mesh.num_vertices];
let mut joint_weights = vec![[0.0f32; 4]; mesh.num_vertices];
for vertex_index in 0..mesh.num_vertices {
let mut weight_count = 0;
let mut total_weight = 0.0f32;
for (cluster_index, cluster) in skin_deformer.clusters.iter().enumerate() {
if weight_count >= 4 { break; }
// Find weight for this vertex in this cluster
for &weight_vertex in cluster.vertices.iter() {
if weight_vertex as usize == vertex_index {
if let Some(weight_index) = cluster.vertices.iter().position(|&v| v as usize == vertex_index) {
if weight_index < cluster.weights.len() {
let weight = cluster.weights[weight_index] as f32;
if weight > 0.0 {
joint_indices[vertex_index][weight_count] = cluster_index as u16;
joint_weights[vertex_index][weight_count] = weight;
total_weight += weight;
weight_count += 1;
}
}
}
break;
}
}
}
// Normalize weights to sum to 1.0
if total_weight > 0.0 {
for i in 0..weight_count {
joint_weights[vertex_index][i] /= total_weight;
}
}
}
bevy_mesh.insert_attribute(
Mesh::ATTRIBUTE_JOINT_INDEX,
VertexAttributeValues::Uint16x4(joint_indices),
);
bevy_mesh.insert_attribute(
Mesh::ATTRIBUTE_JOINT_WEIGHT,
joint_weights,
);
}
let mut indices = Vec::new();
for &face in mesh.faces.as_ref() {
scratch.clear();
@ -503,7 +556,7 @@ impl AssetLoader for FbxLoader {
filename: texture.filename.to_string(),
absolute_filename: texture.absolute_filename.to_string(),
uv_set: texture.uv_set.to_string(),
uv_transform: Mat4::IDENTITY, // TODO: Convert ufbx::Transform to Mat4
uv_transform: Mat4::IDENTITY, // Note: UV transform conversion not implemented yet
wrap_u: match texture.wrap_u {
ufbx::WrapMode::Repeat => FbxWrapMode::Repeat,
_ => FbxWrapMode::Clamp,
@ -547,12 +600,12 @@ impl AssetLoader for FbxLoader {
let mut alpha = 1.0f32;
let mut material_textures = HashMap::new();
// TODO: Process material properties from ufbx
// For now, use default values
// Note: Advanced material property extraction not implemented yet
// Using default PBR values for now
roughness = 0.5f32;
// TODO: Process material textures from ufbx
// For now, use empty textures map
// Note: Texture processing not fully implemented yet
// Basic texture loading is supported but not applied to materials
let fbx_material = FbxMaterial {
name: ufbx_material.element.name.to_string(),
@ -579,8 +632,8 @@ impl AssetLoader for FbxLoader {
..Default::default()
};
// TODO: Apply textures to StandardMaterial
// For now, skip texture application
// Note: Texture application to materials not implemented yet
// Textures are loaded but not yet applied to StandardMaterial
let handle = load_context.add_labeled_asset(
FbxAssetLabel::Material(index).to_string(),
@ -595,6 +648,58 @@ impl AssetLoader for FbxLoader {
materials.push(handle);
}
// Process skins first
let mut skins = Vec::new();
let mut named_skins = HashMap::new();
let mut skin_map = HashMap::new(); // Map from ufbx skin ID to FbxSkin handle
for (skin_index, mesh_node) in scene.nodes.as_ref().iter().enumerate() {
let Some(mesh_ref) = &mesh_node.mesh else { continue };
let mesh = mesh_ref.as_ref();
if mesh.skin_deformers.is_empty() { continue; }
let skin_deformer = &mesh.skin_deformers[0];
// Create inverse bind matrices
let mut inverse_bind_matrices = Vec::new();
let mut joint_node_ids = Vec::new();
for cluster in &skin_deformer.clusters {
// Convert ufbx matrix to Mat4
let bind_matrix = cluster.bind_to_world;
let inverse_bind_matrix = Mat4::from_cols_array(&[
bind_matrix.m00 as f32, bind_matrix.m10 as f32, bind_matrix.m20 as f32, 0.0,
bind_matrix.m01 as f32, bind_matrix.m11 as f32, bind_matrix.m21 as f32, 0.0,
bind_matrix.m02 as f32, bind_matrix.m12 as f32, bind_matrix.m22 as f32, 0.0,
bind_matrix.m03 as f32, bind_matrix.m13 as f32, bind_matrix.m23 as f32, 1.0,
]).inverse();
inverse_bind_matrices.push(inverse_bind_matrix);
// Store joint node ID for later resolution
if let Some(bone_node) = cluster.bone_node.as_ref() {
joint_node_ids.push(bone_node.element.element_id);
}
}
if !inverse_bind_matrices.is_empty() {
let inverse_bindposes_handle = load_context.add_labeled_asset(
FbxAssetLabel::Skin(skin_index).to_string() + "_InverseBindposes",
SkinnedMeshInverseBindposes::from(inverse_bind_matrices),
);
let skin_name = if mesh_node.element.name.is_empty() {
format!("Skin_{}", skin_index)
} else {
format!("{}_Skin", mesh_node.element.name)
};
// Store skin info for later processing
skin_map.insert(mesh_node.element.element_id, (inverse_bindposes_handle, joint_node_ids, skin_name, skin_index));
}
}
// Process nodes and build hierarchy
let mut nodes = Vec::new();
let mut named_nodes = HashMap::new();
@ -609,7 +714,7 @@ impl AssetLoader for FbxLoader {
};
// Find associated mesh
let mesh_handle = if let Some(mesh_ref) = &ufbx_node.mesh {
let mesh_handle = if let Some(_mesh_ref) = &ufbx_node.mesh {
// Find the mesh in our processed meshes
meshes.iter().enumerate().find_map(|(mesh_idx, mesh_handle)| {
// Check if this mesh corresponds to this node
@ -652,7 +757,7 @@ impl AssetLoader for FbxLoader {
name: name.clone(),
children: Vec::new(), // Will be filled in second pass
mesh: mesh_handle,
skin: None, // TODO: Process skins
skin: None, // Will be set later after all nodes are created
transform,
visible: ufbx_node.visible,
};
@ -672,16 +777,45 @@ impl AssetLoader for FbxLoader {
// Second pass: establish parent-child relationships
// Note: We skip this for now to avoid ufbx crashes with children access
// TODO: Implement safe children processing
// Note: Parent-child relationships not implemented yet to avoid ufbx crashes
// Process skins (placeholder for now)
let skins = Vec::new();
let named_skins = HashMap::new();
// Third pass: Create actual FbxSkin assets now that all nodes are created
for (_mesh_node_id, (inverse_bindposes_handle, joint_node_ids, skin_name, skin_index)) in skin_map.iter() {
let mut joint_handles = Vec::new();
// Process animations (placeholder for now)
// Resolve joint node IDs to handles
for &joint_node_id in joint_node_ids {
if let Some(joint_handle) = node_map.get(&joint_node_id) {
joint_handles.push(joint_handle.clone());
}
}
let fbx_skin = FbxSkin {
index: *skin_index,
name: skin_name.clone(),
joints: joint_handles,
inverse_bind_matrices: inverse_bindposes_handle.clone(),
};
let skin_handle = load_context.add_labeled_asset(
FbxAssetLabel::Skin(*skin_index).to_string(),
fbx_skin,
);
skins.push(skin_handle.clone());
if !skin_name.starts_with("Skin_") {
named_skins.insert(Box::from(skin_name.as_str()), skin_handle);
}
}
// Process animations (simplified for now)
let animations = Vec::new();
let named_animations = HashMap::new();
// Note: Full animation processing not implemented yet
// Basic structure is in place but needs ufbx animation API integration
let mut scenes = Vec::new();
let named_scenes = HashMap::new();
@ -733,15 +867,15 @@ impl AssetLoader for FbxLoader {
default_scene: Some(scene_handle),
animations,
named_animations,
// FBX_TODO
// Note: Using default axis system (matches Bevy's coordinate system)
axis_system: FbxAxisSystem {
up: Vec3::Y,
front: Vec3::Z,
handedness: Handedness::Right,
},
// FBX_TODO
// Note: Unit scale is handled by ufbx target_unit_meters setting
unit_scale: 1.0,
// FBX_TODO
// Note: Metadata extraction not implemented yet
metadata: FbxMeta {
creator: None,
creation_time: None,

View File

@ -22,12 +22,12 @@ fn main() {
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn((
Camera3d::default(),
Transform::from_xyz(0.7, 2.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
// Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
// Transform::from_xyz(0.7, 2.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
EnvironmentMapLight {
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
intensity: 250.0,
intensity: 550.0,
..default()
},
));
@ -50,9 +50,21 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
));
// Load the FBX file and spawn its first scene
commands.spawn(SceneRoot(
asset_server.load(FbxAssetLabel::Scene(0).from_asset("models/cube/cube.fbx")),
));
// commands.spawn(SceneRoot(
// asset_server.load(FbxAssetLabel::Scene(0).from_asset("models/cube/cube.fbx")),
// ));
// commands.spawn(SceneRoot(
// asset_server.load(FbxAssetLabel::Scene(0).from_asset("models/cube_anim.fbx")),
// ));
// commands.spawn(SceneRoot(asset_server.load(
// FbxAssetLabel::Scene(0).from_asset("models/instanced_materials.fbx"),
// )));
// commands.spawn(SceneRoot(
// asset_server.load(FbxAssetLabel::Scene(0).from_asset("models/nurbs_saddle.fbx")),
// ));
commands.spawn(SceneRoot(asset_server.load(
FbxAssetLabel::Scene(0).from_asset("models/max2009_blob_6100_binary.fbx"),
)));
}
fn animate_light_direction(