Beispiel #1
0
        private void RenderText()
        {
            lock (Prims)
            {
                int primNr = 0;
                foreach (FacetedMesh mesh in Prims.Values)
                {
                    primNr++;
                    Primitive prim = mesh.Prim;
                    if (string.IsNullOrEmpty(prim.Text))
                    {
                        continue;
                    }

                    string         text      = System.Text.RegularExpressions.Regex.Replace(prim.Text, "(\r?\n)+", "\n");
                    OpenTK.Vector3 screenPos = OpenTK.Vector3.Zero;
                    OpenTK.Vector3 primPos   = OpenTK.Vector3.Zero;

                    // Is it child prim
                    FacetedMesh parent = null;
                    if (Prims.TryGetValue(prim.ParentID, out parent))
                    {
                        var newPrimPos = prim.Position * Matrix4.CreateFromQuaternion(parent.Prim.Rotation);
                        primPos = new OpenTK.Vector3(newPrimPos.X, newPrimPos.Y, newPrimPos.Z);
                    }

                    primPos.Z += prim.Scale.Z * 0.8f;
                    if (!Math3D.GluProject(primPos, ModelMatrix, ProjectionMatrix, Viewport, out screenPos))
                    {
                        continue;
                    }
                    screenPos.Y = glControl.Height - screenPos.Y;

                    textRendering.Begin();

                    Color           color = Color.FromArgb((int)(prim.TextColor.A * 255), (int)(prim.TextColor.R * 255), (int)(prim.TextColor.G * 255), (int)(prim.TextColor.B * 255));
                    TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.Top;

                    using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular))
                    {
                        var size = TextRendering.Measure(text, f, flags);
                        screenPos.X -= size.Width / 2;
                        screenPos.Y -= size.Height;

                        // Shadow
                        if (color != Color.Black)
                        {
                            textRendering.Print(text, f, Color.Black, new Rectangle((int)screenPos.X + 1, (int)screenPos.Y + 1, size.Width, size.Height), flags);
                        }
                        textRendering.Print(text, f, color, new Rectangle((int)screenPos.X, (int)screenPos.Y, size.Width, size.Height), flags);
                    }
                    textRendering.End();
                }
            }
        }
Beispiel #2
0
        void frmPrimWorkshop_Disposed(object sender, EventArgs e)
        {
            if (textRendering != null)
            {
                textRendering.Dispose();
                textRendering = null;
            }

            glControl?.Dispose();
            glControl = null;
            Client.Objects.TerseObjectUpdate     -= new EventHandler <TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate          -= new EventHandler <PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.ObjectDataBlockUpdate -= new EventHandler <ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);
        }
Beispiel #3
0
        public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID)
            : base(instance)
        {
            this.RootPrimLocalID = rootLocalID;

            InitializeComponent();
            Disposed            += new EventHandler(frmPrimWorkshop_Disposed);
            AutoSavePosition     = true;
            UseMultiSampling     = cbAA.Checked = instance.GlobalSettings["use_multi_sampling"];
            cbAA.CheckedChanged += cbAA_CheckedChanged;

            this.instance = instance;

            renderer      = new MeshmerizerR();
            textRendering = new TextRendering(instance);

            Client.Objects.TerseObjectUpdate     += new EventHandler <TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate          += new EventHandler <PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.ObjectDataBlockUpdate += new EventHandler <ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);
        }
Beispiel #4
0
        public SceneWindow(RadegastInstance instance)
            : base(instance)
        {
            InitializeComponent();

            this.Instance = instance;
            this.Client = instance.Client;

            UseMultiSampling = Instance.GlobalSettings["use_multi_sampling"];

            genericTaskThread = new Thread(new ThreadStart(GenericTaskRunner));
            genericTaskThread.IsBackground = true;
            genericTaskThread.Name = "Generic task queue";
            genericTaskThread.Start();

            renderer = new MeshmerizerR();
            renderTimer = new System.Diagnostics.Stopwatch();
            renderTimer.Start();

            // Camera initial setting
            Instance.State.CameraTracksOwnAvatar = false;
            Camera = new Camera();
            InitCamera();
            SetWaterPlanes();

            chatOverlay = new ChatOverlay(instance, this);
            textRendering = new TextRendering(instance);
            terrain = new RenderTerrain(instance);

            cbChatType.SelectedIndex = 1;

            DrawDistance = Instance.GlobalSettings["draw_distance"];
            pnlDebug.Visible = Instance.GlobalSettings["scene_viewer_debug_panel"];

            Client.Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.AvatarUpdate += new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate);

            Client.Network.RegisterCallback(PacketType.KillObject, KillObjectHandler);
            Client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged);
            Client.Terrain.LandPatchReceived += new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived);
            Client.Avatars.AvatarAnimation += new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged);
            Client.Avatars.AvatarAppearance += new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance);
            Client.Appearance.AppearanceSet += new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);
            Instance.Netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected);
            Application.Idle += new EventHandler(Application_Idle);

            Radegast.GUI.GuiHelpers.ApplyGuiFixes(this);
        }
Beispiel #5
0
        void DisposeInternal()
        {
            RenderingEnabled = false;
            Application.Idle -= new EventHandler(Application_Idle);
            Instance.State.CameraTracksOwnAvatar = true;
            Instance.State.SetDefaultCamera();

            if (!PendingTextures.Closed)
            {
                TextureThreadContextReady.Reset();
                TextureThreadRunning = false;
                PendingTextures.Close();
                TextureThreadContextReady.WaitOne(5000, false);
            }

            if (chatOverlay != null)
            {
                chatOverlay.Dispose();
                chatOverlay = null;
            }

            if (textRendering != null)
            {
                textRendering.Dispose();
                textRendering = null;
            }

            Client.Objects.TerseObjectUpdate -= new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.AvatarUpdate -= new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate);
            Client.Network.UnregisterCallback(PacketType.KillObject, KillObjectHandler);
            Client.Network.SimChanged -= new EventHandler<SimChangedEventArgs>(Network_SimChanged);
            Client.Terrain.LandPatchReceived -= new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived);
            Client.Avatars.AvatarAnimation -= new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged);
            Client.Avatars.AvatarAppearance -= new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance);
            Client.Appearance.AppearanceSet -= new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);

            if (!PendingTasks.Closed)
            {
                PendingTasks.Close();
            }

            if (genericTaskThread != null)
            {
                genericTaskThread.Join(2000);
                genericTaskThread = null;
            }

            if (instance.Netcom != null)
            {
                Instance.Netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected);
            }

            lock (sculptCache)
            {
                foreach (var img in sculptCache.Values)
                    img.Dispose();
                sculptCache.Clear();
            }

            lock (Prims) Prims.Clear();
            lock (Avatars) Avatars.Clear();

            TexturesPtrMap.Clear();

            if (glControl != null)
            {
                glControl_UnhookEvents();
                try
                {
                    glControl.MakeCurrent();
                }
                catch { }
                try
                {
                    glControl.Dispose();
                }
                catch { }
            }
            glControl = null;

            GC.Collect();
        }
Beispiel #6
0
        void frmPrimWorkshop_Disposed(object sender, EventArgs e)
        {
            if (textRendering != null)
            {
                textRendering.Dispose();
                textRendering = null;
            }

            if (glControl != null)
            {
                glControl.Dispose();
            }
            glControl = null;
            Client.Objects.TerseObjectUpdate -= new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.ObjectDataBlockUpdate -= new EventHandler<ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);
        }
Beispiel #7
0
        public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID)
            : base(instance)
        {
            this.RootPrimLocalID = rootLocalID;

            InitializeComponent();
            Disposed += new EventHandler(frmPrimWorkshop_Disposed);
            AutoSavePosition = true;
            UseMultiSampling = cbAA.Checked = instance.GlobalSettings["use_multi_sampling"];
            cbAA.CheckedChanged += cbAA_CheckedChanged;

            this.instance = instance;

            renderer = new MeshmerizerR();
            textRendering = new TextRendering(instance);

            Client.Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.ObjectDataBlockUpdate += new EventHandler<ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);
        }