예제 #1
0
 public CookData(PropertiesProxy proxy, string resultUrl, CollisionDataType type, Model model, int modelLodIndex, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit)
     : base("Collision Data", resultUrl)
 {
     Proxy             = proxy;
     Type              = type;
     Model             = model;
     ModelLodIndex     = modelLodIndex;
     ConvexFlags       = convexFlags;
     ConvexVertexLimit = convexVertexLimit;
 }
예제 #2
0
            public void OnLoad(CollisionDataWindow window)
            {
                // Link
                Window = window;
                Asset  = window.Asset;

                // Setup cooking parameters
                var options = Asset.Options;

                Type = options.Type;
                if (Type == CollisionDataType.None)
                {
                    Type = CollisionDataType.ConvexMesh;
                }
                Model             = FlaxEngine.Content.LoadAsync <ModelBase>(options.Model);
                ModelLodIndex     = options.ModelLodIndex;
                ConvexFlags       = options.ConvexFlags;
                ConvexVertexLimit = options.ConvexVertexLimit;
            }
예제 #3
0
 /// <summary>
 /// Gets the set of options used to generate a collision data mesh.
 /// </summary>
 /// <param name="modelLodIndex">Index of the model LOD index used to generate a collision data (value provided during data cooking, may be higher than actual source model LODs collection size).</param>
 /// <param name="convexFlags">The convex mesh generation flags.</param>
 /// <param name="convexVertexLimit">The convex mesh vertex limit.</param>
 public void GetCookOptions(out int modelLodIndex, out ConvexMeshGenerationFlags convexFlags, out int convexVertexLimit)
 {
     Internal_GetCookOptions(unmanagedPtr, out modelLodIndex, out convexFlags, out convexVertexLimit);
 }
예제 #4
0
 internal static extern bool Internal_CookCollision(IntPtr obj, CollisionDataType type, IntPtr model, int modelLodIndex, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit);
예제 #5
0
 internal static extern void Internal_GetCookOptions(IntPtr obj, out int modelLodIndex, out ConvexMeshGenerationFlags convexFlags, out int convexVertexLimit);
예제 #6
0
        /// <summary>
        /// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
        /// </summary>
        /// <remarks>
        /// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
        /// </remarks>
        /// <param name="type">The collision data type.</param>
        /// <param name="model">The source model.</param>
        /// <param name="modelLodIndex">The source model LOD index.</param>
        /// <param name="convexFlags">The convex mesh generation flags.</param>
        /// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
        public void CookCollision(CollisionDataType type, Model model, int modelLodIndex = 0, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
        {
            // Validate state and input
            if (!IsVirtual)
            {
                throw new InvalidOperationException("Only virtual assets can be updated at runtime.");
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (type == CollisionDataType.None)
            {
                throw new ArgumentException(nameof(type));
            }

            if (Internal_CookCollision(unmanagedPtr, type, model.unmanagedPtr, modelLodIndex, convexFlags, convexVertexLimit))
            {
                throw new FlaxException("Mesh cooking failed. See log to learn more.");
            }
        }
예제 #7
0
 internal static extern bool Internal_CookCollisionDataInt(IntPtr obj, CollisionDataType type, int vertexCount, int triangleCount, Vector3[] vertices, int[] triangles, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit);
예제 #8
0
        /// <summary>
        /// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
        /// </summary>
        /// <remarks>
        /// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
        /// </remarks>
        /// <param name="type">The collision data type.</param>
        /// <param name="model">The source geometry vertex buffer with vertices positions. Cannot be null.</param>
        /// <param name="triangles">The source data index buffer (triangles). Uses 32-bit stride buffer. Cannot be null.</param>
        /// <param name="convexFlags">The convex mesh generation flags.</param>
        /// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
        public void CookCollision(CollisionDataType type, List <Vector3> vertices, List <int> triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
        {
            // Validate state and input
            if (!IsVirtual)
            {
                throw new InvalidOperationException("Only virtual assets can be updated at runtime.");
            }
            if (vertices == null)
            {
                throw new ArgumentNullException(nameof(vertices));
            }
            if (triangles == null)
            {
                throw new ArgumentNullException(nameof(triangles));
            }
            if (triangles.Count == 0 || triangles.Count % 3 != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(triangles));
            }
            if (type == CollisionDataType.None)
            {
                throw new ArgumentException(nameof(type));
            }

            if (Internal_CookCollisionDataInt(
                    unmanagedPtr,
                    type,
                    vertices.Count,
                    triangles.Count / 3,
                    Utils.ExtractArrayFromList(vertices),
                    Utils.ExtractArrayFromList(triangles),
                    convexFlags,
                    convexVertexLimit
                    ))
            {
                throw new FlaxException("Mesh cooking failed. See log to learn more.");
            }
        }
예제 #9
0
        /// <summary>
        /// Cooks the mesh collision data and saves it to the asset using <see cref="CollisionData"/> format. action cannot be performed on a main thread.
        /// </summary>
        /// <param name="path">The output asset path.</param>
        /// <param name="type">The collision data type.</param>
        /// <param name="model">The source model.</param>
        /// <param name="modelLodIndex">The source model LOD index.</param>
        /// <param name="convexFlags">The convex mesh generation flags.</param>
        /// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
        /// <returns>True if failed, otherwise false.</returns>
        public static bool CookMeshCollision(string path, CollisionDataType type, Model model, int modelLodIndex = 0, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (type == CollisionDataType.None)
            {
                throw new ArgumentException(nameof(type));
            }

            return(Internal_CookMeshCollision(path, type, model.unmanagedPtr, modelLodIndex, convexFlags, convexVertexLimit));
        }
 /// <summary>
 /// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
 /// </summary>
 /// <remarks>
 /// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
 /// </remarks>
 /// <param name="type">The collision data type.</param>
 /// <param name="vertices">The source geometry vertex buffer with vertices positions. Cannot be empty.</param>
 /// <param name="triangles">The source data index buffer (triangles list). Uses 32-bit stride buffer. Cannot be empty. Length must be multiple of 3 (as 3 vertices build a triangle).</param>
 /// <param name="convexFlags">The convex mesh generation flags.</param>
 /// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
 public bool CookCollision(CollisionDataType type, Vector3[] vertices, uint[] triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
 {
     return(Internal_CookCollision1(unmanagedPtr, type, vertices, triangles, convexFlags, convexVertexLimit));
 }
 /// <summary>
 /// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
 /// </summary>
 /// <remarks>
 /// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
 /// </remarks>
 /// <param name="type">The collision data type.</param>
 /// <param name="model">The source model.</param>
 /// <param name="modelLodIndex">The source model LOD index.</param>
 /// <param name="convexFlags">The convex mesh generation flags.</param>
 /// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
 public bool CookCollision(CollisionDataType type, Model model, int modelLodIndex = 0, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
 {
     return(Internal_CookCollision(unmanagedPtr, type, FlaxEngine.Object.GetUnmanagedPtr(model), modelLodIndex, convexFlags, convexVertexLimit));
 }
예제 #12
0
        public bool CookCollision(CollisionDataType type, Vector3[] vertices, int[] triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags.None, int convexVertexLimit = 255)
        {
            if (vertices == null)
            {
                throw new ArgumentNullException();
            }
            var tmp = new Float3[vertices.Length];

            for (int i = 0; i < tmp.Length; i++)
            {
                tmp[i] = vertices[i];
            }
            return(CookCollision(type, tmp, triangles, convexFlags, convexVertexLimit));
        }