Esempio n. 1
0
        public void show(SceneObjectLight light)
        {
            currentLight = light;

            if (sliderType == SliderType.COLOR)
            {
                colorWheel.gameObject.SetActive(true);
                colorWheel.Value = currentLight.getLightColor();
            }
            else
            {
                colorWheel.gameObject.SetActive(false);
            }
        }
Esempio n. 2
0
        public override void SendObject(byte cID, SceneObject sceneObject, ParameterType paramType, bool sendParent, Transform parent)
        {
#if SCENE_HOST
            if (sceneObject && paramType != ParameterType.LOCK)
            {
                if (!sceneObject.selected)
                {
                    sceneObject.unlockTime = 0.5f;
                    sceneObject.selected   = true;
                    SendObject(cID, sceneObject, ParameterType.LOCK, sendParent, parent);
                }
            }
#endif
            byte[] msg = null;
            switch (paramType)
            {
            case ParameterType.POS:
            {
                Vector3 locPos;
                if (sendParent)
                {
                    locPos = sceneObject.transform.position - parent.position;
                }
                else
                {
                    locPos = sceneObject.transform.localPosition;
                }

                msg = new byte[18];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locPos.x), 0, msg, 6, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locPos.y), 0, msg, 10, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locPos.z), 0, msg, 14, 4);
            }
            break;

            case ParameterType.ROT:
            {
                Quaternion locRot;
                if (sendParent)
                {
                    locRot = Quaternion.Inverse(parent.rotation) * sceneObject.transform.rotation;
                }
                else
                {
                    locRot = sceneObject.transform.localRotation;
                }
                msg = new byte[22];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locRot.x), 0, msg, 6, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locRot.y), 0, msg, 10, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locRot.z), 0, msg, 14, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locRot.w), 0, msg, 18, 4);
            }
            break;

            case ParameterType.SCALE:
            {
                Vector3 locScale = sceneObject.transform.localScale;
                msg = new byte[18];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locScale.x), 0, msg, 6, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locScale.y), 0, msg, 10, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(locScale.z), 0, msg, 14, 4);
            }
            break;

            case ParameterType.LOCK:
            {
                msg = new byte[7];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                msg[6] = Convert.ToByte(sceneObject.selected);
            }
            break;

            case ParameterType.HIDDENLOCK:
            {
                msg = new byte[7];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                msg[6] = Convert.ToByte(sceneObject.isPhysicsActive || sceneObject.isPlayingAnimation);
            }
            break;

            case ParameterType.KINEMATIC:
            {
                msg = new byte[7];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                msg[6] = Convert.ToByte(sceneObject.globalKinematic);
            }
            break;

            case ParameterType.FOV:
            {
                SceneObjectCamera soc = (SceneObjectCamera)sceneObject;
                if (soc)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(soc.fov), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.ASPECT:
            {
                SceneObjectCamera soc = (SceneObjectCamera)sceneObject;
                if (soc)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(soc.aspect), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.FOCUSDIST:
            {
                SceneObjectCamera soc = (SceneObjectCamera)sceneObject;
                if (soc)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(soc.focDist), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.FOCUSSIZE:
            {
                SceneObjectCamera soc = (SceneObjectCamera)sceneObject;
                if (soc)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(soc.focSize), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.APERTURE:
            {
                SceneObjectCamera soc = (SceneObjectCamera)sceneObject;
                if (soc)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(soc.aperture), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.COLOR:
            {
                SceneObjectLight sol = (SceneObjectLight)sceneObject;
                if (sol)
                {
                    Color color = sol.getLightColor();
                    msg = new byte[18];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(color.r), 0, msg, 6, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(color.g), 0, msg, 10, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(color.b), 0, msg, 14, 4);
                }
            }
            break;

            case ParameterType.INTENSITY:
            {
                SceneObjectLight sol = (SceneObjectLight)sceneObject;
                if (sol)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(sol.getLightIntensity()), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.EXPOSURE:
            {
                SceneObjectLight sol = (SceneObjectLight)sceneObject;
                if (sol)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(sol.exposure), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.RANGE:
            {
                SceneObjectLight sol = (SceneObjectLight)sceneObject;
                if (sol)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(sol.getLightRange()), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.ANGLE:
            {
                SceneObjectLight sol = (SceneObjectLight)sceneObject;
                if (sol)
                {
                    msg = new byte[10];

                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(sol.getLightAngle()), 0, msg, 6, 4);
                }
            }
            break;

            case ParameterType.BONEANIM:
            {
                Animator animator = sceneObject.gameObject.GetComponent <Animator>();

                if (animator)
                {
                    int numHBones = Enum.GetNames(typeof(HumanBodyBones)).Length - 1;
                    msg = new byte[18 + numHBones * 16];

                    //TODO: check what needs to be send here to support all character variants
                    Vector3 locPos = animator.bodyPosition;
                    msg[0] = cID;
                    msg[1] = (byte)paramType;
                    Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(locPos.x), 0, msg, 6, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(locPos.y), 0, msg, 10, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(locPos.z), 0, msg, 14, 4);
                    int offset = 12;

                    for (int i = 0; i < numHBones; i++)
                    {
                        Transform t = animator.GetBoneTransform((HumanBodyBones)i);
                        if (t)
                        {
                            Buffer.BlockCopy(BitConverter.GetBytes(t.localRotation.x), 0, msg, offset + 6, 4);
                            Buffer.BlockCopy(BitConverter.GetBytes(t.localRotation.y), 0, msg, offset + 10, 4);
                            Buffer.BlockCopy(BitConverter.GetBytes(t.localRotation.z), 0, msg, offset + 14, 4);
                            Buffer.BlockCopy(BitConverter.GetBytes(t.localRotation.w), 0, msg, offset + 18, 4);
                            offset += 16;
                        }
                    }
                }
            }
            break;

            case ParameterType.PING:
            {
                msg = new byte[2];

                msg[0] = cID;
                msg[1] = (byte)paramType;
            }
            break;

            case ParameterType.RESENDUPDATE:
            {
                msg = new byte[2];

                msg[0] = cID;
                msg[1] = (byte)paramType;
            }
            break;

            case ParameterType.CHARACTERTARGET:
            {
                Vector3 targetPos = sceneObject.targetTranslation;

                msg = new byte[18];

                msg[0] = cID;
                msg[1] = (byte)paramType;
                Buffer.BlockCopy(BitConverter.GetBytes((Int32)sceneObject.id), 0, msg, 2, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(targetPos.x), 0, msg, 6, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(targetPos.y), 0, msg, 10, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(targetPos.z), 0, msg, 14, 4);
            }
            break;

            default:
            {
                Debug.Log("Unknown paramType in ObjectSenderBasic:SendObject");
            }
            break;
            }
            if (msg != null)
            {
                sendMessageQueue.Add(msg);
            }
        }