.FBXを読み込んでみる1(解析編)

.FBX を読み込んで表示できると便利です。
.FBX は Autodesk 社の製品の中間ファイルフォーマットです。
3ds Max , Maya , MotionBuilder , Mudbox , Softimage 間のデータを
受け渡す時のために作られました。
その後、Lightwave 3D や CINEMA 4D や Shade でも使えるようになりました。
FBXはバージョンによってファイルの内容が違います。
一般的に使用するには FBX SDK を使うのが良いです。

解析編という事で一応中身を見ておきます。
例によってメタセコイアを使います。
http://horsetail.sakura.ne.jp/index.html
こちらのサイトに FBXエクスポーター というプラグインがあるのでインストールします。
そしてメタセコイアで立方体を作って四角形面を三角形面にし、FBXエクスポーター で
出力します。
その際は、 ASCII 形式で保存します。

; FBX 6.1.0 project file
; Copyright (C) 1997-2008 Autodesk Inc. and/or its licensors.
; All rights reserved.
; ----------------------------------------------------

FBXHeaderExtension:  {
    FBXHeaderVersion: 1003
    FBXVersion: 6100
    CreationTimeStamp:  {
        Version: 1000
        Year: 2011
        Month: 4
        Day: 17
        Hour: 22
        Minute: 56
        Second: 53
        Millisecond: 151
    }
    Creator: "FBX SDK/FBX Plugins version 2009.3"
    OtherFlags:  {
        FlagPLE: 0
    }
}
CreationTime: "2011-04-17 22:56:53:151"
Creator: "FBX SDK/FBX Plugins build 20080926"

; Document Description
;------------------------------------------------------------------

Document:  {
    Name: ""
}

; Document References
;------------------------------------------------------------------

References:  {
}

; Object definitions
;------------------------------------------------------------------

Definitions:  {
    Version: 100
    Count: 4
    ObjectType: "Model" {
        Count: 1
    }
    ObjectType: "Material" {
        Count: 1
    }
    ObjectType: "SceneInfo" {
        Count: 1
    }
    ObjectType: "GlobalSettings" {
        Count: 1
    }
}

; Object properties
;------------------------------------------------------------------

Objects:  {
    Model: "Model::obj1", "Mesh" {
        Version: 232
        Properties60:  {
            Property: "QuaternionInterpolate", "bool", "",0
            Property: "RotationOffset", "Vector3D", "",0,0,0
            Property: "RotationPivot", "Vector3D", "",0,0,0
            Property: "ScalingOffset", "Vector3D", "",0,0,0
            Property: "ScalingPivot", "Vector3D", "",0,0,0
            Property: "TranslationActive", "bool", "",0
            Property: "TranslationMin", "Vector3D", "",0,0,0
            Property: "TranslationMax", "Vector3D", "",0,0,0
            Property: "TranslationMinX", "bool", "",0
            Property: "TranslationMinY", "bool", "",0
            Property: "TranslationMinZ", "bool", "",0
            Property: "TranslationMaxX", "bool", "",0
            Property: "TranslationMaxY", "bool", "",0
            Property: "TranslationMaxZ", "bool", "",0
            Property: "RotationOrder", "enum", "",0
            Property: "RotationSpaceForLimitOnly", "bool", "",0
            Property: "RotationStiffnessX", "double", "",0
            Property: "RotationStiffnessY", "double", "",0
            Property: "RotationStiffnessZ", "double", "",0
            Property: "AxisLen", "double", "",10
            Property: "PreRotation", "Vector3D", "",0,0,0
            Property: "PostRotation", "Vector3D", "",0,0,0
            Property: "RotationActive", "bool", "",1
            Property: "RotationMin", "Vector3D", "",0,0,0
            Property: "RotationMax", "Vector3D", "",0,0,0
            Property: "RotationMinX", "bool", "",0
            Property: "RotationMinY", "bool", "",0
            Property: "RotationMinZ", "bool", "",0
            Property: "RotationMaxX", "bool", "",0
            Property: "RotationMaxY", "bool", "",0
            Property: "RotationMaxZ", "bool", "",0
            Property: "InheritType", "enum", "",0
            Property: "ScalingActive", "bool", "",0
            Property: "ScalingMin", "Vector3D", "",1,1,1
            Property: "ScalingMax", "Vector3D", "",1,1,1
            Property: "ScalingMinX", "bool", "",0
            Property: "ScalingMinY", "bool", "",0
            Property: "ScalingMinZ", "bool", "",0
            Property: "ScalingMaxX", "bool", "",0
            Property: "ScalingMaxY", "bool", "",0
            Property: "ScalingMaxZ", "bool", "",0
            Property: "GeometricTranslation", "Vector3D", "",0,0,0
            Property: "GeometricRotation", "Vector3D", "",0,0,0
            Property: "GeometricScaling", "Vector3D", "",1,1,1
            Property: "MinDampRangeX", "double", "",0
            Property: "MinDampRangeY", "double", "",0
            Property: "MinDampRangeZ", "double", "",0
            Property: "MaxDampRangeX", "double", "",0
            Property: "MaxDampRangeY", "double", "",0
            Property: "MaxDampRangeZ", "double", "",0
            Property: "MinDampStrengthX", "double", "",0
            Property: "MinDampStrengthY", "double", "",0
            Property: "MinDampStrengthZ", "double", "",0
            Property: "MaxDampStrengthX", "double", "",0
            Property: "MaxDampStrengthY", "double", "",0
            Property: "MaxDampStrengthZ", "double", "",0
            Property: "PreferedAngleX", "double", "",0
            Property: "PreferedAngleY", "double", "",0
            Property: "PreferedAngleZ", "double", "",0
            Property: "LookAtProperty", "object", ""
            Property: "UpVectorProperty", "object", ""
            Property: "Show", "bool", "",1
            Property: "NegativePercentShapeSupport", "bool", "",1
            Property: "DefaultAttributeIndex", "int", "",0
            Property: "Lcl Translation", "Lcl Translation", "A+",0,0,0
            Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0
            Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1
            Property: "Visibility", "Visibility", "A+",1
            Property: "Color", "ColorRGB", "N",0.8,0.8,0.8
            Property: "BBoxMin", "Vector3D", "N",0,0,0
            Property: "BBoxMax", "Vector3D", "N",0,0,0
        }
        MultiLayer: 0
        MultiTake: 1
        Shading: Y
        Culling: "CullingOff"
        Vertices: -100,100,100,-100,-100,100,100,100,100,100,-100,100,100,100,-100,100,-100,-100,-100,100,-100,-100,-100,-100
        PolygonVertexIndex: 1,3,-3,0,1,-3,3,5,-5,2,3,-5,5,7,-7,4,5,-7,7,1,-1,6,7,-1,0,2,-5,6,0,-5,7,5,-4,1,7,-4
        GeometryVersion: 124
        LayerElementNormal: 0 {
            Version: 101
            Name: "Face Vertex Normal"
            MappingInformationType: "ByPolygonVertex"
            ReferenceInformationType: "Direct"
            Normals: 0,0,1,0,0,1,0,0,1,-0,0,1,0,0,1,0,0,1,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,-1,0,0,-1,0,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,-0,1,0,-0,1,0,0,-1,0,0,-1,0,0,-1
             ,0,0,-1,0,0,-1,0,0,-1,0
        }
        LayerElementColor: 0 {
            Version: 101
            Name: ""
            MappingInformationType: "ByPolygonVertex"
            ReferenceInformationType: "IndexToDirect"
            Colors: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
             ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
             ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
            ColorIndex: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
        }
        LayerElementMaterial: 0 {
            Version: 101
            Name: ""
            MappingInformationType: "AllSame"
            ReferenceInformationType: "IndexToDirect"
            Materials: 0
        }
        Layer: 0 {
            Version: 100
            LayerElement:  {
                Type: "LayerElementNormal"
                TypedIndex: 0
            }
            LayerElement:  {
                Type: "LayerElementMaterial"
                TypedIndex: 0
            }
            LayerElement:  {
                Type: "LayerElementColor"
                TypedIndex: 0
            }
        }
        NodeAttributeName: "Geometry::obj1_ncl1_1"
    }
    SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
        Type: "UserData"
        Version: 100
        MetaData:  {
            Version: 100
            Title: ""
            Subject: ""
            Author: ""
            Keywords: ""
            Revision: ""
            Comment: ""
        }
        Properties60:  {
            Property: "DocumentUrl", "KString", "", "C:\Users\OWNER\Desktop\test.fbx"
            Property: "SrcDocumentUrl", "KString", "", "C:\Users\OWNER\Desktop\test.fbx"
            Property: "Original", "Compound", ""
            Property: "Original|ApplicationVendor", "KString", "", ""
            Property: "Original|ApplicationName", "KString", "", ""
            Property: "Original|ApplicationVersion", "KString", "", ""
            Property: "Original|DateTime_GMT", "DateTime", "", ""
            Property: "Original|FileName", "KString", "", ""
            Property: "LastSaved", "Compound", ""
            Property: "LastSaved|ApplicationVendor", "KString", "", ""
            Property: "LastSaved|ApplicationName", "KString", "", ""
            Property: "LastSaved|ApplicationVersion", "KString", "", ""
            Property: "LastSaved|DateTime_GMT", "DateTime", "", ""
        }
    }
    Material: "Material::Default", "" {
        Version: 102
        ShadingModel: "phong"
        MultiLayer: 0
        Properties60:  {
            Property: "ShadingModel", "KString", "", "Phong"
            Property: "MultiLayer", "bool", "",0
            Property: "EmissiveColor", "ColorRGB", "",0,0,0
            Property: "EmissiveFactor", "double", "",1
            Property: "AmbientColor", "ColorRGB", "",0.600000023841858,0.600000023841858,0.600000023841858
            Property: "AmbientFactor", "double", "",1
            Property: "DiffuseColor", "ColorRGB", "",0.800000011920929,0.800000011920929,0.800000011920929
            Property: "DiffuseFactor", "double", "",1
            Property: "Bump", "Vector3D", "",0,0,0
            Property: "NormalMap", "Vector3D", "",0,0,0
            Property: "BumpFactor", "double", "",1
            Property: "TransparentColor", "ColorRGB", "",0,0,0
            Property: "TransparencyFactor", "double", "",1
            Property: "SpecularColor", "ColorRGB", "",0,0,0
            Property: "SpecularFactor", "double", "",1
            Property: "ShininessExponent", "double", "",5
            Property: "ReflectionColor", "ColorRGB", "",0,0,0
            Property: "ReflectionFactor", "double", "",1
            Property: "Emissive", "Vector3D", "",0,0,0
            Property: "Ambient", "Vector3D", "",0.600000023841858,0.600000023841858,0.600000023841858
            Property: "Diffuse", "Vector3D", "",0.800000011920929,0.800000011920929,0.800000011920929
            Property: "Specular", "Vector3D", "",0,0,0
            Property: "Shininess", "double", "",5
            Property: "Opacity", "double", "",1
            Property: "Reflectivity", "double", "",0
        }
    }
    GlobalSettings:  {
        Version: 1000
        Properties60:  {
            Property: "UpAxis", "int", "",1
            Property: "UpAxisSign", "int", "",1
            Property: "FrontAxis", "int", "",2
            Property: "FrontAxisSign", "int", "",1
            Property: "CoordAxis", "int", "",0
            Property: "CoordAxisSign", "int", "",1
            Property: "UnitScaleFactor", "double", "",1
        }
    }
}

; Object connections
;------------------------------------------------------------------

Connections:  {
    Connect: "OO", "Model::obj1", "Model::Scene"
    Connect: "OO", "Material::Default", "Model::obj1"
}
;Takes and animation section
;----------------------------------------------------

Takes:  {
    Current: ""
}
;Version 5 settings
;------------------------------------------------------------------

Version5:  {
    AmbientRenderSettings:  {
        Version: 101
        AmbientLightColor: 0.4,0.4,0.4,0
    }
    FogOptions:  {
        FlogEnable: 0
        FogMode: 0
        FogDensity: 0.002
        FogStart: 0.3
        FogEnd: 1000
        FogColor: 1,1,1,1
    }
    Settings:  {
        FrameRate: "30"
        TimeFormat: 1
        SnapOnFrames: 0
        ReferenceTimeIndex: -1
        TimeLineStartTime: 0
        TimeLineStopTime: 46186158000
    }
    RendererSetting:  {
        DefaultCamera: ""
        DefaultViewingMode: 0
    }
}

このようになりました。
非常に冗長かつ、一見、必要なさそうな記述が大量にあります。
これは異なるソフト間でなるべくデータの互換性を高めるためのものです。
頑張れば、ASCII形式のパーサーを作る事もできるかもしれませんが
バージョン間の違いなどに対応するのは面倒なので素直に FBX SDK を使いましょう。
では次回の読み込み編で読み込んでみます。

 

最終更新:2011年04月17日 23:54