public void StringInterop() { var v = new float3(2f, 7.5f, -8.5f); var s0 = v.ToString(); var s1 = v.ToString("#"); var v0 = float3.Parse(s0); var v1 = float3.Parse(s1, "#"); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); var b0 = float3.TryParse(s0, out v0); var b1 = float3.TryParse(s1, "#", out v1); Assert.That(b0); Assert.That(b1); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); b0 = float3.TryParse(null, out v0); Assert.False(b0); b0 = float3.TryParse("", out v0); Assert.False(b0); b0 = float3.TryParse(s0 + ", 0", out v0); Assert.False(b0); Assert.Throws <NullReferenceException>(() => { float3.Parse(null); }); Assert.Throws <FormatException>(() => { float3.Parse(""); }); Assert.Throws <FormatException>(() => { float3.Parse(s0 + ", 0"); }); var s2 = v.ToString(";", CultureInfo.InvariantCulture); Assert.That(s2.Length > 0); var s3 = v.ToString("; ", "G"); var s4 = v.ToString("; ", "G", CultureInfo.InvariantCulture); var v3 = float3.Parse(s3, "; ", NumberStyles.Number); var v4 = float3.Parse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture); Assert.AreEqual(v, v3); Assert.AreEqual(v, v4); var b4 = float3.TryParse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture, out v4); Assert.That(b4); Assert.AreEqual(v, v4); }
public void ToString_CultureDE() { string s = "(1,5; 1,5; 1,5)"; float3 f = float3.One * 1.5f; Assert.Equal(s, f.ToString(new CultureInfo("de-DE"))); }
public override string ToString() { string a = Origin.ToString(); string b = Direction.ToString(); return("p" + a + " + t * " + b); }
protected override void OnCommonUpdate() { base.OnCommonUpdate(); if (this.LocalUser.UserID == "U-guillefix") { UniLog.Log("Update"); if (record_skeleton) { foreach (var item in joint_slots) { User user = item.Key; List <Slot> slots = item.Value; Slot root_slot = slots[0]; float3 root_global_position = root_slot.GlobalPosition; floatQ root_global_rotation = root_slot.GlobalRotation; output_file.Write(root_global_position.ToString() + "," + root_global_rotation.ToString()); for (int i = 1; i < slots.Count; i++) { Slot slot = slots[i]; float3 global_position = slot.GlobalPosition; floatQ global_rotation = slot.GlobalRotation; float3 relative_position = root_slot.GlobalPointToLocal(global_position); floatQ relative_rotation = root_slot.GlobalRotationToLocal(global_rotation); output_file.Write("," + relative_position.ToString() + "," + relative_rotation.ToString()); } output_file.Write("\n"); } } } }
public void ToString_InvariantCulture() { string s = "(1.5, 1.5, 1.5)"; float3 f = float3.One * 1.5f; Assert.Equal(s, f.ToString(CultureInfo.InvariantCulture)); }
public void Float3_WriteToString(float v0, float v1, float v2) { string s = NormalFormat.F(v0, v1, v2); float3 n = new float3(v0, v1, v2); string sn = n.ToString(); Assert.That(sn, Is.EqualTo(s)); }
public void ConvertFromFloat3(int i, float f, double d, bool isTrue, string text, double2 d2, double3 d3, double4 d4, double4x4 d4x4, float2 f2, float3 f3, float4 f4, float4x4 f4x4) { text = f3.ToString(); ConverterClass source = new ConverterClass(); ConverterClass expected = new ConverterClass(); Node root = new Node(source); Node node = new Node(expected); Circuit circuit = new Circuit(); circuit.AddNode(root); circuit.AddNode(node); circuit.AddRoot(root); source.f3 = f3; root.Attach("f3", node, "i"); root.Attach("f3", node, "f"); root.Attach("f3", node, "d"); root.Attach("f3", node, "isTrue"); root.Attach("f3", node, "text"); root.Attach("f3", node, "d2"); root.Attach("f3", node, "d3"); root.Attach("f3", node, "d4"); root.Attach("f3", node, "d4x4"); root.Attach("f3", node, "f2"); root.Attach("f3", node, "f3"); root.Attach("f3", node, "f4"); root.Attach("f3", node, "f4x4"); circuit.Execute(); Assert.True(expected.i == i, "Error when parsing to int: Should be " + i + " but is " + expected.i + "."); Assert.True(expected.f == f, "Error when parsing to float: Should be " + f + " but is " + expected.f + "."); Assert.True(expected.d == d, "Error when parsing to double: Should be " + d + " but is " + expected.d + "."); Assert.True(expected.isTrue == isTrue, "Error when parsing to bool: Should be " + isTrue + " but is " + expected.isTrue + "."); Assert.True(expected.text == text, "Error when parsing to string: Should be " + text + " but is " + expected.text + "."); Assert.True(expected.d2 == d2, "Error when parsing to double2: Should be " + d2 + " but is " + expected.d2 + "."); Assert.True(expected.d3 == d3, "Error when parsing to double3: Should be " + d3 + " but is " + expected.d3 + "."); Assert.True(expected.d4 == d4, "Error when parsing to double4: Should be " + d4 + " but is " + expected.d4 + "."); Assert.True(expected.d4x4 == d4x4, "Error when parsing to double4x4: Should be " + d4x4 + " but is " + expected.d4x4 + "."); Assert.True(expected.f2 == f2, "Error when parsing to float2: Should be " + f2 + " but is " + expected.f2 + "."); Assert.True(expected.f3 == f3, "Error when parsing to float3: Should be " + f3 + " but is " + expected.f3 + "."); Assert.True(expected.f4 == f4, "Error when parsing to float4: Should be " + f4 + " but is " + expected.f4 + "."); Assert.True(expected.f4x4 == f4x4, "Error when parsing to float4x4: Should be " + f4x4 + " but is " + expected.f4x4 + "."); }
private void SpawnWorld(int id, float3 spawnPosition, MapDatam map, Entity gameEntity) { if (map != null) { Entity world = World.EntityManager.CreateEntity(worldArchtype); worlds.Add(id, world); worldLookups.Add(id, new WorldChunkMap { chunks = new Dictionary <int3, Entity>() }); World.EntityManager.SetComponentData(world, new Translation { Value = spawnPosition }); UpdateMap(world, map, id); Game game = World.EntityManager.GetComponentData <Game>(gameEntity); game.map = world; World.EntityManager.SetComponentData(gameEntity, game); } else { Debug.LogError("Cannot spawn world at: " + spawnPosition.ToString() + " as map is null."); } }
/// <summary> /// Returns a string representation of this vector using a provided seperator. /// </summary> public static string ToString(float3 v, string sep) => v.ToString(sep);
/// <summary> /// Returns a string representation of this vector using ', ' as a seperator. /// </summary> public static string ToString(float3 v) => v.ToString();
public static void SetEnviromentEntityData(EntityManager entityManager, GameObject go, NativeArray <Entity> entities, NativeArray <Bounds> entitiesToAviod, bool disposeOnCompletion, string region, string name, float3 entitySize, float3 center, float3 bounds) { Unity.Mathematics.Random rand = new Unity.Mathematics.Random(0x6E624EB7u); float3 newPosition; Debug.Log("entitySize = " + entitySize); for (int i = 0; i < entities.Length; i++) { switch (name) { case "Tree": center.y = 0; // bounds -= entitySize; bool overlap = false; float3 scale = go.GetComponent <Transform>().localScale; Bounds _bounds = go.GetComponent <MeshFilter>().sharedMesh.bounds; Debug.Log("Tree stuff = " + scale.ToString() + "," + _bounds.ToString() + "," + (_bounds.size * scale)); int attempt = 0; while (true) { newPosition = center + rand.NextFloat3(-bounds / 2, bounds / 2); newPosition.y = -0.1f; //spawning on flat land for now for (int j = 0; j < i; j++) { float3 entityPosition = entityManager.GetComponentData <Translation>(entities[j]).Value; //Note that this treats the coreData position and size as cube which may not be tree for all entities (we just want the AABBs) Bounds a = new Bounds(newPosition, _bounds.size * scale); if (!a.Intersects(new Bounds(entityPosition, _bounds.size * scale))) { if (entitiesToAviod.Length > 0 && !entitiesToAviod[0].size.Equals(new float3(-1f, -1f, -1f))) { for (int k = 0; k < entitiesToAviod.Length; k++) { if (a.Intersects(entitiesToAviod[k])) { Debug.LogWarning("AAA"); overlap = true; break; } } } else { Debug.LogWarning("No entities to compare"); } } else { Debug.LogWarning("B"); overlap = true; break; } } if (!overlap) { break; } else { attempt++; } if (attempt == 50) { Debug.LogWarning("Failed to create entity " + i + " for Tree"); break; } else { overlap = false; } } if (!overlap) { entityManager.SetComponentData(entities[i], new Translation { Value = newPosition }); entityManager.SetComponentData(entities[i], new Scale { Value = scale.x }); entityManager.SetSharedComponentData(entities[i], new RenderMesh { mesh = go.GetComponent <MeshFilter>().sharedMesh, castShadows = UnityEngine.Rendering.ShadowCastingMode.On, material = go.GetComponent <MeshRenderer>().sharedMaterial, receiveShadows = true }); entityManager.SetComponentData(entities[i], GetEnviromentPhysicsCollider(region + "|" + name, scale.x)); entityManager.SetName(entities[i], region + "|" + name + i); entityManager.SetComponentData(entities[i], new CoreData(new ByteString30(name), new ByteString30(region), bounds, scale)); } break; default: Debug.LogWarning("Failed to set data for entity with name \"" + region + "|" + name + "\""); break; } } if (disposeOnCompletion) { entitiesToAviod.Dispose(); } }
public override string ToString() { return(Values.ToString()); }
public void Parse_ToString_CultureDE() { float3 f = float3.One * 1.5f; Assert.Equal(f, float3.Parse(f.ToString(new CultureInfo("de-DE")), new CultureInfo("de-DE"))); }
public override string ToString() { return(string30.ToString() + " | " + _float3.ToString()); }
/// <summary> /// Returns a string representation of this vector using a provided seperator and a format for each component. /// </summary> public static string ToString(float3 v, string sep, string format) => v.ToString(sep, format);
public override string ToString() { return(_value.ToString()); }
public override string ToString() { return(string.Format(CultureInfo.CurrentCulture, "Minimum:{0} Maximum:{1}", min.ToString(), max.ToString())); }
/// <summary> /// Returns a string representation of this vector using a provided seperator and a format and format provider for each component. /// </summary> public static string ToString(float3 v, string sep, string format, IFormatProvider provider) => v.ToString(sep, format, provider);
public void Parse_ToString_NoCulture() { float3 f = float3.One * 1.5f; Assert.Equal(f, float3.Parse(f.ToString())); }
public void Parse_ToString_InvariantCulture() { float3 f = float3.One * 1.5f; Assert.Equal(f, float3.Parse(f.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)); }
private void CutBeam(int beamIndex, float3 cutOffPosition) { bool exceptionChecker = true; for (int i = 0; i < _discreteBeams[beamIndex].movementCoordinates.Count; i++) { if (ChechTwofloat3sEqual(cutOffPosition, _discreteBeams[beamIndex].movementCoordinates[i])) { ; _discreteBeams[beamIndex] = _discreteBeams[beamIndex].CutBeam(i); exceptionChecker = false; break; } } if (exceptionChecker) { throw new Exception("The point for cutoff was not found. The position is : " + cutOffPosition.ToString()); } }