Add package content.
This commit is contained in:
8
Runtime.meta
Normal file
8
Runtime.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 926c2a7dc7f1546b9926e929b2feb39c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Runtime/LICENSE.MD
Normal file
29
Runtime/LICENSE.MD
Normal file
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2011, Khaled Mamou (kmamou at gmail dot com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
7
Runtime/LICENSE.MD.meta
Normal file
7
Runtime/LICENSE.MD.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7251e877ef5d543d2b72461f9b0019e3
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
192
Runtime/VHACD.cs
Normal file
192
Runtime/VHACD.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshProcess
|
||||
{
|
||||
public class VHACD : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public unsafe struct Parameters
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
m_resolution = 100000;
|
||||
m_concavity = 0.001;
|
||||
m_planeDownsampling = 4;
|
||||
m_convexhullDownsampling = 4;
|
||||
m_alpha = 0.05;
|
||||
m_beta = 0.05;
|
||||
m_pca = 0;
|
||||
m_mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based
|
||||
m_maxNumVerticesPerCH = 64;
|
||||
m_minVolumePerCH = 0.0001;
|
||||
m_callback = null;
|
||||
m_logger = null;
|
||||
m_convexhullApproximation = 1;
|
||||
m_oclAcceleration = 0;
|
||||
m_maxConvexHulls = 1024;
|
||||
m_projectHullVertices = true; // This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results
|
||||
}
|
||||
|
||||
[Tooltip("maximum concavity")]
|
||||
[Range(0, 1)]
|
||||
public double m_concavity;
|
||||
|
||||
[Tooltip("controls the bias toward clipping along symmetry planes")]
|
||||
[Range(0, 1)]
|
||||
public double m_alpha;
|
||||
|
||||
[Tooltip("controls the bias toward clipping along revolution axes")]
|
||||
[Range(0, 1)]
|
||||
public double m_beta;
|
||||
|
||||
[Tooltip("controls the adaptive sampling of the generated convex-hulls")]
|
||||
[Range(0, 0.01f)]
|
||||
public double m_minVolumePerCH;
|
||||
|
||||
public void* m_callback;
|
||||
public void* m_logger;
|
||||
|
||||
[Tooltip("maximum number of voxels generated during the voxelization stage")]
|
||||
[Range(10000, 64000000)]
|
||||
public uint m_resolution;
|
||||
|
||||
[Tooltip("controls the maximum number of triangles per convex-hull")]
|
||||
[Range(4, 1024)]
|
||||
public uint m_maxNumVerticesPerCH;
|
||||
|
||||
[Tooltip("controls the granularity of the search for the \"best\" clipping plane")]
|
||||
[Range(1, 16)]
|
||||
public uint m_planeDownsampling;
|
||||
|
||||
[Tooltip("controls the precision of the convex-hull generation process during the clipping plane selection stage")]
|
||||
[Range(1, 16)]
|
||||
public uint m_convexhullDownsampling;
|
||||
|
||||
[Tooltip("enable/disable normalizing the mesh before applying the convex decomposition")]
|
||||
[Range(0, 1)]
|
||||
public uint m_pca;
|
||||
|
||||
[Tooltip("0: voxel-based (recommended), 1: tetrahedron-based")]
|
||||
[Range(0, 1)]
|
||||
public uint m_mode;
|
||||
|
||||
[Range(0, 1)]
|
||||
public uint m_convexhullApproximation;
|
||||
|
||||
[Range(0, 1)]
|
||||
public uint m_oclAcceleration;
|
||||
|
||||
public uint m_maxConvexHulls;
|
||||
|
||||
[Tooltip("This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results")]
|
||||
public bool m_projectHullVertices;
|
||||
};
|
||||
|
||||
unsafe struct ConvexHull
|
||||
{
|
||||
public double* m_points;
|
||||
public uint* m_triangles;
|
||||
public uint m_nPoints;
|
||||
public uint m_nTriangles;
|
||||
public double m_volume;
|
||||
public fixed double m_center[3];
|
||||
};
|
||||
|
||||
[DllImport("libvhacd")] static extern unsafe void* CreateVHACD();
|
||||
|
||||
[DllImport("libvhacd")] static extern unsafe void DestroyVHACD(void* pVHACD);
|
||||
|
||||
[DllImport("libvhacd")]
|
||||
static extern unsafe bool ComputeFloat(
|
||||
void* pVHACD,
|
||||
float* points,
|
||||
uint countPoints,
|
||||
uint* triangles,
|
||||
uint countTriangles,
|
||||
Parameters* parameters);
|
||||
|
||||
[DllImport("libvhacd")]
|
||||
static extern unsafe bool ComputeDouble(
|
||||
void* pVHACD,
|
||||
double* points,
|
||||
uint countPoints,
|
||||
uint* triangles,
|
||||
uint countTriangles,
|
||||
Parameters* parameters);
|
||||
|
||||
[DllImport("libvhacd")] static extern unsafe uint GetNConvexHulls(void* pVHACD);
|
||||
|
||||
[DllImport("libvhacd")]
|
||||
static extern unsafe void GetConvexHull(
|
||||
void* pVHACD,
|
||||
uint index,
|
||||
ConvexHull* ch);
|
||||
|
||||
public Parameters m_parameters;
|
||||
|
||||
public VHACD() { m_parameters.Init(); }
|
||||
|
||||
[ContextMenu("Generate Convex Meshes")]
|
||||
public unsafe List<Mesh> GenerateConvexMeshes(Mesh mesh = null)
|
||||
{
|
||||
if (mesh == null)
|
||||
{
|
||||
mesh = GetComponent<MeshFilter>().sharedMesh;
|
||||
}
|
||||
var vhacd = CreateVHACD();
|
||||
var parameters = m_parameters;
|
||||
|
||||
var verts = mesh.vertices;
|
||||
var tris = mesh.triangles;
|
||||
fixed (Vector3* pVerts = verts)
|
||||
fixed (int* pTris = tris)
|
||||
{
|
||||
ComputeFloat(
|
||||
vhacd,
|
||||
(float*)pVerts, (uint)verts.Length,
|
||||
(uint*)pTris, (uint)tris.Length / 3,
|
||||
¶meters);
|
||||
}
|
||||
|
||||
var numHulls = GetNConvexHulls(vhacd);
|
||||
List<Mesh> convexMesh = new List<Mesh>((int)numHulls);
|
||||
foreach (var index in Enumerable.Range(0, (int)numHulls))
|
||||
{
|
||||
ConvexHull hull;
|
||||
GetConvexHull(vhacd, (uint)index, &hull);
|
||||
|
||||
var hullMesh = new Mesh();
|
||||
var hullVerts = new Vector3[hull.m_nPoints];
|
||||
fixed (Vector3* pHullVerts = hullVerts)
|
||||
{
|
||||
var pComponents = hull.m_points;
|
||||
var pVerts = pHullVerts;
|
||||
|
||||
for (var pointCount = hull.m_nPoints; pointCount != 0; --pointCount)
|
||||
{
|
||||
pVerts->x = (float)pComponents[0];
|
||||
pVerts->y = (float)pComponents[1];
|
||||
pVerts->z = (float)pComponents[2];
|
||||
|
||||
pVerts += 1;
|
||||
pComponents += 3;
|
||||
}
|
||||
}
|
||||
|
||||
hullMesh.SetVertices(hullVerts);
|
||||
|
||||
var indices = new int[hull.m_nTriangles * 3];
|
||||
Marshal.Copy((System.IntPtr)hull.m_triangles, indices, 0, indices.Length);
|
||||
hullMesh.SetTriangles(indices, 0);
|
||||
|
||||
|
||||
convexMesh.Add(hullMesh);
|
||||
}
|
||||
return convexMesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/VHACD.cs.meta
Normal file
11
Runtime/VHACD.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 845ffa358c43240dda6ed5379b4f0c8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Runtime/liblibvhacd.dylib
LFS
Normal file
BIN
Runtime/liblibvhacd.dylib
LFS
Normal file
Binary file not shown.
32
Runtime/liblibvhacd.dylib.meta
Normal file
32
Runtime/liblibvhacd.dylib.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94c2c889690e246e8af1941d40e09b36
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Runtime/liblibvhacd.so
LFS
Normal file
BIN
Runtime/liblibvhacd.so
LFS
Normal file
Binary file not shown.
80
Runtime/liblibvhacd.so.meta
Normal file
80
Runtime/liblibvhacd.so.meta
Normal file
@@ -0,0 +1,80 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47c08989d7bad470487e2f72442e442f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Linux
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: X86
|
||||
DontProcess: true
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Runtime/libvhacd.dll
LFS
Normal file
BIN
Runtime/libvhacd.dll
LFS
Normal file
Binary file not shown.
75
Runtime/libvhacd.dll.meta
Normal file
75
Runtime/libvhacd.dll.meta
Normal file
@@ -0,0 +1,75 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d1723769ada3482b80ae4dd6837ab53
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 0
|
||||
Exclude WindowsStoreApps: 1
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: X86
|
||||
DontProcess: false
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Runtime/vhacd.asmdef
Normal file
15
Runtime/vhacd.asmdef
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "vhacd",
|
||||
"rootNamespace": "VHACD",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Runtime/vhacd.asmdef.meta
Normal file
7
Runtime/vhacd.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0dc65aa46d174cbab72d2bfef413320
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
package.json
Normal file
9
package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "com.unity.robotics.vhacd",
|
||||
"version": "0.0.1-preview",
|
||||
"displayName": "VHACD",
|
||||
"description": "",
|
||||
"unity": "2020.3",
|
||||
"unityRelease": "19f1",
|
||||
"_fingerprint": "d52fd80370d9257cb417999c6f5eab56604b3da9"
|
||||
}
|
||||
7
package.json.meta
Normal file
7
package.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bece70ee13b874e1b9d0a20a25213f62
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user