Exemplo n.º 1
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LOD o;
         System.Single   a1;
         checkType(l, 2, out a1);
         UnityEngine.Renderer[] a2;
         checkArray(l, 3, out a2);
         o = new UnityEngine.LOD(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static void LOD_renderers(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.LOD _this  = (UnityEngine.LOD)vc.csObj;
         var             result = _this.renderers;
         var             arrRet = result;
         for (int i = 0; arrRet != null && i < arrRet.Length; i++)
         {
             JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
             JSApi.moveSaveID2Arr(i);
         }
         JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
     }
     else
     {
         UnityEngine.Renderer[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.Renderer[]>(() =>
         {
             int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
             int length  = JSApi.getArrayLength(jsObjID);
             var ret     = new UnityEngine.Renderer[length];
             for (var i = 0; i < length; i++)
             {
                 JSApi.getElement(jsObjID, i);
                 ret[i] = (UnityEngine.Renderer)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
             }
             return(ret);
         });
         UnityEngine.LOD _this = (UnityEngine.LOD)vc.csObj;
         _this.renderers = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Exemplo n.º 3
0
 static public int constructor(IntPtr l)
 {
     try {
         int             argc = LuaDLL.lua_gettop(l);
         UnityEngine.LOD o;
         if (argc == 3)
         {
             System.Single a1;
             checkType(l, 2, out a1);
             UnityEngine.Renderer[] a2;
             checkArray(l, 3, out a2);
             o = new UnityEngine.LOD(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc <= 2)
         {
             o = new UnityEngine.LOD();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 4
0
 static public int set_screenRelativeTransitionHeight(IntPtr l)
 {
     UnityEngine.LOD o = (UnityEngine.LOD)checkSelf(l);
     System.Single   v;
     checkType(l, 2, out v);
     o.screenRelativeTransitionHeight = v;
     setBack(l, o);
     return(0);
 }
Exemplo n.º 5
0
 static public int set_renderers(IntPtr l)
 {
     UnityEngine.LOD        o = (UnityEngine.LOD)checkSelf(l);
     UnityEngine.Renderer[] v;
     checkType(l, 2, out v);
     o.renderers = v;
     setBack(l, o);
     return(0);
 }
Exemplo n.º 6
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.LOD o;
     System.Single   a1;
     checkType(l, 2, out a1);
     UnityEngine.Renderer[] a2;
     checkType(l, 3, out a2);
     o = new UnityEngine.LOD(a1, a2);
     pushObject(l, o);
     return(1);
 }
Exemplo n.º 7
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.LOD o;
         System.Single   a1;
         checkType(l, 2, out a1);
         UnityEngine.Renderer[] a2;
         checkType(l, 3, out a2);
         o = new UnityEngine.LOD(a1, a2);
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 8
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.LOD o;
			System.Single a1;
			checkType(l,2,out a1);
			UnityEngine.Renderer[] a2;
			checkArray(l,3,out a2);
			o=new UnityEngine.LOD(a1,a2);
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 static void LOD_fadeTransitionWidth(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.LOD _this  = (UnityEngine.LOD)vc.csObj;
         var             result = _this.fadeTransitionWidth;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single   arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.LOD _this = (UnityEngine.LOD)vc.csObj;
         _this.fadeTransitionWidth = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.LOD o;
         System.Single a1;
         checkType(l,2,out a1);
         UnityEngine.Renderer[] a2;
         checkType(l,3,out a2);
         o=new UnityEngine.LOD(a1,a2);
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Exemplo n.º 11
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.LOD o;
     if (matchType(l, 1, typeof(float), typeof(UnityEngine.Renderer[])))
     {
         System.Single a1;
         checkType(l, 1, out a1);
         UnityEngine.Renderer[] a2;
         checkType(l, 2, out a2);
         o = new UnityEngine.LOD(a1, a2);
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Exemplo n.º 12
0
    static bool LODGroup_SetLODS__LOD_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.LOD[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.LOD[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.LOD[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.LOD)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            ((UnityEngine.LODGroup)vc.csObj).SetLODS(arg0);
        }

        return(true);
    }
Exemplo n.º 13
0
		public extern void SetLODS(LOD[] scriptingLODs);
		void BuildLODS(GameObject target,Vector3[] verts,Vector2[] uvs, int[] tris, Color[] colors, Vector3[] normals)
		{
			GameObject go;
			LODGroup group;

			group = target.transform.parent.gameObject.AddComponent<LODGroup>();
			LOD[] lods = new LOD[lodLevels];


			float lerpStep = 1/(float)(lodLevels-1);
			float lerpVal=1;

			// make LODS
			for (int i=0; i<lodLevels; i++)
			{

				if (i==0) // main mesh
				{
					go = target;

				}else{ // make simplified meshes

					go = new GameObject();
					go.AddComponent<MeshFilter>();
					go.AddComponent<MeshRenderer>();

					Mesh mesh = new Mesh();
					go.GetComponent<MeshFilter>().mesh = mesh;
					go.transform.name = "PC_"+meshCounter+"_"+i.ToString();
					go.GetComponent<Renderer>().sharedMaterial = meshMaterial;
					go.GetComponent<Renderer>().receiveShadows = false;
					go.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

					lerpVal-=lerpStep;
					int newVertCount = (int)Mathf.Lerp(minLodVertexCount,decimatePoints?vertCount/removeEveryNth:vertCount,lerpVal);

					var newVerts = new Vector3[newVertCount];
					var newUvs = new Vector2[newVertCount];
					var newColors = new Color[newVertCount];
					var newNormals = new Vector3[newVertCount];
					var newTris = new int[newVertCount];

					// get new verts
					float oldIndex=0;
					float stepSize= vertCount/(float)newVertCount;

					// TODO: if rounds to same index, take next instead of same point?
					float o=0;

					for (int newIndex = 0; newIndex < newVertCount; newIndex++)
					{
						newVerts[newIndex] = verts[Mathf.FloorToInt(o)];
						newUvs[newIndex] = uvs[Mathf.FloorToInt(o)];
						newTris[newIndex] = newIndex; //tris[newIndex];


						if (readRGB) newColors[newIndex] = colors[Mathf.FloorToInt(o)];

						/*
						// for debugging LODS, different colors per lod
						switch(i)
						{
						case 1:
							newColors[newIndex] = Color.red;
							break;
						case 2:
							newColors[newIndex] = Color.green;
							break;
						case 3:
							newColors[newIndex] = Color.yellow;
							break;
						case 4:
							newColors[newIndex] = Color.cyan;
							break;
						default:
							newColors[newIndex] = Color.magenta;
							break;
						}*/

						if (readNormals) newNormals[newIndex] = normals[Mathf.FloorToInt(o)];
						o+=stepSize;
					}

					mesh.vertices = newVerts;
					mesh.uv = newUvs;
					if (readRGB||readIntensity) mesh.colors = newColors;
					if (readNormals) mesh.normals = newNormals;
					mesh.SetIndices (newTris, MeshTopology.Points, 0);
				} // if master


				go.transform.parent = target.transform.parent;
				Renderer[] renderers = new Renderer[1];
				renderers[0] = go.GetComponent<Renderer>();
				float LODVal = Mathf.Lerp(1f,0.1f,(i+1)/(float)lodLevels);
				lods[i] = new LOD(LODVal, renderers);
			}// for create lods

			group.SetLODs(lods);
			group.RecalculateBounds();
		} //BuildLODS
Exemplo n.º 15
0
 public void SetLODs(LOD[] lods);
Exemplo n.º 16
0
 public extern void SetLODs(LOD[] lods);
Exemplo n.º 17
0
 static public int get_renderers(IntPtr l)
 {
     UnityEngine.LOD o = (UnityEngine.LOD)checkSelf(l);
     pushValue(l, o.renderers);
     return(1);
 }
Exemplo n.º 18
0
 public void SetLODS(LOD[] lods)
 {
   this.SetLODs(lods);
 }
Exemplo n.º 19
0
 static public int get_screenRelativeTransitionHeight(IntPtr l)
 {
     UnityEngine.LOD o = (UnityEngine.LOD)checkSelf(l);
     pushValue(l, o.screenRelativeTransitionHeight);
     return(1);
 }