public Parse ( GameBitBuffer buffer ) : void | ||
buffer | GameBitBuffer | |
Результат | void |
/// <summary> /// Attempts to find a telehub in the region; if one is not found, returns false. /// </summary> /// <param name="regionID">Region ID</param> /// <returns></returns> public Telehub FindTelehub(UUID regionID) { string sql = "SELECT * FROM telehubs where RegionID=?RegionID"; using (MySqlConnection conn = GetConnection()) { using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.Parameters.Add("?RegionID", regionID.ToString()); using (IDataReader r = cmd.ExecuteReader()) { if (r.Read()) { if (r.FieldCount == 0) { return(null); } return(new Telehub() { RegionID = UUID.Parse(r["RegionID"].ToString()), TelehubLoc = Vector3.Parse(r["TelehubLoc"].ToString()), TelehubRot = Quaternion.Parse(r["TelehubRot"].ToString()), Name = r["Name"].ToString(), ObjectUUID = UUID.Parse(r["ObjectUUID"].ToString()), SpawnPos = Telehub.BuildToList(r["Spawns"].ToString()) }); } return(null); } } } }
public void Quaternion_ParseHandlesValidInput() { var result = Quaternion.Parse("123.4 -567.8 901.2 345.6"); TheResultingValue(result).WithinDelta(0.1f) .ShouldBe(123.4f, -567.8f, 901.2f, 345.6f); }
private void UpdateParseXYZWSettings(object sender, EventArgs e) { //Clear prior values myprocTransformGroup.Children.Clear(); XAxisValue.Clear(); YAxisValue.Clear(); ZAxisValue.Clear(); AngleValue.Clear(); //<SnippetQuaternionView3DN3> try { endQuaternion = Quaternion.Parse(ParseValue.Text); } catch { ParseValue.Text = "Must input (X, Y, Z, W)"; } endRotation.Quaternion = endQuaternion; //</SnippetQuaternionView3DN3> //Update axis and angle textboxes XAxisValue.Text = endQuaternion.Axis.X.ToString(); YAxisValue.Text = endQuaternion.Axis.Y.ToString(); ZAxisValue.Text = endQuaternion.Axis.Z.ToString(); AngleValue.Text = endQuaternion.Angle.ToString(); startAnimation(); }
public void GenOperand(IToken operand) { int val = 0; switch (operand.Type) { case AssemblerParser.INT: val = ConvertToInt(operand.Text); break; case AssemblerParser.FLOAT: val = GetConstantPoolIndex(Convert.ToSingle(operand.Text)); break; case AssemblerParser.STRING: val = GetConstantPoolIndex(UnescapeStringChars(operand.Text)); break; case AssemblerParser.VECTOR: val = GetConstantPoolIndex(Vector3.Parse(operand.Text)); break; case AssemblerParser.ROTATION: val = GetConstantPoolIndex(Quaternion.Parse(operand.Text)); break; case AssemblerParser.FUNC: val = GetFunctionIndex(operand.Text); break; case AssemblerParser.ID: val = GetLabelAddress(operand.Text); break; case AssemblerParser.STATE_ID: val = GetStateId(operand.Text); break; default: throw new GenerationException(String.Format("Invalid operand type {0} in GenOperand()", operand.Type)); } EnsureCapacity(_ip + 4); Util.Encoding.WriteInt(_code, _ip, val); _ip += 4; }
public void ToStringAndParse() { Quaternion quaternion = new Quaternion(0.0123f, 9.876f, 0.0f, -2.3f); string s = quaternion.ToString(); Quaternion parsedQuaternion = Quaternion.Parse(s); Assert.AreEqual(quaternion, parsedQuaternion); }
public override void Parse(GameBitBuffer buffer) { ActorId = buffer.ReadInt(32); Scale = buffer.ReadFloat32(); Position = Position.Parse(buffer); Orientation = Orientation.Parse(buffer); MapId = buffer.ReadInt(32); }
public void Parse(GameBitBuffer buffer) { Scale = buffer.ReadFloat32(); Position = new Vector3(); Position = Position.Parse(buffer); lookAt = new Vector3(); lookAt = lookAt.Parse(buffer); Orientation = new Quaternion(); Orientation = Orientation.Parse(buffer); WorldID = buffer.ReadInt(32); }
/// <summary> /// Converts a string into a Quaternion. /// </summary> public override object ConvertFromString(string value, IValueSerializerContext context) { if (value != null) { return(Quaternion.Parse(value)); } else { return(base.ConvertFromString(value, context)); } }
protected override void DoUpdate() { mat4 model = this.arcballManipulater.GetRotationMatrix(); Quaternion quaternion = model.ToQuaternion(); float angleDegree; vec3 axis; quaternion.Parse(out angleDegree, out axis); RendererBase renderer = this.BindingObject.Renderer; renderer.RotationAngleDegree = angleDegree; renderer.RotationAxis = axis; }
public void Parse() { Quaternion vector = Quaternion.Parse("(0.0123; (9.876; 0.0; -2.3))", CultureInfo.InvariantCulture); Assert.AreEqual(0.0123f, vector.W); Assert.AreEqual(9.876f, vector.X); Assert.AreEqual(0.0f, vector.Y); Assert.AreEqual(-2.3f, vector.Z); vector = Quaternion.Parse("( 0.0123 ; ( 9; 0.1 ; -2.3 ) ) ", CultureInfo.InvariantCulture); Assert.AreEqual(0.0123f, vector.W); Assert.AreEqual(9f, vector.X); Assert.AreEqual(0.1f, vector.Y); Assert.AreEqual(-2.3f, vector.Z); }
private void UpdateRotation() { var manipulater = this.manipulater; if (manipulater != null) { mat4 model = this.manipulater.GetRotationMatrix(); Quaternion quaternion = model.ToQuaternion(); float angleDegree; vec3 axis; quaternion.Parse(out angleDegree, out axis); this.RotationAngle = angleDegree; this.RotationAxis = axis; } }
/// <summary> /// Initializes a new instance of the <see cref="PdbViewState"/> class. /// </summary> /// <param name="xmlNode">The XML node representing the initial ViewState.</param> internal PdbViewState(XmlNode xmlNode) { try { this.translation = Vector3D.Parse(xmlNode.SelectSingleNode("Translation").InnerText); } catch { this.translation = new Vector3D(); } try { this.scale = Double.Parse(xmlNode.SelectSingleNode("Scale").InnerText); } catch { this.scale = 1; } try { this.rotation = Quaternion.Parse(xmlNode.SelectSingleNode("Rotation").InnerText); } catch { this.rotation = Quaternion.Identity; } try { this.clip = Double.Parse(xmlNode.SelectSingleNode("Clip").InnerText); } catch { this.clip = 1; } try { this.slab = Double.Parse(xmlNode.SelectSingleNode("Slab").InnerText); } catch { this.slab = 0; } }
public Quaternion GetQuaternion(UUID regionID, string parameter) => Quaternion.Parse(this[regionID, parameter]);
private bool TryAddAdditionalObject(SceneInterface scene, string sectionName) { IConfig config = m_Loader.Config.Configs[sectionName]; Vector3 position = Vector3.Parse(config.GetString("Position", m_Position.ToString())); Quaternion rotation = Quaternion.Parse(config.GetString("Rotation", m_Rotation.ToString())); UUID objectid = UUID.Parse(config.GetString("ID", UUID.Random.ToString())); int scriptPin = config.GetInt("ScriptAccessPin", 0); string objectName = config.GetString("ObjectName", sectionName); string scriptName = config.GetString("ScriptName", "Script"); string experienceName = config.GetString("ExperienceName", "My Experience"); UUID itemID = UUID.Parse(config.GetString("ScriptItemID", UUID.Zero.ToString())); UUID rezzingObjID = UUID.Parse(config.GetString("RezzingObjectID", UUID.Zero.ToString())); UEI experienceID; UUID expID; UUID.TryParse(config.GetString("ExperienceID", m_ExperienceID.ToString()), out expID); experienceID = new UEI(expID, experienceName, null); string objectDescription = config.GetString("ObjectDescription", ""); string scriptDescription = config.GetString("ScriptDescription", ""); var objectOwner = new UGUIWithName(config.GetString("ObjectOwner", m_ObjectOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectOwner); try { m_UserAccountService.Add(new UserAccount { Principal = objectOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var objectCreator = new UGUIWithName(config.GetString("ObjectCreator", m_ObjectCreator.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectCreator); try { m_UserAccountService.Add(new UserAccount { Principal = objectCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var objectLastOwner = new UGUIWithName(config.GetString("ObjectLastOwner", m_ObjectLastOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = objectLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptOwner = new UGUIWithName(config.GetString("ScriptOwner", m_ScriptOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptOwner); try { m_UserAccountService.Add(new UserAccount { Principal = scriptOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptCreator = new UGUIWithName(config.GetString("ScriptCreator", m_ScriptCreator.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptCreator); try { m_UserAccountService.Add(new UserAccount { Principal = scriptCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptLastOwner = new UGUIWithName(config.GetString("ScriptLastOwner", m_ScriptLastOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = scriptLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } int startParameter = config.GetInt("StartParameter", m_StartParameter); InventoryPermissionsMask objectPermissionsBase = GetPermissions(config, "ObjectPermisionsBase", m_ObjectPermissionsBase); InventoryPermissionsMask objectPermissionsOwner = GetPermissions(config, "ObjectPermisionsOwner", m_ObjectPermissionsOwner); InventoryPermissionsMask objectPermissionsGroup = GetPermissions(config, "ObjectPermisionsGroup", m_ObjectPermissionsGroup); InventoryPermissionsMask objectPermissionsNext = GetPermissions(config, "ObjectPermisionsNext", m_ObjectPermissionsNext); InventoryPermissionsMask objectPermissionsEveryone = GetPermissions(config, "ObjectPermisionsEveryone", m_ObjectPermissionsEveryone); InventoryPermissionsMask scriptPermissionsBase = GetPermissions(config, "ScriptPermisionsBase", m_ScriptPermissionsBase); InventoryPermissionsMask scriptPermissionsOwner = GetPermissions(config, "ScriptPermisionsOwner", m_ScriptPermissionsOwner); InventoryPermissionsMask scriptPermissionsGroup = GetPermissions(config, "ScriptPermisionsGroup", m_ScriptPermissionsGroup); InventoryPermissionsMask scriptPermissionsNext = GetPermissions(config, "ScriptPermisionsNext", m_ScriptPermissionsNext); InventoryPermissionsMask scriptPermissionsEveryone = GetPermissions(config, "ScriptPermisionsEveryone", m_ScriptPermissionsEveryone); UUID assetID = UUID.Zero; string scriptFile = string.Empty; /* we use same asset id keying here so to make them compatible with the other scripts */ foreach (string key in config.GetKeys()) { if (UUID.TryParse(key, out assetID)) { scriptFile = config.GetString(key); break; } } IScriptAssembly scriptAssembly = null; if (!string.IsNullOrEmpty(scriptFile)) { if (itemID == UUID.Zero) { itemID = UUID.Random; } try { using (var reader = new StreamReader(scriptFile, new UTF8Encoding(false))) { scriptAssembly = CompilerRegistry.ScriptCompilers.Compile(AppDomain.CurrentDomain, UGUI.Unknown, m_AssetID, reader); } m_Log.InfoFormat("Compilation of {1} ({0}) successful", m_AssetID, scriptFile); } catch (CompilerException e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, scriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace.ToString()); return(false); } catch (Exception e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, scriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace.ToString()); return(false); } } try { ExperienceServiceInterface experienceService = scene.ExperienceService; if (null != experienceService) { ExperienceInfo test; if (!experienceService.TryGetValue(experienceID, out test)) { experienceService.Add(new ExperienceInfo { ID = experienceID, Creator = scriptOwner, Owner = scriptOwner, Properties = ExperiencePropertyFlags.Grid /* make this grid-wide since otherwise we have to configure a lot more */ }); } } else { experienceID = UEI.Unknown; } } catch (Exception e) { m_Log.Error("Creating experience failed", e); return(false); } string[] additionalInventoryConfigs = config.GetString("AdditionalInventories", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (additionalInventoryConfigs.Length == 1 && additionalInventoryConfigs[0] == string.Empty) { additionalInventoryConfigs = new string[0]; } try { var grp = new ObjectGroup { RezzingObjectID = rezzingObjID }; var part = new ObjectPart(objectid); grp.Add(1, part.ID, part); part.ObjectGroup = grp; grp.Owner = objectOwner; grp.LastOwner = objectLastOwner; part.Creator = objectCreator; part.Name = objectName; part.Description = objectDescription; part.GlobalPosition = position; part.GlobalRotation = rotation; part.BaseMask = objectPermissionsBase; part.OwnerMask = objectPermissionsOwner; part.NextOwnerMask = objectPermissionsNext; part.EveryoneMask = objectPermissionsEveryone; part.GroupMask = objectPermissionsGroup; part.ScriptAccessPin = scriptPin; var item = new ObjectPartInventoryItem(itemID) { AssetType = AssetType.LSLText, AssetID = assetID, InventoryType = InventoryType.LSL, LastOwner = scriptLastOwner, Creator = scriptCreator, Owner = scriptOwner, Name = scriptName, Description = scriptDescription }; item.Permissions.Base = scriptPermissionsBase; item.Permissions.Current = scriptPermissionsOwner; item.Permissions.EveryOne = scriptPermissionsEveryone; item.Permissions.Group = scriptPermissionsGroup; item.Permissions.NextOwner = scriptPermissionsNext; item.ExperienceID = experienceID; scene.Add(grp); foreach (string invconfig in additionalInventoryConfigs) { AddAdditionalInventory(part, invconfig); } if (scriptAssembly != null) { byte[] serializedState; m_ScriptStates.TryGetValue(item.ID, out serializedState); ScriptInstance scriptInstance = scriptAssembly.Instantiate(part, item, serializedState); part.Inventory.Add(item); item.ScriptInstance = scriptInstance; item.ScriptInstance.Start(startParameter); } } catch (Exception e) { m_Log.Error("Adding object failed", e); return(false); } return(true); }
public void Startup(ConfigurationLoader loader) { m_Scenes = loader.Scenes; m_Loader = loader; m_GatekeeperURI = loader.GatekeeperURI; IConfig config = loader.Config.Configs[GetType().FullName]; /* we use same asset id keying here so to make them compatible with the other scripts */ foreach (string key in config.GetKeys()) { if (UUID.TryParse(key, out m_AssetID)) { m_ScriptFile = config.GetString(key); break; } } m_ObjectPermissionsBase = GetPermissions(config, "ObjectPermisionsBase"); m_ObjectPermissionsOwner = GetPermissions(config, "ObjectPermisionsOwner"); m_ObjectPermissionsGroup = GetPermissions(config, "ObjectPermisionsGroup"); m_ObjectPermissionsNext = GetPermissions(config, "ObjectPermisionsNext"); m_ObjectPermissionsEveryone = GetPermissions(config, "ObjectPermisionsEveryone"); m_ScriptPermissionsBase = GetPermissions(config, "ScriptPermisionsBase"); m_ScriptPermissionsOwner = GetPermissions(config, "ScriptPermisionsOwner"); m_ScriptPermissionsGroup = GetPermissions(config, "ScriptPermisionsGroup"); m_ScriptPermissionsNext = GetPermissions(config, "ScriptPermisionsNext"); m_ScriptPermissionsEveryone = GetPermissions(config, "ScriptPermisionsEveryone"); m_LoadOarFileName = config.GetString("OarFilename", string.Empty); m_TimeoutMs = config.GetInt("RunTimeout", 1000); m_RegionID = UUID.Parse(config.GetString("RegionID")); m_RegionOwner = new UGUIWithName(config.GetString("RegionOwner")) { IsAuthoritative = true }; m_EstateOwner = new UGUIWithName(config.GetString("EstateOwner", m_RegionOwner.ToString())) { IsAuthoritative = true }; m_EstateID = (uint)config.GetInt("EstateID", 100); m_EstateName = config.GetString("EstateName", "My Estate"); m_ObjectID = UUID.Parse(config.GetString("ID", UUID.Random.ToString())); m_RegionName = config.GetString("RegionName", "Testing Region"); m_ProductName = config.GetString("RegionProductName", "Mainland"); m_RegionLocation = new GridVector(config.GetString("RegionLocation", "10000,10000"), 256); m_RegionSize = new GridVector(config.GetString("RegionSize", "1,1"), 256); m_RegionAccess = (RegionAccess)Enum.Parse(typeof(RegionAccess), config.GetString("RegionAccess", "PG")); m_RegionPort = config.GetInt("RegionPort", 9300); m_Runner = loader.GetServicesByValue <TestRunner>()[0]; m_Position = Vector3.Parse(config.GetString("Position", "<128, 128, 23>")); m_Rotation = Quaternion.Parse(config.GetString("Rotation", "<0,0,0,1>")); m_ItemID = UUID.Parse(config.GetString("ScriptItemID", UUID.Random.ToString())); m_RezzingObjID = UUID.Parse(config.GetString("RezzingObjectID", UUID.Zero.ToString())); m_ObjectName = config.GetString("ObjectName", "Object"); m_ScriptName = config.GetString("ScriptName", "Script"); string experienceName = config.GetString("ExperienceName", "My Experience"); UUID experienceID; UUID.TryParse(config.GetString("ExperienceID", UUID.Zero.ToString()), out experienceID); m_ExperienceID = new UEI(experienceID, experienceName, null); m_ObjectDescription = config.GetString("ObjectDescription", ""); m_ScriptDescription = config.GetString("ScriptDescription", ""); m_RegionStorage = loader.GetService <GridServiceInterface>("RegionStorage"); m_SceneFactory = loader.GetService <SceneFactoryInterface>("DefaultSceneImplementation"); m_EstateService = loader.GetService <EstateServiceInterface>("EstateService"); m_AvatarNameService = loader.GetService <AvatarNameServiceInterface>("AvatarNameStorage"); m_UserAccountService = loader.GetService <UserAccountServiceInterface>("UserAccountService"); m_AvatarNameService.Store(m_RegionOwner); m_AvatarNameService.Store(m_EstateOwner); try { m_UserAccountService.Add(new UserAccount { Principal = m_RegionOwner, IsLocalToGrid = true, }); } catch { m_Log.Info("UserAccount creation failed for RegionOwner"); } if (!m_EstateOwner.EqualsGrid(m_RegionOwner)) { try { m_UserAccountService.Add(new UserAccount { Principal = m_RegionOwner, IsLocalToGrid = true, }); } catch { m_Log.Info("UserAccount creation failed for EstateOwner"); } } m_ObjectOwner = new UGUIWithName(config.GetString("ObjectOwner")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ObjectOwner); if (config.Contains("ObjectCreator")) { m_ObjectCreator = new UGUIWithName(config.GetString("ObjectCreator")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ObjectCreator); try { m_UserAccountService.Add(new UserAccount { Principal = m_ObjectCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } } else { m_ObjectCreator = m_ObjectOwner; } if (config.Contains("ObjectLastOwner")) { m_ObjectLastOwner = new UGUIWithName(config.GetString("ObjectLastOwner")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ObjectLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = m_ObjectLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } } else { m_ObjectLastOwner = m_ObjectOwner; } m_ScriptOwner = new UGUIWithName(config.GetString("ScriptOwner")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ScriptOwner); if (config.Contains("ScriptCreator")) { m_ScriptCreator = new UGUIWithName(config.GetString("ScriptCreator")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ScriptCreator); try { m_UserAccountService.Add(new UserAccount { Principal = m_ScriptCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } } else { m_ScriptCreator = m_ScriptOwner; } if (config.Contains("ScriptLastOwner")) { m_ScriptLastOwner = new UGUIWithName(config.GetString("ScriptLastOwner")) { IsAuthoritative = true }; m_AvatarNameService.Store(m_ScriptLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = m_ScriptLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } } else { m_ScriptLastOwner = m_ScriptOwner; } m_StartParameter = config.GetInt("StartParameter", 0); if (string.IsNullOrEmpty(m_ScriptFile)) { throw new ArgumentException("Script filename and UUID missing"); } m_AdditionalObjectConfigs = config.GetString("AdditionalObjects", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (m_AdditionalObjectConfigs.Length == 1 && m_AdditionalObjectConfigs[0] == string.Empty) { m_AdditionalObjectConfigs = new string[0]; } m_AdditionalInventoryConfigs = config.GetString("AdditionalInventories", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (m_AdditionalInventoryConfigs.Length == 1 && m_AdditionalInventoryConfigs[0] == string.Empty) { m_AdditionalInventoryConfigs = new string[0]; } m_AssetSourcesConfig = config.GetString("AssetSources", string.Empty); m_ScriptStatesConfig = config.GetString("ScriptStates", string.Empty); CompilerRegistry.ScriptCompilers.DefaultCompilerName = config.GetString("DefaultCompiler"); }
public void Parse(GameBitBuffer buffer) { Field0 = new Quaternion(); Field0.Parse(buffer); Field1 = new Vector3D(); Field1.Parse(buffer); }
public void Quaternion_ParseRejectsInvalidInput() { Assert.That(() => Quaternion.Parse("sfdjhkfsh"), Throws.TypeOf <FormatException>()); }
public Quaternion Parse(string val) { return(Quaternion.Parse(val)); }
public void ParseException() { Quaternion vector = Quaternion.Parse("(0.0123; 9.876; 4.1; -9.0)"); }
public Quaternion GetQuaternion(UUID regionID, string parameter, Quaternion defvalue) => Quaternion.Parse(this[regionID, parameter, defvalue.ToString()]);