示例#1
0
        void MoveLightNearAvatar(Vector3d Position)
        {
            if (light == null)
            {
                light = (MLight)MScene.UtilityRoot.FindModuleByType(MObject.EType.DirectionalLight);
            }

            if (light != null)
            {
                MPlanetHandler._Instance.Update();
                light.transform.Position = Position
                                           + Globals.LocalUpVector * 22
                                           + Globals.Avatar.Forward() * 21
                                           + Globals.Avatar.Right() * 21;
                light.LookAt(Globals.Avatar.GetPosition());
            }

            MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByName("LightSphere");

            if (mo != null)
            {
                mo.transform.Position = light.transform.Position + Globals.LocalUpVector;
                mo.transform.Rotation = Extensions.LookAt(light.transform.Position, light.TargetVector, Vector3d.UnitY);
            }
        }
示例#2
0
        void MoveToSunVector()
        {
            Vector3d pos = Globals.Avatar.GetPosition();

            MLight light = (MLight)MScene.UtilityRoot.FindModuleByType(MObject.EType.DirectionalLight);

            if (light == null)
            {
                return;
            }

            if (Sun == null)
            {
                Sun = (MSceneObject)MScene.AstroRoot.FindModuleByName("Sol");
                if (Sun == null)
                {
                    return;
                }
            }

            Vector3d dir = Sun.transform.Position - pos;

            dir.Normalize();

            Vector3d TargetPos = pos + dir * 20;

            light.transform.Position = TargetPos;

            light.LookAt(pos);
        }
示例#3
0
        private void MMessageBus_AvatarMovedEvent(object sender, MoveEvent e)
        {
            MLight light = (MLight)MScene.UtilityRoot.FindModuleByType(MObject.EType.DirectionalLight);

            if (light == null)
            {
                return;
            }

            if (Sun == null)
            {
                Sun = (MSceneObject)MScene.AstroRoot.FindModuleByName("Sol");
                if (Sun == null)
                {
                    return;
                }
            }

            Vector3d dir = Sun.transform.Position - e.Position;

            dir.Normalize();

            Vector3d TargetPos = e.Position + dir * 20;


            MMoveSync ms  = null;
            MObject   ms0 = light.FindModuleByType(MObject.EType.MoveSync);

            if (ms == null)
            {
                // ms = new MMoveSync(light, e.Position
                // + Globals.LocalUpVector * 5
                //+ Globals.LocalUpRotation() * new Vector3d(10, 10, 0), Quaterniond.Identity);
                ms       = new MMoveSync(light, TargetPos, Quaterniond.Identity);
                ms.Speed = 1;
                light.Add(ms);
            }
            else
            {
                ms = (MMoveSync)ms0;
                ms.SetTarget(TargetPos, Quaterniond.Identity);
            }


            /*
             * light.transform.Position = e.Position
             + Globals.LocalUpVector * 5
             + Globals.LocalUpRotation() * new Vector3d(10, 10, 0);
             */
            light.LookAt(e.Position);
            //light.DebugDepth = true;
        }