Exemple #1
0
    public static IEnumerator CreateMirror(IEyeTargetModule eyeTarget, Atom containingAtom)
    {
        var uid        = CreateUid("Mirror");
        var enumerator = SuperController.singleton.AddAtomByType("Glass", uid, true);

        while (enumerator.MoveNext())
        {
            yield return(enumerator.Current);
        }
        var atom = SuperController.singleton.GetAtomByUid(uid);

        if (atom == null)
        {
            throw new NullReferenceException("Mirror did not spawn");
        }
        atom.collisionEnabled = false;
        // ReSharper disable once Unity.NoNullCoalescing
        var         head           = containingAtom.rigidbodies.FirstOrDefault(rb => rb.name == "head")?.transform ?? containingAtom.mainController.transform;
        var         atomControl    = atom.mainController.transform;
        var         headPosition   = head.position;
        var         headRotation   = Quaternion.LookRotation(Vector3.Scale(head.forward, new Vector3(1f, 0f, 1f)), Vector3.up);
        const float mirrorDistance = 0.8f;

        atomControl.position = headPosition - (new Vector3(0, headPosition.y, 0) / 2f) + headRotation * (Vector3.forward * mirrorDistance);
        atomControl.rotation = headRotation;
        atomControl.Rotate(Vector3.right, -90);

        var scale = atom.GetStorableByID("scale") as SetTransformScaleIndependent;

        if (scale != null)
        {
            scale.SetFloatParamValue("scaleX", 1.4f);
            scale.SetFloatParamValue("scaleZ", 2f);
        }

        var reflection = atom.GetStorableByID("MirrorRender") as MirrorReflection;

        if (reflection != null)
        {
            reflection.reflectionOpacity   = 0.92f;
            reflection.surfaceTexturePower = 0.001f;
            reflection.specularIntensity   = 0.05f;
            reflection.textureSize         = 2048;
            reflection.SetReflectionColor(new HSVColor {
                V = 1
            });
        }

        yield return(0);

        if (eyeTarget.activeJSON.val)
        {
            eyeTarget.Rescan();
        }
    }
Exemple #2
0
 public EyeTargetSettingsScreen(EmbodyContext context, IEyeTargetModule eyeTarget)
     : base(context)
 {
     _eyeTarget = eyeTarget;
 }