Example #1
0
        //public int animationTrackIndex = 0;

        //public readonly SyncList<ACMngr> trackedFields;

        protected override void OnAttach()
        {
            base.OnAttach();
            Slot visual = Slot.AddSlot("Visual");

            visual.LocalRotation = floatQ.Euler(90f, 0f, 0f);
            visual.LocalPosition = new float3(0, 0, 0);

            PBS_Metallic material = visual.AttachComponent <PBS_Metallic>();

            visual.AttachComponent <SphereCollider>().Radius.Value = 0.025f;

            ValueMultiplexer <color> vm = visual.AttachComponent <ValueMultiplexer <color> >();

            vm.Target.Target = material.EmissiveColor;
            vm.Values.Add(new color(0, 0.5f, 0, 1));
            vm.Values.Add(new color(0.5f, 0, 0, 1));
            vm.Values.Add(new color(0.5f, 0.5f, 0, 1));
            vm.Values.Add(new color(0, 0, 0.5f, 1));
            vm.Index.DriveFrom <int>(state);

            CylinderMesh mesh = visual.AttachMesh <CylinderMesh>(material);

            mesh.Radius.Value = 0.015f;
            mesh.Height.Value = 0.05f;
        }
Example #2
0
        public void OnReplace(Animator anim)
        {
            Slot           root = _rt.rootSlot.Target;
            ResultTypeEnum rte  = ResultType.Value;

            if (rte == ResultTypeEnum.DO_NOTHING)
            {
                if (positionTrack != null)
                {
                    anim.Fields.Add();
                }
                if (rotationTrack != null)
                {
                    anim.Fields.Add();
                }
                if (scaleTrack != null)
                {
                    anim.Fields.Add();
                }
                return;
            }

            if (rte == ResultTypeEnum.CONTROL_SLOT_TRANSFORM)
            {
                IField <float3> pos;
                IField <floatQ> rot;
                IField <float3> scale;
                RecordedSlotProcessor.AttachComponents(holding_slot, slot, out pos, out rot, out scale);
                if (positionTrack != null)
                {
                    anim.Fields.Add().Target = pos;
                }
                if (rotationTrack != null)
                {
                    anim.Fields.Add().Target = rot;
                }
                if (scaleTrack != null)
                {
                    anim.Fields.Add().Target = scale;
                }
                return;
            }

            Slot s = root.AddSlot((rte == ResultTypeEnum.CREATE_VISUAL || rte == ResultTypeEnum.CREATE_NON_PERSISTENT_VISUAL) ? "Visual" : slot.Target.Name, rte != ResultTypeEnum.CREATE_NON_PERSISTENT_VISUAL);

            newSlot.Target = s;
            if (positionTrack != null)
            {
                anim.Fields.Add().Target = s.Position_Field;
            }
            if (rotationTrack != null)
            {
                anim.Fields.Add().Target = s.Rotation_Field;
            }
            if (scaleTrack != null)
            {
                anim.Fields.Add().Target = s.Scale_Field;
            }
            if (rte == ResultTypeEnum.COPY_COMPONENTS)
            {
                Slot old = slot.Target;
                old.CopyComponents(s);
            }
            if (rte == ResultTypeEnum.CREATE_VISUAL || rte == ResultTypeEnum.CREATE_NON_PERSISTENT_VISUAL)
            {
                CrossMesh mesh = root.GetComponentOrAttach <CrossMesh>();
                mesh.Size.Value     = 0.05f;
                mesh.BarRatio.Value = 0.05f;
                PBS_Metallic mat = root.GetComponentOrAttach <PBS_Metallic>();
                mat.EmissiveColor.Value = new color(0.5f, 0.5f, 0.5f);
                MeshRenderer meshRenderer = s.AttachComponent <MeshRenderer>();
                meshRenderer.Mesh.Target = mesh;
                meshRenderer.Materials.Add(mat);
            }
            else if (rte == ResultTypeEnum.CREATE_PARENT_SLOTS)
            {
                Slot old = slot.Target;
                old.SetParent(s, false);
                if (positionTrack != null)
                {
                    old.LocalPosition = new float3(0, 0, 0);
                }
                if (rotationTrack != null)
                {
                    old.LocalRotation = floatQ.Identity;
                }
                if (scaleTrack != null)
                {
                    old.LocalScale = new float3(1, 1, 1);
                }
            }
            else if (rte == ResultTypeEnum.REPLACE_REFERENCES)
            {
                foreach (SyncRef <Slot> it in references)
                {
                    it.Target = s;
                }
                foreach (SlotListReference it in listReferences)
                {
                    it.list.Target[it.index.Value] = s;
                }
            }
        }