public override void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { StructureType obj = Type; // Debug.Assert(obj == null, "This command should be inactive if Selected Object isn't a StructureTypeObj"); if(obj == null) return; Parent.spriteBatch.Begin(); string title = obj.Code; if(this.Parent.spriteBatch != null && this.oldMouse != null) { Vector2 offset = Parent.fontArial.MeasureString(title); offset.X /= 2; offset.Y /= 2; Parent.spriteBatch.DrawString(Parent.fontArial, title, new Vector2((float)this.oldMouse.X - offset.X, (float)this.oldMouse.Y - offset.Y), new Microsoft.Xna.Framework.Color(obj.Color.R, obj.Color.G, obj.Color.B, 196)); } Parent.spriteBatch.End(); return; }
public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect) { BookmarkOverlay.DrawCircle(graphicsDevice, basicEffect, this.oldWorldPosition, Global.DefaultBookmarkRadius * scene.Camera.Downsample, new Microsoft.Xna.Framework.Color(Microsoft.Xna.Framework.Color.Gold.R, Microsoft.Xna.Framework.Color.Gold.G, Microsoft.Xna.Framework.Color.Gold.B, 0.5f)); }
public override void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { if (CommandActive == false) return; //Retrieve the mouse position from the last update, the base class records this for us Vector3 target = new Vector3((float)this.oldWorldPosition.X, (float)oldWorldPosition.Y, 0f); ; Color lineColor = new Color(Color.YellowGreen.R, Color.YellowGreen.G, Color.YellowGreen.B, 0.75f); double Distance = GridVector2.Distance(Origin, this.oldWorldPosition) * MeasurementExtension.Global.UnitsPerPixel; RoundLineCode.RoundLine lineToParent = new RoundLineCode.RoundLine((float)Origin.X, (float)Origin.Y, (float)target.X, (float)target.Y); Parent.LineManager.Draw(lineToParent, (float)(1 * Parent.Downsample), lineColor, scene.Camera.View * scene.Projection, 1, "Glow"); //Draw the distance near the cursor Parent.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); GridVector2 DrawPosition = Parent.WorldToScreen(target.X, target.Y); Parent.spriteBatch.DrawString(Parent.fontArial, Distance.ToString("#0.00") + " " + Global.UnitOfMeasure, new Vector2((float)DrawPosition.X, (float)DrawPosition.Y), lineColor, 0, new Vector2(0,0), 0.5f, SpriteEffects.None, 0); Parent.spriteBatch.End(); base.OnDraw(graphicsDevice, scene, basicEffect); }
public override void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { //PORT XNA 4 //basicEffect.Begin(); // foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) // { //PORT XNA 4 //pass.Begin(); //rectangle.Draw(graphicsDevice); //PORT XNA 4 //pass.End(); // } //PORT XNA 4 //basicEffect.End(); base.OnDraw(graphicsDevice, scene, basicEffect); }
public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect) { // double OldRadius = selected.Radius; SectionLocationsViewModel sectionAnnotations = AnnotationOverlay.GetAnnotationsForSection(Parent.Section.Number); if (sectionAnnotations == null) return; GridVector2 Pos = selected.VolumePosition; /* bool found = sectionAnnotations.TryGetPositionForLocation(selected, out Pos); if (found == false) return; */ Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(LocType.Color.R, LocType.Color.G, LocType.Color.B, 128); GlobalPrimitives.DrawCircle(graphicsDevice, basicEffect, Pos, this.radius, color); base.OnDraw(graphicsDevice, scene, basicEffect); }
public override void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { if (this.oldMouse == null) return; GlobalPrimitives.DrawCircle(graphicsDevice, basicEffect, transformedPos, putativeLoc.Radius, linecolor); Vector3 target; if (nearestParent != null) { SectionLocationsViewModel sectionAnnotations = AnnotationOverlay.GetAnnotationsForSection(Parent.Section.Number); if (sectionAnnotations == null) return; //Snap the line to a nearby target if it exists GridVector2 targetPos = nearestParent.VolumePosition; /* bool success = sectionAnnotations.TryGetPositionForLocation(nearestParent, out targetPos); if (!success) return; */ target = new Vector3((float)targetPos.X, (float)targetPos.Y, 0f); } else { //Otherwise use the old mouse position target = new Vector3((float)this.oldWorldPosition.X, (float)oldWorldPosition.Y, 0f); } RoundLine lineToParent = new RoundLine((float)transformedPos.X, (float)transformedPos.Y, (float)target.X, (float)target.Y); Parent.LineManager.Draw(lineToParent, (float)(putativeLoc.Radius / 6.0), linecolor, basicEffect.View * basicEffect.Projection, 1, null); base.OnDraw(graphicsDevice, scene, basicEffect); }
public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect) { if (this.oldMouse == null) return; if (basicEffect == null) throw new ArgumentNullException("basicEffect"); if (scene == null) throw new ArgumentNullException("scene"); //Draw a line from the selected location to the new location if we are holding left button down if (this.oldMouse.Button == MouseButtons.Left) { SectionLocationsViewModel sectionAnnotations = AnnotationOverlay.GetAnnotationsForSection(Parent.Section.Number); if (sectionAnnotations == null) return; GridVector2 selectedPos = selected.VolumePosition; /*bool found = sectionAnnotations.TryGetPositionForLocation(selected, out selectedPos); if (found == false) return; */ //PORT XNA 4 /* VertexDeclaration oldVertexDeclaration = graphicsDevice.VertexDeclaration; graphicsDevice.VertexDeclaration = Parent.VertexPositionColorDeclaration; graphicsDevice.RenderState.PointSize = 5.0f; */ basicEffect.Texture = null; basicEffect.TextureEnabled = false; basicEffect.VertexColorEnabled = true; //PORT XNA 4 //basicEffect.CommitChanges(); //Draw the new location if (LocType != null && selected.Section == Parent.Section.Number) { Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(LocType.Color.R, LocType.Color.G, LocType.Color.B, 128); GlobalPrimitives.DrawCircle(graphicsDevice, basicEffect, this.oldWorldPosition, selected.Radius, color); } else { VertexPositionColor[] verts = new VertexPositionColor[] { new VertexPositionColor(new Vector3((float)selectedPos.X, (float)selectedPos.Y, 0f), Color.Gold), new VertexPositionColor(new Vector3((float)this.oldWorldPosition.X, (float)oldWorldPosition.Y, 0f), Color.Gold)}; int[] indicies = new int[] { 0, 1 }; //PORT XNA 4 //basicEffect.Begin(); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { //PORT XNA 4 //pass.Begin(); pass.Apply(); if (verts != null && verts.Length > 0) graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, verts, 0, verts.Length, indicies, 0, indicies.Length / 2); //PORT XNA 4 //pass.End(); } //PORT XNA 4 //basicEffect.End(); } //PORT XNA 4 //graphicsDevice.VertexDeclaration = oldVertexDeclaration; } basicEffect.VertexColorEnabled = false; //PORT XNA 4 //basicEffect.CommitChanges(); base.OnDraw(graphicsDevice, scene, basicEffect); }
public void Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.Texture BackgroundLuma, Microsoft.Xna.Framework.Graphics.Texture BackgroundColors, ref int nextStencilValue) { /// <summary> /// Steps: /// Find all the locations for a section. This could be optimized to return only visible sections immediately with a better data structure /// Filter out invisible locations /// Draw the backgrounds /// Draw the overlapping linked locations over the backgrounds /// Draw the structure links /// Draw the labels /// </summary> /// <param name="graphicsDevice"></param> /// <param name="scene"></param> /// <param name="BackgroundLuma"></param> /// <param name="BackgroundColors"></param> /// <param name="nextStencilValue"></param> if(_Parent.Section == null) return; if (_Parent.spriteBatch.GraphicsDevice.IsDisposed) return; Matrix ViewProjMatrix = scene.Camera.View * scene.Projection; GridRectangle Bounds = scene.VisibleWorldBounds; nextStencilValue++; if (basicEffect == null) basicEffect = new BasicEffect(graphicsDevice); else if(basicEffect.IsDisposed) basicEffect = new BasicEffect(graphicsDevice); VikingXNA.AnnotationOverBackgroundLumaEffect overlayEffect = Parent.annotationOverlayEffect; overlayEffect.LumaTexture = BackgroundLuma; overlayEffect.RenderTargetSize = graphicsDevice.Viewport; basicEffect.Alpha = 1; RasterizerState OriginalRasterState = graphicsDevice.RasterizerState; SectionLocationsViewModel currentSectionAnnotations = CurrentSectionAnnotations; Debug.Assert(currentSectionAnnotations != null); int SectionNumber = _Parent.Section.Number; float Time = (float)TimeSpan.FromTicks(DateTime.Now.Ticks - DateTime.Today.Ticks).TotalSeconds; // Debug.WriteLine("Time: " + Time.ToString()); IncrementDepthStencilValue(graphicsDevice, ref nextStencilValue); //Get all the lines to draw first so the text and geometric shapes are over top of them LocationLink[] VisibleLinks = linksView.VisibleLocationLinks(_Parent.Section.Number, Bounds); foreach (LocationLink link in VisibleLinks) { DrawLocationLink(link, ViewProjMatrix); } graphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0); IncrementDepthStencilValue(graphicsDevice, ref nextStencilValue); //graphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0); //IncrementDepthStencilValue(graphicsDevice, ref nextStencilValue); ICollection<Location_CanvasViewModel> Locations = currentSectionAnnotations.GetLocations(); List<Location_CanvasViewModel> listLocationsToDraw = FindVisibleLocations(Locations, Bounds); //Find a circle that encloses the visible bounds GridCircle VisibleCircle = new GridCircle(Bounds.Center, GridVector2.Distance(Bounds.Center, new GridVector2(Bounds.Left, Bounds.Top))); List<Location_CanvasViewModel> RefLocations = new List<Location_CanvasViewModel>(); if(_Parent.Section.ReferenceSectionBelow != null) { SectionLocationsViewModel sectionLocations = GetAnnotationsForSection(_Parent.Section.ReferenceSectionBelow.Number); if (sectionLocations != null) RefLocations.AddRange(sectionLocations.GetLocations());//(Bounds)); } if(_Parent.Section.ReferenceSectionAbove != null) { SectionLocationsViewModel sectionLocations = GetAnnotationsForSection(_Parent.Section.ReferenceSectionAbove.Number); if (sectionLocations != null) { RefLocations.AddRange(sectionLocations.GetLocations()); } } //Draw text for locations on the reference sections List<Location_CanvasViewModel> listVisibleNonOverlappingLocationsOnAdjacentSections = FindVisibleLocations(RefLocations, Bounds); List<Location_CanvasViewModel> listVisibleOverlappingLocationsOnAdjacentSections = RemoveOverlappingLocations(listVisibleNonOverlappingLocationsOnAdjacentSections, _Parent.Section.Number); //Draw all of the locations on the current section WebAnnotation.LocationObjRenderer.DrawBackgrounds(listLocationsToDraw, graphicsDevice, basicEffect, overlayEffect, scene, SectionNumber); IncrementDepthStencilValue(graphicsDevice, ref nextStencilValue); graphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0); WebAnnotation.LocationObjRenderer.DrawBackgrounds(listVisibleNonOverlappingLocationsOnAdjacentSections, graphicsDevice, basicEffect, overlayEffect, scene, SectionNumber); IncrementDepthStencilValue(graphicsDevice, ref nextStencilValue); graphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0); WebAnnotation.LocationObjRenderer.DrawOverlappedAdjacentLinkedLocations(listLocationsToDraw, scene, graphicsDevice, basicEffect, overlayEffect, SectionNumber); TryDrawLineFromOverlappingLocation(AnnotationOverlay.LastMouseOverObject as OverlappedLocation, _Parent.LineManager, _Parent.Section.Number, Time); if (defaultBlendState == null || defaultBlendState.IsDisposed) { defaultBlendState = new BlendState(); defaultBlendState.AlphaBlendFunction = BlendFunction.Add; defaultBlendState.AlphaSourceBlend = Blend.SourceAlpha; defaultBlendState.AlphaDestinationBlend = Blend.DestinationAlpha; defaultBlendState.ColorSourceBlend = Blend.SourceColor; defaultBlendState.ColorDestinationBlend = Blend.DestinationColor; defaultBlendState.ColorBlendFunction = BlendFunction.Add; } graphicsDevice.BlendState = defaultBlendState; //Get all the lines to draw StructureLink[] VisibleStructureLinks = currentSectionAnnotations.VisibleStructureLinks(Bounds); foreach (StructureLink link in VisibleStructureLinks) { DrawStructureLink(link, ViewProjMatrix, Time); } graphicsDevice.BlendState = defaultBlendState; //Draw text DrawLocationLabels(listLocationsToDraw); DrawLocationLabels(listVisibleNonOverlappingLocationsOnAdjacentSections); graphicsDevice.RasterizerState = OriginalRasterState; }
public void Draw(GraphicsDevice graphicsDevice, VikingXNA.TileLayoutEffect effect, bool AsynchTextureLoad, bool UseColor) { if (TriangleIndicies == null) { #if DEBUG if(!NullGridWarningPrinted) { NullGridWarningPrinted = true; Trace.WriteLine("Null Grid Indicies for " + this.TextureFileName, "Tile"); } #endif return; } if (TriangleIndicies.Length == 0) { #if DEBUG if (!NullGridWarningPrinted) { NullGridWarningPrinted = true; Trace.WriteLine("No Grid Indicies for " + this.TextureFileName, "Tile"); } #endif return; } Texture2D currentTexture = GetTexture(graphicsDevice, AsynchTextureLoad); //Do not draw if we don't have a texture if (currentTexture == null) return; lock (this) { currentTexture = GetTexture(graphicsDevice, AsynchTextureLoad); //Do not draw if we don't have a texture if (currentTexture == null) return; if (currentTexture.IsDisposed) return; //Create the verticies if they don't exist if (this.VertBuffer == null) { VertBuffer = CreateVertexBuffer(graphicsDevice, Tile.Verticies); } if (VertBuffer == null || VertBuffer.VertexCount == 0) return; //Create Index buffer if it doesn't exist if (IndBuffer == null) { IndBuffer = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, Tile.TriangleIndicies.Length, BufferUsage.None); IndBuffer.SetData<ushort>(Array.ConvertAll<int, ushort>(TriangleIndicies, new Converter<int, ushort>(IntToShort))); } graphicsDevice.SetVertexBuffer(this.VertBuffer); graphicsDevice.Indices = this.IndBuffer; effect.Texture = currentTexture; if (UseColor) effect.TileColor = TileColor; //PORT XNA 4 //effect.effect.Begin(); foreach (EffectPass pass in effect.effect.CurrentTechnique.Passes) { //PORT XNA 4 //pass.Begin(); pass.Apply(); graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertBuffer.VertexCount, 0, TriangleIndicies.Length / 3); /* graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.Verticies, 0, this.Verticies.Length, TriangleIndicies, 0, TriangleIndicies.Length / 3); */ //PORT XNA 4 //pass.End(); } //PORT XNA 4 //effect.effect.End(); } }
public override void OnDraw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect) { if (CommandActive == false) return; //PORT XNA 4 //VertexDeclaration oldVertexDeclaration = graphicsDevice.VertexDeclaration; //PORT XNA 4 //graphicsDevice.VertexDeclaration = Parent.VertexPositionColorDeclaration; basicEffect.VertexColorEnabled = true; basicEffect.TextureEnabled = false; //PORT XNA 4 //basicEffect.CommitChanges(); VertexPositionColor[] verts = new VertexPositionColor[] { new VertexPositionColor( new Vector3((float)MyRect.Left, (float)MyRect.Bottom, 1), Color.Yellow), new VertexPositionColor( new Vector3((float)MyRect.Right, (float)MyRect.Bottom, 1), Color.Yellow), new VertexPositionColor( new Vector3((float)MyRect.Right, (float)MyRect.Top, 1), Color.Yellow), new VertexPositionColor( new Vector3((float)MyRect.Left, (float)MyRect.Top, 1), Color.Yellow)}; Color CrossColor = new Color(Color.Yellow.R, Color.Yellow.G, Color.Yellow.B, 0.25f); float EightWidth = (float)(MyRect.Width / 16); float EightHeight = (float)(MyRect.Height / 16); VertexPositionColor[] crossVerts = new VertexPositionColor[] { new VertexPositionColor( new Vector3((float)MyRect.Center.X - EightWidth, (float)MyRect.Center.Y, 1), CrossColor), new VertexPositionColor( new Vector3((float)MyRect.Center.X + EightWidth, (float)MyRect.Center.Y, 1), CrossColor), new VertexPositionColor( new Vector3((float)MyRect.Center.X, (float)MyRect.Center.Y - EightHeight, 1), CrossColor), new VertexPositionColor( new Vector3((float)MyRect.Center.X, (float)MyRect.Center.Y + EightHeight, 1), CrossColor)}; int[] indicies = new int[] { 0, 1, 2, 3, 0 }; int[] crossIndicies = new int[] { 0, 1, 2, 3 }; //PORT XNA 4 //basicEffect.Begin(); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { //PORT XNA 4 //pass.Begin(); pass.Apply(); //if(gridIndicies.Count > 0) // MyRect.Draw(graphicsDevice); graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, verts, 0, verts.Length, indicies, 0, indicies.Length - 1); graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, crossVerts, 0, crossVerts.Length, crossIndicies, 0, crossIndicies.Length / 2); // graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length, gridIndicies, 0, gridIndicies.Length / 3); // graphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length / 3); // GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, GridVerticies, 0, GridVerticies.Length, GridIndicies, 2, 2); // graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, this.verticies, 0, verticies.Length, gridIndicies, 0, 1); //PORT XNA 4 //pass.End(); } //PORT XNA 4 //basicEffect.End(); //PORT XNA 4 //graphicsDevice.VertexDeclaration = oldVertexDeclaration; basicEffect.TextureEnabled = true; basicEffect.VertexColorEnabled = false; base.OnDraw(graphicsDevice,scene, basicEffect); }
public virtual void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { return; }
void RecursiveDrawBookmarks(FolderUIObj ParentFolder, Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect, VikingXNA.Scene scene) { float alpha = 1; GridRectangle Bounds = scene.VisibleWorldBounds; double Downsample = scene.Camera.Downsample; double maxDimension = Math.Max(Bounds.Width, Bounds.Height); //We use the default radius unless it would be invisible. In that case radius is scaled after calculating the alpha value double BookmarkRadius = Global.DefaultBookmarkRadius; //If the bookmark is more than 2.5% of the screen begin making it transparent Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(Microsoft.Xna.Framework.Color.Gold.ToVector3()); double BookmarkAlphaThreshold = 0.001; //double BookmarkToVisibleBoundsRatio = Global.BookmarkArea / Bounds.Area; //if (BookmarkToVisibleBoundsRatio > BookmarkAlphaThreshold) double BookmarkDimensionRatio = BookmarkRadius * 2 / maxDimension; if(BookmarkDimensionRatio > BookmarkAlphaThreshold) { //A circle fills 0.78% of the screen area, so divide that by four double BookmarkTransparentThreshold = 0.25; alpha = 1f - (float)Math.Sqrt(((BookmarkDimensionRatio - BookmarkAlphaThreshold) / (BookmarkTransparentThreshold - BookmarkAlphaThreshold))); if (alpha < 0.00) alpha = 0.00f; } double ScreenPixelRadius = BookmarkRadius / Downsample; //What is the absolute smallest size a bookmark should have? double minBookmarkPixelRadius = (maxDimension / Downsample) / (BookmarkRadius * Downsample) > 7.5 ? (maxDimension / Downsample) / (BookmarkRadius * Downsample) : 7.5; if (ScreenPixelRadius < minBookmarkPixelRadius) { BookmarkRadius = minBookmarkPixelRadius * (Downsample * (1 + (Math.Sin((DateTime.UtcNow.Millisecond / 1000.0) * Math.PI) / 10))); //To make it a bit more visible, vary the alpha slightly with time //alpha *= (float)(0.5 + (Math.Sin((DateTime.UtcNow.Millisecond / 1000.0) * Math.PI)/2)); } color.A = (byte)(255.0 * alpha); foreach(BookmarkUIObj bookmark in ParentFolder.Bookmarks) { if (Viking.UI.State.ViewerControl.Section.Number == bookmark.Z) { if (Bounds.Intersects(new GridRectangle(bookmark.GridPosition, Global.DefaultBookmarkRadius))) { DrawCircle(graphicsDevice, basicEffect, bookmark.GridPosition, BookmarkRadius, color); DrawLabel(bookmark, alpha, graphicsDevice); } // bookmark.Draw(graphicsDevice, basicEffect, DownSample); } } //Walk the bookmark tree and draw every bookmark foreach (FolderUIObj folder in ParentFolder.Folders) { RecursiveDrawBookmarks(folder, graphicsDevice, basicEffect, scene); } }
void Viking.Common.ISectionOverlayExtension.Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, VikingXNA.Scene scene, Microsoft.Xna.Framework.Graphics.Texture BackgroundLuma, Microsoft.Xna.Framework.Graphics.Texture BackgroundColors, ref int nextStencilValue) { if (basicEffect == null) basicEffect = new BasicEffect(graphicsDevice); if (basicEffect.IsDisposed) basicEffect = new BasicEffect(graphicsDevice); basicEffect.World = scene.World; basicEffect.Projection = scene.Projection; basicEffect.View = scene.Camera.View; basicEffect.FogEnabled = false; basicEffect.LightingEnabled = false; RecursiveDrawBookmarks(Global.FolderUIObjRoot, graphicsDevice, basicEffect, scene); return; }
public override void OnDraw(GraphicsDevice graphicsDevice, VikingXNA.Scene scene, BasicEffect basicEffect) { if (this.oldMouse == null) return; WebAnnotation.ViewModel.SectionLocationsViewModel sectionAnnotations = AnnotationOverlay.GetAnnotationsForSection(OriginObj.Section); if (sectionAnnotations == null) return; GridVector2 OriginPosition = OriginObj.VolumePosition; Vector3 target; if (NearestTarget != null) { //Snap the line to a nearby target if it exists GridVector2 targetPos = NearestTarget.VolumePosition; /*bool success = sectionAnnotations.TryGetPositionForLocation(NearestTarget, out targetPos); if (!success) return; */ target = new Vector3((float)targetPos.X, (float)targetPos.Y, 0f); } else { //Otherwise use the old mouse position target = new Vector3((float)this.oldWorldPosition.X, (float)oldWorldPosition.Y, 0f); } Color lineColor = new Color(Color.Black.R, Color.Black.G, Color.Black.B, 0.5f); if (NearestTarget != null) { Structure TargetStruct = NearestTarget.Parent; if (TargetStruct != null) { //If they are the same structure on different sections use the color for a location link, otherwise white if (TargetStruct == OriginObj.Parent) { if (NearestTarget.Z != OriginObj.Z) { //Make sure the locations aren't already linked bool ValidTarget = true; foreach (long linkID in OriginObj.Links) { if (linkID == NearestTarget.ID) { ValidTarget = false; break; } } if (ValidTarget) { StructureType type = OriginObj.Parent.Type; //If you don't cast to byte the wrong constructor is used and the alpha value is wrong lineColor = new Microsoft.Xna.Framework.Color((byte)(255 - type.Color.R), (byte)(255 - type.Color.G), (byte)(255 - type.Color.B), (byte)128); } } } else { lineColor = new Color(Color.White.R, Color.White.G, Color.White.B, 0.5f); } } } RoundLine lineToParent = new RoundLine((float)OriginPosition.X, (float)OriginPosition.Y, (float)target.X, (float)target.Y); Parent.LineManager.Draw(lineToParent, (float)(OriginObj.Radius / 6.0), lineColor, basicEffect.View * basicEffect.Projection, 1, null); base.OnDraw(graphicsDevice, scene, basicEffect); }