static StackObject *DrawWireMesh_16(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Vector3 position = (UnityEngine.Vector3) typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Mesh mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); UnityEngine.Gizmos.DrawWireMesh(mesh, position); return(__ret); }
static StackObject *DrawWireMesh_31(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int32 @submeshIndex = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Mesh @mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); UnityEngine.Gizmos.DrawWireMesh(@mesh, @submeshIndex); return(__ret); }
static StackObject *SetMesh_21(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.CanvasRenderer instance_of_this_method; instance_of_this_method = (UnityEngine.CanvasRenderer) typeof(UnityEngine.CanvasRenderer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.SetMesh(mesh); return(__ret); }
static StackObject *FillMesh_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh @mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.VertexHelper instance_of_this_method = (UnityEngine.UI.VertexHelper) typeof(UnityEngine.UI.VertexHelper).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.FillMesh(@mesh); return(__ret); }
int UnityEngineSkinnedMeshRenderer_m_BakeMesh(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.SkinnedMeshRenderer gen_to_be_invoked = (UnityEngine.SkinnedMeshRenderer)translator.FastGetCSObj(L, 1); { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); gen_to_be_invoked.BakeMesh(_mesh); return(0); } }
static StackObject *ModifyMesh_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh @mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.BaseMeshEffect instance_of_this_method = (UnityEngine.UI.BaseMeshEffect) typeof(UnityEngine.UI.BaseMeshEffect).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.ModifyMesh(@mesh); return(__ret); }
static StackObject *set_sharedMesh_9(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh @value = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.SkinnedMeshRenderer instance_of_this_method = (UnityEngine.SkinnedMeshRenderer) typeof(UnityEngine.SkinnedMeshRenderer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.sharedMesh = value; return(__ret); }
static StackObject *set_additionalVertexStreams_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh value = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.MeshRenderer instance_of_this_method; instance_of_this_method = (UnityEngine.MeshRenderer) typeof(UnityEngine.MeshRenderer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.additionalVertexStreams = value; return(__ret); }
static StackObject *set_vertices_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Vector3[] @value = (UnityEngine.Vector3[]) typeof(UnityEngine.Vector3[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Mesh instance_of_this_method = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.vertices = value; return(__ret); }
public OCMeshBuilder FromMesh(UnityEngine.Mesh mesh) { if (mesh == null) { return(this); } _vertices.AddRange(mesh.vertices); _colors.AddRange(mesh.colors); _normals.AddRange(mesh.normals); _uv.AddRange(mesh.uv); for (int i = 0; i < mesh.subMeshCount; ++i) { AddIndices(0, mesh.GetTriangles(i)); } return(this); }
static StackObject *set_mesh_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Mesh value = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.CombineInstance instance_of_this_method; instance_of_this_method = (UnityEngine.CombineInstance) typeof(UnityEngine.CombineInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); instance_of_this_method.mesh = value; WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); return(__ret); }
private void Awake() { #if UNITY_EDITOR if (UnityEditor.BuildPipeline.isBuildingPlayer || AkUtilities.IsMigrating) { return; } var reference = AkUtilities.DragAndDropObjectReference; if (reference) { UnityEngine.GUIUtility.hotControl = 0; if (AcousticTextures == null || AcousticTextures.Length < 1) { AcousticTextures = new AK.Wwise.AcousticTexture[1]; } if (AcousticTextures[0] == null) { AcousticTextures[0] = new AK.Wwise.AcousticTexture(); } AcousticTextures[0].ObjectReference = reference; } if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif if (Mesh == null) { var meshFilter = GetComponent <UnityEngine.MeshFilter>(); if (meshFilter != null) { Mesh = meshFilter.sharedMesh; } } }
static int _m_BakeMesh(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.SkinnedMeshRenderer gen_to_be_invoked = (UnityEngine.SkinnedMeshRenderer)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && translator.Assignable <UnityEngine.Mesh>(L, 2)) { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); gen_to_be_invoked.BakeMesh( _mesh); return(0); } if (gen_param_count == 3 && translator.Assignable <UnityEngine.Mesh>(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); bool _useScale = LuaAPI.lua_toboolean(L, 3); gen_to_be_invoked.BakeMesh( _mesh, _useScale); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.SkinnedMeshRenderer.BakeMesh!")); }
static int _m_ImportFile_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { string _filePath = LuaAPI.lua_tostring(L, 1); UnityEngine.Mesh gen_ret = Pathfinding.ObjImporter.ImportFile(_filePath); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static StackObject *BakeMesh_31(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Boolean @useTransform = ptr_of_this_method->Value == 1; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Mesh @mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); UnityEngine.LineRenderer instance_of_this_method = (UnityEngine.LineRenderer) typeof(UnityEngine.LineRenderer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.BakeMesh(@mesh, @useTransform); return(__ret); }
private static void MenuItem_LoadAssetWithAssetsPath() { //SaveAssetWithAssetsPath { UnityEngine.Mesh t_mesh = new UnityEngine.Mesh(); { System.Collections.Generic.List <UnityEngine.Vector3> t_vertex_list = new System.Collections.Generic.List <UnityEngine.Vector3>(); System.Collections.Generic.List <UnityEngine.Vector3> t_nomal_list = new System.Collections.Generic.List <UnityEngine.Vector3>(); System.Collections.Generic.List <int> t_index_list = new System.Collections.Generic.List <int>(); { t_vertex_list.Add(new UnityEngine.Vector3(0.0f, 0.0f, 0.0f)); t_vertex_list.Add(new UnityEngine.Vector3(0.0f, 1.0f, 0.0f)); t_vertex_list.Add(new UnityEngine.Vector3(0.0f, 0.0f, 1.0f)); t_nomal_list.Add(new UnityEngine.Vector3(0.0f, 0.0f, 1.0f)); t_nomal_list.Add(new UnityEngine.Vector3(0.0f, 0.0f, 1.0f)); t_nomal_list.Add(new UnityEngine.Vector3(0.0f, 0.0f, 1.0f)); t_index_list.Add(0); t_index_list.Add(1); t_index_list.Add(2); } t_mesh.vertices = t_vertex_list.ToArray(); t_mesh.normals = t_nomal_list.ToArray(); t_mesh.triangles = t_index_list.ToArray(); t_mesh.RecalculateNormals(); t_mesh.RecalculateBounds(); t_mesh.RecalculateTangents(); } BlueBack.AssetLib.Editor.CreateDirectoryWithAssetsPath.Create("Out"); BlueBack.AssetLib.Editor.SaveAssetWithAssetsPath.Save <UnityEngine.Mesh>(t_mesh, "Out/test.mesh"); BlueBack.AssetLib.Editor.RefreshAssetDatabase.Refresh(); } //LoadAssetWithAssetsPath { UnityEngine.Mesh t_mesh = BlueBack.AssetLib.Editor.LoadAssetWithAssetsPath.Load <UnityEngine.Mesh>("Out/test.mesh"); UnityEngine.Debug.Log(t_mesh.triangles.Length.ToString()); } }
static StackObject *DrawMesh_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 4); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Quaternion rotation = (UnityEngine.Quaternion) typeof(UnityEngine.Quaternion).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Vector3 position = (UnityEngine.Vector3) typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Int32 submeshIndex = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 4); UnityEngine.Mesh mesh = (UnityEngine.Mesh) typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); UnityEngine.Gizmos.DrawMesh(mesh, submeshIndex, position, rotation); return(__ret); }
static int _m_FillMesh(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.VertexHelper __cl_gen_to_be_invoked = (UnityEngine.UI.VertexHelper)translator.FastGetCSObj(L, 1); try { { UnityEngine.Mesh mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); __cl_gen_to_be_invoked.FillMesh(mesh); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
private UnityEngine.Mesh ScaleItemMesh(UnityEngine.Mesh itemMesh, UnityEngine.RectTransform meshRendererUIRect) { //UI is on x,y coordinates but mesh still needs scaling in all directions, we will assume that the item slot has a square shape for now. //So we take the y axis for z scaling //Scale it up to the size of the "cell" float3 scaling = new float3(meshRendererUIRect.sizeDelta.x, meshRendererUIRect.sizeDelta.y, meshRendererUIRect.sizeDelta.y) - new float3(itemMesh.bounds.size); //This vertices array needs to be copied before modyfying! Otherwise Unity will throw invalid AABB errors because some vertices are already scaled while others are not yet UnityEngine.Vector3[] vertices = itemMesh.vertices; for (int i = 0; i < vertices.Length; ++i) { vertices[i].x *= scaling.x; vertices[i].y *= scaling.y; vertices[i].z *= scaling.z; } itemMesh.vertices = vertices; itemMesh.RecalculateBounds(); return(itemMesh); }
static int _m_BakeMesh(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.SkinnedMeshRenderer gen_to_be_invoked = (UnityEngine.SkinnedMeshRenderer)translator.FastGetCSObj(L, 1); { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); gen_to_be_invoked.BakeMesh(_mesh); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public UnityEngine.Mesh ToMesh() { return(ab); var mesh = new UnityEngine.Mesh(); // mesh.uv=uv.ToArray(); // mesh.triangles = Faces.ToArray(); for (int i = 0; i < Vertices.Count; i++) { var v = Vertices[i]; v.x -= 30; Vertices[i] = v; // Vertices[i]=new UnityEngine.Vector3(); } mesh.vertices = (Vertices).ToArray(); UnityEngine.Debug.Log("count" + uv.Count); var wr = Faces.ToArray(); Array.Resize(ref wr, Vertices.Count); mesh.SetIndices(wr, UnityEngine.MeshTopology.Triangles, 0); var tw = uv.ToArray(); Array.Resize(ref tw, Vertices.Count); // uv.ToArray(); //var sz= new UnityEngine.Vector3[] { normal }; // Array.Resize(ref sz, Vertices.Count); // mesh.normals = sz; mesh.SetUVs(0, tw.ToList()); // mesh.normals = new UnityEngine.Vector3[] { normal }; return(mesh); }
static int _m_ModifyMesh(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.BaseMeshEffect gen_to_be_invoked = (UnityEngine.UI.BaseMeshEffect)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && translator.Assignable <UnityEngine.Mesh>(L, 2)) { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); gen_to_be_invoked.ModifyMesh(_mesh); return(0); } if (gen_param_count == 2 && translator.Assignable <UnityEngine.UI.VertexHelper>(L, 2)) { UnityEngine.UI.VertexHelper _vh = (UnityEngine.UI.VertexHelper)translator.GetObject(L, 2, typeof(UnityEngine.UI.VertexHelper)); gen_to_be_invoked.ModifyMesh(_vh); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.UI.BaseMeshEffect.ModifyMesh!")); }
static int _m_ModifyMesh(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Extensions.UIFlippable __cl_gen_to_be_invoked = (UnityEngine.UI.Extensions.UIFlippable)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 2 && translator.Assignable <UnityEngine.UI.VertexHelper>(L, 2)) { UnityEngine.UI.VertexHelper verts = (UnityEngine.UI.VertexHelper)translator.GetObject(L, 2, typeof(UnityEngine.UI.VertexHelper)); __cl_gen_to_be_invoked.ModifyMesh(verts); return(0); } if (__gen_param_count == 2 && translator.Assignable <UnityEngine.Mesh>(L, 2)) { UnityEngine.Mesh mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); __cl_gen_to_be_invoked.ModifyMesh(mesh); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.UI.Extensions.UIFlippable.ModifyMesh!")); }
static int _m_UpdateGeometry(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); TMPro.TextMeshProUGUI gen_to_be_invoked = (TMPro.TextMeshProUGUI)translator.FastGetCSObj(L, 1); { UnityEngine.Mesh _mesh = (UnityEngine.Mesh)translator.GetObject(L, 2, typeof(UnityEngine.Mesh)); int _index = LuaAPI.xlua_tointeger(L, 3); gen_to_be_invoked.UpdateGeometry(_mesh, _index); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public static UnityEngine.Mesh ToUnityMesh(File file) { if (file.FileType != File.Type.Model) { return(null); } Assimp.AssimpContext ctx = new Assimp.AssimpContext(); Assimp.Scene s = ctx.ImportFileFromStream(file.StreamData, Assimp.PostProcessSteps.Triangulate); if (!s.HasMeshes) { return(null); } var mesh = s.Meshes[0]; var newMesh = new UnityEngine.Mesh(); newMesh.vertices = mesh.Vertices.ConvertAll(v => v.ToV3()).ToArray(); //int[] indicies = mesh.GetIndices(); List <int> indicies = new List <int>(); foreach (var face in mesh.Faces) { indicies.AddRange(face.Indices); } newMesh.triangles = indicies.ToArray(); for (int i = 0; i < mesh.TextureCoordinateChannelCount; ++i) { newMesh.SetUVs(i, mesh.TextureCoordinateChannels[i].ConvertAll(v => v.ToV2())); } return(newMesh); }
private static void SetGeometryFromMesh( UnityEngine.Mesh mesh, AK.Wwise.AcousticTexture[] acousticTextures, float[] occlusionValues, UnityEngine.Transform transform, ulong geometryID, ulong associatedRoomID, bool enableDiffraction, bool enableDiffractionOnBoundaryEdges, string name = "") { var vertices = mesh.vertices; // Remove duplicate vertices var vertRemap = new int[vertices.Length]; var uniqueVerts = new System.Collections.Generic.List <UnityEngine.Vector3>(); var vertDict = new System.Collections.Generic.Dictionary <UnityEngine.Vector3, int>(); for (var v = 0; v < vertices.Length; ++v) { int vertIdx = 0; if (!vertDict.TryGetValue(vertices[v], out vertIdx)) { vertIdx = uniqueVerts.Count; uniqueVerts.Add(vertices[v]); vertDict.Add(vertices[v], vertIdx); } vertRemap[v] = vertIdx; } int vertexCount = uniqueVerts.Count; var vertexArray = new UnityEngine.Vector3[vertexCount]; for (var v = 0; v < vertexCount; ++v) { var point = transform.TransformPoint(uniqueVerts[v]); vertexArray[v].x = point.x; vertexArray[v].y = point.y; vertexArray[v].z = point.z; } int surfaceCount = mesh.subMeshCount; var numTriangles = mesh.triangles.Length / 3; if ((mesh.triangles.Length % 3) != 0) { UnityEngine.Debug.LogFormat("SetGeometryFromMesh({0}): Wrong number of triangles", mesh.name); } using (var surfaceArray = new AkAcousticSurfaceArray(surfaceCount)) using (var triangleArray = new AkTriangleArray(numTriangles)) { int triangleArrayIdx = 0; for (var s = 0; s < surfaceCount; ++s) { var surface = surfaceArray[s]; var triangles = mesh.GetTriangles(s); var triangleCount = triangles.Length / 3; if ((triangles.Length % 3) != 0) { UnityEngine.Debug.LogFormat("SetGeometryFromMesh({0}): Wrong number of triangles in submesh {1}", mesh.name, s); } AK.Wwise.AcousticTexture acousticTexture = null; float occlusionValue = 1.0f; if (s < acousticTextures.Length) { acousticTexture = acousticTextures[s]; } if (s < occlusionValues.Length) { occlusionValue = occlusionValues[s]; } surface.textureID = acousticTexture == null ? AK.Wwise.AcousticTexture.InvalidId : acousticTexture.Id; surface.occlusion = occlusionValue; surface.strName = name + "_" + mesh.name + "_" + s; for (var i = 0; i < triangleCount; ++i) { var triangle = triangleArray[triangleArrayIdx]; triangle.point0 = (ushort)vertRemap[triangles[3 * i + 0]]; triangle.point1 = (ushort)vertRemap[triangles[3 * i + 1]]; triangle.point2 = (ushort)vertRemap[triangles[3 * i + 2]]; triangle.surface = (ushort)s; if (triangle.point0 != triangle.point1 && triangle.point0 != triangle.point2 && triangle.point1 != triangle.point2) { ++triangleArrayIdx; } else { UnityEngine.Debug.LogFormat("SetGeometryFromMesh({0}): Skipped degenerate triangle({1}, {2}, {3}) in submesh {4}", mesh.name, 3 * i + 0, 3 * i + 1, 3 * i + 2, s); } } } if (triangleArrayIdx > 0) { AkSoundEngine.SetGeometry( geometryID, triangleArray, (uint)triangleArrayIdx, vertexArray, (uint)vertexArray.Length, surfaceArray, (uint)surfaceArray.Count(), associatedRoomID, enableDiffraction, enableDiffractionOnBoundaryEdges); } else { UnityEngine.Debug.LogFormat("SetGeometry({0}): No valid triangle was found. Geometry was not set", mesh.name); } } }
/// <summary> /// method for rendering a sphere /// by taking a centerpoint, radius, mesh, and n vertices /// </summary> /// <param name="crossSectionRadius"></param> /// <param name="center"></param> /// <param name="crossSectionRenderer"></param> /// <param name="n"></param> public static void RenderSphere(float crossSectionRadius, Unity.Mathematics.float3 center, UnityEngine.Mesh crossSectionRenderer, int n) { crossSectionRenderer.Clear(); int nbLong = n; int nbLat = n; #region Vertices UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[(nbLong + 1) * nbLat + 2]; float pi = UnityEngine.Mathf.PI; float _2pi = pi * 2f; vertices[0] = UnityEngine.Vector3.up * crossSectionRadius; for (int lat = 0; lat < nbLat; lat++) { float a1 = pi * (lat + 1) / (nbLat + 1); float sin1 = UnityEngine.Mathf.Sin(a1); float cos1 = UnityEngine.Mathf.Cos(a1); for (int lon = 0; lon <= nbLong; lon++) { float a2 = _2pi * (lon == nbLong ? 0 : lon) / nbLong; float sin2 = UnityEngine.Mathf.Sin(a2); float cos2 = UnityEngine.Mathf.Cos(a2); vertices[lon + lat * (nbLong + 1) + 1] = new UnityEngine.Vector3(sin1 * cos2, cos1, sin1 * sin2) * crossSectionRadius; } } vertices[vertices.Length - 1] = UnityEngine.Vector3.up * -crossSectionRadius; #endregion #region Normals UnityEngine.Vector3[] normals = new UnityEngine.Vector3[vertices.Length]; for (int j = 0; j < vertices.Length; j++) { normals[j] = vertices[j].normalized; } #endregion #region UVs UnityEngine.Vector2[] uvs = new UnityEngine.Vector2[vertices.Length]; uvs[0] = UnityEngine.Vector2.up; uvs[uvs.Length - 1] = UnityEngine.Vector2.zero; for (int lat = 0; lat < nbLat; lat++) { for (int lon = 0; lon <= nbLong; lon++) { uvs[lon + lat * (nbLong + 1) + 1] = new UnityEngine.Vector2((float)lon / nbLong, 1f - (float)(lat + 1) / (nbLat + 1)); } } #endregion #region Triangles int nbFaces = vertices.Length; int nbTriangles = nbFaces * 2; int nbIndexes = nbTriangles * 3; int[] triangles = new int[nbIndexes]; //Top Cap int i = 0; for (int lon = 0; lon < nbLong; lon++) { triangles[i++] = lon + 2; triangles[i++] = lon + 1; triangles[i++] = 0; } //Middle for (int lat = 0; lat < nbLat - 1; lat++) { for (int lon = 0; lon < nbLong; lon++) { int current = lon + lat * (nbLong + 1) + 1; int next = current + nbLong + 1; triangles[i++] = current; triangles[i++] = current + 1; triangles[i++] = next + 1; triangles[i++] = current; triangles[i++] = next + 1; triangles[i++] = next; } } //Bottom Cap for (int lon = 0; lon < nbLong; lon++) { triangles[i++] = vertices.Length - 1; triangles[i++] = vertices.Length - (lon + 2) - 1; triangles[i++] = vertices.Length - (lon + 1) - 1; } #endregion crossSectionRenderer.vertices = vertices; crossSectionRenderer.normals = normals; crossSectionRenderer.uv = uvs; crossSectionRenderer.triangles = triangles; crossSectionRenderer.RecalculateBounds(); }
public Primitive(UnityEngine.Mesh mesh, int[] materialIndex) { this.mesh = mesh; this.materialIndices = materialIndex; }
public UnityEngine.Mesh ToMesh(UnityEngine.Mesh mesh) { if(_vertices.Count == 0) { UnityEngine.GameObject.Destroy(mesh); return null; } if(mesh == null) mesh = new UnityEngine.Mesh(); mesh.Clear(); mesh.vertices = _vertices.ToArray(); mesh.colors = _colors.ToArray(); mesh.normals = _normals.ToArray(); mesh.uv = _uv.ToArray(); mesh.subMeshCount = indices.Length; for(int i=0; i<indices.Length; i++) { mesh.SetTriangles( indices[i].ToArray(), i ); } return mesh; }
public static object Serialize_UnityMesh(object obj, System.Type type, OverloadLevelConvertSerializer serializer) { uint version = serializer.Version; UnityEngine.Mesh mesh = (UnityEngine.Mesh)obj; int flags; if (version <= 3) { // old version, we just had 'colors' flags = 1; } else { // new version, use a flags value to report what we have if (serializer.IsWriting) { flags = 0; if (mesh.colors != null && mesh.colors.Length > 0) { flags |= 1; } if (mesh.colors32 != null && mesh.colors32.Length > 0) { flags |= 2; } serializer.SerializeOut_int32(flags); } else { flags = serializer.SerializeIn_int32(); } } serializer.SerializeX(mesh, x => x.name); serializer.SerializeX(mesh, x => x.vertices); // Note: vertices must come first since the other fields may check size invariants serializer.SerializeX(mesh, x => x.uv); serializer.SerializeX(mesh, x => x.uv2); serializer.SerializeX(mesh, x => x.uv3); serializer.SerializeX(mesh, x => x.normals); serializer.SerializeX(mesh, x => x.tangents); if ((flags & 1) != 0) { serializer.SerializeX(mesh, x => x.colors); } if ((flags & 2) != 0) { serializer.SerializeX(mesh, x => x.colors32); } if (version > 3) { serializer.SerializeX(mesh, x => x.boneWeights); serializer.SerializeX(mesh, x => x.bindposes); } if (serializer.IsWriting) { Int32 numSubmeshes = mesh.subMeshCount; serializer.SerializeOut_int32(numSubmeshes); for (Int32 i = 0; i < numSubmeshes; ++i) { Int32[] tris = mesh.GetTriangles(i); serializer.SerializeOut_array(typeof(Int32), tris); } } else { Int32 numSubmeshes = serializer.SerializeIn_int32(); mesh.subMeshCount = numSubmeshes; for (Int32 i = 0; i < numSubmeshes; ++i) { Int32[] tris = (Int32[])serializer.SerializeIn_array(typeof(Int32)); mesh.SetTriangles(tris, i); } } return(mesh); }
private ulong GetGeometryID() { ulong geometryID = AkSurfaceReflector.INVALID_GEOMETRY_ID; AkSurfaceReflector surfaceReflector = GetComponent <AkSurfaceReflector>(); if (surfaceReflector && surfaceReflector.enabled) { geometryID = surfaceReflector.GetID(); } else { if (roomCollider == null) { roomCollider = GetComponent <UnityEngine.Collider>(); } if (roomCollider.GetType() == typeof(UnityEngine.MeshCollider)) { geometryID = GetID(); UnityEngine.MeshCollider meshCollider = GetComponent <UnityEngine.MeshCollider>(); #if UNITY_EDITOR if (previousColliderType == typeof(UnityEngine.MeshCollider) && previousMeshCollider != null && previousMeshCollider.sharedMesh == meshCollider.sharedMesh && previousPosition == transform.position && previousRotation == transform.rotation && previousScale == transform.localScale) { return(geometryID); } #endif AkSurfaceReflector.SetGeometryFromMesh(meshCollider.sharedMesh, transform, geometryID, INVALID_ROOM_ID, false, false, false); #if UNITY_EDITOR previousMeshCollider = meshCollider; previousPosition = transform.position; previousRotation = transform.rotation; previousScale = transform.localScale; #endif previousColliderType = typeof(UnityEngine.MeshCollider); } else if (roomCollider.GetType() == typeof(UnityEngine.BoxCollider)) { geometryID = GetID(); UnityEngine.BoxCollider boxCollider = GetComponent <UnityEngine.BoxCollider>(); #if UNITY_EDITOR if (previousColliderType == typeof(UnityEngine.BoxCollider) && previousBoxCollider != null && previousPosition == roomCollider.bounds.center && previousRotation == transform.rotation && previousScale == new UnityEngine.Vector3(transform.localScale.x * boxCollider.size.x, transform.localScale.y * boxCollider.size.y, transform.localScale.z * boxCollider.size.z)) { return(geometryID); } #endif UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube); UnityEngine.Mesh mesh = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh; tempGameObject.transform.position = boxCollider.bounds.center; tempGameObject.transform.rotation = transform.rotation; UnityEngine.Vector3 roomScale = new UnityEngine.Vector3(); roomScale.x = transform.localScale.x * boxCollider.size.x; roomScale.y = transform.localScale.y * boxCollider.size.y; roomScale.z = transform.localScale.z * boxCollider.size.z; tempGameObject.transform.localScale = roomScale; AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false); #if UNITY_EDITOR previousBoxCollider = boxCollider; previousPosition = tempGameObject.transform.position; previousRotation = tempGameObject.transform.rotation; previousScale = tempGameObject.transform.localScale; #endif previousColliderType = typeof(UnityEngine.BoxCollider); UnityEngine.GameObject.Destroy(tempGameObject); } else if (roomCollider.GetType() == typeof(UnityEngine.CapsuleCollider)) { geometryID = GetID(); UnityEngine.CapsuleCollider capsuleCollider = GetComponent <UnityEngine.CapsuleCollider>(); #if UNITY_EDITOR if (previousColliderType == typeof(UnityEngine.CapsuleCollider) && previousCapsuleCollider != null && previousPosition == capsuleCollider.bounds.center && previousRotation == transform.rotation && previousScale == GetCapsuleScale(transform.localScale, capsuleCollider.radius, capsuleCollider.height, capsuleCollider.direction)) { return(geometryID); } #endif UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube); UnityEngine.Mesh mesh = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh; tempGameObject.transform.position = capsuleCollider.bounds.center; tempGameObject.transform.rotation = transform.rotation; tempGameObject.transform.localScale = GetCapsuleScale(transform.localScale, capsuleCollider.radius, capsuleCollider.height, capsuleCollider.direction); AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false); #if UNITY_EDITOR previousCapsuleCollider = capsuleCollider; previousPosition = tempGameObject.transform.position; previousRotation = tempGameObject.transform.rotation; previousScale = tempGameObject.transform.localScale; #endif previousColliderType = typeof(UnityEngine.CapsuleCollider); UnityEngine.GameObject.Destroy(tempGameObject); } else if (roomCollider.GetType() == typeof(UnityEngine.SphereCollider)) { geometryID = GetID(); #if UNITY_EDITOR if (previousColliderType == typeof(UnityEngine.SphereCollider) && previousPosition == roomCollider.bounds.center && previousScale == roomCollider.bounds.size) { return(geometryID); } #endif UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Sphere); UnityEngine.Mesh mesh = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh; tempGameObject.transform.position = roomCollider.bounds.center; tempGameObject.transform.localScale = roomCollider.bounds.size; AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false); #if UNITY_EDITOR previousColliderType = typeof(UnityEngine.SphereCollider); previousPosition = tempGameObject.transform.position; previousScale = tempGameObject.transform.localScale; #endif previousColliderType = typeof(UnityEngine.SphereCollider); UnityEngine.GameObject.Destroy(tempGameObject); } else { if (previousColliderType == roomCollider.GetType()) { return(geometryID); } UnityEngine.Debug.LogWarning(name + " has an invalid collider for wet transmission. Wet Transmission will be disabled."); // in case a geometry was added with the room's ID, remove it if (previousColliderType == typeof(UnityEngine.MeshCollider) || previousColliderType == typeof(UnityEngine.BoxCollider) || previousColliderType == typeof(UnityEngine.SphereCollider) || previousColliderType == typeof(UnityEngine.CapsuleCollider)) { AkSoundEngine.RemoveGeometry(GetID()); } previousColliderType = roomCollider.GetType(); } } return(geometryID); }