static public void UnInitializeFactories() { Node.UnInitializeFactory(); Group.UnInitializeFactory(); Transform.UnInitializeFactory(); Lod.UnInitializeFactory(); State.UnInitializeFactory(); Geometry.UnInitializeFactory(); Scene.UnInitializeFactory(); PerspCamera.UnInitializeFactory(); DynamicLoader.UnInitializeFactory(); CullTraverseAction.UnInitializeFactory(); NodeAction.UnInitializeFactory(); Context.UnInitializeFactory(); Texture.UnInitializeFactory(); Roi.UnInitializeFactory(); RoiNode.UnInitializeFactory(); ExtRef.UnInitializeFactory(); }
static public void InitializeFactories() { Node.InitializeFactory(); Group.InitializeFactory(); Transform.InitializeFactory(); Lod.InitializeFactory(); State.InitializeFactory(); Geometry.InitializeFactory(); Scene.InitializeFactory(); PerspCamera.InitializeFactory(); DynamicLoader.InitializeFactory(); CullTraverseAction.InitializeFactory(); NodeAction.InitializeFactory(); Context.InitializeFactory(); Texture.InitializeFactory(); Roi.InitializeFactory(); RoiNode.InitializeFactory(); ExtRef.InitializeFactory(); Crossboard.InitializeFactory(); }
// Traverse function iterates the scene graph to build local branches on Unity GameObject Traverse(Node n, Material currentMaterial) { if (n == null || !n.IsValid()) { return(null); } string name = n.GetName(); if (String.IsNullOrEmpty(name)) { name = n.GetNativeTypeName(); } GameObject gameObject = new GameObject(name); var nodeHandle = gameObject.AddComponent <NodeHandle>(); nodeHandle.node = n; nodeHandle.inObjectDict = false; // ---------------------------- Check material state ---------------------------------- if (n.HasState()) { State state = n.State; if (state.HasTexture(0) && state.GetMode(StateMode.TEXTURE) == StateModeActivation.ON) { gzTexture texture = state.GetTexture(0); if (texture.HasImage()) { gzImage image = texture.GetImage(); int depth = (int)image.GetDepth(); int width = (int)image.GetWidth(); int height = (int)image.GetHeight(); if (depth == 1) { if (currentMaterial == null) { currentMaterial = new Material(Shader); } TextureFormat format = TextureFormat.ARGB32; ImageType image_type = image.GetImageType(); switch (image_type) { case ImageType.RGB_8_DXT1: format = TextureFormat.DXT1; break; } Texture2D tex = new Texture2D(width, height, format, false); byte[] image_data; image.GetImageArray(out image_data); tex.LoadRawTextureData(image_data); tex.filterMode = FilterMode.Trilinear; tex.Apply(); currentMaterial.mainTexture = tex; } image.Dispose(); } texture.Dispose(); } state.Dispose(); } // ---------------------------- Transform check ------------------------------------- gzTransform tr = n as gzTransform; if (tr != null) { Vec3 translation; if (tr.GetTranslation(out translation)) { Vector3 trans = new Vector3(translation.x, translation.y, translation.z); gameObject.transform.localPosition = trans; } } // ---------------------------- DynamicLoader check ------------------------------------- DynamicLoader dl = n as DynamicLoader; if (dl != null) { if (!nodeHandle.inObjectDict) { AddGameObjectReference(dl.GetNativeReference(), gameObject); nodeHandle.inObjectDict = true; } } // ---------------------------- Lod check ------------------------------------- Lod ld = n as Lod; if (ld != null) { foreach (Node child in ld) { GameObject go_child = Traverse(child, currentMaterial); NodeHandle h = go_child.GetComponent <NodeHandle>(); if (h != null) { if (!h.inObjectDict) { AddGameObjectReference(h.node.GetNativeReference(), go_child); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_TRAVERSABLE); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_NOT_TRAVERSABLE); h.inObjectDict = true; } } go_child.transform.SetParent(gameObject.transform, false); } // Dont process group return(gameObject); } // ---------------------------- Roi check ------------------------------------- Roi roi = n as Roi; if (roi != null) { nodeHandle.updateTransform = true; foreach (Node child in roi) { GameObject go_child = Traverse(child, currentMaterial); NodeHandle h = go_child.GetComponent <NodeHandle>(); if (h != null) { if (!h.inObjectDict) { AddGameObjectReference(h.node.GetNativeReference(), go_child); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_TRAVERSABLE); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_NOT_TRAVERSABLE); h.inObjectDict = true; } } go_child.transform.SetParent(gameObject.transform, false); } // Dont process group return(gameObject); } // ---------------------------- RoiNode check ------------------------------------- RoiNode roinode = n as RoiNode; if (roinode != null) { nodeHandle.updateTransform = true; } // ---------------------------- Group check ------------------------------------- Group g = n as Group; if (g != null) { foreach (Node child in g) { GameObject go_child = Traverse(child, currentMaterial); go_child.transform.SetParent(gameObject.transform, false); } return(gameObject); } // ---------------------------ExtRef check ----------------------------------------- ExtRef ext = n as ExtRef; if (ext != null) { AssetLoadInfo info = new AssetLoadInfo(gameObject, ext.ResourceURL, ext.ObjectID); pendingAssetLoads.Push(info); } // ---------------------------- Geometry check ------------------------------------- Geometry geom = n as Geometry; if (geom != null) { float[] float_data; int[] indices; if (geom.GetVertexData(out float_data, out indices)) { MeshFilter filter = gameObject.AddComponent <MeshFilter>(); MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>(); Mesh mesh = new Mesh(); Vector3[] vertices = new Vector3[float_data.Length / 3]; int float_index = 0; for (int i = 0; i < vertices.Length; i++) { vertices[i] = new Vector3(float_data[float_index], float_data[float_index + 1], float_data[float_index + 2]); float_index += 3; } mesh.vertices = vertices; mesh.triangles = indices; if (geom.GetColorData(out float_data)) { if (float_data.Length / 4 == vertices.Length) { float_index = 0; Color[] cols = new Color[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { cols[i] = new Color(float_data[float_index], float_data[float_index + 1], float_data[float_index + 2], float_data[float_index + 3]); float_index += 4; } mesh.colors = cols; } } if (geom.GetNormalData(out float_data)) { if (float_data.Length / 3 == vertices.Length) { float_index = 0; Vector3[] normals = new Vector3[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { normals[i] = new Vector3(float_data[float_index], float_data[float_index + 1], float_data[float_index + 2]); float_index += 3; } mesh.normals = normals; } } //else // mesh.RecalculateNormals(); uint texture_units = geom.GetTextureUnits(); if (texture_units > 0) { if (geom.GetTexCoordData(out float_data, 0)) { if (float_data.Length / 2 == vertices.Length) { float_index = 0; Vector2[] tex_coords = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { tex_coords[i] = new Vector2(float_data[float_index], float_data[float_index + 1]); float_index += 2; } mesh.uv = tex_coords; } } if ((texture_units > 1) && geom.GetTexCoordData(out float_data, 1)) { if (float_data.Length / 2 == vertices.Length) { float_index = 0; Vector2[] tex_coords = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { tex_coords[i] = new Vector2(float_data[float_index], float_data[float_index + 1]); float_index += 2; } mesh.uv2 = tex_coords; } } if ((texture_units > 2) && geom.GetTexCoordData(out float_data, 2)) { if (float_data.Length / 2 == vertices.Length) { float_index = 0; Vector2[] tex_coords = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { tex_coords[i] = new Vector2(float_data[float_index], float_data[float_index + 1]); float_index += 2; } mesh.uv3 = tex_coords; } } if ((texture_units > 3) && geom.GetTexCoordData(out float_data, 3)) { if (float_data.Length / 2 == vertices.Length) { float_index = 0; Vector2[] tex_coords = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { tex_coords[i] = new Vector2(float_data[float_index], float_data[float_index + 1]); float_index += 2; } mesh.uv4 = tex_coords; } } } filter.sharedMesh = mesh; renderer.sharedMaterial = currentMaterial; } } return(gameObject); }
// OLD signature notice the case, this did NOT work with the deserialise // public String batch_id, myinterface, voucher_type, trans_type, client, account, dim_1, dim_2, dim_3, dim_4, // dim_5, dim_6, dim_7, tax_code, tax_system, currency, dc_flag, cur_amount, amount, number_1, // value_1, value_2, value_3, description, trans_date, voucher_date, voucher_no, period, tax_flag, ext_inv_ref, // ext_ref, due_date, disc_date, discount, commitment, order_id, kid, pay_transfer, status, apar_type, // apar_id, pay_flag, voucher_ref, sequence_ref, intrule_id, factor_short, responsible, apar_name, address, province, // place, bank_account, pay_method, vat_reg_no, zip_code, curr_licence, account2, base_amount, base_curr, pay_temp_id, // allocation_key, period_no, clearing_code, swift, arrive_id, bank_acc_type //; public String beautifyGL07() { // this function will process the NULL values and return a GL07 fixed width line // ? allows null to not give a runtime error // ?? is effectively a coalesce. do the right side of the ?? if the left side is null else do the left side PayMethod = PayMethod?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); BatchId = BatchId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Interface = Interface?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); VoucherType = VoucherType?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TransType = TransType?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Client = Client?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Account = Account?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat1 = Cat1?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat2 = Cat2?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat3 = Cat3?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat4 = Cat4?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat5 = Cat5?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat6 = Cat6?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat7 = Cat7?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TaxCode = TaxCode?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TaxSystem = TaxSystem?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Currency = Currency?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); DcFlag = DcFlag?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); CurAmount = CurAmount.Trim().PadLeft(20); Amount = Amount.Trim().PadLeft(20); Number1 = Number1.Trim().PadLeft(11); Value1 = Value1.Trim().PadLeft(20); Value2 = Value2.Trim().PadLeft(20); Value3 = Value3.Trim().PadLeft(20); Description = Description?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); TransDate = TransDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); VoucherDate = VoucherDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); VoucherNo = VoucherNo?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); Period = Period?.Trim().PadRight(6).Substring(0, 6) ?? "".PadRight(6); TaxFlag = TaxFlag?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); ExtInvRef = ExtInvRef?.Trim().PadRight(100).Substring(0, 100) ?? "".PadRight(100); ExtRef = ExtRef?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); DueDate = DueDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); DiscDate = DiscDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); Discount = Discount?.Trim().PadRight(20).Substring(0, 20) ?? "".PadRight(20); Commitment = Commitment?.Trim().PadLeft(25).Substring(0, 25) ?? "".PadRight(25); OrderId = OrderId?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); Kid = Kid?.Trim().PadRight(27).Substring(0, 27) ?? "".PadRight(27); PayTransfer = PayTransfer?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Status = Status?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); AparType = AparType?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); AparId = AparId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); PayFlag = PayFlag?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); VoucherRef = VoucherRef?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); SequenceRef = SequenceRef?.Trim().PadRight(9).Substring(0, 9) ?? "".PadRight(9); IntruleId = IntruleId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); FactorShort = FactorShort?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Responsible = Responsible?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); AparName = AparName?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); Address = Address?.Trim().PadRight(160).Substring(0, 160) ?? "".PadRight(160); Province = Province?.Trim().PadRight(40).Substring(0, 40) ?? "".PadRight(40); Place = Place?.Trim().PadRight(40).Substring(0, 40) ?? "".PadRight(40); BankAccount = BankAccount?.Trim().PadRight(35).Substring(0, 35) ?? "".PadRight(35); PayMethod = PayMethod?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); VatRegNo = VatRegNo?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); ZipCode = ZipCode?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); CurrLicence = CurrLicence?.Trim().PadRight(3).Substring(0, 3) ?? "".PadRight(3); Account2 = Account2?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); BaseAmount = BaseAmount?.Trim().PadLeft(20).Substring(0, 20) ?? "".PadRight(20); BaseCurr = BaseCurr?.Trim().PadLeft(20).Substring(0, 20) ?? "".PadRight(20); PayTempId = PayTempId?.Trim().PadRight(4).Substring(0, 4) ?? "".PadRight(4); AllocationKey = AllocationKey?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); PeriodNo = PeriodNo?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Clearingcode = Clearingcode?.Trim().PadRight(13).Substring(0, 13) ?? "".PadRight(13); Swift = Swift?.Trim().PadRight(11).Substring(0, 11) ?? "".PadRight(11); Arriveid = Arriveid?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); BankAccType = BankAccType?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); return(BatchId + Interface + VoucherType + TransType + Client + Account + Cat1 + Cat2 + Cat3 + Cat4 + Cat5 + Cat6 + Cat7 + TaxCode + TaxSystem + Currency + DcFlag + CurAmount + Amount + Number1 + Value1 + Value2 + Value3 + Description + TransDate + VoucherDate + VoucherNo + Period + TaxFlag + ExtInvRef + ExtRef + DueDate + DiscDate + Discount + Commitment + OrderId + Kid + PayTransfer + Status + AparType + AparId + PayFlag + VoucherRef + SequenceRef + IntruleId + FactorShort + Responsible + AparName + Address + Province + Place + BankAccount + PayMethod + VatRegNo + ZipCode + CurrLicence + Account2 + BaseAmount + BaseCurr + PayTempId + AllocationKey + PeriodNo + Clearingcode + Swift + Arriveid + BankAccType ); // String GL07Line = fw.BatchId.Trim().PadRight(25) + fw.Interface?.Trim().PadRight(25) + fw.VoucherType.Trim().PadRight(25) + fw.TransType.Trim().PadRight(2) + fw.Client.Trim().PadRight(25) //+ fw.Account.Trim().PadRight(25) + fw.Cat1.Trim().PadRight(25) + fw.Cat2.Trim().PadRight(25) + fw.Cat3.Trim().PadRight(25) + fw.Cat4.Trim().PadRight(25) //+ fw.Cat5.Trim().PadRight(25) + fw.Cat6.Trim().PadRight(25) + fw.Cat7.Trim().PadRight(25) + fw.TaxCode.Trim().PadRight(25) + fw.TaxSystem.Trim().PadRight(25) + fw.Currency.Trim().PadRight(25) //+ fw.DcFlag.Trim().PadRight(2) + fw.CurAmount.Trim().PadLeft(20) + fw.Amount.Trim().PadLeft(20) + fw.Number1.Trim().PadLeft(11) + fw.Value1.Trim().PadLeft(20) + fw.Value2.Trim().PadLeft(20) //+ fw.Value3.Trim().PadLeft(20) + fw.Description.Trim().PadRight(255) + fw.TransDate.Trim().PadRight(8) + fw.VoucherDate.Trim().PadRight(8) + fw.VoucherNo.Trim().PadRight(15) //+ fw.Period.Trim().PadRight(6) + fw.TaxFlag.Trim().PadRight(1) + fw.ExtInvRef.Trim().PadRight(100) + fw.ExtRef.Trim().PadRight(255) + fw.DueDate.Trim().PadRight(8) + fw.DiscDate.Trim().PadRight(8) //+ fw.Discount.Trim().PadRight(20) + fw.Commitment.Trim().PadLeft(25) + fw.OrderId.Trim().PadRight(15) + fw.Kid.Trim().PadRight(27) + fw.PayTransfer.Trim().PadRight(2) + fw.PayTransfer.Trim().PadRight(1) //+ fw.AparType.Trim().PadRight(1) + fw.AparId.Trim().PadRight(25) + fw.PayFlag.Trim().PadRight(1) + fw.VoucherRef.Trim().PadRight(15) + fw.SequenceRef.Trim().PadRight(9) + fw.IntruleId.Trim().PadRight(25) //+ fw.FactorShort.Trim().PadRight(25) + fw.Responsible.Trim().PadRight(25) + fw.AparName.Trim().PadRight(255) + fw.Address.Trim().PadRight(160) + fw.Province.Trim().PadRight(40) + fw.Place.Trim().PadRight(40) //+ fw.BankAccount.Trim().PadRight(35) + fw.PayMethod + fw.VatRegNo.Trim().PadRight(25) + fw.ZipCode.Trim().PadRight(15) + fw.CurrLicence.Trim().PadRight(3) + fw.Account2.Trim().PadRight(25) //+ fw.BaseAmount.Trim().PadLeft(20) + fw.BaseCurr.Trim().PadLeft(20) + fw.PayTempId.Trim().PadRight(4) + fw.AllocationKey.Trim().PadRight(2) + fw.PeriodNo.Trim().PadRight(2) + fw.Clearingcode.Trim().PadRight(13) //+ fw.Swift.Trim().PadRight(11) + fw.Arriveid.Trim().PadRight(15) + fw.BankAccType.Trim().PadRight(2) // ; }
//Add GameObjects to dictionary // Traverse function iterates the scene graph to build local branches on Unity GameObject Traverse(Node n, Material currentMaterial) { // We must be called in edit lock if (n == null || !n.IsValid()) { return(null); } // --------------------------- Add game object --------------------------------------- string name = n.GetName(); if (String.IsNullOrEmpty(name)) { name = n.GetNativeTypeName(); } GameObject gameObject = new GameObject(name); var nodeHandle = gameObject.AddComponent <NodeHandle>(); //nodeHandle.Renderer = Renderer; nodeHandle.node = n; nodeHandle.currentMaterial = currentMaterial; nodeHandle.ComputeShader = Settings.ComputeShader; // ---------------------------- Check material state ---------------------------------- if (n.HasState()) { State state = n.State; if (state.HasTexture(0) && state.GetMode(StateMode.TEXTURE) == StateModeActivation.ON) { gzTexture texture = state.GetTexture(0); if (!textureMaterialStorage.TryGetValue(texture.GetNativeReference(), out currentMaterial)) { if (texture.HasImage()) { ImageFormat image_format; ComponentType comp_type; uint components; uint depth; uint width; uint height; uint size; bool uncompress = false; Image image = texture.GetImage(); image_format = image.GetFormat(); image.Dispose(); switch (image_format) // Not yet { case ImageFormat.COMPRESSED_RGBA8_ETC2: if (!SystemInfo.SupportsTextureFormat(TextureFormat.ETC2_RGBA8)) { uncompress = true; } break; case ImageFormat.COMPRESSED_RGB8_ETC2: if (!SystemInfo.SupportsTextureFormat(TextureFormat.ETC2_RGB)) { uncompress = true; } break; case ImageFormat.COMPRESSED_RGBA_S3TC_DXT1: case ImageFormat.COMPRESSED_RGB_S3TC_DXT1: if (!SystemInfo.SupportsTextureFormat(TextureFormat.DXT1)) { uncompress = true; } break; case ImageFormat.COMPRESSED_RGBA_S3TC_DXT5: if (!SystemInfo.SupportsTextureFormat(TextureFormat.DXT5)) { uncompress = true; } break; } if (texture.GetMipMapImageArray(ref _image_texture_data, out size, out image_format, out comp_type, out components, out width, out height, out depth, true, uncompress)) { if (depth == 1) { if (n is Crossboard) { currentMaterial = new Material(Settings.CrossboardShader); } else { currentMaterial = new Material(Settings.DefaultShader); } TextureFormat format = TextureFormat.ARGB32; switch (comp_type) { case ComponentType.UNSIGNED_BYTE: { switch (image_format) { case ImageFormat.RGBA: format = TextureFormat.RGBA32; break; case ImageFormat.RGB: format = TextureFormat.RGB24; break; case ImageFormat.COMPRESSED_RGBA_S3TC_DXT1: case ImageFormat.COMPRESSED_RGB_S3TC_DXT1: format = TextureFormat.DXT1; break; case ImageFormat.COMPRESSED_RGBA_S3TC_DXT5: format = TextureFormat.DXT5; break; case ImageFormat.COMPRESSED_RGB8_ETC2: format = TextureFormat.ETC2_RGB; break; case ImageFormat.COMPRESSED_RGBA8_ETC2: format = TextureFormat.ETC2_RGBA8; break; default: // Issue your own error here because we can not use this texture yet return(null); } } break; default: // Issue your own error here because we can not use this texture yet return(null); } Texture2D tex = new Texture2D((int)width, (int)height, format, true); tex.LoadRawTextureData(_image_texture_data); switch (texture.MinFilter) { default: tex.filterMode = FilterMode.Point; break; case gzTexture.TextureMinFilter.LINEAR: case gzTexture.TextureMinFilter.LINEAR_MIPMAP_NEAREST: tex.filterMode = FilterMode.Bilinear; break; case gzTexture.TextureMinFilter.LINEAR_MIPMAP_LINEAR: tex.filterMode = FilterMode.Trilinear; break; } tex.Apply(texture.UseMipMaps, true); currentMaterial.mainTexture = tex; } } } // Add some kind of check for textures shared by many // Right now only for crossboards if (n is Crossboard) { textureMaterialStorage.Add(texture.GetNativeReference(), currentMaterial); } } nodeHandle.currentMaterial = currentMaterial; texture.Dispose(); } state.Dispose(); } // ---------------------------- Transform check ------------------------------------- gzTransform tr = n as gzTransform; if (tr != null) { Vec3 translation; if (tr.GetTranslation(out translation)) { Vector3 trans = new Vector3(translation.x, translation.y, translation.z); gameObject.transform.localPosition = trans; } // Notify subscribers of new Transform OnNewTransform?.Invoke(gameObject); } // ---------------------------- DynamicLoader check ------------------------------------- DynamicLoader dl = n as DynamicLoader; // Add dynamic loader as game object in dictionary // so other dynamic loaded data can parent them as child to loader if (dl != null) { List <GameObject> list; if (!NodeUtils.FindGameObjects(dl.GetNativeReference(), out list)) // We are not registered { NodeUtils.AddGameObjectReference(dl.GetNativeReference(), gameObject); nodeHandle.inNodeUtilsRegistry = true; // Added to registry // We shall continue to iterate as a group to see if we already have loaded children } else // We are already in list { return(list[0]); // Lets return first object wich is our main registered node } // Notify subscribers of new Loader OnNewLoader?.Invoke(gameObject); } // ---------------------------- Lod check ------------------------------------- Lod ld = n as Lod; if (ld != null) { foreach (Node child in ld) { GameObject go_child = Traverse(child, currentMaterial); if (go_child == null) { return(null); } NodeHandle h = go_child.GetComponent <NodeHandle>(); if (h != null) { if (!NodeUtils.HasGameObjects(h.node.GetNativeReference())) { NodeUtils.AddGameObjectReference(h.node.GetNativeReference(), go_child); h.inNodeUtilsRegistry = true; h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_TRAVERSABLE); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_NOT_TRAVERSABLE); } } go_child.transform.SetParent(gameObject.transform, false); } // Notify subscribers of new Lod OnNewLod?.Invoke(gameObject); // Dont process group as group is already processed return(gameObject); } // ---------------------------- Roi check ------------------------------------- Roi roi = n as Roi; if (roi != null) { nodeHandle.updateTransform = true; nodeHandle.inNodeUpdateList = true; updateNodeObjects.AddLast(gameObject); foreach (Node child in roi) { GameObject go_child = Traverse(child, currentMaterial); if (go_child == null) { return(null); } NodeHandle h = go_child.GetComponent <NodeHandle>(); if (h != null) { if (!NodeUtils.HasGameObjects(h.node.GetNativeReference())) { NodeUtils.AddGameObjectReference(h.node.GetNativeReference(), go_child); h.inNodeUtilsRegistry = true; h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_TRAVERSABLE); h.node.AddActionInterface(_actionReceiver, NodeActionEvent.IS_NOT_TRAVERSABLE); } } go_child.transform.SetParent(gameObject.transform, false); } // Dont process group return(gameObject); } // ---------------------------- RoiNode check ------------------------------------- RoiNode roinode = n as RoiNode; if (roinode != null) { nodeHandle.updateTransform = true; nodeHandle.inNodeUpdateList = true; updateNodeObjects.AddLast(gameObject); } // ---------------------------- Group check ------------------------------------- Group g = n as Group; if (g != null) { foreach (Node child in g) { GameObject go_child = Traverse(child, currentMaterial); if (go_child == null) { return(null); } go_child.transform.SetParent(gameObject.transform, false); } return(gameObject); } // ---------------------------ExtRef check ----------------------------------------- ExtRef ext = n as ExtRef; if (ext != null) { AssetLoadInfo info = new AssetLoadInfo(gameObject, ext.ResourceURL, ext.ObjectID); pendingAssetLoads.Push(info); } // ---------------------------- Crossboard check ----------------------------------- Crossboard cb = n as Crossboard; if (cb != null && GfxCaps.HasCapability(Capability.UseTreeCrossboards)) { // Scheduled for later build pendingBuilds.Enqueue(nodeHandle); } // ---------------------------- Geometry check ------------------------------------- Geometry geom = n as Geometry; if (geom != null) { nodeHandle.BuildGameObject(); // Notify subscribers of new Geometry OnNewGeometry?.Invoke(gameObject); // Later on we will identify types of geoemtry that will be scheduled later if they are extensive and not ground that covers other geometry // and build them in a later pass distributed over time // pendingBuilds.Enqueue(nodeHandle); } return(gameObject); }