void triggerLoad(telara_obj obj) { if (obj != null) { if (!(obj.doLoad || obj.loaded)) { obj.doLoad = true; worldLoader.addJob(obj, obj.file); } } }
public void addJob(telara_obj parent, string filename) { NifLoadJob job = new NifLoadJob(filename); job.parent = parent; Vector3 pos = parent.transform.position; job.parentPos = pos; lock (jobsToAdd) { jobsToAdd.Enqueue(job); } }
private bool finalizeJob(NifLoadJob job) { telara_obj to = job.parent; Transform loadingObj = to.gameObject.transform.FindDeepChild("Loading"); if (loadingObj != null) { GameObject.Destroy(loadingObj.gameObject); } if (to.gameObject != null) { // reapply the lod to take into account any new meshes created applyLOD(to.gameObject); } to.doLoad = false; to.loaded = true; return(true); }
private void addLoading(NifLoadJob job) { // Add a loading capsule to the location of the job if (!job.IsDone) { telara_obj obj = job.parent; GameObject loading = (GameObject)GameObject.Instantiate(Resources.Load("LoadingCapsule")); loading.name = "Loading"; SphereCollider sp = obj.GetComponent <SphereCollider>(); if (sp != null) { loading.transform.localScale = Vector3.one * 3; } loading.transform.parent = obj.gameObject.transform; loading.transform.localPosition = Vector3.zero; loading.transform.localRotation = Quaternion.identity; //applyLOD(loading); } }
private GameObject process(ObjectPosition op) { if (op is LightPosition) { GameObject lgo = new GameObject(); //#if UNITY_EDITOR addCDR(op, lgo); //#endif LightPosition lp = (LightPosition)op; lgo.transform.SetParent(meshRoot.transform); lgo.transform.localScale = new Vector3(op.scale, op.scale, op.scale); lgo.transform.localPosition = op.min; lgo.transform.localRotation = op.qut; Light light = lgo.AddComponent <Light>(); light.type = LightType.Point; light.color = new Color(lp.r, lp.g, lp.b); light.intensity = lp.range; light.shadows = LightShadows.Hard; return(lgo); } GameObject go = GameObject.Instantiate(telaraObjectPrefab, meshRoot.transform); #if UNITY_EDITOR addCDR(op, go); #endif if (!op.visible || (op.nifFile != null && op.nifFile.Contains("30meter.nif"))) { go.tag = "invisible"; go.SetActive(false); invisibleObjects.Add(go); } string name = op.nifFile; Assets.RiftAssets.AssetDatabase.RequestCategory category = Assets.RiftAssets.AssetDatabase.RequestCategory.NONE; if (name.Contains("_terrain_") || name.Contains("ocean_chunk")) { if (name.Contains("_terrain_")) { category = Assets.RiftAssets.AssetDatabase.RequestCategory.GEOMETRY; } } telara_obj tobj = go.GetComponent <telara_obj>(); tobj.setProps(category); //go.transform.SetParent(meshRoot.transform); tobj.setFile(name); go.name = name; go.transform.localScale = new Vector3(op.scale, op.scale, op.scale); go.transform.localPosition = op.min; go.transform.localRotation = op.qut; triggerLoad(tobj); return(go); }