Beispiel #1
0
        public FBXTreeNode(FBXFileNode node, FBXFile file, FBXTreeNode parent = null)
        {
            Node = node;

            var nodeId = (Node != null) ? Node.Id : 0;

            var nodeConns = file.Connections.Where(a => a.Dst == nodeId);

            foreach (var con in nodeConns)
            {
                var childNode = file.FindChild(con.Src);

                if (childNode != null)
                {
                    Children.Add((new FBXTreeNode(childNode, file, this)));
                }
            }
        }
Beispiel #2
0
        public Model(FBXFileNode node, FBXFile fbx)
        {
            Id   = node.Id;
            Name = ((string)node.Properties[1].Data);

            HasGeometry = node.Nodes.Where(a => a.Name == "Geometry").Count() > 0;

            switch ((string)node.Properties[2].Data)
            {
            case "Mesh":
                ModelType = FBXModelType.Mesh;
                break;

            case "LimbNode":
                ModelType = FBXModelType.LimbNode;
                break;
            }

            var propNode       = node.Nodes.Where(a => a.Name == "Properties70").FirstOrDefault();
            var rotationActive = true;

            // if(fbx.GlobalSettings != null && fbx.GlobalSettings.UnitScaleFactor != 0)
            //     Scaling = Scaling.SetScalingPart((float)fbx.GlobalSettings.UnitScaleFactor, (float)fbx.GlobalSettings.UnitScaleFactor, (float)fbx.GlobalSettings.UnitScaleFactor);

            if (propNode != null)
            {
                foreach (var child in propNode.Nodes)
                {
                    if (child.Name == "P")
                    {
                        var property = (string)child.Properties[0].Data;

                        switch (property)
                        {
                        case "PreRotation":
                            PreRotation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "Lcl Rotation":
                            LclRotation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "RotationActive":
                            rotationActive = (int)child.Properties[4].Data == 1;
                            break;

                        case "Lcl Translation":
                            LclTranslation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "Lcl Scaling":
                            LclScaling = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "PostRotation":
                            PostRotation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "GeometricTranslation":
                            GeometricTranslation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "GeometricScaling":
                            GeometricScaling = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "GeometricRotation ":
                            GeometricRotation = new float[]
                            {
                                (float)(double)child.Properties[4].Data,
                                (float)(double)child.Properties[5].Data,
                                (float)(double)child.Properties[6].Data
                            };
                            break;

                        case "InheritType":
                            InheritType = (InheritTypeOption)child.Properties[4].Data;
                            break;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public GlobalSettings(FBXFile fbx)
        {
            var globalNode = fbx.Nodes.Where(a => a.Name == "GlobalSettings").FirstOrDefault();

            if (globalNode != null)
            {
                var versionNode = globalNode.Nodes.Where(a => a.Name == "Version").FirstOrDefault();

                if (versionNode != null)
                {
                    Version = (int)versionNode.Properties[0].Data;
                }

                var propNode = globalNode.Nodes.Where(a => a.Name == "Properties70").FirstOrDefault();

                if (propNode != null)
                {
                    foreach (var child in propNode.Nodes)
                    {
                        if (child.Name == "P")
                        {
                            var property = (string)child.Properties[0].Data;

                            switch (property)
                            {
                            case "UpAxis":
                                UpAxis = (int)child.Properties[4].Data;
                                break;

                            case "UpAxisSign":
                                UpAxisSign = (int)child.Properties[4].Data;
                                break;

                            case "FrontAxis":
                                FrontAxis = (int)child.Properties[4].Data;
                                break;

                            case "FrontAxisSign":
                                FrontAxisSign = (int)child.Properties[4].Data;
                                break;

                            case "CoordAxis":
                                CoordAxis = (int)child.Properties[4].Data;
                                break;

                            case "CoordAxisSign":
                                CoordAxisSign = (int)child.Properties[4].Data;
                                break;

                            case "OriginalUpAxis":
                                OriginalUpAxis = (int)child.Properties[4].Data;
                                break;

                            case "OriginalUpAxisSign":
                                OriginalUpAxisSign = (int)child.Properties[4].Data;
                                break;

                            case "UnitScaleFactor":
                                UnitScaleFactor = (double)child.Properties[4].Data;
                                break;

                            case "OriginalUnitScaleFactor":
                                OriginalUnitScaleFactor = (double)child.Properties[4].Data;
                                break;

                            case "TimeMode":
                                TimeMode = (TimeModeOption)child.Properties[4].Data;
                                break;

                            case "CustomFrameRate":
                                CustomFrameRate = (double)child.Properties[4].Data;
                                break;
                            }
                        }
                    }
                }
            }
        }