Ejemplo n.º 1
0
        public new static FbxNodeAttribute Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxNodeAttribute_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxNodeAttribute      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);

            return(ret);
        }
Ejemplo n.º 2
0
        public FbxNodeAttribute Triangulate(FbxNodeAttribute pNodeAttribute, bool pReplace)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxGeometryConverter_Triangulate__SWIG_3(swigCPtr, FbxNodeAttribute.getCPtr(pNodeAttribute), pReplace);
            FbxNodeAttribute      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);

            return(ret);
        }
Ejemplo n.º 3
0
        public new static FbxNodeAttribute Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxNodeAttribute_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxNodeAttribute      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);

            return(ret);
        }
Ejemplo n.º 4
0
 public bool Equals(FbxNodeAttribute other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }
Ejemplo n.º 5
0
        public static FbxNode CreateNode(this FbxNodeAttribute nodeAttribute)
        {
            FbxNode node = FbxNode.Create(nodeAttribute, nodeAttribute.GetName() + "_Node");

            node.SetNodeAttribute(nodeAttribute);

            return(node);
        }
Ejemplo n.º 6
0
        public new static FbxNodeAttribute Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxNodeAttribute_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxNodeAttribute      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 7
0
        public FbxNodeAttribute GetNodeAttribute()
        {
            global::System.IntPtr cPtr = NativeMethods.FbxNode_GetNodeAttribute(swigCPtr);
            FbxNodeAttribute      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 8
0
        private GameObject ImportNodes(
            FbxNode node, float fbxUnitToTiltUnit,
            ref long completedVerts, long totalVerts)
        {
            FbxNodeAttribute a = node.GetNodeAttribute();
            int nChildren      = node.GetChildCount();

            GameObject go = null;

            if (a != null)
            {
                var attrType = a.GetAttributeType();
                if (attrType == FbxNodeAttribute.EType.eMesh)
                {
                    go = ImportMesh(
                        node, fbxUnitToTiltUnit,
                        ref completedVerts, totalVerts);
                }
                else if (attrType == FbxNodeAttribute.EType.eNurbs ||
                         attrType == FbxNodeAttribute.EType.eSubDiv ||
                         attrType == FbxNodeAttribute.EType.eNurbsSurface)
                {
                    warnings.Add("Ignoring non-mesh geometry");
                }
            }

            for (int i = 0; i < nChildren; i++)
            {
                GameObject child = ImportNodes(
                    node.GetChild(i), fbxUnitToTiltUnit,
                    ref completedVerts, totalVerts);
                if (child != null)
                {
                    if (go == null)
                    {
                        go = new GameObject("Node");
                    }
                    child.transform.parent = go.transform;
                }
            }

            if (go != null)
            {
                ApplyTransform(node, go.transform, fbxUnitToTiltUnit);
            }
            return(go);
        }
Ejemplo n.º 9
0
        public static FbxNodeAttribute[] GetAttributes(FbxNode node)
        {
            //не null только когда node.GetNodeAttributeCount()==1. Иначе использовать GetNodeAttributeByIndex
            var attribute = node.GetNodeAttribute();

            if (attribute != null)
            {
                return new[] { attribute }
            }
            ;
            var ret = new FbxNodeAttribute[node.GetNodeAttributeCount()];

            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = node.GetNodeAttributeByIndex(i);
            }
            return(ret);
        }
Ejemplo n.º 10
0
            /// <summary>
            /// Exports the game object has a camera component
            /// </summary>
            protected void ExportComponents(GameObject unityGo, FbxScene fbxScene, FbxNode fbxNodeParent)
            {
                Camera unityCamera = unityGo.GetComponent <Camera> ();

                if (unityCamera == null)
                {
                    return;
                }

                // create an node and add it as a child of parent
                FbxNode fbxNode = FbxNode.Create(fbxScene, unityGo.name);

                NumNodes++;

                FbxNodeAttribute fbxNodeAttr = ExportCamera(unityCamera, fbxScene, fbxNode);

                if (fbxNodeAttr != null)
                {
                    fbxNode.SetNodeAttribute(fbxNodeAttr);

                    // make the last camera exported the default camera
                    DefaultCamera = fbxNode.GetName();
                }

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting {0}", fbxNode.GetName()));
                }

                fbxNodeParent.AddChild(fbxNode);

                // add mapping between fbxnode for light
                // and unity game object for animation export
                MapUnityObjectToFbxNode [unityGo] = fbxNode;

                // now  unityGo  through our children and recurse
                foreach (Transform childT in  unityGo.transform)
                {
                    ExportComponents(childT.gameObject, fbxScene, fbxNode);
                }

                return;
            }
        protected void CheckAnimCurve(
            FbxObject origAnimObject, FbxObject importAnimObject,
            FbxAnimLayer origLayer, FbxAnimLayer importLayer,
            List <PropertyComponentPair> propCompPairs,
            FbxNodeAttribute origNodeAttr = null, FbxNodeAttribute importNodeAttr = null)
        {
            foreach (var pair in propCompPairs)
            {
                FbxProperty origProperty = origAnimObject.FindProperty(pair.propertyName, false);
                if (origNodeAttr != null && (origProperty == null || !origProperty.IsValid()))
                {
                    origProperty = origNodeAttr.FindProperty(pair.propertyName, false);
                }
                FbxProperty importProperty = importAnimObject.FindProperty(pair.propertyName, false);
                if (importNodeAttr != null && (importProperty == null || !importProperty.IsValid()))
                {
                    importProperty = importNodeAttr.FindProperty(pair.propertyName, false);
                }

                Assert.IsNotNull(origProperty);
                Assert.IsNotNull(importProperty);
                Assert.IsTrue(origProperty.IsValid());
                Assert.IsTrue(importProperty.IsValid());

                foreach (var component in pair.componentList)
                {
                    FbxAnimCurve origAnimCurve   = origProperty.GetCurve(origLayer, component, false);
                    FbxAnimCurve importAnimCurve = importProperty.GetCurve(importLayer, component, false);

                    Assert.IsNotNull(origAnimCurve);
                    Assert.IsNotNull(importAnimCurve);

                    Assert.AreEqual(origAnimCurve.KeyGetCount(), importAnimCurve.KeyGetCount());

                    for (int i = 0; i < origAnimCurve.KeyGetCount(); i++)
                    {
                        Assert.AreEqual(origAnimCurve.KeyGetTime(i), importAnimCurve.KeyGetTime(i));
                        Assert.AreEqual(origAnimCurve.KeyGetValue(i), importAnimCurve.KeyGetValue(i));
                    }
                }
            }
        }
Ejemplo n.º 12
0
        static void LoadSkinsFromNodeRecursive(FbxNode pNode, List <FbxSkin> skinsResult)
        {
            FbxNodeAttribute pNodeAttribute = pNode.GetNodeAttribute();

            if (pNodeAttribute?.GetAttributeType() == FbxNodeAttribute.EType.eMesh)
            {
                FbxMesh pMesh     = pNode.GetMesh();
                int     skinCount = pMesh.GetDeformerCount(FbxDeformer.EDeformerType.eSkin);
                for (int i = 0; i < skinCount; i++)
                {
                    FbxSkin pSkin = FbxSkin.Cast(pMesh.GetDeformer(i, FbxDeformer.EDeformerType.eSkin));
                    skinsResult.Add(pSkin);
                }
            }

            for (int i = 0; i < pNode.GetChildCount(); i++)
            {
                LoadSkinsFromNodeRecursive(pNode.GetChild(i), skinsResult);
            }
        }
Ejemplo n.º 13
0
        private static long GetTotalVerts(FbxNode node)
        {
            FbxNodeAttribute a = node.GetNodeAttribute();
            int  nChildren     = node.GetChildCount();
            long vertCount     = 0;

            if (a != null)
            {
                var attrType = a.GetAttributeType();
                if (attrType == FbxNodeAttribute.EType.eMesh)
                {
                    FbxMesh fbxMesh = node.GetMesh();
                    fbxMesh.SplitPoints();
                    vertCount = fbxMesh.GetControlPointsCount();
                }
            }
            for (int i = 0; i < nChildren; i++)
            {
                vertCount += GetTotalVerts(node.GetChild(i));
            }
            return(vertCount);
        }
        protected void CreateAnimCurves(
            FbxObject animObject, FbxAnimLayer animLayer,
            List <PropertyComponentPair> properties,
            System.Func <int, double> calcTime, // lambda function for calculating time based on index
            System.Func <int, float> calcValue, // lambda function for calculating value based on index
            FbxNodeAttribute animNodeAttr = null)
        {
            foreach (var pair in properties)
            {
                FbxProperty fbxProperty = animObject.FindProperty(pair.propertyName, false);
                if (animNodeAttr != null && (fbxProperty == null || !fbxProperty.IsValid()))
                {
                    // backup method for finding the property if we can't find it on the node itself
                    fbxProperty = animNodeAttr.FindProperty(pair.propertyName, false);
                }

                Assert.IsNotNull(fbxProperty);
                Assert.IsTrue(fbxProperty.IsValid());
                Assert.That(fbxProperty.GetFlag(FbxPropertyFlags.EFlags.eAnimatable), Is.True);

                foreach (var component in pair.componentList)
                {
                    // Create the AnimCurve on the channel
                    FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve(animLayer, component, true);

                    Assert.IsNotNull(fbxAnimCurve);

                    fbxAnimCurve.KeyModifyBegin();
                    for (int keyIndex = 0; keyIndex < m_keyCount; ++keyIndex)
                    {
                        FbxTime fbxTime = FbxTime.FromSecondDouble(calcTime(keyIndex));
                        fbxAnimCurve.KeyAdd(fbxTime);
                        fbxAnimCurve.KeySet(keyIndex, fbxTime, calcValue(keyIndex));
                    }
                    fbxAnimCurve.KeyModifyEnd();
                }
            }
        }
Ejemplo n.º 15
0
        public void TestSetNodeAttribute()
        {
            using (FbxNode node = CreateObject("root")) {
                var nodeAttribute = FbxNodeAttribute.Create(Manager, "node attribute");

                // from Fbx Sdk 2017 docs:
                //    Returns pointer to previous node attribute. NULL if the node didn't have a node
                //    attribute, or if the new node attribute is equal to the one currently set.
                FbxNodeAttribute prevNodeAttribute = node.SetNodeAttribute(nodeAttribute);

                Assert.IsNull(prevNodeAttribute);
                Assert.AreEqual(nodeAttribute, node.GetNodeAttribute());

                prevNodeAttribute = node.SetNodeAttribute(nodeAttribute);

                Assert.IsNull(prevNodeAttribute);
                Assert.AreEqual(nodeAttribute, node.GetNodeAttribute());

                prevNodeAttribute = node.SetNodeAttribute(FbxNodeAttribute.Create(Manager, "node attribute 2"));

                Assert.AreEqual(prevNodeAttribute, nodeAttribute);
            }
        }
Ejemplo n.º 16
0
        void PrintAttribute(FbxNodeAttribute attri)
        {
            Log.Info("attri " + attri.GetName());
            Log.Info("attri type " + Enum.GetName(typeof(FbxNodeAttribute.EType), attri.GetAttributeType()));
            //attri.is

            if (attri.GetAttributeType() == FbxNodeAttribute.EType.eMesh)
            {
                Type t = attri.GetType();
                Log.Info("type name " + t.Name);

                FbxMesh mesh = attri.GetNode().GetMesh();
                //FbxMesh mesh = attri as FbxMesh;
                if (mesh == null)
                {
                    Log.Error("convert mesh failed!");
                    return;
                }

                //FbxMesh mesh;
                //FbxLayerElementUV uv = mesh.GetElementUV();

                //uv.GetDirectArray()

                FbxLayerElementNormal normal = mesh.GetElementNormal();
                DirectArrayFbxVector4 array  = normal.GetDirectArray();

                Log.Info("normal count " + array.GetCount());
                for (int i = 0; i < array.GetCount(); i++)
                {
                    FbxVector4        v    = array.GetAt(i);
                    SWIGTYPE_p_double data = v.mData;
                    DoubleArray       d    = DoubleArray.frompointer(data);
                    PrintDoubleArray(d, 4);
                }
            }
        }
Ejemplo n.º 17
0
        void Run()
        {
            FbxManager    manager = FbxManager.Create();
            FbxIOSettings setting = FbxIOSettings.Create(manager, "IOSRoot");

            manager.SetIOSettings(setting);

            FbxImporter impoter = FbxImporter.Create(manager, "");

            bool status = impoter.Initialize(@"D:\develop\FbxWrapper\1.fbx", -1, setting);

            Log.Info(status);

            if (!status)
            {
                return;
            }

            FbxScene scene = FbxScene.Create(manager, "scene1");

            status = impoter.Import(scene);
            Log.Info(status);


            int numTrack = scene.GetSrcObjectCount(FbxAnimStack.ClassId);

            Log.Info("num stack " + numTrack);

            FbxObject obj = scene.GetSrcObject(FbxAnimStack.ClassId, 0);

            FbxAnimStack stack = FbxAnimStack.Cast(obj);

            if (stack == null)
            {
                Log.Error("can not get anim stack!");
                return;
            }

            FbxCriteria cri      = FbxCriteria.ObjectTypeStrict(FbxAnimLayer.ClassId);
            int         numLayer = stack.GetMemberCount(cri);

            Log.Info("anim layer count : " + numLayer);

            FbxAnimLayer layer = null;

            if (numLayer > 0)
            {
                FbxObject layerobj = stack.GetMember(cri, 0);
                layer = FbxAnimLayer.Cast(layerobj);
                if (layer == null)
                {
                    Log.Error("anim layer is null!");
                    return;
                }

                Log.Info("anim layer name " + layer.GetName());
            }


            Log.Info("node count " + scene.GetNodeCount());
            for (int i = 0; i < scene.GetNodeCount(); i++)
            {
                FbxNode node = scene.GetNode(i);
                Log.Info("node " + i + " " + node.GetName());

                if (node.LclTranslation.IsAnimated(layer))
                {
                    FbxAnimCurveNode curveNode = node.LclTranslation.GetCurveNode(layer);
                    if (curveNode == null)
                    {
                        Log.Error("curve node is null");
                    }
                    else
                    {
                        for (int c = 0; c < curveNode.GetCurveCount(0); c++)
                        {
                            FbxAnimCurve curve = curveNode.GetCurve(0, (uint)c);
                            if (curve != null)
                            {
                                Log.Info("curve " + curve.GetName());
                                Log.Info("key count " + curve.KeyGetCount());
                                FbxAnimCurveKey key = curve.KeyGet(0);
                                FbxTime         t   = key.GetTime();
                                Log.Info("key " + t.GetTimeString() + " value " + key.GetValue());
                            }
                        }
                    }
                }



                if (node.GetNodeAttribute() != null)
                {
                    Log.Info("got attribu");
                    FbxNodeAttribute att = node.GetNodeAttribute();
                    PrintAttribute(att);
                }
                else
                {
                    Log.Info("att count " + node.GetNodeAttributeCount());
                    for (int j = 0; j < node.GetNodeAttributeCount(); j++)
                    {
                        FbxNodeAttribute att = node.GetNodeAttributeByIndex(j);
                        PrintAttribute(att);
                    }
                }

                FbxVector4    rot = node.GetPostRotation(FbxNode.EPivotSet.eSourcePivot);
                FbxQuaternion q;
            }
        }
Ejemplo n.º 18
0
  // override void Dispose() {base.Dispose();}

  public new static FbxNodeAttribute Create(FbxManager pManager, string pName) {
    global::System.IntPtr cPtr = NativeMethods.FbxNodeAttribute_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
    FbxNodeAttribute ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);
    if (NativeMethods.SWIGPendingException.Pending) throw NativeMethods.SWIGPendingException.Retrieve();
    return ret;
  }
Ejemplo n.º 19
0
            /// <summary>
            /// Export an AnimationCurve.
            ///
            /// This is not used for rotations, because we need to convert from
            /// quaternion to euler and various other stuff.
            /// </summary>
            protected void ExportAnimCurve(UnityEngine.Object unityObj,
                                           AnimationCurve unityAnimCurve,
                                           string unityPropertyName,
                                           FbxAnimLayer fbxAnimLayer)
            {
                FbxPropertyChannelPair fbxPair;

                if (!MapUnityPropertyNameToFbx.TryGetValue(unityPropertyName, out fbxPair))
                {
                    Debug.LogWarning(string.Format("no property-channel mapping found for {0}", unityPropertyName));
                    return;
                }

                GameObject unityGo = GetGameObject(unityObj);

                if (unityGo == null)
                {
                    Debug.LogError(string.Format("cannot convert to GameObject from {0}", unityObj.ToString()));
                    return;
                }

                FbxNode fbxNode;

                if (!MapUnityObjectToFbxNode.TryGetValue(unityGo, out fbxNode))
                {
                    Debug.LogError(string.Format("cannot find fbxNode for {0}", unityGo.ToString()));
                    return;
                }

                FbxProperty fbxProperty = null;

                // try finding unity property name on node attribute
                FbxNodeAttribute fbxNodeAttribute = fbxNode.GetNodeAttribute();

                if (fbxNodeAttribute != null)
                {
                    fbxProperty = fbxNodeAttribute.FindProperty(fbxPair.Property, false);
                }

                // try finding unity property on the node
                if (fbxProperty == null || !fbxProperty.IsValid())
                {
                    fbxProperty = fbxNode.FindProperty(fbxPair.Property, false);
                }

                if (fbxProperty == null || !fbxProperty.IsValid())
                {
                    Debug.LogError(string.Format("cannot find fbxProperty {0} on {1}", fbxPair.Property, fbxNode.GetName()));
                    return;
                }

                if (Verbose)
                {
                    Debug.Log(string.Format("Exporting animation for {0} ({1})",
                                            unityObj.ToString(),
                                            fbxPair.Property));
                }

                // Create the AnimCurve on the channel
                FbxAnimCurve fbxAnimCurve = (fbxPair.Channel != null)
                    ? fbxProperty.GetCurve(fbxAnimLayer, fbxPair.Channel, true)
                                 : fbxProperty.GetCurve(fbxAnimLayer, true);

                // copy Unity AnimCurve to FBX AnimCurve.
                fbxAnimCurve.KeyModifyBegin();

                for (int keyIndex = 0, n = unityAnimCurve.length; keyIndex < n; ++keyIndex)
                {
                    var key     = unityAnimCurve [keyIndex];
                    var fbxTime = FbxTime.FromSecondDouble(key.time);
                    fbxAnimCurve.KeyAdd(fbxTime);
                    fbxAnimCurve.KeySet(keyIndex, fbxTime, key.value);
                }

                fbxAnimCurve.KeyModifyEnd();
            }
Ejemplo n.º 20
0
        void PrintAttribute(FbxManager manager, FbxNodeAttribute attri)
        {
            FbxLayerElementVertexColor pp;


            Log.Info("attri " + attri.GetName());
            Log.Info("attri type " + Enum.GetName(typeof(FbxNodeAttribute.EType), attri.GetAttributeType()));
            //attri.is

            if (attri.GetAttributeType() == FbxNodeAttribute.EType.eMesh)
            {
                Type t = attri.GetType();
                Log.Info("type name " + t.Name);

                FbxMesh mesh = attri.GetNode().GetMesh();


                //FbxMesh mesh = attri as FbxMesh;
                if (mesh == null)
                {
                    Log.Error("convert mesh failed!");
                    return;
                }


                Console.WriteLine($"mesh.GetMeshEdgeCount() = {mesh.GetMeshEdgeCount()}; mesh.GetPolygonCount() = {mesh.GetPolygonCount()}; mesh.GetPolygonVertexCount()={mesh.GetPolygonVertexCount()}; " +
                                  $"mesh.GetTextureUVCount() {mesh.GetTextureUVCount()}; mesh.GetControlPointsCount()={mesh.GetControlPointsCount()}; mesh.GetElementTangentCount()={mesh.GetElementTangentCount()};" +
                                  $" mesh.GetElementNormalCount()={mesh.GetElementNormalCount()}; mesh.GetElementVertexColorCount()={mesh.GetElementVertexColorCount()};" +
                                  $"mesh.GetUVLayerCount() = {mesh.GetUVLayerCount()}; mesh.GetLayerCount() = {mesh.GetLayerCount()}");
                var pts = mesh.GetControlPoints();
                var ar  = FbxVector4Array.frompointer(pts);

                for (int i = 0; i < mesh.GetLayerCount(); i++)
                {
                    var layer = mesh.GetLayer(i);
                }

                try
                {
                    var v2 = new FbxVector2();

                    IntPtr mem = Marshal.AllocHGlobal(4);

                    FbxStringList lst = new FbxStringList();
                    //int nameCount = lst.GetCount();
                    mesh.GetUVSetNames(lst); //ToDo : что за List, расширяется ли он сам?
                    var name = lst.GetItemAt(0).mString.Buffer();

                    //var myBool = new _MyBool(mem);
                    //var res = mesh.GetPolygonVertexUV(0, 0, name, v2, myBool);
                    //            var c0 = v2.at(0);
                    //            var c2 = v2.at(1);

                    var    fbxArV2 = new FbxArrayFbxVector2();
                    var    fbxArI  = new FbxArrayInt();
                    var    res     = mesh.GetPolygonVertexUVs(name, fbxArV2, fbxArI);
                    var    ptr     = fbxArV2.GetAt(2).mData;
                    double coord1  = FbxWrapperNative.DoubleArrayFunc_getitem(ptr, 0);
                    double coord2  = FbxWrapperNative.DoubleArrayFunc_getitem(ptr, 1);
                    var    param   = FbxWrapperNative.new_FbxLayerElementArrayTemplateIntPtrFunc();
                    res = mesh.GetMaterialIndices(param);
                    var param2 = FbxWrapperNative.FbxLayerElementArrayTemplateIntPtrFunc_value(param);
                    int count  = param2.GetCount();

                    List <int> mind = new List <int>();
                    for (int i = 0; i < count; i++)
                    {
                        mind.Add(param2.GetAt(i));
                    }



                    //var vec = new FbxVector4Array(5);
                    //var res2 = mesh.GetPolygonVertexUVs("", , null);

                    bool res1 = mesh.GenerateTangentsData(0);
                    //bool res2 = mesh.GenerateTangentsDataForAllUVSets( );
                    var tCount = mesh.GetElementTangentCount();
                    var tang   = mesh.GetElementTangent(  );
                    var tangAr = tang.GetDirectArray();
                    int tC     = tangAr.GetCount();

                    //int binCount = mesh.GetElementBinormalCount();
                    //var bin = mesh.GetElementBinormal().GetDirectArray().GetCount();
                }
                catch (Exception ex)
                {
                }


                //var vertices =  mesh.GetPolygonVertices();

                //FbxMesh mesh;
                //FbxLayerElementUV uv = mesh.GetElementUV();

                //uv.GetDirectArray()


                FbxLayerElementNormal normal = mesh.GetElementNormal();

                //ToDo

                //DirectArrayFbxVector4 array = normal.GetDirectArray();
                var array = normal.GetDirectArray();

                Log.Info("normal count " + array.GetCount());
                //for (int i = 0; i < array.GetCount(); i++)
                //{
                //    FbxVector4 v = array.GetAt(i);
                //    SWIGTYPE_p_double data = v.mData;
                //    DoubleArray d = DoubleArray.frompointer(data);
                //    PrintDoubleArray(d, 4);
                //}
            }
        }
Ejemplo n.º 21
0
        void Run()
        {
            FbxManager    manager = FbxManager.Create();
            FbxIOSettings setting = FbxIOSettings.Create(manager, "IOSRoot");

            //fbxiosettingspath.h
            //PostProcessSteps.CalculateTangentSpace = #define EXP_TANGENTSPACE				EXP_GEOMETRY "|" IOSN_TANGENTS_BINORMALS
            //PostProcessSteps.JoinIdenticalVertices = #define IOSN_DXF_WELD_VERTICES           "WeldVertices"
            //PostProcessSteps.Triangulate = #define IOSN_TRIANGULATE                "Triangulate"
            //PostProcessSteps.RemoveComponent =
            //PostProcessSteps.GenerateSmoothNormals =
            //setting.AddProperty()
            setting.SetBoolProp("Import|AdvOptGrp|Dxf|WeldVertices", true);
            setting.SetBoolProp("Triangulate", true);

            manager.SetIOSettings(setting);

            FbxImporter impoter = FbxImporter.Create(manager, "");

            bool status = impoter.Initialize(@"1.fbx", -1, setting);

            Log.Info(status);

            if (!status)
            {
                return;
            }

            FbxScene scene = FbxScene.Create(manager, "scene1");

            status = impoter.Import(scene);
            Log.Info(status);


            int numTrack = scene.GetSrcObjectCount(FbxCriteria.ObjectType(FbxAnimStack.ClassId));

            Log.Info("num stack " + numTrack);

            FbxObject obj = scene.GetSrcObject(FbxCriteria.ObjectType(FbxAnimStack.ClassId), 0);

            FbxAnimStack stack = FbxAnimStack.Cast(obj);

            if (stack == null)
            {
                Log.Error("can not get anim stack!");
                return;
            }

            FbxCriteria cri      = FbxCriteria.ObjectTypeStrict(FbxAnimLayer.ClassId);
            int         numLayer = stack.GetMemberCount(cri);

            Log.Info("anim layer count : " + numLayer);

            FbxAnimLayer layer = null;

            if (numLayer > 0)
            {
                FbxObject layerobj = stack.GetMember(cri, 0);
                layer = FbxAnimLayer.Cast(layerobj);
                if (layer == null)
                {
                    Log.Error("anim layer is null!");
                    return;
                }

                Log.Info("anim layer name " + layer.GetName());
            }


            Log.Info("node count " + scene.GetNodeCount());
            for (int i = 0; i < scene.GetNodeCount(); i++)
            {
                FbxNode node = scene.GetNode(i);
                Log.Info("node " + i + " " + node.GetName() + " ChildCount:" + node.GetChildCount());

                //----------------
                //node.LclTranslation.IsAnimated
                //----------------
                //ToDo :

                if (node.LclTranslation.IsAnimated(layer))
                {
                    FbxAnimCurveNode curveNode = node.LclTranslation.GetCurveNode(layer);
                    if (curveNode == null)
                    {
                        Log.Error("curve node is null");
                    }
                    else
                    {
                        for (int c = 0; c < curveNode.GetCurveCount(0); c++)
                        {
                            FbxAnimCurve curve = curveNode.GetCurve(0, (uint)c);
                            if (curve != null)
                            {
                                Log.Info("curve " + curve.GetName());
                                Log.Info("key count " + curve.KeyGetCount());
                                FbxAnimCurveKey key = curve.KeyGet(0);
                                FbxTime         t   = key.GetTime();
                                Log.Info("key " + t.GetTimeString() + " value " + key.GetValue());
                            }
                        }
                    }
                }



                if (node.GetNodeAttribute() != null)
                {
                    Log.Info("got attribu");
                    FbxNodeAttribute att = node.GetNodeAttribute();
                    PrintAttribute(manager, att);
                }
                else
                {
                    Log.Info("att count " + node.GetNodeAttributeCount());
                    for (int j = 0; j < node.GetNodeAttributeCount(); j++)
                    {
                        FbxNodeAttribute att = node.GetNodeAttributeByIndex(j);
                        PrintAttribute(manager, att);
                    }
                }

                FbxVector4    rot = node.GetPostRotation(FbxNode.EPivotSet.eSourcePivot);
                FbxQuaternion q;
            }
        }
Ejemplo n.º 22
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxNodeAttribute obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Ejemplo n.º 23
0
 public FbxNodeAttribute Triangulate(FbxNodeAttribute pNodeAttribute, bool pReplace, bool pLegacy)
 {
     global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxGeometryConverter_Triangulate__SWIG_2(swigCPtr, FbxNodeAttribute.getCPtr(pNodeAttribute), pReplace, pLegacy);
     FbxNodeAttribute ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxNodeAttribute(cPtr, false);
     return ret;
 }