Exemple #1
0
        /// <summary>
        /// Constructor which builds a Bone object from a pointer to an aiFace structure.  As a user, you should not call this by hand.
        /// <remarks>This will copy the data inside the structure into managed memory.  It *DOES NOT* free the unmanaged memory.</remarks>
        /// </summary>
        /// <param name="aiBone*">A pointer to the bone structure in the low level unmanaged wrapper.</param>
        internal unsafe Bone(IntPtr p_aiBone)
        {
            // Unmarshal our structure into (what will be for us, some temporary) managed memory.  This is naturally, automatically released when we exit the function.
            UnmanagedAssimp.aiBone tBone = (UnmanagedAssimp.aiBone)Marshal.PtrToStructure(p_aiBone, typeof(UnmanagedAssimp.aiBone));

            // Copy over the nice, simple value types into managed memory.  Value types copy the entire structure rather than just the pointer to it.
            this.mOffsetMatrix = tBone.mOffsetMatrix;

            // Copy the properties over into our class as marshalled managed memory.
            // Note that with strings, prepending an empty string "" forces a copy.
            this.sName              = "" + tBone.mName.data;

            // Marshal the vertex weight array.
            this.tWeights = UnmanagedAssimp.MarshalArray<aiVertexWeight>(new IntPtr(tBone.mWeights), tBone.mNumWeights);
        }
Exemple #2
0
        /// <summary>
        /// Constructor which builds a Node object from a pointer to an aiNode structure.  As a user, you should not call this by hand.
        /// <remarks>This will copy the data inside the structure into managed memory.  It *DOES NOT* free the unmanaged memory.</remarks>
        /// </summary>
        /// <param name="aiNode*">A pointer to the face structure in the low level unmanaged wrapper.</param>
        internal unsafe Node(IntPtr p_aiNode, Node pParent)
        {
            // Unmarshal our structure into (what will be for us, some temporary) managed memory.  This is naturally, automatically released when we exit the function.
            UnmanagedAssimp.aiNode tNode = (UnmanagedAssimp.aiNode)Marshal.PtrToStructure(p_aiNode, typeof(UnmanagedAssimp.aiNode));

            // Copy over the nice, simple value types into managed memory.  Value types copy the entire structure rather than just the pointer to it.
            this.mTransformation = tNode.mTransformation;

            // Copy the properties over into our class as marshalled managed memory.
            // Note that with strings, prepending an empty string "" forces a copy.
            this.sName      = "" + tNode.mName.data;

            // Check the parent is not null.
            //this.mParent = null;
            //if (tNode.mParent != IntPtr.Zero)
            //    this.mParent = new Node(tNode.mParent);

            // To link the heirarchy we use a .NET reference to the parent.  This assumes we create in hierarchy order.
            this.mParent = pParent;

            // If we have children.
            if (tNode.mNumChildren > 0)
            {
                // Copy over the array of node animations into managed memory belonging to this class instance.
                int iIntPtrSize = sizeof(IntPtr);
                tChildren = new Node[tNode.mNumChildren];
                IntPtr pChildPtr = tNode.mChildren;
                for (int iElement = 0; iElement < tNode.mNumChildren; ++iElement)
                {
                    // Copy the element at this index and then increment the channel pointer (which should be sizeof(IntPtr) away.
                    tChildren[iElement] = new Node(Marshal.ReadIntPtr(pChildPtr), this);
                    pChildPtr = new IntPtr(pChildPtr.ToInt64() + iIntPtrSize);
                }
            }

            // Marshal the array of unsigned integers for each mesh.
            tMeshes = UnmanagedAssimp.MarshalUintArray(tNode.mMeshes, tNode.mNumMeshes);
        }