public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } NetMsg.AbilityComponent.StartAbilityComponent(fbb); NetMsg.AbilityComponent.AddHasPhysics(fbb, _hasPhysics); NetMsg.AbilityComponent.AddDuration(fbb, _Duration); NetMsg.AbilityComponent.AddPower(fbb, _Power); NetMsg.AbilityComponent.AddCooldown(fbb, _Cooldown); NetMsg.AbilityComponent.AddId(fbb, _id); NetMsg.AbilityComponent.AddOffset(fbb, XFBType.Vec3f.CreateVec3f(fbb, _offset.X, _offset.Y, _offset.Z)); NetMsg.AbilityComponent.AddShape(fbb, _shape); NetMsg.AbilityComponent.AddSize(fbb, XFBType.Vec3f.CreateVec3f(fbb, _size.X, _size.Y, _size.Z)); NetMsg.AbilityComponent.AddAbilityBehavior(fbb, _abilityBehavior); var finishOffset = NetMsg.AbilityComponent.EndAbilityComponent(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } var graphics = FBSettings.Graphics.CreateGraphics(fbb, Fullscreen, FSAA); //var ressData = FBSettings.ResourceData.CreateResourceData(fbb, fbb.CreateString(HLMSDataFolder ?? ""), // fbb.CreateString(DBDataFolder ?? ""), fbb.CreateString(AssetsFolder ?? ""), fbb.CreateString(DBFileName ?? "")); var windowTitle = fbb.CreateString(WindowTitle ?? ""); FBSettings.Settings.StartSettings(fbb); FBSettings.Settings.AddGraphics(fbb, graphics); // FBSettings.Settings.AddResourceData(fbb, ressData); FBSettings.Settings.AddWindowTitle(fbb, windowTitle); var finishOffset = FBSettings.Settings.EndSettings(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } XFBType.Scene.StartScene(fbb); var finishOffset = XFBType.Scene.EndScene(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. // Dump to output directory so we can inspect later, if needed //using (var ms = new MemoryStream(fbb.DataBuffer().Data))//, fbb.DataBuffer().position(), fbb.Offset())) //{ // var data = ms.ToArray(); //FBType.Sound test = FBType.Sound.GetRootAsSound(fbb.DataBuffer(), fbb.DataBuffer().position()); // string gg = test.FileName(); // funtzt // File.WriteAllBytes(@"Resources/monsterdata_cstest.mon", data); // } return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer //-------------------------------------- }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } List <Offset <NetMsg.Component> > componentOffsets = new List <Offset <NetMsg.Component> >(); foreach (var component in _Components) { var test = component.FBObject.CreateFBData(fbbParent); component.FBObject.Read(test._fbData); // NetMsg.Component.StartComponent(fbbParent); // NetMsg.Component.AddComp(fbbParent, test); // NetMsg.Component.AddCompType(fbbParent, NetMsg.UComponent.Camera); //var compOffset = NetMsg.Component.EndComponent(fbbParent); componentOffsets.Add(NetMsg.Component.CreateComponent(fbbParent, component.UComponent, test._offset));// fbbParent.CreateString(mesh.Name ?? ""), fbbParent.CreateString(mesh.RessGrp ?? ""), planeOffset, new Offset<OgreCube>()).Value); } VectorOffset componentsOffset = NetMsg.Entity.CreateComponentsVector(fbbParent, componentOffsets.ToArray()); var finishOffset = NetMsg.Entity.CreateEntity(fbbParent, EntityID, fbbParent.CreateString(m_Name), false, componentsOffset); fbbParent.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbbParent, TypeSafeOffset = finishOffset }); //bytebuffer }
/// <summary> /// used by Editor Filewatcher Event /// </summary> /// <param name="localFile"></param> /// <returns></returns> public override FBNetData CreateFBData(FlatBufferBuilder fbbParent, IFBObject child = null) { var fileOffset = XFBType.LocalFile.CreateLocalFile(fbbParent, FileLocation, fbbParent.CreateString(FileName ?? ""), fbbParent.CreateString(FilePath ?? ""), fbbParent.CreateString(ResourceGroup ?? "")); VectorOffset texturesOffset = new VectorOffset(); if (Textures.Count > 0) { List <int> texturesOffsets = new List <int>(); foreach (var texture in Textures) { texturesOffsets.Add(fbbParent.CreateString(texture.FileName).Value); } XFBType.Material.StartTexturesVector(fbbParent, Textures.Count); foreach (var texture in texturesOffsets) { fbbParent.AddOffset(texture); } texturesOffset = fbbParent.EndVector(); } var name = fbbParent.CreateString(Name ?? ""); var offset = XFBType.Material.CreateMaterial(fbbParent, fileOffset, texturesOffset, TextureType, name); fbbParent.Finish(offset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = offset.Value, Fbb = fbbParent, TypeSafeOffset = offset }); //bytebuffer }
public override FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } // XFBType.LocalFile.StartLocalFile(fbbParent); //var material = Materials[0]; //var localMaterialFileOffset = XFBType.LocalFile.CreateLocalFile(fbbParent, FileLocation, // fbbParent.CreateString(FileName ?? ""), // fbbParent.CreateString(FilePath ?? ""), // fbbParent.CreateString(ResourceGroup ?? "")); //XFBType.LocalFile.AddFileLocation(fbbParent, material.FileLocation); //if (material.FileName != null) // XFBType.LocalFile.AddFileName(fbbParent, fbbParent.CreateString(material.FileName)); //if (material.FilePath != null) // XFBType.LocalFile.AddFilePath(fbbParent, fbbParent.CreateString(material.FilePath)); //if (material.ResourceGroup != null) // XFBType.LocalFile.AddResourceGrp(fbbParent, fbbParent.CreateString(material.ResourceGroup)); //var localMaterialFileOffset = XFBType.LocalFile.EndLocalFile(fbbParent); var localFileOffset = XFBType.LocalFile.CreateLocalFile(fbbParent, FileLocation, fbbParent.CreateString(FileName ?? ""), fbbParent.CreateString(FilePath ?? ""), fbbParent.CreateString(ResourceGroup ?? "")); Offset <XFBType.Material> materialOffset = base.Material.CreateFBData(fbbParent).TypeSafeOffset; XFBType.MeshPlane.StartMeshPlane(fbbParent); XFBType.MeshPlane.AddMaterial(fbbParent, materialOffset); XFBType.MeshPlane.AddConstant(fbbParent, constant); XFBType.MeshPlane.AddHeight(fbbParent, height); XFBType.MeshPlane.AddNormal(fbbParent, XFBType.Vec3f.CreateVec3f(fbbParent, normal.X, normal.Y, normal.Z)); XFBType.MeshPlane.AddNormals(fbbParent, normals); XFBType.MeshPlane.AddNumTexCoordSets(fbbParent, numTexCoordSets); XFBType.MeshPlane.AddUpVector(fbbParent, XFBType.Vec3f.CreateVec3f(fbbParent, upVector.X, upVector.Y, upVector.Z)); XFBType.MeshPlane.AddWidth(fbbParent, width); XFBType.MeshPlane.AddXsegments(fbbParent, xsegments); XFBType.MeshPlane.AddXTile(fbbParent, xTile); XFBType.MeshPlane.AddYsegments(fbbParent, ysegments); XFBType.MeshPlane.AddYTile(fbbParent, yTile); var planeOffset = XFBType.MeshPlane.EndMeshPlane(fbbParent); // int soundoffset = XFBType.Sound.CreateSound(fbb, fbb.CreateString(m_Name), fbb.CreateString(m_FileName), fbb.CreateString(m_RessGrp)); fbbParent.Finish(planeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = planeOffset.Value, Fbb = fbbParent }); //bytebuffer }
public static bool SendToSocket(IFBObject FBObject, NetMsg.Data msgType, uint netID, uint sceneID) { var _SocketServerManager = VEFModule.UnityContainer.Resolve(typeof(SocketServerManager), "") as SocketServerManager; //if (NetID <= 0) // NetID = _SocketServerManager.NewNetID(); var fbdata = FBObject.CreateFBData(); FBObject.Read(fbdata._fbData); return(_SocketServerManager.SendMessageToServer(netID, sceneID, msgType, fbdata));//Parent.NetID, SceneID, msgType, fbdata); }
/// <summary> /// used by Editor Filewatcher Event /// </summary> /// <param name="localFile"></param> /// <returns></returns> public override FBNetData CreateFBData(FlatBufferBuilder fbbParent, IFBObject child = null) { var offset = XFBType.LocalFile.CreateLocalFile(fbbParent, FileLocation, fbbParent.CreateString(FileName ?? ""), fbbParent.CreateString(FilePath ?? ""), fbbParent.CreateString(ResourceGroup ?? "")); fbbParent.Finish(offset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = offset.Value, Fbb = fbbParent, TypeSafeOffset = offset }); //bytebuffer }
public new FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } VectorOffset abilitiesOffset = new VectorOffset(); if (Abilities.Count > 0) { List <int> abilitiesOffsets = new List <int>(); foreach (var ability in Abilities) { NetMsg.AbilityInfo.StartAbilityInfo(fbb); NetMsg.AbilityInfo.AddAbilityId(fbb, ability.AbilityId); NetMsg.AbilityInfo.AddInstant(fbb, ability.Instant); NetMsg.AbilityInfo.AddIsAttached(fbb, ability.IsAttached); abilitiesOffsets.Add(NetMsg.AbilityInfo.EndAbilityInfo(fbb).Value); } NetMsg.CharacterComponent.StartAbilitiesVector(fbb, Abilities.Count); foreach (var ability in abilitiesOffsets) { fbb.AddOffset(ability); } abilitiesOffset = fbb.EndVector(); } var name = fbb.CreateString(Name ?? "Unknown"); NetMsg.CharacterComponent.StartCharacterComponent(fbb); NetMsg.CharacterComponent.AddName(fbb, name); NetMsg.CharacterComponent.AddMoveSpeed(fbb, MoveSpeed); NetMsg.CharacterComponent.AddHp(fbb, HP); NetMsg.CharacterComponent.AddResourcePoints(fbb, ResourcePoints); NetMsg.CharacterComponent.AddOffsetPunch(fbb, XFBType.Vec3f.CreateVec3f(fbb, OffsetPunch.X, OffsetPunch.Y, OffsetPunch.Z)); NetMsg.CharacterComponent.AddAbilities(fbb, abilitiesOffset); var finishOffset = NetMsg.CharacterComponent.EndCharacterComponent(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } //todo var finishOffset = XFBType.SpawnPointComponent.CreateSpawnPointComponent(fbb, SpawnPointGroup, SpawnPointId, fbb.CreateString(SpawnPointName ?? "SP New")); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } var nameVal = fbbParent.CreateString(Name); var paremterNodeOffset = XFBType.Constant.CreateConstant(fbbParent, Id, NodeId, PortId, Value); fbbParent.Finish(paremterNodeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = paremterNodeOffset.Value, Fbb = fbbParent }); //bytebuffer }
/// <summary> /// resets the flatbufferbuilder /// </summary> /// <param name="fbb">flatbufferbuilder from parent object</param> /// <returns>byte data</returns> public new FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } XFBType.MeshCube.StartMeshCube(fbbParent); var cubeOffset = XFBType.MeshCube.EndMeshCube(fbbParent); // var finishOffset = XFBType.OgreCube.CreateOgreCube(fbb, m_width); fbbParent.Finish(cubeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = cubeOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } XFBType.LookAtNode.StartLookAtNode(fbbParent); // XFBType.LookAtNode.AddId(fbbParent, Id); var paremterNodeOffset = XFBType.LookAtNode.EndLookAtNode(fbbParent); fbbParent.Finish(paremterNodeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = paremterNodeOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } VectorOffset soundsOffset = new VectorOffset(); if (Sounds.Any()) { List <int> soundOffsets = new List <int>(); foreach (var sound in Sounds) { var localSoundFileOffset = XFBType.LocalFile.CreateLocalFile(fbbParent, sound.FileLocation, fbbParent.CreateString(sound.FileName), fbbParent.CreateString(sound.FilePath), fbbParent.CreateString(sound.ResourceGroup ?? "")); soundOffsets.Add(XFBType.Sound.CreateSound(fbbParent, localSoundFileOffset).Value); } XFBType.SoundComponent.StartSoundsVector(fbbParent, Sounds.Count); foreach (var sound in soundOffsets) { fbbParent.AddOffset(sound); } soundsOffset = fbbParent.EndVector(); } XFBType.SoundComponent.StartSoundComponent(fbbParent); if (Sounds.Any()) { XFBType.SoundComponent.AddSounds(fbbParent, soundsOffset); } var finishOffset = XFBType.SoundComponent.EndSoundComponent(fbbParent); fbbParent.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } Offset <AmbientLight> ambientlight = new Offset <AmbientLight>(); if (Ambient.UserAmbient) { XFBType.AmbientLight.StartAmbientLight(fbb); XFBType.AmbientLight.AddLowerHemisphere(fbb, XFBType.Colour.CreateColour(fbb, Ambient.LowerHemisphere.ScR, Ambient.LowerHemisphere.ScG, Ambient.LowerHemisphere.ScB, Ambient.LowerHemisphere.ScA)); XFBType.AmbientLight.AddUpperHemisphere(fbb, XFBType.Colour.CreateColour(fbb, Ambient.UpperHemisphere.ScR, Ambient.UpperHemisphere.ScG, Ambient.UpperHemisphere.ScB, Ambient.UpperHemisphere.ScA)); XFBType.AmbientLight.AddHemisphereDir(fbb, XFBType.Vec3f.CreateVec3f(fbb, 0, -1, 0)); XFBType.AmbientLight.AddEnvmapScale(fbb, 1); ambientlight = XFBType.AmbientLight.EndAmbientLight(fbb); } XFBType.Light.StartLight(fbb); XFBType.Light.AddColourDiffuse(fbb, XFBType.Colour.CreateColour(fbb, ColorDiffuse.ScR, ColorDiffuse.ScG, ColorDiffuse.ScB, ColorDiffuse.ScA)); XFBType.Light.AddColourSpecular(fbb, XFBType.Colour.CreateColour(fbb, ColorSpecular.ScR, ColorSpecular.ScG, ColorSpecular.ScB, ColorSpecular.ScA)); XFBType.Light.AddDirectionVector(fbb, XFBType.Vec3f.CreateVec3f(fbb, DirectionVector.X, DirectionVector.Y, DirectionVector.Z)); XFBType.Light.AddLightType(fbb, LightType); XFBType.Light.AddAttenuation(fbb, XFBType.Attenuation.CreateAttenuation(fbb, Attenuation.range, Attenuation.constant, Attenuation.linear, Attenuation.quadratic)); XFBType.Light.AddPowerScale(fbb, PowerScale); XFBType.Light.AddCastShadows(fbb, CastShadows); XFBType.Light.AddUseInstantRadiosity(fbb, UseInstantRadiosity); XFBType.Light.AddIRVplThreshold(fbb, IRVplThreshold); if (Ambient.UserAmbient) { XFBType.Light.AddAmbientLight(fbb, ambientlight); } var finishOffset = XFBType.Light.EndLight(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } var script = fbb.CreateString(Script ?? ""); NetMsg.AIComponent.StartAIComponent(fbb); //, new Offset<XFBType.EntityBase>(base.CreateFBData(fbb)._offset)); NetMsg.AIComponent.AddScript(fbb, script); var finishOffset = NetMsg.AIComponent.EndAIComponent(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
/// <summary> /// resets the flatbufferbuilder /// </summary> /// <returns>byte data</returns> public override FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } var localFileOffset = XFBType.LocalFile.CreateLocalFile(fbbParent, FileLocation, fbbParent.CreateString(FileName ?? ""), fbbParent.CreateString(FilePath ?? ""), fbbParent.CreateString(ResourceGroup ?? "")); //VectorOffset materialOffset = new VectorOffset(); //if (Materials.Any()) //{ // List<int> matOffsets = new List<int>(); // foreach (var material in m_Materials) // { // matOffsets.Add(XFBType.Material.CreateMaterial(fbbParent, material.CreateFBData(fbbParent).TypeSafeOffset).Value); // } // XFBType.MeshFile.StartMaterialsVector(fbbParent, m_Materials.Count); // foreach (var material in matOffsets) // fbbParent.AddOffset(material); // materialOffset = fbbParent.EndVector(); //} // Offset<XFBType.Material> materialOffset = XFBType.Material.CreateMaterial(fbbParent, m_Material.CreateFBData(fbbParent).TypeSafeOffset); Offset <XFBType.Material> materialOffset = m_Material.CreateFBData(fbbParent).TypeSafeOffset; XFBType.MeshFile.StartMeshFile(fbbParent); XFBType.MeshFile.AddFile(fbbParent, localFileOffset); XFBType.MeshFile.AddMaterial(fbbParent, materialOffset); var meshFileOffset = XFBType.MeshFile.EndMeshFile(fbbParent); fbbParent.Finish(meshFileOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = meshFileOffset.Value, Fbb = fbbParent }); //bytebuffer }
//update selected object on c++ side public static T UpdateSelectedObject <T>(IFBObject objectdata, T oldValue, T newValue) { //todo !! only update if not loaded from xml! //var _SocketServerManager = VEFModule.UnityContainer.Resolve(typeof(SocketServerManager), "") as SocketServerManager; //EntityX entity = objectdata.Parent as EntityX; //if (entity != null) //{ // List<Type> types = new List<Type>() { typeof(BodyComponent) }; // var fbData = entity.FB_Entity.CreateFBData(types); // _SocketServerManager.Client.SendToServer(0, fbData._fbData, ENet.PacketFlags.Reliable); //} int res = 0; // string objectName = objectdata.GetType().Name; //object name e.g. FB_Physics //todo send only if changed from GUI! //var sceneData = objectdata.Parent as IEntity; //if (sceneData != null) //{ // (VEFModule.UnityContainer.Resolve(typeof(ILoggerService), "") as ILoggerService).Log("Flatbuffer SceneDataModel.ColourAmbient.SetColourAmbient ungültig (" + newValue.ToString() + "): " + res, LogCategory.Error, LogPriority.High); // //send to c++ DLL // FBNetData tmp = objectdata.CreateFBData(null, null); // //if (DLL_Singleton.Instance != null) // //{ // // // todo res = DLL_Singleton.Instance.command("cmd update 0", tmp, tmp.Length); // //} //} if (res == 0) // OK = 0 { oldValue = newValue; } return(oldValue); }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } XFBType.BodyComponent.StartBodyComponent(fbb); //struct must be serialized inline XFBType.BodyComponent.AddRotation(fbb, XFBType.Quat4f.CreateQuat4f(fbb, m_Rotation.W, m_Rotation.X, m_Rotation.Y, m_Rotation.Z)); XFBType.BodyComponent.AddPosition(fbb, XFBType.Vec3f.CreateVec3f(fbb, m_Location.X, m_Location.Y, m_Location.Z)); XFBType.BodyComponent.AddScale(fbb, XFBType.Vec3f.CreateVec3f(fbb, m_Scale.X, m_Scale.Y, m_Scale.Z)); XFBType.BodyComponent.AddGroup(fbb, 0); XFBType.BodyComponent.AddVisible(fbb, m_IsVisible); var finishOffset = XFBType.BodyComponent.EndBodyComponent(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } VectorOffset triggersOffset = new VectorOffset(); if (Animation.AnimTriggers.Any()) { List <int> triggersOffsets = new List <int>(); foreach (var trigger in Animation.AnimTriggers) { triggersOffsets.Add(XFBType.AnimTrigger.CreateAnimTrigger(fbbParent, trigger.Id, trigger.Time, trigger.TimeType, trigger.MinWeightTreshold).Value); } XFBType.AnimationComponent.StartConnectionsVector(fbbParent, Animation.AnimTriggers.Count); foreach (var trigger in triggersOffsets) { fbbParent.AddOffset(trigger); } triggersOffset = fbbParent.EndVector(); } var animation = XFBType.Animation.CreateAnimation(fbbParent, Animation.Id, Animation.Loop, triggersOffset, fbbParent.CreateString(Animation.Name ?? "")); XFBType.AnimationNode.StartAnimationNode(fbbParent); XFBType.AnimationNode.AddAnimation(fbbParent, animation); var animationNodeOffset = XFBType.AnimationNode.EndAnimationNode(fbbParent); fbbParent.Finish(animationNodeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = animationNodeOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (Size == 0) { throw new Exception("TransitionSelectNode(NodeId:" + base.NodeId + "):Please enter a value bigger than 0"); } if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } XFBType.TransitionSelectNode.StartTransitionSelectNode(fbbParent); // XFBType.TransitionSelectNode.AddId(fbbParent, Id); XFBType.TransitionSelectNode.AddSize(fbbParent, Size); var paremterNodeOffset = XFBType.TransitionSelectNode.EndTransitionSelectNode(fbbParent); fbbParent.Finish(paremterNodeOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = paremterNodeOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } VectorOffset spritesOffset = new VectorOffset(); if (_sprites.Count > 0) { List <int> spriteOffsets = new List <int>(); foreach (var sprite in _sprites) { spriteOffsets.Add(XFBType.Sprite.CreateSprite(fbb, sprite.width, sprite.height, sprite.posX, sprite.posY, fbb.CreateString(sprite.Name ?? "")).Value); } XFBType.Atlas.StartSpritesVector(fbb, _sprites.Count); foreach (var sprite in spriteOffsets) { fbb.AddOffset(sprite); } spritesOffset = fbb.EndVector(); } XFBType.Atlas.StartAtlas(fbb); XFBType.Atlas.AddSprites(fbb, spritesOffset); var finishOffset = XFBType.Atlas.EndAtlas(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } VectorOffset physicsOffset = new VectorOffset(); if (m_Physics.Any()) { List <int> physOffsets = new List <int>(); foreach (var physic in m_Physics) { StringOffset boneParentOS = new StringOffset(); if (physic.AttachToBone != null) { boneParentOS = fbbParent.CreateString(physic.AttachToBone); } XFBType.PhysicsObject.StartPhysicsObject(fbbParent); XFBType.PhysicsObject.AddId(fbbParent, physic.Id); XFBType.PhysicsObject.AddColMask(fbbParent, physic.colMask); XFBType.PhysicsObject.AddType(fbbParent, physic.type); XFBType.PhysicsObject.AddMode(fbbParent, physic.mode); XFBType.PhysicsObject.AddShape(fbbParent, physic.shape); XFBType.PhysicsObject.AddMass(fbbParent, physic.mass); XFBType.PhysicsObject.AddMargin(fbbParent, physic.margin); XFBType.PhysicsObject.AddRadius(fbbParent, physic.radius); XFBType.PhysicsObject.AddAngularDamp(fbbParent, physic.angularDamp); XFBType.PhysicsObject.AddLinearDamp(fbbParent, physic.linearDamp); XFBType.PhysicsObject.AddFormFactor(fbbParent, physic.formFactor); XFBType.PhysicsObject.AddMinVel(fbbParent, physic.minVel); XFBType.PhysicsObject.AddMaxVel(fbbParent, physic.maxVel); XFBType.PhysicsObject.AddRestitution(fbbParent, physic.restitution); XFBType.PhysicsObject.AddFriction(fbbParent, physic.friction); XFBType.PhysicsObject.AddColGroupMask(fbbParent, physic.colGroupMask); XFBType.PhysicsObject.AddCharStepHeight(fbbParent, physic.charStepHeight); XFBType.PhysicsObject.AddCharJumpSpeed(fbbParent, physic.charJumpSpeed); XFBType.PhysicsObject.AddCharFallSpeed(fbbParent, physic.charFallSpeed); //Structures are always stored inline, they need to be created right where they're used XFBType.PhysicsObject.AddOffset(fbbParent, XFBType.Vec3f.CreateVec3f(fbbParent, physic.Offset.X, physic.Offset.Y, physic.Offset.Z)); XFBType.PhysicsObject.AddSize(fbbParent, XFBType.Vec3f.CreateVec3f(fbbParent, physic.Size.X, physic.Size.Y, physic.Size.Z)); XFBType.PhysicsObject.AddScale(fbbParent, XFBType.Vec3f.CreateVec3f(fbbParent, physic.Scale.X, physic.Scale.Y, physic.Scale.Z)); XFBType.PhysicsObject.AddParentIsNode(fbbParent, physic.ParentIsNode); if (physic.AttachToBone != null) { XFBType.PhysicsObject.AddBoneparent(fbbParent, boneParentOS); } physOffsets.Add(XFBType.PhysicsObject.EndPhysicsObject(fbbParent).Value); } XFBType.PhysicsComponent.StartPhysicsVector(fbbParent, m_Physics.Count); foreach (var physic in physOffsets) { fbbParent.AddOffset(physic); } physicsOffset = fbbParent.EndVector(); } XFBType.PhysicsComponent.StartPhysicsComponent(fbbParent); if (m_Physics.Any()) { XFBType.PhysicsComponent.AddPhysics(fbbParent, physicsOffset); } var finishOffset = XFBType.PhysicsComponent.EndPhysicsComponent(fbbParent); fbbParent.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbbParent }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } VectorOffset inputControllersVectorOffset = new VectorOffset(); if (InputControllers.Count > 0) { List <int> inputControllersOffsets = new List <int>(); //------------ controller ---------------- foreach (var controller in InputControllers) { //------------ Actions ------------ VectorOffset inputActionsVectorOffset = new VectorOffset(); if (controller.InputActions.Count > 0) { List <int> inputActionsOffsets = new List <int>(); foreach (var action in controller.InputActions) { //-------------------- Events --------------- VectorOffset inputEventsVectorOffset = new VectorOffset(); if (action.Events.Count > 0) { List <int> inputEventsOffsets = new List <int>(); foreach (var inputEvent in action.Events) { inputEventsOffsets.Add(ControllerSettings.Event.CreateEvent(fbb, inputEvent.EventType, inputEvent.ActionOperator, inputEvent.KeyCode, inputEvent.MouseButtonID, inputEvent.MouseWheelEvent, inputEvent.JoyAxis, inputEvent.JoyBtn).Value); } ControllerSettings.Action.StartEventsVector(fbb, action.Events.Count); foreach (var inputEvent in inputEventsOffsets) { fbb.AddOffset(inputEvent); } inputEventsVectorOffset = fbb.EndVector(); } //------------------------------------------------ inputActionsOffsets.Add(ControllerSettings.Action.CreateAction(fbb, action.ActionType, inputEventsVectorOffset).Value); } ControllerSettings.ControllerMap.StartActionMapVector(fbb, inputActionsOffsets.Count); foreach (var action in inputActionsOffsets) { fbb.AddOffset(action); } inputActionsVectorOffset = fbb.EndVector(); } inputControllersOffsets.Add(ControllerSettings.ControllerMap.CreateControllerMap(fbb, controller.DeviceType, inputActionsVectorOffset).Value); } ControllerSettings.ControllerList.StartCtrlListVector(fbb, InputControllers.Count); foreach (var inputCtrl in inputControllersOffsets) { fbb.AddOffset(inputCtrl); } inputControllersVectorOffset = fbb.EndVector(); ControllerSettings.ControllerList.StartControllerList(fbb); ControllerSettings.ControllerList.AddCtrlList(fbb, inputControllersVectorOffset); var finishOffset = ControllerSettings.ControllerList.EndControllerList(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer } return(new FBNetData()); }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } // StringOffset animInfoOffset = m_AnimationInfo != null ? fbb.CreateString(m_AnimationInfo) : new StringOffset(); // StringOffset animTreeOffset = m_AnimationTree != null ? fbb.CreateString(m_AnimationTree) : new StringOffset(); VectorOffset animNodesOffset = new VectorOffset(); if (AnimationBlendTree.AnimNodes.Any()) { List <int> animNodeOffsets = new List <int>(); foreach (var animNode in AnimationBlendTree.AnimNodes) { var animNodeObject = animNode as AnimNode; if (animNodeObject != null) { var fbobject = animNodeObject as IFBObject; if (fbobject != null) { animNodeOffsets.Add(XFBType.AnimNode.CreateAnimNode(fbb, animNodeObject.NodeId, animNodeObject.AnimNodeType, fbobject.CreateFBData(fbb)._offset).Value); } } } XFBType.AnimationComponent.StartNodesVector(fbb, animNodeOffsets.Count); foreach (var animNode in animNodeOffsets) { fbb.AddOffset(animNode); } animNodesOffset = fbb.EndVector(); } VectorOffset connectionsOffset = new VectorOffset(); if (AnimationBlendTree.NodeConnections.Any()) { XFBType.AnimationComponent.StartConnectionsVector(fbb, AnimationBlendTree.NodeConnections.Count); foreach (var connection in AnimationBlendTree.NodeConnections) { var animNodeFrom = connection.From.Element as AnimNode; // AnimNode; //from = out var nodeTo = connection.To.Element as AnimNode; //to = in uint outId = animNodeFrom.NodeId; uint inId = 0; //0 = outpout if (nodeTo != null) { inId = nodeTo.NodeId; } uint portIn = connection.To.PortId; //todo index as port ??? XFBType.Connection.CreateConnection(fbb, inId, outId, portIn); //structs doesnt need explicit offset!! } connectionsOffset = fbb.EndVector(); } VectorOffset constantsOffset = new VectorOffset(); if (AnimationBlendTree.Constants.Any()) { XFBType.AnimationComponent.StartConstantsVector(fbb, AnimationBlendTree.NodeConnections.Count); foreach (var constant in AnimationBlendTree.Constants) { XFBType.Constant.CreateConstant(fbb, constant.NodeId, constant.NodeId, constant.PortId, constant.Value); } constantsOffset = fbb.EndVector(); } //StringOffset BoneparentOffset = m_Boneparent != null ? fbb.CreateString(m_Boneparent) : new StringOffset(); XFBType.AnimationComponent.StartAnimationComponent(fbb); // if (m_Boneparent != null) XFBType.AnimationComponent.AddBoneparent(fbb, BoneparentOffset); // if (m_AnimationInfo != null) XFBType.AnimationComponent.AddAnimationInfo(fbb, animInfoOffset); // if (m_AnimationTree != null) XFBType.AnimationComponent.AddAnimationTree(fbb, animTreeOffset); if (AnimationBlendTree.AnimNodes.Any()) { XFBType.AnimationComponent.AddNodes(fbb, animNodesOffset); } if (AnimationBlendTree.NodeConnections.Any()) { XFBType.AnimationComponent.AddConnections(fbb, connectionsOffset); } if (AnimationBlendTree.Constants.Any()) { XFBType.AnimationComponent.AddConstants(fbb, constantsOffset); } XFBType.AnimationComponent.AddOutput(fbb, AnimationBlendTree.Output); var finishOffset = XFBType.AnimationComponent.EndAnimationComponent(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public FBNetData CreateFBData(FlatBufferBuilder fbb = null, IFBObject child = null) { if (fbb == null) { fbb = new FlatBufferBuilder(1); } VectorOffset spritesOffset = new VectorOffset(); if (_sprites.Count > 0) { List <int> spriteOffsets = new List <int>(); foreach (var sprite in _sprites) { spriteOffsets.Add(XFBType.Sprite.CreateSprite(fbb, sprite.width, sprite.height, sprite.posX, sprite.posY, fbb.CreateString(sprite.Name ?? "")).Value); } XFBType.Atlas.StartSpritesVector(fbb, _sprites.Count); foreach (var sprite in spriteOffsets) { fbb.AddOffset(sprite); } spritesOffset = fbb.EndVector(); } //------------------------ fonts ------------------------ VectorOffset fontsOffset = new VectorOffset(); if (_fonts.Count > 0) { List <int> fontsOffsets = new List <int>(); foreach (FontModel font in _fonts) { //------------------------ Font (e.g. [Font.24] ) = glyphData ------------------------ VectorOffset glyphsOffset = new VectorOffset(); if (font.Items.Count > 0) //font glyphs { //------------------------ FontData contains glyph,kerning data ------------------------ List <int> glyphsOffsets = new List <int>(); foreach (FontData fontData in font.Items) { //------------------------ kernings ------------------------ VectorOffset kerningsOffset = new VectorOffset(); if (fontData.Kerning.Count > 0) { List <int> kerningsOffsets = new List <int>(); foreach (Kerning kerningModel in fontData.Kerning) { kerningsOffsets.Add(XFBType.KerningData.CreateKerningData(fbb, kerningModel.RightGlyphID, kerningModel.KerningValue).Value); } XFBType.Glyph.StartKerningListVector(fbb, fontData.Kerning.Count); foreach (var kerning in kerningsOffsets) { fbb.AddOffset(kerning); } kerningsOffset = fbb.EndVector(); } //glyph->uvLeft = offset.x + Ogre::StringConverter::parseReal(str_values[0]); //glyph->uvTop = offset.y + Ogre::StringConverter::parseReal(str_values[1]); //glyph->uvWidth = Ogre::StringConverter::parseReal(str_values[2]); //glyph->uvHeight = Ogre::StringConverter::parseReal(str_values[3]); //glyph->uvRight = glyph->uvLeft + glyph->uvWidth; //glyph->uvBottom = glyph->uvTop + glyph->uvHeight; //if (str_values.size() == 5) // glyph->glyphAdvance = Ogre::StringConverter::parseInt(str_values[4]); //else // glyph->glyphAdvance = glyph->uvWidth; glyphsOffsets.Add(XFBType.Glyph.CreateGlyph(fbb , fontData.CharacterAsUint //glyph code , font.offset.y + fontData.Glyph.Y //uvTop , font.offset.y + fontData.Glyph.Y + fontData.Glyph.height //uvBottom , fontData.Glyph.width //uvWidth , fontData.Glyph.height //uvHeight , font.offset.x + fontData.Glyph.X //uvLeft , font.offset.x + fontData.Glyph.X + fontData.Glyph.width //uvRight , fontData.Glyph.width //glyphWidth , fontData.Glyph.height //glyphHeight , (fontData.Glyph.advance > 0 ? fontData.Glyph.advance : fontData.Glyph.width) //glyphAdvance , fontData.VerticalOffset //verticalOffset , kerningsOffset).Value); } XFBType.Font.StartGlyphsVector(fbb, font.Items.Count); foreach (var glyph in glyphsOffsets) { fbb.AddOffset(glyph); } glyphsOffset = fbb.EndVector(); } fontsOffsets.Add(XFBType.Font.CreateFont(fbb, font.Id, glyphsOffset, font.rangeFrom, font.rangeTo, font.spacelength, font.lineheight, font.baseline, font.lineSpacing, font.letterspacing, font.monowidth).Value); } XFBType.Atlas.StartFontsVector(fbb, _fonts.Count); foreach (var fonts in fontsOffsets) { fbb.AddOffset(fonts); } fontsOffset = fbb.EndVector(); } var atlasName = fbb.CreateString(AtlasName); var texName = fbb.CreateString(Path.GetFileName(TextureName)); XFBType.Atlas.StartAtlas(fbb); XFBType.Atlas.AddName(fbb, atlasName); XFBType.Atlas.AddSprites(fbb, spritesOffset); XFBType.Atlas.AddFonts(fbb, fontsOffset); XFBType.Atlas.AddTexture(fbb, texName); var finishOffset = XFBType.Atlas.EndAtlas(fbb); fbb.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbb.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbb }); //bytebuffer }
public abstract FBNetData CreateFBData(FlatBufferBuilder fbb, IFBObject child = null);
public FBNetData CreateFBData(FlatBufferBuilder fbbParent = null, IFBObject child = null) { if (fbbParent == null) { fbbParent = new FlatBufferBuilder(1); } //VectorOffset materialOffset = new VectorOffset(); //if (m_Materials.Any()) //{ // List<int> matOffsets = new List<int>(); // foreach (var material in m_Materials) // matOffsets.Add(XFBType.Material.CreateMaterial(fbbParent, fbbParent.CreateString(material.FileName ?? ""), fbbParent.CreateString(material.ResourceGroup ?? "")).Value); // XFBType.RenderableComponent.StartMaterialsVector(fbbParent, m_Materials.Count); // foreach (var material in matOffsets) // fbbParent.AddOffset(material); // materialOffset = fbbParent.EndVector(); //} VectorOffset meshesOffset = new VectorOffset(); if (m_Meshes.Any()) { List <int> meshOffsets = new List <int>(); foreach (var mesh in m_Meshes) { var plane = mesh as PlaneObject; if (plane != null) { meshOffsets.Add(XFBType.Mesh.CreateMesh(fbbParent, UMesh.MeshPlane, plane.CreateFBData(fbbParent)._offset).Value); // meshOffsets.Add(XFBType.Mesh.CreateMesh(fbbParent, fbbParent.CreateString(mesh.Name ?? ""), fbbParent.CreateString(mesh.RessGrp ?? ""), planeOffset, new Offset<OgreCube>()).Value); continue; } var cube = mesh as CubeObject; if (cube != null) { meshOffsets.Add(XFBType.Mesh.CreateMesh(fbbParent, UMesh.MeshCube, cube.CreateFBData()._offset).Value); // meshOffsets.Add(XFBType.Mesh.CreateMesh(fbbParent, fbbParent.CreateString(mesh.Name), fbbParent.CreateString(mesh.RessGrp), new Offset<OgrePlane>(), XFBType.OgreCube.CreateOgreCube(fbbParent, cube.width)).Value); continue; } var meshFile = mesh as MeshObject; if (meshFile != null) { meshOffsets.Add(XFBType.Mesh.CreateMesh(fbbParent, UMesh.MeshFile, meshFile.CreateFBData(fbbParent)._offset).Value); continue; } } XFBType.RenderableComponent.StartMeshesVector(fbbParent, m_Meshes.Count); foreach (var mesh in meshOffsets) { fbbParent.AddOffset(mesh); } meshesOffset = fbbParent.EndVector(); } // var debugOffset = XFBType.Debug.CreateDebug(fbbParent, m_ShowDebug, m_ShowAABB); XFBType.RenderableComponent.StartRenderableComponent(fbbParent); // if (m_Materials.Any()) XFBType.RenderableComponent.AddMaterials(fbbParent, materialOffset); if (m_Meshes.Any()) { XFBType.RenderableComponent.AddMeshes(fbbParent, meshesOffset); } XFBType.RenderableComponent.AddCastShadows(fbbParent, m_CastShadows); XFBType.RenderableComponent.AddMemType(fbbParent, m_memoryType); XFBType.RenderableComponent.AddVisible(fbbParent, m_Visible); XFBType.RenderableComponent.AddVisibilityFlags(fbbParent, m_VisibilityFlags); XFBType.RenderableComponent.AddLightMask(fbbParent, m_lightMask); XFBType.RenderableComponent.AddShadowconstBias(fbbParent, m_shadowConstBias); // XFBType.RenderableComponent.AddDebug(fbbParent, debugOffset); XFBType.RenderableComponent.AddMode(fbbParent, m_Mode); var finishOffset = XFBType.RenderableComponent.EndRenderableComponent(fbbParent); fbbParent.Finish(finishOffset.Value); //!!!!! important .. return(new FBNetData() { _fbData = fbbParent.SizedByteArray(), _offset = finishOffset.Value, Fbb = fbbParent }); //bytebuffer }