예제 #1
0
 public static void Setup(TestContext testContext)
 {
     child1.SetParent(root, false);
     child2.SetParent(root, false);
     grandchild1.SetParent(child1, false);
     grandchild2.SetParent(child2, false);
 }
예제 #2
0
        public void ChangingTransformTest()
        {
            NitroxVector3    beforeLocalPosition = new NitroxVector3(15, 2, -7);
            NitroxQuaternion beforeRotation      = NitroxQuaternion.FromEuler(45, 15, 1);

            NitroxVector3    beforeChildLocalPosition = new NitroxVector3(75, -10, 13.333f);
            NitroxQuaternion beforeChildRotation      = NitroxQuaternion.FromEuler(75, 11, 5);

            NitroxVector3    setGlobalPosition = new NitroxVector3(34.62131f, 45.99337f, -10.77733f);
            NitroxQuaternion setGlobalRotation = new NitroxQuaternion(0.6743798f, 0.2302919f, 0.02638498f, 0.7010573f);

            NitroxVector3    afterLocalPosition = new NitroxVector3(17, 14, -13);
            NitroxQuaternion afterLocalRotation = NitroxQuaternion.FromEuler(60, 25, 0);

            NitroxVector3    afterChildGlobalPosition = new NitroxVector3(379.541f, 109.6675f, -167.4466f);
            NitroxQuaternion afterChildGlobalRotation = NitroxQuaternion.FromEuler(17.81689f, 187.7957f, 151.9425f);

            NitroxTransform grandchild3      = new NitroxTransform(beforeLocalPosition, beforeRotation, new NitroxVector3(2.5f, 2.5f, 2.5f), null);
            NitroxTransform grandgrandchild1 = new NitroxTransform(beforeChildLocalPosition, beforeChildRotation, new NitroxVector3(1, 1, 1), null);

            grandgrandchild1.SetParent(grandchild3, false);
            grandchild3.SetParent(child1, true);

            grandchild3.Position.Equals(beforeLocalPosition, TOLERANCE).Should().BeTrue($"Expected: {beforeLocalPosition} Found: {grandchild3.Position}");
            grandchild3.Rotation.Equals(beforeRotation, TOLERANCE).Should().BeTrue($"Expected: {beforeRotation} Found: {grandchild3.Rotation}");

            grandchild3.Position = setGlobalPosition;
            grandchild3.Rotation = setGlobalRotation;

            grandchild3.LocalPosition.Equals(afterLocalPosition, TOLERANCE).Should().BeTrue($"Expected: {afterLocalPosition} Found: {grandchild3.LocalPosition}");
            grandchild3.LocalRotation.Equals(afterLocalRotation, TOLERANCE).Should().BeTrue($"Expected: {afterLocalRotation} Found: {grandchild3.LocalRotation}");

            grandgrandchild1.Position.Equals(afterChildGlobalPosition, TOLERANCE).Should().BeTrue($"Expected: {afterChildGlobalPosition} Found: {grandgrandchild1.Position}");
            grandgrandchild1.Rotation.Equals(afterChildGlobalRotation, TOLERANCE).Should().BeTrue($"Expected: {afterChildGlobalRotation} Found: {grandgrandchild1.Rotation}");
        }
예제 #3
0
        public Entity(Vector3 localPosition, Quaternion localRotation, Vector3 scale, TechType techType, int level, string classId, bool spawnedByServer, NitroxId id, Entity parentEntity = null)
        {
            Transform            = new NitroxTransform(localPosition, localRotation, scale, this);
            TechType             = techType;
            Id                   = id;
            Level                = level;
            ClassId              = classId;
            SpawnedByServer      = spawnedByServer;
            WaterParkId          = null;
            SerializedGameObject = null;
            ExistsInGlobalRoot   = false;

            if (parentEntity != null)
            {
                ParentId = parentEntity.Id;
                Transform.SetParent(parentEntity.Transform);
            }
        }