상속: IDisposable
예제 #1
0
 public aiMatrix4x4(aiVector3D scaling, aiQuaternion rotation, aiVector3D position) : this(assimp_swigPINVOKE.new_aiMatrix4x4__SWIG_3(aiVector3D.getCPtr(scaling), aiQuaternion.getCPtr(rotation), aiVector3D.getCPtr(position)), true)
 {
     if (assimp_swigPINVOKE.SWIGPendingException.Pending)
     {
         throw assimp_swigPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #2
0
 public aiQuatKey(double time, aiQuaternion value) : this(assimp_swigPINVOKE.new_aiQuatKey__SWIG_1(time, aiQuaternion.getCPtr(value)), true)
 {
     if (assimp_swigPINVOKE.SWIGPendingException.Pending)
     {
         throw assimp_swigPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #3
0
 public static void Interpolate(aiQuaternion pOut, aiQuaternion pStart, aiQuaternion pEnd, float pFactor)
 {
     AssimpPINVOKE.aiQuaternion_Interpolate(aiQuaternion.getCPtr(pOut), aiQuaternion.getCPtr(pStart), aiQuaternion.getCPtr(pEnd), pFactor);
     if (AssimpPINVOKE.SWIGPendingException.Pending)
     {
         throw AssimpPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #4
0
 public void Decompose(aiVector3D scaling, aiQuaternion rotation, aiVector3D position)
 {
     AssimpPINVOKE.aiMatrix4x4_Decompose(swigCPtr, aiVector3D.getCPtr(scaling), aiQuaternion.getCPtr(rotation), aiVector3D.getCPtr(position));
     if (AssimpPINVOKE.SWIGPendingException.Pending)
     {
         throw AssimpPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #5
0
 public void DecomposeNoScaling(aiQuaternion rotation, aiVector3D position)
 {
     assimp_swigPINVOKE.aiMatrix4x4_DecomposeNoScaling(swigCPtr, aiQuaternion.getCPtr(rotation), aiVector3D.getCPtr(position));
     if (assimp_swigPINVOKE.SWIGPendingException.Pending)
     {
         throw assimp_swigPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #6
0
    public bool __equal__(aiQuaternion o)
    {
        bool ret = AssimpPINVOKE.aiQuaternion___equal__(swigCPtr, aiQuaternion.getCPtr(o));

        if (AssimpPINVOKE.SWIGPendingException.Pending)
        {
            throw AssimpPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #7
0
    public aiQuaternion __mul__(aiQuaternion two)
    {
        aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion___mul__(swigCPtr, aiQuaternion.getCPtr(two)), true);

        if (AssimpPINVOKE.SWIGPendingException.Pending)
        {
            throw AssimpPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #8
0
 public aiQuaternion Normalize() {
   aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion_Normalize(swigCPtr), false);
   return ret;
 }
예제 #9
0
 internal static HandleRef getCPtr(aiQuaternion obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
예제 #10
0
파일: Node.cs 프로젝트: clarte53/armine
        public static Node FromAssimp(Module.Import.Assimp.Context context, aiScene scene, aiNode assimp_node)
        {
            // Create new node object
            Node node = new Node();

            // Get node ID
            node.id = context.id++;

            // Get node name
            node.name = Assimp.Convert.Name(assimp_node.mName, "node");

            // Get node metadata
            using (aiMetadata meta = assimp_node.mMetaData)
            {
                UnityComponent metadata = UnityComponent.FromAssimpMetadata(meta);

                if (metadata != null)
                {
                    node.components = new UnityComponent[] { metadata };
                }
            }

            // Parse children recursively
            using (aiNodeArray children = assimp_node.Children)
            {
                uint children_size = children.Size();

                if (children_size > 0)
                {
                    node.children = new Node[children_size];

                    for (uint i = 0; i < children_size; i++)
                    {
                        aiNode child = children.Get(i);

                        // ParseNode must dispose of the given node afterward
                        // We must use a proxy method for saving the result into the array because the index i is captured by the lambda otherwise and it's value is indefinite across multiple threads.
                        context.threads.ExecAndSaveToArray(node.children, (int)i, () => FromAssimp(context, scene, child));
                    }
                }
            }

            // Parse meshes associated to this node
            using (aiUIntArray meshes = assimp_node.Meshes)
            {
                uint meshes_size = meshes.Size();

                if (meshes_size > 0)
                {
                    int global_meshes_size = (int)scene.Meshes.Size();

                    node.meshes = new GraphicMesh[meshes_size];

                    for (uint j = 0; j < meshes_size; j++)
                    {
                        node.meshes[j] = new GraphicMesh();

                        if (j < global_meshes_size)
                        {
                            uint mesh_index = meshes.Get(j);

                            node.meshes[j].meshIndex = (int)mesh_index;
                        }
                    }
                }
            }

            // Get the transform of this node
            using (aiVector3D position = new aiVector3D())
            {
                using (aiVector3D scaling = new aiVector3D())
                {
                    using (aiQuaternion rotation = new aiQuaternion())
                    {
                        assimp_node.mTransformation.Decompose(scaling, rotation, position);

                        node.position = Assimp.Convert.AssimpToUnity.Vector3(position);
                        node.rotation = Assimp.Convert.AssimpToUnity.Quaternion(rotation);
                        node.scale    = Assimp.Convert.AssimpToUnity.Vector3(scaling);
                    }
                }
            }

            // We must dispose of the given parameter to avoid memory leaks
            assimp_node.Dispose();

            context.progress.Update(ASSIMP_PROGRESS_FACTOR);

            return(node);
        }
예제 #11
0
    public aiQuaternion Normalize()
    {
        aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion_Normalize(swigCPtr), false);

        return(ret);
    }
예제 #12
0
    public aiQuaternion Conjugate()
    {
        aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion_Conjugate(swigCPtr), false);

        return(ret);
    }
예제 #13
0
파일: Node.cs 프로젝트: clarte53/armine
        public aiNode ToAssimp(Module.Export.Assimp.Context context, Scene scene, aiNode parent)
        {
            uint index = 0;

            aiNode node_object = new aiNode(name);

            // Set parent
            node_object.mParent = parent;

            // Set transform
            using (aiVector3D assimp_scale = Assimp.Convert.UnityToAssimp.Vector3(scale))
            {
                using (aiQuaternion assimp_rotation = Assimp.Convert.UnityToAssimp.Quaternion(rotation))
                {
                    using (aiVector3D assimp_position = Assimp.Convert.UnityToAssimp.Vector3(position))
                    {
                        using (aiMatrix4x4 matrix = new aiMatrix4x4(assimp_scale, assimp_rotation, assimp_position))
                        {
                            node_object.mTransformation = matrix.Unmanaged();
                        }
                    }
                }
            }

            // Parse the children nodes
            if (children != null && children.Length > 0)
            {
                using (aiNodeArray assimp_children = node_object.Children)
                {
                    assimp_children.Reserve((uint)children.Length, true);

                    index = 0;

                    foreach (Node child in children)
                    {
                        using (aiNode assimp_child = child.ToAssimp(context, scene, node_object))
                        {
                            if (assimp_child != null)
                            {
                                assimp_children.Set(index++, assimp_child.Unmanaged());
                            }
                        }
                    }
                }
            }

            // Parse the mesh objects
            if (meshes != null && meshes.Length > 0)
            {
                using (aiUIntArray assimp_meshes = node_object.Meshes)
                {
                    assimp_meshes.Reserve((uint)meshes.Length, true);

                    index = 0;

                    foreach (GraphicMesh graphic_mesh in meshes)
                    {
                        Mesh mesh = scene.meshes[graphic_mesh.meshIndex];

                        int nb_materials = (graphic_mesh.materialsIndexes != null ? graphic_mesh.materialsIndexes.Length : 0);

                        // Handle unity submeshes by creating new meshes for each submesh
                        for (int i = 0; i < mesh.SubMeshesCount; i++)
                        {
                            // Assimp meshes can only have one material. Therefore, mutliple instances of one mesh
                            // using different materials must be detected and replaced by different output meshes.

                            uint assimp_mesh_index;

                            int mat_index = (i < nb_materials ? graphic_mesh.materialsIndexes[i] : 0 /*Assimp default*/);

                            Module.Export.Assimp.Mesh key = new Module.Export.Assimp.Mesh(graphic_mesh.meshIndex, i, mat_index);

                            if (!context.meshes.TryGetValue(key, out assimp_mesh_index))
                            {
                                assimp_mesh_index = (uint)context.meshes.Count;

                                context.meshes.Add(key, assimp_mesh_index);
                            }

                            assimp_meshes.Set(index++, assimp_mesh_index);
                        }
                    }
                }
            }

            // Parse the node metadata
            if (components != null)
            {
                foreach (UnityComponent component in components)
                {
                    aiMetadata assimp_meta = component.ToAssimpMetadata();

                    if (assimp_meta != null)
                    {
                        node_object.mMetaData = assimp_meta.Unmanaged();

                        break;
                    }
                }
            }

            context.progress.Update(ASSIMP_PROGRESS_FACTOR);

            return(node_object);
        }
예제 #14
0
 public static void aiDecomposeMatrix(aiMatrix4x4 mat, aiVector3D scaling, aiQuaternion rotation, aiVector3D position)
 {
     assimp_swigPINVOKE.aiDecomposeMatrix(aiMatrix4x4.getCPtr(mat), aiVector3D.getCPtr(scaling), aiQuaternion.getCPtr(rotation), aiVector3D.getCPtr(position));
 }
예제 #15
0
        private void ApplyAssimpConfiguration(Importer importer, Property.Data data)
        {
            if (data.isStepFlag)
            {
                bool value_step;

                if (Boolean.TryParse(data.currentValue, out value_step))
                {
                    importer.Assimp.ChangeFlag(data.processStep, value_step);
                }
            }
            else
            {
                switch (data.propertyType)
                {
                case Property.Type.BOOL:
                    bool?value_bool = Property.Data.GetBool(data);

                    if (value_bool.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_bool.Value);
                    }

                    break;

                case Property.Type.FLAG:
                case Property.Type.INT:
                    int?value_int = Property.Data.GetInt(data);

                    if (value_int.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_int.Value);
                    }

                    break;

                case Property.Type.FLOAT:
                    float?value_float = Property.Data.GetFloat(data);

                    if (value_float.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_float.Value);
                    }

                    break;

                case Property.Type.STRING:
                    importer.Assimp.SetProperty(data.propertyFlag, data.currentValue);

                    break;

                case Property.Type.MATRIX:
                    const int size = 9;

                    List <string> values_matrix_str = UI.List.Parse(data.currentValue);

                    if (values_matrix_str.Count == size)
                    {
                        float[] value_matrix = new float[size];

                        for (int i = 0; i < size; i++)
                        {
                            if (!float.TryParse(values_matrix_str[i], out value_matrix[i]))
                            {
                                Debug.LogWarning("Invalid value \"" + data.optionText + " = " + values_matrix_str[i] + "\": should be a float.");
                            }
                        }

                        Vector3    pos = new Vector3(value_matrix[0], value_matrix[1], value_matrix[2]);
                        Quaternion rot = new Quaternion();
                        rot.eulerAngles = new Vector3(value_matrix[3], value_matrix[4], value_matrix[5]);
                        Vector3 scale = new Vector3(value_matrix[6], value_matrix[7], value_matrix[8]);

                        using (aiVector3D scaling = Type.Assimp.Convert.UnityToAssimp.Vector3(scale))
                        {
                            using (aiQuaternion rotation = Type.Assimp.Convert.UnityToAssimp.Quaternion(rot))
                            {
                                using (aiVector3D position = Type.Assimp.Convert.UnityToAssimp.Vector3(pos))
                                {
                                    using (aiMatrix4x4 matrix = new aiMatrix4x4(scaling, rotation, position))
                                    {
                                        importer.Assimp.SetProperty(data.propertyFlag, matrix);
                                    }
                                }
                            }
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }
예제 #16
0
파일: Convert.cs 프로젝트: clarte53/armine
 internal static Quaternion Quaternion(aiQuaternion assimp)
 {
     return(new Quaternion(assimp.x, assimp.y, assimp.z, assimp.w));
 }
예제 #17
0
 public bool __nequal__(aiQuaternion o) {
   bool ret = AssimpPINVOKE.aiQuaternion___nequal__(swigCPtr, aiQuaternion.getCPtr(o));
   if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
예제 #18
0
 internal static HandleRef getCPtr(aiQuaternion obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #19
0
 public static void Interpolate(aiQuaternion pOut, aiQuaternion pStart, aiQuaternion pEnd, float pFactor) {
   AssimpPINVOKE.aiQuaternion_Interpolate(aiQuaternion.getCPtr(pOut), aiQuaternion.getCPtr(pStart), aiQuaternion.getCPtr(pEnd), pFactor);
   if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #20
0
 public void DecomposeNoScaling(aiQuaternion rotation, aiVector3D position) {
   AssimpPINVOKE.aiMatrix4x4_DecomposeNoScaling(swigCPtr, aiQuaternion.getCPtr(rotation), aiVector3D.getCPtr(position));
   if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #21
0
 public aiQuaternion Conjugate() {
   aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion_Conjugate(swigCPtr), false);
   return ret;
 }
예제 #22
0
 public aiQuaternion __mul__(aiQuaternion two) {
   aiQuaternion ret = new aiQuaternion(AssimpPINVOKE.aiQuaternion___mul__(swigCPtr, aiQuaternion.getCPtr(two)), true);
   if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
예제 #23
0
            private static System.Object InitValue(Importer importer, string key_name, Property.Type type, System.Object default_value)
            {
                if (PlayerPrefs.HasKey(key_name))
                {
                    return(PlayerPrefs.GetString(key_name));
                }
                else
                {
                    try
                    {
                        switch (type)
                        {
                        case Property.Type.FLAG:
                        case Property.Type.INT:
                            return(importer.Assimp.GetProperty <int>(key_name));

                        case Property.Type.BOOL:
                            // Do not check importer value because we can not determine if a value is present, so use default value instead.
                            //return importer.GetProperty<bool>(key_name);
                            return(default_value);

                        case Property.Type.FLOAT:
                            return(importer.Assimp.GetProperty <float>(key_name));

                        case Property.Type.STRING:
                            return(importer.Assimp.GetProperty <string>(key_name));

                        case Property.Type.MATRIX:
                            string value;

                            using (aiMatrix4x4 matrix = importer.Assimp.GetProperty <aiMatrix4x4>(key_name))
                            {
                                using (aiVector3D position = new aiVector3D())
                                {
                                    using (aiVector3D scaling = new aiVector3D())
                                    {
                                        using (aiQuaternion rot = new aiQuaternion())
                                        {
                                            matrix.Decompose(scaling, rot, position);

                                            Quaternion rotation = Model.Type.Assimp.Convert.AssimpToUnity.Quaternion(rot);
                                            Vector3    angles   = rotation.eulerAngles;

                                            value = UI.List.Serialize(new List <string> {
                                                position.x.ToString(), position.y.ToString(), position.z.ToString(),
                                                angles.x.ToString(), angles.y.ToString(), angles.z.ToString(),
                                                scaling.x.ToString(), scaling.y.ToString(), scaling.z.ToString()
                                            });
                                        }
                                    }
                                }
                            }

                            return(value);
                        }
                    }
                    catch (Module.Import.Assimp.NotDefinedException)
                    {
                        if (type == Property.Type.FLAG)
                        {
                            return((int)default_value);                             // Must be cast explicitely to int to avoid ToString conversion of enums
                        }
                        else
                        {
                            return(default_value);
                        }
                    }
                }

                Debug.LogWarning("Incorrect type of property (" + key_name + ", " + type + "): unable to initialize it.");

                return("");
            }
예제 #24
0
 public aiQuatKey(double time, aiQuaternion value) : this(AssimpPINVOKE.new_aiQuatKey__SWIG_1(time, aiQuaternion.getCPtr(value)), true) {
   if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #25
0
 public static void aiCreateQuaternionFromMatrix(aiQuaternion quat, aiMatrix3x3 mat)
 {
     assimp_swigPINVOKE.aiCreateQuaternionFromMatrix(aiQuaternion.getCPtr(quat), aiMatrix3x3.getCPtr(mat));
 }