/// <summary> /// Maps from a flatbuffer serialized group to a SOG /// </summary> /// <param name="inGroup">The flatbuffer group to serialize</param> /// <returns></returns> public static SceneObjectGroup MapFlatbufferGroupToSceneObjectGroup(HalcyonGroup inGroup) { if (!inGroup.Root.HasValue) { throw new NullReferenceException(); } var group = new SceneObjectGroup(); group.SetRootPart(MapFlatbufferPrimToPart(inGroup.Root.Value)); for (int i = 0; i < inGroup.ChildPartsLength; i++) { if (!inGroup.ChildParts(i).HasValue) { continue; } SceneObjectPart childPart = Mapper.MapFlatbufferPrimToPart(inGroup.ChildParts(i).Value); int originalLinkNum = childPart.LinkNum; group.AddPart(childPart); // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. // We override that here if (originalLinkNum != 0) { childPart.LinkNum = originalLinkNum; } } return(group); }
public static Offset <HalcyonGroup> CreateHalcyonGroup(FlatBufferBuilder builder, Offset <InWorldz.Arbiter.Serialization.HalcyonPrimitive> rootOffset = default(Offset <InWorldz.Arbiter.Serialization.HalcyonPrimitive>), VectorOffset childPartsOffset = default(VectorOffset), Offset <InWorldz.Arbiter.Serialization.HalcyonPrimitiveBaseShape> shapeOffset = default(Offset <InWorldz.Arbiter.Serialization.HalcyonPrimitiveBaseShape>)) { builder.StartObject(3); HalcyonGroup.AddShape(builder, shapeOffset); HalcyonGroup.AddChildParts(builder, childPartsOffset); HalcyonGroup.AddRoot(builder, rootOffset); return(HalcyonGroup.EndHalcyonGroup(builder)); }
public static HalcyonGroup GetRootAsHalcyonGroup(ByteBuffer _bb, HalcyonGroup obj) { return(obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }