private void OnCollision(CollisionData data)
    {
        // Check to see if any agent has control
        // If no agent has control, the agent that has just entered the trigger volume is now in control
        // When leaving the agent loses control

        if (data.Phase == CollisionEventPhase.TriggerEnter)
        {
            //Log.Write("Trigger Enter");
            if (!UserIn)
            {
                //Log.Write("CollisionData Data: " + data);
                ObjId = data.HitComponentId.ObjectId;
                agent = ScenePrivate.FindAgent(ObjId);
                agent.Client.SubscribeToCommand("Trigger", CommandAction.Pressed, TriggerCommandPressed, CommandCanceled);
                agent.Client.SubscribeToCommand("Trigger", CommandAction.Released, TriggerCommandReleased, CommandCanceled);

                //Log.Write("Agent: " + agent);
                //Log.Write("Name: " + agent.AgentInfo.Name);
                UserIn = true;
                // Check to See if wearing VR Headset
                if (agent.GetControlPointEnabled(ControlPointType.GazeTarget) || agent.GetControlPointEnabled(ControlPointType.LeftTool))
                {
                    Log.Write("VR");
                    VR = true;
                    sendSimpleMessage("VR");
                }
                else
                {
                    Log.Write("NoVR");
                    VR = false;
                    //sendSimpleMessage("NoVR");
                }
            }
        }
        else if (data.Phase == CollisionEventPhase.TriggerExit)
        {
            ObjectId     exitObjId = data.HitComponentId.ObjectId;
            AgentPrivate exitAgent = ScenePrivate.FindAgent(ObjId);
            //Log.Write("agent: " + agent);
            //Log.Write("exitObjId  " + exitObjId);
            //Log.Write("exitAgent: " + exitAgent);
            if (agent == exitAgent)
            {
                Log.Write("User has Left: " + agent.AgentInfo.Name);
                UserIn = false;
            }
            else
            {
                Log.Write("Another User had Control: " + agent.AgentInfo.Name);
            }
        }

        if (UserIn && VR) //Active User and they are wearing VR Headset
        {
            //Log.Write("User in Conrol Has VR - Left Tool: " + agent.GetControlPointEnabled(ControlPointType.LeftTool) + " - Right Tool: " + agent.GetControlPointEnabled(ControlPointType.RightTool));
            //UpdatePosition();
        }
    }
Ejemplo n.º 2
0
        private void getSegment(AgentPrivate ap, ObjectPrivate op, out Vector start, out Vector end)
        {
            float            distance = 10;
            Quaternion       orientation;
            Vector           offset;
            ControlPointType controlPoint = ControlPointType.GazeTarget;

            if (ap.GetControlPointEnabled(controlPoint))
            {
                offset      = Vector.Forward * distance;
                start       = ap.GetControlPointPosition(controlPoint);
                orientation = ap.GetControlPointOrientation(controlPoint);
            }
            else
            {
                offset      = Vector.Left * distance;
                start       = op.Position + Vector.Up * 0.5f;
                orientation = op.Rotation;
            }

            offset = offset.Rotate(ref orientation);
            end    = start + offset;
        }