Ejemplo n.º 1
0
        public override void OnSelected(MSceneObject mo)
        {
            // base.OnClick();
            if (_Activator == null)
            {
                return;
            }
            string result = _ScriptHost.Invoke(_Activator, "OnSelected", new object[] { mo });

            if (!string.IsNullOrEmpty(result))
            {
                Console.WriteLine(result);
            }
            base.OnClick();
        }
Ejemplo n.º 2
0
        //private MSceneObject parent;
        public MTeleportOneShot(MSceneObject inparent, Vector3d inTargetPos, Quaterniond inTargetRot) : base(EType.Teleport, "TeleportAnim")
        {
            Parent        = inparent;
            StartPosition = inparent.transform.Position;
            StartRotation = inparent.transform.Rotation;

            TargetPosition = inTargetPos;
            TargetRotation = inTargetRot;
            MPhysicsObject po = (MPhysicsObject)Parent.FindModuleByType(EType.PhysicsObject);

            if (po != null)
            {
                po.SetActive(false);
            }
            Start = 0;
        }
Ejemplo n.º 3
0
        public override void Update()
        {
            MSceneObject parent = (MSceneObject)Parent;

            if (DoorIsLocked == false)
            {
                if (parent.DistanceFromAvatar < DistanceToOpen)
                {
                    OpenDoor();
                }
                else
                {
                    CloseDoor();
                }
            }
        }
Ejemplo n.º 4
0
        public override void Update()
        {
            if (Enabled == false)
            {
                return;
            }
            MSceneObject so = (MSceneObject)Parent;

            if (so != null)
            {
                so.transform.Position += Speed.Position * Time.DeltaTime;
                Quaterniond q = so.transform.Rotation * Speed.Rotation;
                so.transform.Rotation = q;// Quaterniond.Slerp(so.transform.Rotation, q, 0.5) ;
                // Console.WriteLine(so.transform.Rotation.X + "," + so.transform.Rotation.Y + "," + so.transform.Rotation.Z + "," + so.transform.Rotation.W);
                so.transform.Scale += Speed.Scale * Time.DeltaTime;
            }
        }
Ejemplo n.º 5
0
        public override void Update()
        {
            if (Enabled == false)
            {
                return;
            }
            MSceneObject so = (MSceneObject)Parent;

            if (so != null)
            {
                Quaterniond q = so.transform.Rotation * AngleOffset;
                so.transform.Rotation = Quaterniond.Slerp(so.transform.Rotation, q, Time.DeltaTime * Speed);
            }
            if (_physics != null)
            {
                _physics.SetRotation(so.transform.Rotation);
            }
        }
Ejemplo n.º 6
0
        public void TeleportComplete()
        {
            MPhysicsObject po  = (MPhysicsObject)Parent.FindModuleByType(EType.PhysicsObject);
            MSceneObject   msp = (MSceneObject)Parent;

            msp.SetPosition(TargetPosition);
            msp.SetRotation(TargetRotation);
            if (po != null)
            {
                po.SetActive(true);
                po.StopAllMotion();
            }

            if (TeleportCompleteHandler != null)
            {
                TeleportCompleteHandler(this, new MoveEvent(Parent.InstanceID, TargetPosition, TargetRotation));
            }

            Parent.Remove(this);
            Dispose();
        }
Ejemplo n.º 7
0
        void DoIdle()
        {
            accum += Time.DeltaTime * direction * speed;
            if (accum > 1)
            {
                direction = -direction;
                accum     = 1;
            }
            if (accum <= -1)
            {
                accum     = -1;
                direction = -direction;
            }
            MSceneObject msoParent = (MSceneObject)Parent;

            msoParent.SetRotation(OriginalRotation * Quaterniond.FromEulerAngles(0, accum, 0));

            if (Parent is MAnimatedModel)
            {
                MAnimatedModel m = (MAnimatedModel)Parent;
                m._animationController.PlayAnimation("idle", 1);
            }
        }
Ejemplo n.º 8
0
        public override void CopyTo(MObject m1)
        {
            base.CopyTo(m1);

            MSceneObject mo = (MSceneObject)m1;

            mo.transform.Scale          = transform.Scale;
            mo.transform.RotationOffset = transform.RotationOffset;

            //we don't want to use the template position, since these will be set by the world map
            //mo.transform.Position = transform.Position;
            //mo.transform.Rotation = transform.Rotation;
            mo.SetMaterial(material);
            mo.TemplateID     = TemplateID;
            mo.IsAvatar       = IsAvatar;
            mo.CastsShadow    = CastsShadow;
            mo.BoundingBox    = BoundingBox;
            mo.IndicesLength  = IndicesLength;
            mo.VerticesLength = VerticesLength;
            mo.IsTransparent  = IsTransparent;

            foreach (MObject m in Modules)
            {
                if (m.Type == EType.PhysicsObject)
                {
                    MPhysicsObject p1 = (MPhysicsObject)m;
                    MPhysicsObject p2 = new MPhysicsObject(mo, mo.Name, (float)p1.Mass, p1.Shape, false, p1.CreateScale);
                    p2.Name = p1.Name;
                    p2.SetDamping(p1._rigidBody.LinearDamping, p1._rigidBody.AngularDamping);
                    p2._rigidBody.AngularFactor = p1._rigidBody.AngularFactor;
                    p2._rigidBody.LinearFactor  = p1._rigidBody.LinearFactor;
                    p2._rigidBody.Restitution   = p1._rigidBody.Restitution;
                    p2.SetPosRot(mo.transform.Position, mo.transform.Rotation);
                    //p2.SetPosition(mo.transform.Position);
                    //p2.SetRotation(mo.transform.Rotation);
                    p2.StopAllMotion();
                }

                if (m.Type == EType.PointLight)
                {
                    MPointLight p = new MPointLight(m.Name);
                    MScene.LightRoot.Add(p);
                    m.CopyTo(p);
                    mo.Add(p);
                }

                if (m.Type == EType.Sound)
                {
                    MSound os = (MSound)m;
                    MSound s  = new MSound();
                    os.CopyTo(s);
                    s.Error = os.Error;
                    s.Load(os.Filename, mo);
                    mo.Add(s);
                }

                //network objects can only be owned by the user. When the user is offline the network object is dormant
                //if (mo.OwnerID.Equals(Globals.UserAccount.UserID))
                if (m.Type == EType.NetworkObject)
                {
                    MNetworkObject mn = (MNetworkObject)m.FindModuleByType(MObject.EType.NetworkObject);
                    if (mn != null)
                    {
                        mo.Add(mn);
                    }
                }

                if (m.Type == EType.NPCPlayer)
                {
                    MNPC p = new MNPC(mo, m.Name);
                    m.CopyTo(p);
                    mo.Add(p);
                }

                if (m.Type == EType.Door)
                {
                    MDoor d2 = new MDoor(mo);
                    m.CopyTo(d2);
                    mo.Add(d2);
                }
            }
        }
Ejemplo n.º 9
0
        /**
         * Creates a copy of an existing object from the TemplateRoot
         * */
        public static MSceneObject Spawn(MServerObject mso,
                                         Vector3d Pos, Quaterniond Rot)
        {
            MSceneObject m = (MSceneObject)MScene.TemplateRoot.FindModuleByInstanceID(mso.TemplateID);

            if (m == null)
            {
                Console.WriteLine("TEMPLATE NOT LOADED INTO MScene.TemplateRoot:" + mso.TemplateID);
                return(null);
            }

            MSceneObject t = null;

            MObject TargetRoot = MScene.ModelRoot;

            if (m.IsTransparent)
            {
                TargetRoot = MScene.Priority2;
            }
            else
            {
                TargetRoot = MScene.Priority1;
            }

            if (m.Type == MObject.EType.PrimitiveCube)
            {
                t = CreateCube(TargetRoot, mso.Name, Pos);
            }
            if (m.Type == MObject.EType.PrimitiveSphere)
            {
                t = CreateSphere(TargetRoot, 2, mso.Name, Pos);
            }
            if (m.Type == MObject.EType.Model)
            {
                t = SpawnModel(TargetRoot, mso.TemplateID, mso.OwnerID, mso.Name, Pos);
            }
            if (m.Type == MObject.EType.AnimatedModel)
            {
                t = SpawnAnimatedModel(TargetRoot, mso.TemplateID, mso.OwnerID, mso.Name, Pos);
                //MAnimatedModel man = (MAnimatedModel)m;
                //man.BoneOffset = MassiveTools.VectorFromArray(t.BoneOffset);
            }

            if (m.Type == MObject.EType.InstanceMesh)
            {
                t = SpawnInstanced(TargetRoot, mso.TemplateID, mso.OwnerID, mso.Name, Pos);
            }

            t.transform.Position = Pos;
            t.transform.Rotation = Rot;

            m.CopyTo(t);
            t.OwnerID = mso.OwnerID;

            t.transform.Position = Pos;
            t.transform.Rotation = Rot;

            t.Tag = mso.Tag;

            MClickHandler ch = (MClickHandler)m.FindModuleByType(MObject.EType.ClickHandler);

            if (ch != null)
            {
                MClickHandler ch2 = new MClickHandler();
                ch2.Clicked       = ch.Clicked;
                ch2.RightClicked  = ch.RightClicked;
                ch2.DoubleClicked = ch.DoubleClicked;
                t.Add(ch2);
            }
            return(t);
        }
Ejemplo n.º 10
0
        public override void Setup()
        {
            MSceneObject so = (MSceneObject)Parent;

            _physics = (MPhysicsObject)so.FindModuleByType(EType.PhysicsObject);
        }
Ejemplo n.º 11
0
 public MNPC(MSceneObject parent, string inname = "") : base(EType.NPCPlayer, inname)
 {
     OriginalRotation = parent.transform.Rotation;
 }
Ejemplo n.º 12
0
        public override void Update()
        {
            if (Idle == true)
            {
                return;
            }
            if (msoParent == null)
            {
                return;
            }

            if (po == null)
            {
                po = (MPhysicsObject)Parent.FindModuleByType(EType.PhysicsObject);
            }

            MSceneObject msp        = (MSceneObject)Parent;
            Vector3d     CurrentPos = msp.transform.Position;
            Quaterniond  CurrentRot = msp.transform.Rotation;

            //CurrentPos = Vector3d.Lerp(CurrentPos, TargetPosition, Time.DeltaTime * Speed);
            Value += Time.DeltaTime * Speed;
            if (Value > 1)
            {
                Value = 1;
            }
            double dist = (Vector3d.Distance(TargetPosition, CurrentPos));

            if (dist > 1000)
            {
                Start = 0.999;
                if (po != null)
                {
                    po.SetActive(false);
                }
            }
            CurrentPos = Vector3d.Lerp(StartPosition, TargetPosition, Value);
            CurrentRot = Quaterniond.Slerp(CurrentRot, TargetRotation, Value);

            //if ( dist< 0.1)
            if (Value >= 1)
            {
                CurrentPos = TargetPosition;
                CurrentRot = TargetRotation;
                Idle       = true;
                //msp.SetPosition(TargetPosition);
                //msp.SetRotation(TargetRotation, false);
                //Console.WriteLine("idle");
                if (po != null)
                {
                    po.SetActive(true);
                }
                Complete();
            }
            else
            {
                if (po != null)
                {
                    po.SetActive(true);
                }
            }

            msp.SetPosition(CurrentPos);
            msp.SetRotation(CurrentRot, false);
        }
Ejemplo n.º 13
0
 public void OnSelect(MSceneObject mo)
 {
     Console.WriteLine("Selected:" + mo.Name);
 }
Ejemplo n.º 14
0
 public MDoor(MSceneObject inParent) : base(EType.Door, "Door")
 {
     OriginalOrientation = inParent.transform.Rotation;
     msoParent           = inParent;
     msoParentPhysics    = (MPhysicsObject)msoParent.FindModuleByType(EType.PhysicsObject);
 }