示例#1
0
        public FbxVector4 GetNodeLocalScaling(FbxNode pNode)
        {
            FbxVector4 ret = new FbxVector4(FbxWrapperNativePINVOKE.FbxAnimEvaluator_GetNodeLocalScaling__SWIG_4(swigCPtr, FbxNode.getCPtr(pNode)), false);

            return(ret);
        }
        public FbxVector4 GetLast()
        {
            FbxVector4 ret = new FbxVector4(FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxVector4_GetLast(swigCPtr), true);

            return(ret);
        }
 public void SetLast(FbxVector4 pItem)
 {
     FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxVector4_SetLast(swigCPtr, FbxVector4.getCPtr(pItem));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#4
0
 public virtual void SetControlPointNormalAt(FbxVector4 pNormal, int pIndex)
 {
     fbx_wrapperPINVOKE.FbxGeometryBase_SetControlPointNormalAt__SWIG_1(swigCPtr, FbxVector4.getCPtr(pNormal), pIndex);
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#5
0
 public FbxMatrix(FbxVector4 pT, FbxVector4 pR, FbxVector4 pS) : this(NativeMethods.new_FbxMatrix__SWIG_3(pT, pR, pS), true)
 {
 }
        public void TestGetPolygonVertexNormal()
        {
            using (FbxMesh mesh = CreateObject("mesh")) {
                mesh.InitControlPoints(4);
                mesh.SetControlPointAt(new FbxVector4(0, 0, 0), 0);
                mesh.SetControlPointAt(new FbxVector4(1, 0, 0), 1);
                mesh.SetControlPointAt(new FbxVector4(1, 0, 1), 2);
                mesh.SetControlPointAt(new FbxVector4(0, 0, 1), 3);

                mesh.BeginPolygon();
                mesh.AddPolygon(0);
                mesh.AddPolygon(1);
                mesh.AddPolygon(2);
                mesh.AddPolygon(3);
                mesh.EndPolygon();

                // Add normals to the mesh
                FbxVector4 normal0 = new FbxVector4(0, 0, 1);
                FbxVector4 normal1 = new FbxVector4(0, 1, 0);
                FbxVector4 normal2 = new FbxVector4(0, 1, 1);
                FbxVector4 normal3 = new FbxVector4(0.301511344577764d, 0.904534033733291d, 0.301511344577764d);

                using (var fbxLayerElement = FbxLayerElementNormal.Create(mesh, "Normals")) {
                    // Set the Normals on the default layer
                    FbxLayer fbxLayer = mesh.GetLayer(0);
                    if (fbxLayer == null)
                    {
                        mesh.CreateLayer();
                        fbxLayer = mesh.GetLayer(0);
                    }

                    fbxLayerElement.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
                    fbxLayerElement.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);
                    FbxLayerElementArray fbxElementArray = fbxLayerElement.GetDirectArray();

                    fbxElementArray.Add(normal0);
                    fbxElementArray.Add(normal1);
                    fbxElementArray.Add(normal2);
                    fbxElementArray.Add(normal3);

                    fbxLayer.SetNormals(fbxLayerElement);
                }

                FbxVector4 readNormal0;
                FbxVector4 readNormal1;
                FbxVector4 readNormal2;
                FbxVector4 readNormal3;

                // test if all normals can be read
                Assert.IsTrue(mesh.GetPolygonVertexNormal(0, 0, out readNormal0));
                Assert.IsTrue(mesh.GetPolygonVertexNormal(0, 1, out readNormal1));
                Assert.IsTrue(mesh.GetPolygonVertexNormal(0, 2, out readNormal2));
                Assert.IsTrue(mesh.GetPolygonVertexNormal(0, 3, out readNormal3));

                // test if the normals have the correct values
                Assert.That(normal0.X, Is.EqualTo(readNormal0.X).Using(FloatEqualityComparer.Instance));
                Assert.That(normal0.Y, Is.EqualTo(readNormal0.Y).Using(FloatEqualityComparer.Instance));
                Assert.That(normal0.Z, Is.EqualTo(readNormal0.Z).Using(FloatEqualityComparer.Instance));
                Assert.That(normal0.W, Is.EqualTo(readNormal0.W).Using(FloatEqualityComparer.Instance));

                Assert.That(normal1.X, Is.EqualTo(readNormal1.X).Using(FloatEqualityComparer.Instance));
                Assert.That(normal1.Y, Is.EqualTo(readNormal1.Y).Using(FloatEqualityComparer.Instance));
                Assert.That(normal1.Z, Is.EqualTo(readNormal1.Z).Using(FloatEqualityComparer.Instance));
                Assert.That(normal1.W, Is.EqualTo(readNormal1.W).Using(FloatEqualityComparer.Instance));

                Assert.That(normal2.X, Is.EqualTo(readNormal2.X).Using(FloatEqualityComparer.Instance));
                Assert.That(normal2.Y, Is.EqualTo(readNormal2.Y).Using(FloatEqualityComparer.Instance));
                Assert.That(normal2.Z, Is.EqualTo(readNormal2.Z).Using(FloatEqualityComparer.Instance));
                Assert.That(normal2.W, Is.EqualTo(readNormal2.W).Using(FloatEqualityComparer.Instance));

                Assert.That(normal3.X, Is.EqualTo(readNormal3.X).Using(FloatEqualityComparer.Instance));
                Assert.That(normal3.Y, Is.EqualTo(readNormal3.Y).Using(FloatEqualityComparer.Instance));
                Assert.That(normal3.Z, Is.EqualTo(readNormal3.Z).Using(FloatEqualityComparer.Instance));
                Assert.That(normal3.W, Is.EqualTo(readNormal3.W).Using(FloatEqualityComparer.Instance));
            }
        }
示例#7
0
 public virtual void SetControlPointAt(FbxVector4 pCtrlPoint, FbxVector4 pNormal, int pIndex, bool pI2DSearch)
 {
     fbx_wrapperPINVOKE.FbxGeometryBase_SetControlPointAt__SWIG_0(swigCPtr, FbxVector4.getCPtr(pCtrlPoint), FbxVector4.getCPtr(pNormal), pIndex, pI2DSearch);
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#8
0
        public FbxVector4 mul(double pValue)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_mul__SWIG_0(swigCPtr, pValue), true);

            return(ret);
        }
示例#9
0
        public FbxVector4 div_assign(double pValue)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_div_assign__SWIG_0(swigCPtr, pValue), false);

            return(ret);
        }
示例#10
0
        public bool GetLocalPosition(FbxCharacter.ENodeId pCharacterNodeId, FbxVector4 pLocalT, FbxVector4 pLocalR, FbxVector4 pLocalS)
        {
            bool ret = fbx_wrapperPINVOKE.FbxCharacterPose_GetLocalPosition(swigCPtr, (int)pCharacterNodeId, FbxVector4.getCPtr(pLocalT), FbxVector4.getCPtr(pLocalR), FbxVector4.getCPtr(pLocalS));

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#11
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;
            }
        }
示例#12
0
        public void BasicTests()
        {
            base.TestElementAccessAndDispose(new FbxMatrix());

            FbxMatrix mx;

            // make sure the constructors compile and don't crash
            mx = new FbxMatrix();
            mx = new FbxMatrix(new FbxMatrix());
            mx = new FbxMatrix(new FbxAMatrix());
            mx = new FbxMatrix(new FbxVector4(), new FbxVector4(), new FbxVector4(1, 1, 1));
            mx = new FbxMatrix(new FbxVector4(), new FbxQuaternion(), new FbxVector4(1, 1, 1));
            mx = new FbxMatrix(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);

            /* Check the values we typed in match up. */
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 4; ++x)
                {
                    Assert.AreEqual(x + 4 * y, mx.Get(y, x));
                }
            }
            Assert.AreEqual(new FbxVector4(4, 5, 6, 7), mx.GetRow(1));
            Assert.AreEqual(new FbxVector4(1, 5, 9, 13), mx.GetColumn(1));

            /* Check that set and get work (silly transpose operation). */
            FbxMatrix mx2 = new FbxMatrix();

            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 4; ++x)
                {
                    mx2.Set(y, x, y + 4 * x);
                    Assert.AreEqual(mx.Get(x, y), mx2.Get(y, x));
                }
            }

            /* normal transpose operation */
            Assert.AreEqual(mx, mx2.Transpose());

            // Test SetIdentity
            Assert.IsFalse(AssertIsIdentity(mx, nothrow: true));
            AssertIsIdentity(mx, 15); // squint very, very, very hard
            mx.SetIdentity();
            AssertIsIdentity(mx);

            // Test getting the elements from a matrix built by TRS
            var translate = new FbxVector4(1, 2, 3);
            var rotate    = new FbxVector4(0, 90, 0);
            var scale     = new FbxVector4(1, 2, .5);

            mx = new FbxMatrix(translate, rotate, scale);
            FbxVector4 t, r, s, shear;
            double     sign;

            mx.GetElements(out t, out r, out shear, out s, out sign);
            Assert.AreEqual(1, sign);
            FbxVector4Test.AssertSimilarXYZ(translate, t);
            FbxVector4Test.AssertSimilarEuler(rotate, r);
            FbxVector4Test.AssertSimilarXYZ(new FbxVector4(), shear);
            FbxVector4Test.AssertSimilarXYZ(scale, s);

            FbxQuaternion q = new FbxQuaternion();

            mx.GetElements(out r, q, out shear, out s, out sign);
            Assert.AreEqual(1, sign);
            FbxVector4Test.AssertSimilarXYZ(translate, t);
            FbxQuaternionTest.AssertSimilar(rotate, q);
            FbxVector4Test.AssertSimilarXYZ(new FbxVector4(), shear);
            FbxVector4Test.AssertSimilarXYZ(scale, s);

            // Try SetTRS and SetTQS with the same arguments.
            using (var X = new FbxMatrix()) {
                X.SetTRS(translate, rotate, scale);
                X.GetElements(out r, q, out shear, out s, out sign);
                Assert.AreEqual(1, sign);
                FbxVector4Test.AssertSimilarXYZ(translate, t);
                FbxQuaternionTest.AssertSimilar(rotate, q);
                FbxVector4Test.AssertSimilarXYZ(new FbxVector4(), shear);
                FbxVector4Test.AssertSimilarXYZ(scale, s);
            }

            using (var X = new FbxMatrix()) {
                FbxQuaternion qRotate = new FbxQuaternion();
                qRotate.ComposeSphericalXYZ(rotate);
                X.SetTQS(translate, q, scale);
                X.GetElements(out r, q, out shear, out s, out sign);
                Assert.AreEqual(1, sign);
                FbxVector4Test.AssertSimilarXYZ(translate, t);
                FbxQuaternionTest.AssertSimilar(rotate, q);
                FbxVector4Test.AssertSimilarXYZ(new FbxVector4(), shear);
                FbxVector4Test.AssertSimilarXYZ(scale, s);

                // While we're at it, transform a vertex.
                // Verify also that w turns out normalized.
                var v  = new FbxVector4(1, 2, 3, 4);
                var v2 = X.MultNormalize(v);
                FbxVector4Test.AssertSimilarXYZW(new FbxVector4(2.5, 6, 2, 1), v2);

                // While we're at it, test that we can invert the matrix.
                // This matrix is invertible (since it's an affine transformation),
                // and the inversion turns out to be exact.
                AssertIsIdentity(X.Inverse() * X);
                using (var inv = new FbxMatrix(
                           0, 0, 2, 0,
                           0, 0.5, 0, 0,
                           -1, 0, 0, 0,
                           3, -1, -2, 1)) {
                    Assert.AreEqual(inv, X.Inverse());
                }
            }

            // Test set column + set row
            mx = new FbxMatrix();
            mx.SetColumn(1, new FbxVector4(1, 2, 3, 4));
            mx.SetRow(2, new FbxVector4(5, 6, 7, 8));
            //check that the column is what we expect
            Assert.AreEqual(1, mx.Get(0, 1));
            Assert.AreEqual(2, mx.Get(1, 1));
            Assert.AreEqual(6, mx.Get(2, 1));   // this value got changed by SetRow
            Assert.AreEqual(4, mx.Get(3, 1));
            // check that the row is what we expect
            Assert.AreEqual(new FbxDouble4(5, 6, 7, 8), mx [2]);

            // Test operators on two matrices.
            using (var a = new FbxMatrix(
                       0, 1, 2, 3,
                       4, 5, 6, 7,
                       8, 9, 10, 11,
                       12, 13, 14, 15)) {
                using (var b = new FbxMatrix(
                           15, 14, 13, 12,
                           11, 10, 9, 8,
                           7, 6, 5, 4,
                           3, 2, 1, 0)) {
                    using (var sum = new FbxMatrix(
                               15, 15, 15, 15,
                               15, 15, 15, 15,
                               15, 15, 15, 15,
                               15, 15, 15, 15)) {
                        Assert.AreEqual(sum, a + b);
                    }
                    using (var diff = new FbxMatrix(
                               -15, -13, -11, -9,
                               -7, -5, -3, -1,
                               1, 3, 5, 7,
                               9, 11, 13, 15)) {
                        Assert.AreEqual(diff, a - b);
                    }
                    using (var prod = new FbxMatrix(
                               304, 358, 412, 466,
                               208, 246, 284, 322,
                               112, 134, 156, 178,
                               16, 22, 28, 34)) {
                        Assert.AreEqual(prod, a * b);
                    }
                    using (var neg = new FbxMatrix(
                               0, -1, -2, -3,
                               -4, -5, -6, -7,
                               -8, -9, -10, -11,
                               -12, -13, -14, -15)) {
                        Assert.AreEqual(neg, -a);
                    }
                }
            }

            var eyePosition  = new FbxVector4(1, 2, 3);
            var eyeDirection = new FbxVector4(-1, -1, -1);
            var eyeUp        = new FbxVector4(0, 1, 0);

            using (mx = new FbxMatrix()) {
                mx.SetLookToRH(eyePosition, eyeDirection, eyeUp);
                AssertSimilar(new FbxMatrix(
                                  0.707, -0.408, 0.577, 0,
                                  0, 0.816, 0.577, 0,
                                  -0.707, -0.408, 0.577, 0,
                                  1.414, 0, -3.464, 1), mx, 1e-2);

                mx.SetLookToLH(eyePosition, eyeDirection, eyeUp);
                AssertSimilar(new FbxMatrix(
                                  -0.707, -0.408, -0.577, 0,
                                  0, 0.816, -0.577, 0,
                                  0.707, -0.408, -0.577, 0,
                                  -1.414, 0, 3.464, 1), mx, 1e-2);

                mx.SetLookAtRH(eyePosition, eyeDirection, eyeUp);
                AssertSimilar(new FbxMatrix(
                                  0.894, -0.249, 0.371, 0,
                                  0, 0.834, 0.557, 0,
                                  -0.447, -0.498, 0.742, 0,
                                  0.447, 0.083, -3.713, 1), mx, 1e-2);

                mx.SetLookAtLH(eyePosition, eyeDirection, eyeUp);
                AssertSimilar(new FbxMatrix(
                                  -0.894, -0.249, -0.371, 0,
                                  0, 0.834, -0.557, 0,
                                  0.447, -0.498, -0.742, 0,
                                  -0.447, 0.083, 3.713, 1), mx, 1e-2);
            }
        }
示例#13
0
 public void ComputeLocalTRSFromGlobal(FbxVector4 pRetLT, FbxVector4 pRetLR, FbxVector4 pRetLS, FbxNode pNode, FbxAMatrix pGX)
 {
     FbxWrapperNativePINVOKE.FbxAnimEvaluator_ComputeLocalTRSFromGlobal__SWIG_4(swigCPtr, FbxVector4.getCPtr(pRetLT), FbxVector4.getCPtr(pRetLR), FbxVector4.getCPtr(pRetLS), FbxNode.getCPtr(pNode), FbxAMatrix.getCPtr(pGX));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#14
0
 public void ComputeLocalTRSFromGlobal(FbxVector4 pRetLT, FbxVector4 pRetLR, FbxVector4 pRetLS, FbxNode pNode, FbxAMatrix pGX, FbxTime pTime, FbxNode.EPivotSet pPivotSet, bool pApplyTarget)
 {
     FbxWrapperNativePINVOKE.FbxAnimEvaluator_ComputeLocalTRSFromGlobal__SWIG_1(swigCPtr, FbxVector4.getCPtr(pRetLT), FbxVector4.getCPtr(pRetLR), FbxVector4.getCPtr(pRetLS), FbxNode.getCPtr(pNode), FbxAMatrix.getCPtr(pGX), FbxTime.getCPtr(pTime), (int)pPivotSet, pApplyTarget);
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#15
0
            /// <summary>
            /// Process mesh data and setup MeshFilter component
            /// </summary>
            private void ProcessMesh(FbxNode fbxNode, GameObject unityGo)
            {
                FbxMesh fbxMesh = fbxNode.GetMesh();

                if (fbxMesh == null)
                {
                    return;
                }

                var unityMesh = new Mesh();

                // create mesh
                var unityVertices        = new List <Vector3> ();
                var unityTriangleIndices = new List <int> ();

                // transfer vertices
                for (int i = 0; i < fbxMesh.GetControlPointsCount(); ++i)
                {
                    FbxVector4 fbxVector4 = fbxMesh.GetControlPointAt(i);

                    Debug.Assert(fbxVector4.X <= float.MaxValue && fbxVector4.X >= float.MinValue);
                    Debug.Assert(fbxVector4.Y <= float.MaxValue && fbxVector4.Y >= float.MinValue);
                    Debug.Assert(fbxVector4.Z <= float.MaxValue && fbxVector4.Z >= float.MinValue);

                    unityVertices.Add(new Vector3((float)fbxVector4.X, (float)fbxVector4.Y, (float)fbxVector4.Z));
                }

                // transfer triangles
                for (int polyIndex = 0; polyIndex < fbxMesh.GetPolygonCount(); ++polyIndex)
                {
                    int polySize = fbxMesh.GetPolygonSize(polyIndex);

                    // only support triangles
                    Debug.Assert(polySize == 3);

                    for (int polyVertexIndex = 0; polyVertexIndex < polySize; ++polyVertexIndex)
                    {
                        int vertexIndex = fbxMesh.GetPolygonVertex(polyIndex, polyVertexIndex);

                        unityTriangleIndices.Add(vertexIndex);
                    }
                }

                unityMesh.vertices = unityVertices.ToArray();

                // TODO:
                // - support Mesh.SetTriangles - multiple materials per mesh
                // - support Mesh.SetIndices - other topologies e.g. quads
                unityMesh.triangles = unityTriangleIndices.ToArray();
                unityMesh.RecalculateNormals();

                ProcessUVs(fbxMesh, unityMesh);

                var unityMeshFilter = unityGo.AddComponent <MeshFilter> ();

                unityMeshFilter.sharedMesh = unityMesh;

                var unityRenderer = unityGo.AddComponent <MeshRenderer> ();
                {
                    // Assign the default material (hack!)
                    var unityPrimitive = GameObject.CreatePrimitive(PrimitiveType.Quad);
                    var unityMat       = unityPrimitive.GetComponent <MeshRenderer> ().sharedMaterial;
                    unityRenderer.sharedMaterial = unityMat;
                    UnityEngine.Object.DestroyImmediate(unityPrimitive);
                }
            }
示例#16
0
        public FbxVector4 neg()
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_neg(swigCPtr), true);

            return(ret);
        }
示例#17
0
            /// <summary>
            /// Process transformation data and setup Transform component
            /// </summary>
            private void ProcessTransform(FbxNode fbxNode, GameObject unityGo)
            {
                // Construct rotation matrices
                FbxVector4 fbxRotation  = new FbxVector4(fbxNode.LclRotation.Get());
                FbxAMatrix fbxRotationM = new FbxAMatrix();

                fbxRotationM.SetR(fbxRotation);

                FbxVector4 fbxPreRotation  = new FbxVector4(fbxNode.GetPreRotation(FbxNode.EPivotSet.eSourcePivot));
                FbxAMatrix fbxPreRotationM = new FbxAMatrix();

                fbxPreRotationM.SetR(fbxPreRotation);

                FbxVector4 fbxPostRotation  = new FbxVector4(fbxNode.GetPostRotation(FbxNode.EPivotSet.eSourcePivot));
                FbxAMatrix fbxPostRotationM = new FbxAMatrix();

                fbxPostRotationM.SetR(fbxPostRotation);

                // Construct translation matrix
                FbxAMatrix fbxTranslationM = new FbxAMatrix();
                FbxVector4 fbxTranslation  = new FbxVector4(fbxNode.LclTranslation.Get());

                fbxTranslationM.SetT(fbxTranslation);

                // Construct scaling matrix
                FbxAMatrix fbxScalingM = new FbxAMatrix();
                FbxVector4 fbxScaling  = new FbxVector4(fbxNode.LclScaling.Get());

                fbxScalingM.SetS(fbxScaling);

                // Construct offset and pivot matrices
                FbxAMatrix fbxRotationOffsetM = new FbxAMatrix();
                FbxVector4 fbxRotationOffset  = fbxNode.GetRotationOffset(FbxNode.EPivotSet.eSourcePivot);

                fbxRotationOffsetM.SetT(fbxRotationOffset);

                FbxAMatrix fbxRotationPivotM = new FbxAMatrix();
                FbxVector4 fbxRotationPivot  = fbxNode.GetRotationPivot(FbxNode.EPivotSet.eSourcePivot);

                fbxRotationPivotM.SetT(fbxRotationPivot);

                FbxAMatrix fbxScalingOffsetM = new FbxAMatrix();
                FbxVector4 fbxScalingOffset  = fbxNode.GetScalingOffset(FbxNode.EPivotSet.eSourcePivot);

                fbxScalingOffsetM.SetT(fbxScalingOffset);

                FbxAMatrix fbxScalingPivotM = new FbxAMatrix();
                FbxVector4 fbxScalingPivot  = fbxNode.GetScalingPivot(FbxNode.EPivotSet.eSourcePivot);

                fbxScalingPivotM.SetT(fbxScalingPivot);

                FbxAMatrix fbxTransform =
                    fbxTranslationM *
                    fbxRotationOffsetM *
                    fbxRotationPivotM *
                    fbxPreRotationM *
                    fbxRotationM *
                    fbxPostRotationM *
                    fbxRotationPivotM.Inverse() *
                    fbxScalingOffsetM *
                    fbxScalingPivotM *
                    fbxScalingM *
                    fbxScalingPivotM.Inverse();

                FbxVector4    lclTrs = fbxTransform.GetT();
                FbxQuaternion lclRot = fbxTransform.GetQ();
                FbxVector4    lclScl = fbxTransform.GetS();

                Debug.Log(string.Format("processing {3} Lcl : T({0}) R({1}) S({2})",
                                        lclTrs.ToString(),
                                        lclRot.ToString(),
                                        lclScl.ToString(),
                                        fbxNode.GetName()));

                unityGo.transform.localPosition = new Vector3((float)lclTrs[0], (float)lclTrs[1], (float)lclTrs[2]);
                unityGo.transform.localRotation = new Quaternion((float)lclRot[0], (float)lclRot[1], (float)lclRot[2], (float)lclRot[3]);
                unityGo.transform.localScale    = new Vector3((float)lclScl[0], (float)lclScl[1], (float)lclScl[2]);
            }
示例#18
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxVector4 obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
示例#19
0
        public static bool GetContinuousOffset(FbxRotationOrder pOrder, FbxVector4 pOffset, FbxVector4 pNew, FbxVector4 pOld)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxAnimCurveFilter_GetContinuousOffset(FbxRotationOrder.getCPtr(pOrder), FbxVector4.getCPtr(pOffset), FbxVector4.getCPtr(pNew), FbxVector4.getCPtr(pOld));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#20
0
        public FbxVector4 CrossProduct(FbxVector4 pVector)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_CrossProduct(swigCPtr, FbxVector4.getCPtr(pVector)), true);

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#21
0
        public virtual FbxVector4 GetControlPointAt(int pIndex)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxGeometryBase_GetControlPointAt(swigCPtr, pIndex), true);

            return(ret);
        }
示例#22
0
        public static bool AxisAlignmentInEulerAngle(FbxVector4 pAB, FbxVector4 pA, FbxVector4 pB, FbxVector4 pAngles)
        {
            bool ret = fbx_wrapperPINVOKE.FbxVector4_AxisAlignmentInEulerAngle(FbxVector4.getCPtr(pAB), FbxVector4.getCPtr(pA), FbxVector4.getCPtr(pB), FbxVector4.getCPtr(pAngles));

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#23
0
 public void GetElements(out FbxVector4 pTranslation, out FbxVector4 pRotation, out FbxVector4 pShearing, out FbxVector4 pScaling, out double pSign)
 {
     NativeMethods.FbxMatrix_GetElements__SWIG_1(swigCPtr, out pTranslation, out pRotation, out pShearing, out pScaling, out pSign);
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
示例#24
0
 public FbxVector4(FbxVector4 pVector4) : this(fbx_wrapperPINVOKE.new_FbxVector4__SWIG_1(FbxVector4.getCPtr(pVector4)), true)
 {
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public bool RemoveIt(FbxVector4 pItem)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxVector4_RemoveIt(swigCPtr, FbxVector4.getCPtr(pItem));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#26
0
        public FbxVector4 assign(FbxVector4 pVector4)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_assign__SWIG_0(swigCPtr, FbxVector4.getCPtr(pVector4)), false);

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public int InsertAt(int pIndex, FbxVector4 pItem)
        {
            int ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxVector4_InsertAt(swigCPtr, pIndex, FbxVector4.getCPtr(pItem));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#28
0
        public FbxVector4 assign(SWIGTYPE_p_double pValue)
        {
            FbxVector4 ret = new FbxVector4(fbx_wrapperPINVOKE.FbxVector4_assign__SWIG_1(swigCPtr, SWIGTYPE_p_double.getCPtr(pValue)), false);

            return(ret);
        }
        public FbxVector4 RemoveAt(int pIndex)
        {
            FbxVector4 ret = new FbxVector4(FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxVector4_RemoveAt(swigCPtr, pIndex), true);

            return(ret);
        }
示例#30
0
            /// <summary>
            /// Process fbx scene by doing nothing
            /// </summary>
            public void ProcessNode(FbxNode fbxNode, GameObject unityParentObj = null, bool constructTransform = false)
            {
                string name = fbxNode.GetName();

                GameObject unityGo = new GameObject(name);

                NumNodes++;

                if (unityParentObj != null)
                {
                    unityGo.transform.parent = unityParentObj.transform;
                }

                FbxAMatrix fbxTransform = null;

                if (constructTransform)
                {
#if UNI_18844
                    // Construct rotation matrices
                    FbxVector4 fbxRotation  = new FbxVector4(fbxNode.LclRotation.Get());
                    FbxAMatrix fbxRotationM = new FbxAMatrix();
                    fbxRotationM.SetR(fbxRotation);

                    FbxVector4 fbxPreRotation  = new FbxVector4(fbxNode.PreRotation.Get());
                    FbxAMatrix fbxPreRotationM = new FbxAMatrix();
                    fbxPreRotationM.SetR(fbxPreRotation);

                    FbxVector4 fbxPostRotation  = new FbxVector4(fbxNode.PostRotation.Get());
                    FbxAMatrix fbxPostRotationM = new FbxAMatrix();
                    fbxPostRotationM.SetR(fbxPostRotation);

                    // Construct translation matrix
                    FbxAMatrix fbxTranslationM = new FbxAMatrix();
                    FbxVector4 fbxTranslation  = new FbxVector4(fbxNode.LclTranslation.Get());
                    fbxTranslationM.SetT(fbxTranslation);

                    // Construct scaling matrix
                    FbxAMatrix fbxScalingM = new FbxAMatrix();
                    FbxVector4 fbxScaling  = new FbxVector4(fbxNode.LclScaling.Get());
                    fbxScalingM.SetS(fbxScaling);

                    // Construct offset and pivot matrices
                    FbxAMatrix fbxRotationOffsetM = new FbxAMatrix();
                    FbxVector4 fbxRotationOffset  = fbxNode.RotationOffset.Get();
                    fbxRotationOffsetM.SetT(fbxRotationOffset);

                    FbxAMatrix fbxRotationPivotM = new FbxAMatrix();
                    FbxVector4 fbxRotationPivot  = fbxNode.RotationPivot.Get();
                    fbxRotationPivotM.SetT(fbxRotationPivot);

                    FbxAMatrix fbxScalingOffsetM = new FbxAMatrix();
                    FbxVector4 fbxScalingOffset  = fbxNode.ScalingOffset.Get();
                    fbxScalingOffsetM.SetT(fbxScalingOffset);

                    FbxAMatrix fbxScalingPivotM = new FbxAMatrix();
                    FbxVector4 fbxScalingPivot  = fbxNode.ScalingPivot.Get();
                    fbxScalingPivotM.SetT(fbxScalingPivot);

                    fbxTransform =
                        fbxTranslationM *
                        fbxRotationOffsetM *
                        fbxRotationPivotM *
                        fbxPreRotationM *
                        fbxRotationM *
                        fbxPostRotationM *
                        fbxRotationPivotM.Inverse() *
                        fbxScalingOffsetM *
                        fbxScalingPivotM *
                        fbxScalingM *
                        fbxScalingPivotM.Inverse();

                    lclTrs = fbxTransform.GetT();
                    lclRot = fbxTransform.GetQ();
                    lclScl = fbxTransform.GetS();
#endif
                }
                else
                {
                    fbxTransform = fbxNode.EvaluateLocalTransform();
                }

                if (fbxTransform == null)
                {
                    Debug.LogError(string.Format("failed to retrieve transform for node : {0}", fbxNode.GetName()));
                    return;
                }

                FbxVector4    lclTrs = fbxTransform.GetT();
                FbxQuaternion lclRot = fbxTransform.GetQ();
                FbxVector4    lclScl = fbxTransform.GetS();

                Debug.Log(string.Format("processing {3} Lcl : T({0}) R({1}) S({2})",
                                        lclTrs.ToString(),
                                        lclRot.ToString(),
                                        lclScl.ToString(),
                                        fbxNode.GetName()));

                // check we can handle translation value
                Debug.Assert(lclTrs.X <= float.MaxValue && lclTrs.X >= float.MinValue);
                Debug.Assert(lclTrs.Y <= float.MaxValue && lclTrs.Y >= float.MinValue);
                Debug.Assert(lclTrs.Z <= float.MaxValue && lclTrs.Z >= float.MinValue);

                unityGo.transform.localPosition = new Vector3((float)lclTrs.X, (float)lclTrs.Y, (float)lclTrs.Z);
                unityGo.transform.localRotation = new Quaternion((float)lclRot[0], (float)lclRot[1], (float)lclRot[2], (float)lclRot[3]);
                unityGo.transform.localScale    = new Vector3((float)lclScl.X, (float)lclScl.Y, (float)lclScl.Z);

                for (int i = 0; i < fbxNode.GetChildCount(); ++i)
                {
                    ProcessNode(fbxNode.GetChild(i), unityGo);
                }
            }