コード例 #1
0
ファイル: Light.cs プロジェクト: oguna/AssimpSharp
        public Light(ulong id, Element element, Document doc, string name)
            : base(id, element, doc, name)
        {
            Color = new SimpleProperty<Vector3>(Props, "Color", new Vector3(1, 1, 1));
            LightType = new SimpleProperty<Type>(Props, "LightType", (Type)0);
            CastLightOnObject = new SimpleProperty<bool>(Props, "CastLightOnObject", false);
            DrawVolumetricLight = new SimpleProperty<bool>(Props, "DrawVolumetricLight", true);
            DrawGroundProjection = new SimpleProperty<bool>(Props, "DrawGroundProjection", true);
            DrawFrontFacingVolumetricLight = new SimpleProperty<bool>(Props, "DrawFrontFacingVolumetricLight", false);
            Intensity = new SimpleProperty<float>(Props, "Intensity", 1.0f);
            InnerAngle = new SimpleProperty<float>(Props, "InnerAngle", 0.0f);
            OuterAngle = new SimpleProperty<float>(Props, "OuterAngle", 45.0f);
            Fog = new SimpleProperty<int>(Props, "Fog", 50);
            DecayType = new SimpleProperty<Decay>(Props, "DecayType", (Decay)0);
            DecayStart = new SimpleProperty<int>(Props, "DecayStart", 0);
            FileName = new SimpleProperty<string>(Props, "FileName", "");

            EnableNearAttenuation = new SimpleProperty<bool>(Props, "EnableNearAttenuation", false);
            NearAttenuationStart = new SimpleProperty<float>(Props, "NearAttenuationStart", 0f);
            NearAttenuationEnd = new SimpleProperty<float>(Props, "NearAttenuationEnd", 0f);
            EnableFarAttenuation = new SimpleProperty<bool>(Props, "EnableFarAttenuation", false);
            FarAttenuationStart = new SimpleProperty<float>(Props, "FarAttenuationStart", 0f);
            FarAttenuationEnd = new SimpleProperty<float>(Props, "FarAttenuationEnd", 0f);

            CastShadow = new SimpleProperty<bool>(Props, "CastShadows", true);
            ShadowColor = new SimpleProperty<Vector3>(Props, "ShadowColor", new Vector3(0, 0, 0));

            AreaLightShape = new SimpleProperty<int>(Props, "AreaLightShape", 0);

            LeftBarnDoor = new SimpleProperty<float>(Props, "LeftBarnDoor", 20.0f);
            RightBarnDoor = new SimpleProperty<float>(Props, "RightBarnDoor", 20.0f);
            TopBarnDoor = new SimpleProperty<float>(Props, "TopBarnDoor", 20.0f);
            BottomBarnDoor = new SimpleProperty<float>(Props, "BottomBarnDoor", 20.0f);
            EnableBarnDoor = new SimpleProperty<bool>(Props, "EnableBarnDoor", true);
        }
コード例 #2
0
ファイル: Deformer.cs プロジェクト: oguna/AssimpSharp
 public Deformer(ulong id, Element element, Document doc, string name)
     : base(id, element, name)
 {
     var sc = Parser.GetRequiredScope(element);
     var classname = Parser.ParseTokenAsString(Parser.GetRequiredToken(element, 2));
     Props = DocumentUtil.GetPropertyTable(doc, "Deformer.Fbx" + classname, element, sc, true);
 }
コード例 #3
0
ファイル: PropertyTable.cs プロジェクト: oguna/AssimpSharp
        public PropertyTable(Element element, PropertyTable templateProps)
        {
            this.templateProps = templateProps;
            this.element = element;

            Scope scope = Parser.GetRequiredScope(element);
            foreach(var i in scope.Elements)
            {
                if (i.Key != "P")
                {
                    Console.Error.WriteLine("expected only P elements in property table");
                    continue;
                }
                foreach (var j in i.Value)
                {
                    string name = PeekPropertyName(j);
                    if (name.Length == 0)
                    {
                        Console.Error.WriteLine("could not read property name");
                        continue;
                    }
                    if (lazyProps.ContainsKey(name))
                    {
                        Console.Error.WriteLine("duplicate property name, will hide previous value: " + name);
                        continue;
                    }
                    lazyProps[name] = j;
                }
            }
        }
コード例 #4
0
ファイル: NodeAttribute.cs プロジェクト: oguna/AssimpSharp
 public NodeAttribute(ulong id, Element element, Document doc, string name)
     : base(id, element, name)
 {
     var sc = Parser.GetRequiredScope(element);
     var classname = Parser.ParseTokenAsString(Parser.GetRequiredToken(element, 2));
     var isNullOrLimb = (classname == "Null") || (classname == "LimbNode");
     props = DocumentUtil.GetPropertyTable(doc, "NodeAttribute.Fbx" + classname, element, sc, isNullOrLimb);
 }
コード例 #5
0
ファイル: AnimationLayer.cs プロジェクト: oguna/AssimpSharp
        /// <summary>
        /// Represents a FBX animation layer (i.e. a list of node animations)
        /// </summary>
        public AnimationLayer(ulong id, Element element, string name, Document doc)
            : base(id, element, name)
        {
            this.doc = doc;
            var sc = Parser.GetRequiredScope(element);

            // note: the props table here bears little importance and is usually absent
            this.props = DocumentUtil.GetPropertyTable(doc, "AnimationLayer.FbxAnimLayer", element, sc, true);
        }
コード例 #6
0
ファイル: DomException.cs プロジェクト: oguna/AssimpSharp
 public DomException(string message, Element element = null)
     : base(message)
 {
     if (element != null)
     {
         throw (new DomException(message, element.KeyToken));
     }
     throw (new Exception("FBX-DOM " + message));
 }
コード例 #7
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
 public static Element GetRequiredElement(Scope sc, string index, Element element = null)
 {
     Element el = sc[index];
     if (el == null)
     {
         throw (new Exception());
     }
     return el;
 }
コード例 #8
0
ファイル: Texture.cs プロジェクト: oguna/AssimpSharp
        public Texture(ulong id, Element element, Document doc, string name)
            : base(id, element, name)
        {
            uvScaling = new Vector2(1, 1);

            var sc = Parser.GetRequiredScope(element);
            var Type = sc["Type"];
            var FileName = sc["FileName"];
            var RelativeFilename = sc["RelativeFilename"];
            var ModelUVTranslation = sc["ModelUVTranslation"];
            var ModelUVScaling = sc["ModelUVScaling"];
            var Texture_Alpha_Source = sc["Texture_Alpha_Source"];
            var Cropping = sc["Cropping"];

            if (Type != null)
            {
                type = Parser.ParseTokenAsString(Parser.GetRequiredToken(Type, 0));
            }
            if (FileName != null)
            {
                fileName = Parser.ParseTokenAsString(Parser.GetRequiredToken(FileName, 0));
            }
            if (RelativeFilename != null)
            {
                relativeFileName = Parser.ParseTokenAsString(Parser.GetRequiredToken(RelativeFilename, 0));
            }
            if (ModelUVTranslation != null)
            {
                uvTrans = new Vector2(Parser.ParseTokenAsFloat(Parser.GetRequiredToken(ModelUVTranslation, 0)), Parser.ParseTokenAsFloat(Parser.GetRequiredToken(ModelUVTranslation, 1)));
            }
            if (ModelUVScaling != null)
            {
                uvTrans = new Vector2(Parser.ParseTokenAsFloat(Parser.GetRequiredToken(ModelUVScaling, 0)), Parser.ParseTokenAsFloat(Parser.GetRequiredToken(ModelUVScaling, 1)));
            }
            if (Cropping != null)
            {
                uint i1 = (uint)Parser.ParseTokenAsInt(Parser.GetRequiredToken(Cropping, 0));
                uint i2 = (uint)Parser.ParseTokenAsInt(Parser.GetRequiredToken(Cropping, 1));
                uint i3 = (uint)Parser.ParseTokenAsInt(Parser.GetRequiredToken(Cropping, 2));
                uint i4 = (uint)Parser.ParseTokenAsInt(Parser.GetRequiredToken(Cropping, 3));
                crop = new Tuple<uint, uint, uint, uint>(i1, i2, i3, i4);
            }
            else
            {
                crop = new Tuple<uint, uint, uint, uint>(0, 0, 0, 0);
            }
            if (Texture_Alpha_Source != null)
            {
                alphaSource = Parser.ParseTokenAsString(Parser.GetRequiredToken(Texture_Alpha_Source, 0));
            }
            props = DocumentUtil.GetPropertyTable(doc, "Texture.FbxFileTexture", element, sc);
        }
コード例 #9
0
ファイル: Geometry.cs プロジェクト: oguna/AssimpSharp
 public Geometry(ulong id, Element element, string name, Document doc)
     : base(id, element, name)
 {
     var conns = doc.GetConnectionsByDestinationSequenced(ID, "Deformer");
     foreach (var con in conns)
     {
         var sk = DocumentUtil.ProcessSimpleConnection<Skin>(con, false, "Skin -> Geometry", element);
         if (sk != null)
         {
             skin = sk;
             break;
         }
     }
 }
コード例 #10
0
ファイル: Camera.cs プロジェクト: oguna/AssimpSharp
 public Camera(ulong id, Element element, Document doc, string name)
     : base(id, element, doc, name)
 {
     Position = new SimpleProperty<Vector3>(Props, "Position", new Vector3(0, 0, 0));
     UpVector = new SimpleProperty<Vector3>(Props, "UpVector", new Vector3(0, 1, 0));
     InterestPosition = new SimpleProperty<Vector3>(Props, "InterestPosition", new Vector3(0, 0, 0));
     AspectWidth = new SimpleProperty<float>(Props, "AspectWidth", 1.0f);
     AspectHeight = new SimpleProperty<float>(Props, "AspectHeight", 1.0f);
     FilmWidth = new SimpleProperty<float>(Props, "FilmWidth", 1.0f);
     FilmHeight = new SimpleProperty<float>(Props, "FilmHeight", 1.0f);
     FilmAspectRatio = new SimpleProperty<float>(Props, "FilmAspectRatio", 1.0f);
     ApertureMode = new SimpleProperty<int>(Props, "ApertureMode", 0);
     FieldOfView = new SimpleProperty<float>(Props, "FieldOfView", 1.0f);
     FocalLength = new SimpleProperty<float>(Props, "FocalLength", 1.0f);
 }
コード例 #11
0
ファイル: Cluster.cs プロジェクト: oguna/AssimpSharp
        public Cluster(ulong id, Element element, Document doc, string name)
            : base(id, element, doc, name)
        {
            var sc = Parser.GetRequiredScope(element);
            var Indexes = sc["Indexes"];
            var Weights = sc["Weights"];
            var Transform = Parser.GetRequiredElement(sc, "Transform", element);
            var TransformLink = Parser.GetRequiredElement(sc, "Transform", element);
            this.Transform = Parser.ReadMatrix(Transform);
            this.TransformLink = Parser.ReadMatrix(TransformLink);

            // it is actually possible that there be Deformer's with no weights
            if ((Indexes == null) != (Weights == null))
            {
                throw (new DomException("either Indexes or Weights are missing from Cluster", element));
            }
            if (Indexes != null)
            {
                List<uint> indices;
                List<float> weights;
                Parser.ParseVectorDataArray(out indices, Indexes);
                Parser.ParseVectorDataArray(out weights, Weights);
                this.Indices = indices;
                this.Weights = weights;
            }
            if (this.Indices.Count != this.Weights.Count)
            {
                throw (new DomException("sizes of index and weight array don't match up", element));
            }

            // read assigned node
            var conns = doc.GetConnectionsByDestinationSequenced(ID, "Model");
            foreach (var con in conns)
            {
                var mod = DocumentUtil.ProcessSimpleConnection<Model>(con, false, "Model -> Cluster", element);
                if (mod != null)
                {
                    this.TargetNode = mod;
                    break;
                }
            }
            if (this.TargetNode == null)
            {
                throw (new DomException("failed to read target Node for Cluster", element));
            }
        }
コード例 #12
0
ファイル: LayeredTexture.cs プロジェクト: oguna/AssimpSharp
        public LayeredTexture(ulong id, Element element, Document doc, string name)
            : base(id, element, name)
        {
            texture = null;
            blendMode = Blend.Modulate;
            alpha = 1;

            var sc = Parser.GetRequiredScope(element);
            var BlendModes = sc["BlendModes"];
            var Alphas = sc["Alphas"];
            if (BlendModes != null)
            {
                blendMode = (Blend)Parser.ParseTokenAsInt(Parser.GetRequiredToken(BlendModes, 0));
            }
            if (Alphas != null)
            {
                alpha = Parser.ParseTokenAsFloat(Parser.GetRequiredToken(Alphas, 0));
            }
        }
コード例 #13
0
ファイル: CameraSwicher.cs プロジェクト: oguna/AssimpSharp
 public CameraSwicher(ulong id, Element element, Document doc, string name)
     : base(id, element, doc, name)
 {
     var sc = Parser.GetRequiredScope(element);
     var CameraId = sc["CameraId"];
     var CameraName = sc["CameraName"];
     var CameraIndexName = sc["CameraIndexName"];
     if (CameraId != null)
     {
         cameraId = Parser.ParseTokenAsInt(Parser.GetRequiredToken(CameraId, 0));
     }
     if (CameraName != null)
     {
         cameraName = Parser.GetRequiredToken(CameraName, 0).StringContents;
     }
     if (CameraIndexName != null && CameraIndexName.Tokens.Count > 0)
     {
         cameraIndexName = Parser.GetRequiredToken(CameraIndexName, 0).StringContents;
     }
 }
コード例 #14
0
ファイル: Skin.cs プロジェクト: oguna/AssimpSharp
 public Skin(ulong id, Element element, Document doc, string name)
     : base(id, element, doc, name)
 {
     var sc = Parser.GetRequiredScope(element);
     var LinkDeformAcuracy = sc["Link_DeformAcuracy"];
     if (LinkDeformAcuracy != null)
     {
         DeformAccuracy = Parser.ParseTokenAsFloat(Parser.GetRequiredToken(LinkDeformAcuracy, 0));
     }
     var conns = doc.GetConnectionsByDestinationSequenced(ID, "Deformer");
     Clusters = new List<Cluster>(conns.Count);
     foreach (var con in conns)
     {
         var cluster = DocumentUtil.ProcessSimpleConnection<Cluster>(con, false, "Cluster -> Skin", element);
         if (cluster != null)
         {
             Clusters.Add(cluster);
             continue;
         }
     }
 }
コード例 #15
0
ファイル: AnimationStack.cs プロジェクト: oguna/AssimpSharp
        public AnimationStack(ulong id, Element element, string name, Document doc)
            : base(id, element, name)
        {
            var sc = Parser.GetRequiredScope(element);

            // note: we don't currently use any of these properties so we shouldn't bother if it is missing
            props = DocumentUtil.GetPropertyTable(doc, "AnimationStack.FbxAnimStack", element, sc, true);

            // resolve attached animation layers
            var conns = doc.GetConnectionsByDestinationSequenced(ID, "AnimationLayer");
            layers = new List<AnimationLayer>(conns.Count);
            foreach (var con in conns)
            {
                // link should not go to a property
                if (!string.IsNullOrEmpty(con.PropertyName))
                {
                    continue;
                }
                var ob = con.SourceObject;
                if (ob == null)
                {
                    DocumentUtil.DOMWarning("failed to read source object for AnimationLayer->AnimationStack link, ignoring", element);
                    continue;
                }
                var anim = ob as AnimationLayer;
                if (anim == null)
                {
                    DocumentUtil.DOMWarning("source object for ->AnimationStack link is not an AnimationLayer", element);
                    continue;
                }
                layers.Add(anim);
            }

            LocalStart = new SimpleProperty<long>(props, "LocalStart", 0);
            LocalStop = new SimpleProperty<long>(props, "LocalStop", 0);
            ReferenceStart = new SimpleProperty<long>(props, "ReferenceStart", 0);
            ReferenceStop = new SimpleProperty<long>(props, "ReferenceStop", 0);
        }
コード例 #16
0
ファイル: AnimationCurve.cs プロジェクト: oguna/AssimpSharp
        public AnimationCurve(ulong id, Element element, string name, Document doc)
            : base(id, element, name)
        {
            var sc = Parser.GetRequiredScope(element);
            var KeyTime = Parser.GetRequiredElement(sc, "KeyTime");
            var KeyValueFloat = Parser.GetRequiredElement(sc, "KeyValueFloat");

            Parser.ParseVectorDataArray(out this.keys, KeyTime);
            Parser.ParseVectorDataArray(out this.values, KeyValueFloat);

            if (keys.Count != values.Count)
            {
                DocumentUtil.DOMError("the number of key times does not match the number of keyframe values", KeyTime);
            }

            // check if the key times are well-ordered
            for (int i = 0; i < keys.Count - 1; i++)
            {
                if (keys[i] > keys[i + 1])
                {
                    DocumentUtil.DOMError("the keyframes are not in ascending order", KeyTime);
                }
            }

            var keyAttrDataFloat = sc["KeyAttrDataFloat"];
            if (keyAttrDataFloat != null)
            {
                Parser.ParseVectorDataArray(out attributes, keyAttrDataFloat);
            }

            var keyAttrFlags = sc["KeyAttrFlags"];
            if (keyAttrFlags != null)
            {
                Parser.ParseVectorDataArray(out flags, keyAttrFlags);
            }
        }
コード例 #17
0
ファイル: PropertyTable.cs プロジェクト: oguna/AssimpSharp
 public static string PeekPropertyName(Element element)
 {
     List<Token> tok = element.Tokens;
     if (tok.Count < 4)
     {
         return "";
     }
     return Parser.ParseTokenAsString(tok[0]);
 }
コード例 #18
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
 /// <summary>
 /// read the type code and element count of a binary data array and stop there
 /// </summary>
 private static void ReadBinaryDataArrayHead(byte[] data, ref int cursor, int end, out char type, out uint count, Element el)
 {
     if (end - cursor < 5)
     {
         throw (new ParseException("binary data array is too short, need five (5) bytes for type signature and element count", el));
     }
     type = (char)data[cursor];
     uint len = BitConverter.ToUInt32(data, cursor + 1);
     count = len;
     cursor += 5;
 }
コード例 #19
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
 public static Scope GetRequiredScope(Element el)
 {
     Scope s = el.Compound;
     if (s == null)
     {
         throw (new Exception("expected compound scope"));
     }
     return s;
 }
コード例 #20
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
        /// <summary>
        /// read binary data array, assume cursor points to the 'compression mode' field (i.e. behind the header)
        /// </summary>
        private static void ReadBinaryDataArray(char type, uint count, byte[] data, ref int cursor, int end, out byte[] buff, Element el)
        {
            uint encmode = BitConverter.ToUInt32(data, cursor);
            cursor += 4;

            // next comes the compressed length
            uint compLen = BitConverter.ToUInt32(data, cursor);
            cursor += 4;

            Debug.Assert(cursor + compLen == end);

            // determine the length of the uncompressed data by looking at the type signature
            uint stride = 3;
            switch (type)
            {
                case 'f':
                case 'i':
                    stride = 4;
                    break;
                case 'd':
                case 'l':
                    stride = 8;
                    break;
                default:
                    Debug.Assert(false);
                    break;
            }

            uint fullLength = stride * count;
            buff = new byte[fullLength];

            if (encmode == 0)
            {
                Debug.Assert(fullLength == compLen);

                // plain data, no compression
                Array.Copy(data, cursor, buff, 0, fullLength);
            }
            else if (encmode == 1)
            {
                // zlib/deflate, next comes ZIP head (0x78 0x01)
                // see http://www.ietf.org/rfc/rfc1950.txt

                var stream = new MemoryStream(data, cursor, data.Length);
                var zstream = new DeflateStream(stream, CompressionMode.Decompress);
                try {
                    int ret = zstream.Read(buff, 0, buff.Length);
                }
                    catch (Exception e)
                {
                    throw (new ParseException("failure decompressing compressed data section"));
                }
            }
            else
            {
                Debug.Assert(false);
            }

            cursor += (int)compLen;
            Debug.Assert(cursor == end);
        }
コード例 #21
0
ファイル: PropertyTable.cs プロジェクト: oguna/AssimpSharp
 public PropertyTable()
 {
     this.templateProps = null;
     this.element = null;
 }
コード例 #22
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
        public static void ParseVectorDataArray(out List<ulong> result, Element el)
        {
            var tok = el.Tokens;
            if (tok.Count == 0)
            {
                throw (new ParseException("unexpected empty element", el));
            }
            if (tok[0].IsBinary)
            {
                throw (new NotImplementedException());
            }
            int dim = (int)Parser.ParseTokenAsDim(tok[0]);

            result = new List<ulong>(dim);
            Scope scope = Parser.GetRequiredScope(el);
            Element a = Parser.GetRequiredElement(scope, "a", el);
            foreach (var it in a.Tokens)
            {
                ulong ival = Parser.ParseTokenAsID(it);
                result.Add(ival);
            }
        }
コード例 #23
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
 public static Matrix ReadMatrix(Element element)
 {
     List<float> values;
     Parser.ParseVectorDataArray(out values, element);
     if (values.Count != 16)
     {
         throw (new Exception("expected 16 matrix elements"));
     }
     Matrix result = new Matrix(values.ToArray());
     result.Transpose();
     return result;
 }
コード例 #24
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
        /// <summary>
        /// read an array of float2 tuples
        /// </summary>
        public static void ParseVectorDataArray(out List<Vector2> result, Element el)
        {
            result = new List<Vector2>();
            List<Token> tok = el.Tokens;
            if (tok.Count == 0)
            {
                throw (new ParseException("unexpected empty element", el));
            }
            if (tok[0].IsBinary)
            {
                var data = tok[0].BinaryContents;
                var end = tok[0].End;
                char type;
                uint count;
                int cursor = 0;
                ReadBinaryDataArrayHead(data, ref cursor, end, out type, out count, el);

                if (count % 2 != 0)
                {
                    throw (new ParseException("number of floats is not a multiple of two (2) (binary)", el));
                }

                if (count == 0)
                {
                    return;
                }

                if (type != 'd' && type != 'f')
                {
                    throw (new ParseException("expected float or double array (binary)", el));
                }

                byte[] buff;
                ReadBinaryDataArray(type, count, data, ref cursor, end, out buff, el);

                Debug.Assert(cursor == end);
                Debug.Assert(buff.Length == count * (type == 'd' ? 8 : 4));

                uint count2 = count / 2;
                result = new List<Vector2>((int)count2);

                if (type == 'd')
                {
                    int d = 0;
                    for (int i = 0; i < count2; i++, d += 2 * 8)
                    {
                        result.Add(new Vector2((float)BitConverter.ToDouble(buff, 0 + d), (float)BitConverter.ToDouble(buff, 8 + d)));
                    }
                }
                else if (type == 'f')
                {
                    int f = 0;
                    for (int i = 0; i < count2; i++, f += 2 * 4)
                    {
                        result.Add(new Vector2(BitConverter.ToSingle(buff, 0 + f), BitConverter.ToSingle(buff, 4 + f)));
                    }
                }
                return;
            }

            ulong dim = Parser.ParseTokenAsDim(tok[0]);
            result = new List<Vector2>((int)dim);
            Scope scope = Parser.GetRequiredScope(el);
            Element a = Parser.GetRequiredElement(scope, "a", el);
            if (a.Tokens.Count % 2 != 0)
            {
                throw (new ParseException("number of floats is not a multiple of two (2)", el));
            }
            for (int i = 0; i < a.Tokens.Count;)
            {
                Vector2 v = new Vector2();
                v.X = Parser.ParseTokenAsFloat(a.Tokens[i++]);
                v.Y = Parser.ParseTokenAsFloat(a.Tokens[i++]);
                result.Add(v);
            }
        }
コード例 #25
0
ファイル: Parser.cs プロジェクト: oguna/AssimpSharp
 public static Token GetRequiredToken(Element el, int index)
 {
     List<Token> t = el.Tokens;
     if (index >= t.Count)
     {
         throw (new Exception("missing token at index "));
     }
     return t[index];
 }
コード例 #26
0
ファイル: Null.cs プロジェクト: oguna/AssimpSharp
 public Null(ulong id, Element element, Document doc, string name)
     : base(id, element, doc, name)
 {
 }
コード例 #27
0
ファイル: Model.cs プロジェクト: oguna/AssimpSharp
        public Model(ulong id, Element element, Document doc, string name)
            : base(id, element, name)
        {
            shading = "Y";
            var sc = Parser.GetRequiredScope(element);
            var Shading = sc["Shading"];
            var Culling = sc["Culling"];
            if (Shading != null)
            {
                shading = Parser.GetRequiredToken(Shading, 0).StringContents;
            }
            if (Culling != null)
            {
                culling = Parser.ParseTokenAsString(Parser.GetRequiredToken(Culling, 0));
            }
            props = DocumentUtil.GetPropertyTable(doc, "Model.FbxNode", element, sc);
            ResolveLink(element, doc);

            this.QuaternionInterpolate = new SimpleProperty<int>(this.Props, "QuaternionInterpolate", 0);

            this.RotationOrder = new SimpleProperty<RotOrder>(this.Props, "RotationOrder", (RotOrder)0);
            this.RotationOffset = new SimpleProperty<Vector3>(this.Props, "RotationOffset", new Vector3());
            this.RotationPivot = new SimpleProperty<Vector3>(this.Props, "RotationPivot", new Vector3());
            this.ScalingOffset = new SimpleProperty<Vector3>(this.Props, "ScalingOffset", new Vector3());
            this.ScalingPivot = new SimpleProperty<Vector3>(this.Props, "ScalingPivot", new Vector3());
            this.TranslationActive = new SimpleProperty<bool>(this.Props, "TranslationActive", false);

            this.TranslationMin = new SimpleProperty<Vector3>(this.Props, "TranslationMin", new Vector3());
            this.TranslationMax = new SimpleProperty<Vector3>(this.Props, "TranslationMax", new Vector3());

            this.TranslationMinX = new SimpleProperty<bool>(this.Props, "TranslationMinX", false);
            this.TranslationMaxX = new SimpleProperty<bool>(this.Props, "TranslationMaxX", false);
            this.TranslationMinY = new SimpleProperty<bool>(this.Props, "TranslationMinY", false);
            this.TranslationMaxY = new SimpleProperty<bool>(this.Props, "TranslationMaxY", false);
            this.TranslationMinZ = new SimpleProperty<bool>(this.Props, "TranslationMinZ", false);
            this.TranslationMaxZ = new SimpleProperty<bool>(this.Props, "TranslationMaxZ", false);

            this.RotationOrder = new SimpleProperty<RotOrder>(this.Props, "RotationOrder", (RotOrder)0);
            this.RotationSpaceForLimitOnly = new SimpleProperty<bool>(this.Props, "RotationSpaceForLimitOnly", false);
            this.RotationStiffnessX = new SimpleProperty<float>(this.Props, "RotationStiffnessX", 0.0f);
            this.RotationStiffnessY = new SimpleProperty<float>(this.Props, "RotationStiffnessY", 0.0f);
            this.RotationStiffnessZ = new SimpleProperty<float>(this.Props, "RotationStiffnessZ", 0.0f);
            this.AxisLen = new SimpleProperty<float>(this.Props, "AxisLen", 0.0f);

            this.PreRotation = new SimpleProperty<Vector3>(this.Props, "PreRotation", new Vector3());
            this.PostRotation = new SimpleProperty<Vector3>(this.Props, "PostRotation", new Vector3());
            this.RotationActive = new SimpleProperty<bool>(this.Props, "RotationActive", false);

            this.RotationMin = new SimpleProperty<Vector3>(this.Props, "RotationMin", new Vector3());
            this.RotationMax = new SimpleProperty<Vector3>(this.Props, "RotationMax", new Vector3());

            this.RotationMinX = new SimpleProperty<bool>(this.Props, "RotationMinX", false);
            this.RotationMaxX = new SimpleProperty<bool>(this.Props, "RotationMaxX", false);
            this.RotationMinY = new SimpleProperty<bool>(this.Props, "RotationMinY", false);
            this.RotationMaxY = new SimpleProperty<bool>(this.Props, "RotationMaxY", false);
            this.RotationMinZ = new SimpleProperty<bool>(this.Props, "RotationMinZ", false);
            this.RotationMaxZ = new SimpleProperty<bool>(this.Props, "RotationMaxZ", false);
            this.InheritType = new SimpleProperty<TransformInheritance>(this.Props, "InheritType", (TransformInheritance)0);

            this.ScalingActive = new SimpleProperty<bool>(this.Props, "ScalingActive", false);
            this.ScalingMin = new SimpleProperty<Vector3>(this.Props, "ScalingMin", new Vector3());
            this.ScalingMax = new SimpleProperty<Vector3>(this.Props, "ScalingMax", new Vector3(1.0f, 1.0f, 1.0f));
            this.ScalingMinX = new SimpleProperty<bool>(this.Props, "ScalingMinX", false);
            this.ScalingMaxX = new SimpleProperty<bool>(this.Props, "ScalingMaxX", false);
            this.ScalingMinY = new SimpleProperty<bool>(this.Props, "ScalingMinY", false);
            this.ScalingMaxY = new SimpleProperty<bool>(this.Props, "ScalingMaxY", false);
            this.ScalingMinZ = new SimpleProperty<bool>(this.Props, "ScalingMinZ", false);
            this.ScalingMaxZ = new SimpleProperty<bool>(this.Props, "ScalingMaxZ", false);

            this.GeometricTranslation = new SimpleProperty<Vector3>(this.Props, "GeometricTranslation", new Vector3());
            this.GeometricRotation = new SimpleProperty<Vector3>(this.Props, "GeometricRotation", new Vector3());
            this.GeometricScaling = new SimpleProperty<Vector3>(this.Props, "GeometricScaling", new Vector3(1.0f, 1.0f, 1.0f));

            this.MinDampRangeX = new SimpleProperty<float>(this.Props, "MinDampRangeX", 0.0f);
            this.MinDampRangeY = new SimpleProperty<float>(this.Props, "MinDampRangeY", 0.0f);
            this.MinDampRangeZ = new SimpleProperty<float>(this.Props, "MinDampRangeZ", 0.0f);
            this.MaxDampRangeX = new SimpleProperty<float>(this.Props, "MaxDampRangeX", 0.0f);
            this.MaxDampRangeY = new SimpleProperty<float>(this.Props, "MaxDampRangeY", 0.0f);
            this.MaxDampRangeZ = new SimpleProperty<float>(this.Props, "MaxDampRangeZ", 0.0f);

            this.MinDampStrengthX = new SimpleProperty<float>(this.Props, "MinDampStrengthX", 0.0f);
            this.MinDampStrengthY = new SimpleProperty<float>(this.Props, "MinDampStrengthY", 0.0f);
            this.MinDampStrengthZ = new SimpleProperty<float>(this.Props, "MinDampStrengthZ", 0.0f);
            this.MaxDampStrengthX = new SimpleProperty<float>(this.Props, "MaxDampStrengthX", 0.0f);
            this.MaxDampStrengthY = new SimpleProperty<float>(this.Props, "MaxDampStrengthY", 0.0f);
            this.MaxDampStrengthZ = new SimpleProperty<float>(this.Props, "MaxDampStrengthZ", 0.0f);

            this.PreferredAngleX = new SimpleProperty<float>(this.Props, "PreferredAngleX", 0.0f);
            this.PreferredAngleY = new SimpleProperty<float>(this.Props, "PreferredAngleY", 0.0f);
            this.PreferredAngleZ = new SimpleProperty<float>(this.Props, "PreferredAngleZ", 0.0f);

            this.Show = new SimpleProperty<bool>(this.Props, "Show", true);
            this.LODBox = new SimpleProperty<bool>(this.Props, "LODBox", false);
            this.Freeze = new SimpleProperty<bool>(this.Props, "Freeze", false);
        }
コード例 #28
0
ファイル: ParserException.cs プロジェクト: oguna/AssimpSharp
 public ParseException(string message, Element element)
     : base(Util.AddTokenText("FBX-Parsre", message, element.KeyToken))
 {
 }
コード例 #29
0
ファイル: Object.cs プロジェクト: oguna/AssimpSharp
 public Object(ulong id, Element element, string name)
 {
     this.element = element;
     this.name = name;
     this.id = id;
 }
コード例 #30
0
ファイル: Model.cs プロジェクト: oguna/AssimpSharp
 private void ResolveLink(Element element, Document doc)
 {
     var arr = new[] { "Geometry", "Material", "NodeAttribute" };
     var conns = doc.GetConnectionsByDestinationSequenced(ID, arr);
     materials = new List<Material>(conns.Count);
     geometry = new List<Geometry>(conns.Count);
     attributes = new List<NodeAttribute>(conns.Count);
     foreach (var con in conns)
     {
         if (con.PropertyName.Length > 0)
         {
             continue;
         }
         Object ob = con.SourceObject;
         if (ob == null)
         {
             Debug.WriteLine("failed to read source object for incoming Model link, ignoring");
             continue;
         }
         Material mat = ob as Material;
         if (mat != null)
         {
             materials.Add(mat);
             continue;
         }
         Geometry geo = ob as Geometry;
         if (geo != null)
         {
             geometry.Add(geo);
             continue;
         }
         NodeAttribute att = ob as NodeAttribute;
         if (att != null)
         {
             attributes.Add(att);
             continue;
         }
         Debug.WriteLine("source object for model link is neither Material, NodeAttribute nor Geometry, ignoring");
         continue;
     }
 }