this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 3;
- this.button1.Text = "3D View";
+ this.button1.Text = "View";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
private void UpdateControls()
{
- if (InvokeRequired) {
+ if (InvokeRequired)
+ {
Invoke(new MethodInvoker(UpdateControls));
return;
}
{
return (prim.LocalID == attachment.LocalID || prim.ParentID == attachment.LocalID);
}
- );
+ );
lblPrimCount.Text = "Prims: " + parts.Count.ToString();
}
void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e)
{
- if (e.Properties.ObjectID == attachment.ID) {
+ if (e.Properties.ObjectID == attachment.ID)
+ {
attachment.Properties = e.Properties;
UpdateControls();
}
private void button1_Click(object sender, EventArgs e)
{
- var prims = instance.Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == attachment.LocalID || p.LocalID == attachment.LocalID);
- var root = prims.Find((Primitive p) => p.LocalID == attachment.LocalID);
- if (root != null)
- {
- prims.Remove(root);
- root = new Primitive(root);
- root.ParentID = 0;
-
- frmPrimWorkshop pw = new frmPrimWorkshop(instance);
- pw.Shown += (xsender, xe) =>
- {
- Thread.Sleep(500);
- pw.SetupGLControl();
- if (pw.RenderingEnabled)
- {
- pw.LoadPrims(prims);
- }
- };
- pw.Show();
-
- }
+ frmPrimWorkshop pw = new frmPrimWorkshop(instance, attachment.LocalID);
+ pw.Show();
+ pw.SetView(new Vector3(0f, 0.5f, 0f), 0, 0, 90, -10);
}
}
}
RefreshList();
}
- private void RefreshList()
+ public void RefreshList()
{
List<Primitive> attachments = client.Network.CurrentSim.ObjectsPrimitives.FindAll(
delegate(Primitive prim)
Avatar av = currentAvatar;
if (av == null) return;
- if (!instance.TabConsole.TabExists("AT: " + av.Name))
+ if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString()))
{
- instance.TabConsole.AddATTab(av);
+ instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "AT: " + av.Name, new AttachmentTab(instance, av));
+
}
- instance.TabConsole.SelectTab("AT: " + av.Name);
+ instance.TabConsole.SelectTab("AT: " + av.ID.ToString());
}
private void tbtnAnim_Click(object sender, EventArgs e)
return;
}
- var prims = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.LocalID == currentPrim.LocalID || p.ParentID == currentPrim.LocalID);
-
- frmPrimWorkshop pw = new frmPrimWorkshop(instance);
- pw.Shown += (xsender, xe) =>
- {
- Thread.Sleep(500);
- pw.SetupGLControl();
- if (pw.RenderingEnabled)
- {
- pw.LoadPrims(prims);
- }
- };
+ frmPrimWorkshop pw = new frmPrimWorkshop(instance, currentPrim.LocalID);
pw.Show();
}
return msTab;
}
- public AttachmentTab AddATTab(Avatar avatar)
- {
- AttachmentTab atTab = new AttachmentTab(instance, avatar);
-
- RadegastTab tab = AddTab("AT: " + avatar.Name, "AT: " + avatar.Name, atTab);
- return atTab;
- }
-
public AnimTab AddAnimTab(Avatar avatar)
{
AnimTab animTab = new AnimTab(instance, avatar);
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tbtnSLeek = new System.Windows.Forms.ToolStripDropDownButton();
this.newWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.uploadImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tmnuImport = new System.Windows.Forms.ToolStripMenuItem();
this.scriptEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
this.ctxTreyRestore = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.ctxTreyExit = new System.Windows.Forms.ToolStripMenuItem();
- this.uploadImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.myAttachmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.newWindowToolStripMenuItem.Text = "&New window...";
this.newWindowToolStripMenuItem.Click += new System.EventHandler(this.newWindowToolStripMenuItem_Click);
//
+ // uploadImageToolStripMenuItem
+ //
+ this.uploadImageToolStripMenuItem.Name = "uploadImageToolStripMenuItem";
+ this.uploadImageToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
+ this.uploadImageToolStripMenuItem.Text = "Upload image...";
+ this.uploadImageToolStripMenuItem.Click += new System.EventHandler(this.uploadImageToolStripMenuItem_Click);
+ //
// tmnuImport
//
this.tmnuImport.Enabled = false;
this.cleanCacheToolStripMenuItem,
this.reloadInventoryToolStripMenuItem,
this.setAppearanceToolStripMenuItem,
- this.rebakeTexturesToolStripMenuItem});
+ this.rebakeTexturesToolStripMenuItem,
+ this.myAttachmentsToolStripMenuItem});
this.tbnTools.Enabled = false;
this.tbnTools.Image = ((System.Drawing.Image)(resources.GetObject("tbnTools.Image")));
this.tbnTools.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ctxTreyExit.ToolTipText = "Loggs of and closes application";
this.ctxTreyExit.Click += new System.EventHandler(this.ctxTreyExit_Click);
//
- // uploadImageToolStripMenuItem
+ // myAttachmentsToolStripMenuItem
//
- this.uploadImageToolStripMenuItem.Name = "uploadImageToolStripMenuItem";
- this.uploadImageToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
- this.uploadImageToolStripMenuItem.Text = "Upload image...";
- this.uploadImageToolStripMenuItem.Click += new System.EventHandler(this.uploadImageToolStripMenuItem_Click);
+ this.myAttachmentsToolStripMenuItem.Name = "myAttachmentsToolStripMenuItem";
+ this.myAttachmentsToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
+ this.myAttachmentsToolStripMenuItem.Text = "My Attachments";
+ this.myAttachmentsToolStripMenuItem.Click += new System.EventHandler(this.myAttachmentsToolStripMenuItem_Click);
//
// frmMain
//
public System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
public System.Windows.Forms.ToolStripMenuItem uploadImageToolStripMenuItem;
public System.Windows.Forms.ToolStripMenuItem muteListToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem myAttachmentsToolStripMenuItem;
}
}
}
#endregion
+ private void myAttachmentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Avatar av = client.Network.CurrentSim.ObjectsAvatars.Find((Avatar a) => { return a.ID == client.Self.AgentID; });
+
+ if (av == null)
+ {
+ tabsConsole.DisplayNotificationInChat("Unable to find my avatar!", ChatBufferTextStyle.Error);
+ return;
+ }
+
+ if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString()))
+ {
+ instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "My Attachments", new AttachmentTab(instance, av));
+ }
+ instance.TabConsole.SelectTab("AT: " + av.ID.ToString());
+
+ }
+
}
}
\ No newline at end of file
this.scrollYaw.Name = "scrollYaw";
this.scrollYaw.Size = new System.Drawing.Size(200, 16);
this.scrollYaw.TabIndex = 11;
+ this.scrollYaw.Value = 90;
this.scrollYaw.ValueChanged += new System.EventHandler(this.scroll_ValueChanged);
//
// scrollZoom
this.scrollZoom.Name = "scrollZoom";
this.scrollZoom.Size = new System.Drawing.Size(200, 16);
this.scrollZoom.TabIndex = 19;
- this.scrollZoom.Value = -50;
+ this.scrollZoom.Value = -30;
this.scrollZoom.ValueChanged += new System.EventHandler(this.scrollZoom_ValueChanged);
//
// gbZoom
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmPrimWorkshop";
this.Text = "Object Viewer";
+ this.Shown += new System.EventHandler(this.frmPrimWorkshop_Shown);
this.gbZoom.ResumeLayout(false);
this.gbZoom.PerformLayout();
this.ctxObjects.ResumeLayout(false);
/// List of prims in the scene
/// </summary>
Dictionary<uint, FacetedMesh> Prims = new Dictionary<uint, FacetedMesh>();
+
+ /// <summary>
+ /// Local ID of the root prim
+ /// </summary>
+ public uint RootPrimLocalID = 0;
+
+ /// <summary>
+ /// Camera center
+ /// </summary>
+ public Vector3 Center = Vector3.Zero;
#endregion Public fields
#region Private fields
OpenTK.Graphics.GraphicsMode GLMode = null;
AutoResetEvent TextureThreadContextReady = new AutoResetEvent(false);
BlockingQueue<TextureLoadItem> PendingTextures = new BlockingQueue<TextureLoadItem>();
- Vector3 Center = Vector3.Zero;
float[] lightPos = new float[] { 0f, 0f, 1f, 0f };
#endregion Private fields
#region Construction and disposal
- public frmPrimWorkshop(RadegastInstance instance)
+ public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID)
: base(instance)
{
+ this.RootPrimLocalID = rootLocalID;
+
InitializeComponent();
Disposed += new EventHandler(frmPrimWorkshop_Disposed);
AutoSavePosition = true;
GLMode = null;
}
-
+
try
{
if (GLMode == null)
}
#endregion Texture thread
- #region Public methods
- public void LoadPrims(List<Primitive> primList)
+ private void frmPrimWorkshop_Shown(object sender, EventArgs e)
{
- if (!RenderingEnabled) return;
+ SetupGLControl();
+
+ ThreadPool.QueueUserWorkItem(sync =>
+ {
+ if (Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(RootPrimLocalID))
+ {
+ UpdatePrimBlocking(Client.Network.CurrentSim.ObjectsPrimitives[RootPrimLocalID]);
+ var children = Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => { return p.ParentID == RootPrimLocalID; });
+ children.ForEach(p => UpdatePrimBlocking(p));
+ }
+ }
+ );
- ThreadPool.QueueUserWorkItem((object sync) =>
- {
- primList.ForEach(p => UpdatePrimBlocking(p));
- });
}
+ #region Public methods
+ public void SetView(Vector3 center, int roll, int pitch, int yaw, int zoom)
+ {
+ this.Center = center;
+ scrollRoll.Value = roll;
+ scrollPitch.Value = pitch;
+ scrollYaw.Value = yaw;
+ scrollZoom.Value = zoom;
+ }
public FacetedMesh GenerateFacetedMesh(Primitive prim, OSDMap MeshData, DetailLevel LOD)
{
string text = System.Text.RegularExpressions.Regex.Replace(prim.Text, "(\r?\n)+", "\n");
OpenTK.Vector3 screenPos = OpenTK.Vector3.Zero;
OpenTK.Vector3 primPos = OpenTK.Vector3.Zero;
-
- if (prim.ParentID != 0)
+
+ // Is it child prim
+ if (prim.ParentID == RootPrimLocalID)
{
primPos = new OpenTK.Vector3(prim.Position.X, prim.Position.Y, prim.Position.Z);
}
-
- primPos.Z += prim.Scale.Z * 0.7f;
+
+ primPos.Z += prim.Scale.Z * 0.7f;
screenPos = WorldToScreen(primPos);
Printer.Begin();
var size = Printer.Measure(text, f);
screenPos.X -= size.BoundingBox.Width / 2;
screenPos.Y -= size.BoundingBox.Height;
-
+
// Shadow
if (color != Color.Black)
{
// Individual prim matrix
GL.PushMatrix();
- if (prim.ParentID != 0)
+ if (prim.ParentID == RootPrimLocalID)
{
FacetedMesh parent = null;
if (Prims.TryGetValue(prim.ParentID, out parent))
if (belongToAlphaPass && pass != RenderPass.Alpha) continue;
if (!belongToAlphaPass && pass == RenderPass.Alpha) continue;
- }
- // Don't render transparent faces
- if (teFace.RGBA.A <= 0.01f) continue;
- switch (teFace.Shiny)
- {
- case Shininess.High:
- GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 94f);
- break;
+ // Don't render transparent faces
+ if (teFace.RGBA.A <= 0.01f) continue;
- case Shininess.Medium:
- GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 64f);
- break;
+ switch (teFace.Shiny)
+ {
+ case Shininess.High:
+ GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 94f);
+ break;
- case Shininess.Low:
- GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 24f);
- break;
+ case Shininess.Medium:
+ GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 64f);
+ break;
+ case Shininess.Low:
+ GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 24f);
+ break;
- case Shininess.None:
- default:
- GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 0f);
- break;
- }
- if (pass != RenderPass.Picking)
- {
+ case Shininess.None:
+ default:
+ GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 0f);
+ break;
+ }
+
var faceColor = new float[] { teFace.RGBA.R, teFace.RGBA.G, teFace.RGBA.B, teFace.RGBA.A };
GL.Color4(faceColor);
private void SafeInvalidate()
{
+ if (glControl == null || !RenderingEnabled) return;
+
if (InvokeRequired)
{
if (!instance.MonoRuntime || IsHandleCreated)
private void btnReset_Click(object sender, EventArgs e)
{
- scrollYaw.Value = 0;
+ scrollYaw.Value = 90;
scrollPitch.Value = 0;
scrollRoll.Value = 0;
- scrollZoom.Value = -50;
+ scrollZoom.Value = -30;
Center = Vector3.Zero;
SafeInvalidate();
#endregion Context menu
+
}
#region Helper classes
// Autogenerated: run updatebuildnr.bat/sh to update
namespace Radegast
{
- public static class RadegastBuild { public static int CurrentRev = 821; }
+ public static class RadegastBuild { public static int CurrentRev = 870; }
}