Пример #1
0
        public new static FbxConstraint Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxConstraint_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxConstraint         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxConstraint(cPtr, false);

            return(ret);
        }
Пример #2
0
        public new static FbxConstraint Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxConstraint_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxConstraint         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxConstraint(cPtr, false);

            return(ret);
        }
Пример #3
0
 public bool Equals(FbxConstraint other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }
Пример #4
0
        public new static FbxConstraint Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxConstraint_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxConstraint         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxConstraint(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #5
0
 /// <summary>
 /// Get the Fbx property name for the given Unity constraint source property name from the given dictionary.
 ///
 /// This is different from GetFbxProperty() because the Unity constraint source properties contain indices, and
 /// the Fbx constraint source property contains the name of the source object.
 /// </summary>
 /// <param name="uniProperty"></param>
 /// <param name="constraint"></param>
 /// <param name="propertyMap"></param>
 /// <returns>The Fbx property name or null if there was no match in the dictionary</returns>
 private static string GetFbxConstraintSourceProperty(string uniProperty, FbxConstraint constraint, Dictionary <string, string> propertyMap)
 {
     foreach (var prop in propertyMap)
     {
         var match = System.Text.RegularExpressions.Regex.Match(uniProperty, prop.Key);
         if (match.Success && match.Groups.Count > 0)
         {
             var matchedStr = match.Groups[1].Value;
             int index;
             if (!int.TryParse(matchedStr, out index))
             {
                 continue;
             }
             var source = constraint.GetConstraintSource(index);
             return(string.Format(prop.Value, source.GetName()));
         }
     }
     return(null);
 }
Пример #6
0
        protected override FbxScene CreateScene(FbxManager manager)
        {
            // Create a scene with a single node that has an animation clip
            // attached to it
            FbxScene scene = FbxScene.Create(manager, "myScene");

            FbxNode sourceNode      = FbxNode.Create(scene, "source");
            FbxNode constrainedNode = FbxNode.Create(scene, "constrained");

            scene.GetRootNode().AddChild(sourceNode);
            scene.GetRootNode().AddChild(constrainedNode);

            FbxConstraint posConstraint = CreatePositionConstraint(scene, sourceNode, constrainedNode);

            Assert.That(posConstraint, Is.Not.Null);

            bool result = posConstraint.ConnectDstObject(scene);

            Assert.That(result, Is.True);

            // animate weight + active
            // setup anim stack
            FbxAnimStack fbxAnimStack = CreateAnimStack(scene);

            // add an animation layer
            FbxAnimLayer fbxAnimLayer = FbxAnimLayer.Create(scene, "animBaseLayer");

            fbxAnimStack.AddMember(fbxAnimLayer);

            // set up the translation
            CreateAnimCurves(
                posConstraint, fbxAnimLayer, PropertyComponentList, (index) => { return(index * 2.0); }, (index) => { return(index * 3 - 2); }
                );

            // TODO: avoid needing to do this by creating typemaps for
            //       FbxObject::GetSrcObjectCount and FbxCast.
            //       Not trivial to do as both fbxobject.i and fbxemitter.i
            //       have to be moved up before the ignore all statement
            //       to allow use of templates.
            scene.SetCurrentAnimationStack(fbxAnimStack);
            return(scene);
        }
Пример #7
0
        /// <summary>
        /// Map a Unity property name to the corresponding FBX property and
        /// channel names.
        /// </summary>
        public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPair[] prop, FbxConstraint constraint = null)
        {
            prop = new FbxPropertyChannelPair[] { };

            // spot angle is a special case as it returns two channel pairs instead of one
            System.StringComparison ct = System.StringComparison.CurrentCulture;
            if (uniPropertyName.StartsWith("m_SpotAngle", ct))
            {
                prop = new FbxPropertyChannelPair[] {
                    new FbxPropertyChannelPair("OuterAngle", null),
                    new FbxPropertyChannelPair("InnerAngle", null)
                };
                return(true);
            }

            var propertyMaps = new List <PropertyChannelMap>();

            // Try get constraint specific channel pairs first as we know this is a constraint
            if (constraint != null)
            {
                // Aim constraint shares the RotationOffset property with RotationConstraint, so make sure that the correct FBX property is returned
                if (constraint.GetConstraintType() == FbxConstraint.EType.eAim)
                {
                    propertyMaps.Add(AimConstraintPropertyMap);
                }

                propertyMaps.Add(ConstraintSourcePropertyMap);
                propertyMaps.Add(ConstraintSourceTransformPropertyMap);
            }

            // Check if this is a transform, color, or other property and return the channel pairs if they match.
            propertyMaps.Add(TransformPropertyMap);
            propertyMaps.Add(ColorPropertyMap);
            propertyMaps.Add(OtherPropertyMap);

            foreach (var propMap in propertyMaps)
            {
                prop = GetChannelPairs(uniPropertyName, propMap, constraint);
                if (prop != null)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #8
0
        /// <summary>
        /// Try to get the property channel pairs for the given Unity property from the given property channel mapping.
        /// </summary>
        /// <param name="uniPropertyName"></param>
        /// <param name="propertyChannelMap"></param>
        /// <param name="constraint"></param>
        /// <returns>The property channel pairs or null if there was no match</returns>
        private static                             FbxPropertyChannelPair[] GetChannelPairs(string uniPropertyName, PropertyChannelMap propertyChannelMap, FbxConstraint constraint = null)
        {
            // Unity property name is of the format "property.channel" or "property". Handle both cases.
            var possibleUniPropChannelPairs = new List <UnityPropertyChannelPair>();

            // could give same result as already in the list, avoid checking this case twice
            var propChannelPair = GetUnityPropertyChannelPair(uniPropertyName);

            possibleUniPropChannelPairs.Add(propChannelPair);
            if (propChannelPair.property != uniPropertyName)
            {
                possibleUniPropChannelPairs.Add(new UnityPropertyChannelPair(uniPropertyName, null));
            }

            foreach (var uniPropChannelPair in possibleUniPropChannelPairs)
            {
                // try to match property
                var fbxProperty = GetFbxProperty(uniPropChannelPair.property, propertyChannelMap.MapUnityPropToFbxProp);
                if (string.IsNullOrEmpty(fbxProperty) && constraint != null)
                {
                    // check if it's a constraint source property
                    fbxProperty = GetFbxConstraintSourceProperty(uniPropChannelPair.property, constraint, propertyChannelMap.MapUnityPropToFbxProp);
                }
                if (string.IsNullOrEmpty(fbxProperty))
                {
                    continue;
                }

                // matched property, now try to match channel
                string fbxChannel = null;
                if (!string.IsNullOrEmpty(uniPropChannelPair.channel) && propertyChannelMap.MapUnityChannelToFbxChannel != null)
                {
                    fbxChannel = GetFbxChannel(uniPropChannelPair.channel, propertyChannelMap.MapUnityChannelToFbxChannel);
                    if (string.IsNullOrEmpty(fbxChannel))
                    {
                        // couldn't match the Unity channel to the fbx channel
                        continue;
                    }
                }
                return(new FbxPropertyChannelPair[] { new FbxPropertyChannelPair(fbxProperty, fbxChannel) });
            }
            return(null);
        }
Пример #9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxConstraint obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }