![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Canvas as VisualBrush on GeometryModel3D : z-index problem I took the TNF Video Carousel example and modified it (slightly) to use a VisualBrush of a Canvas on each of the 3D planes instead of video clips. Works fine except that I'm noticing some sort of z-index problem. I have 3 ListBox3DItem's each using a different jpg as the background of their canvas and I set the opacity of the canvas to .5 and add them to the Carousel. When I run the app I notice that each canvas is only transparent to a canvas added prior to itself. In other words: Canvas c1 = new Canvas(); c1.Background = new ImageBrush((ImageSource)new ImageSourceConverter().ConvertFromString(@"C:\background1.jpg")); c1.Height = 1120; c1.Width = 624; c1.Opacity = .5; Carousel.Add(c1); Canvas c2 = new Canvas(); c2.Background = new ImageBrush((ImageSource)new ImageSourceConverter().ConvertFromString(@"C:\background2.jpg")); c2.Height = 1120; c2.Width = 624; c2.Opacity = .5; Carousel.Add(c2); Canvas c3 = new Canvas(); c3.Background = new ImageBrush((ImageSource)new ImageSourceConverter().ConvertFromString(@"C:\background3.jpg")); c3.Height = 1120; c3.Width = 624; c3.Opacity = .5; Carousel.Add(c3); Running this example: C1 will be completely solid when it is in the foreground and C2 and C3 are behind it C2 will be transparent (50%) when it is in the foreground and you will see C1 through it as it rotates, but not C3 C3 will be transparent (50%) when it is in the foreground and you will see C1 and C2 through it as it rotates I've tried Canvas.SetZIndex(C3) numerous times trying to give the last- added canvas a higher z-order thinking that might do the trick but no luck. Any ideas? .. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Canvas as VisualBrush on GeometryModel3D : z-index problem Forgot to mention, I've also tried setting the opacity of the VisualBrush directly, instead of the Canvas that it uses, but that has the same effect as the above example. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Canvas as VisualBrush on GeometryModel3D : z-index problem I solved the problem by removing and re-adding the Model3DGroup to the main group. This forces the geometry to render on top of the other children. For future reference, I modified this in ListBox3D.cs: private ListBox3DItem GetFrontmostItem() { ListBox3DItem current = this.Items[_FrontmostItemIndex] as ListBox3DItem; // force the object to render in front of everything else // by adding it on top of the other children each time _ModelItems.Children.Remove(current.ItemGroup); _ModelItems.Children.Add(current.ItemGroup); return current; } Hope this saves someone else a bit of trouble! |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Canvas as VisualBrush on GeometryModel3D : z-index problem I'm not familiar with the video carousel example, but you're encountering transparency issues depending on the order of the objects, right? This is a general problem in 3D graphics having to do with the depth buffer (which DiffuseMaterial writes to). For example, say you have three overlapping transparent DiffuseMaterial models and you draw them back to front, then everything is good. If you draw them front to back, the front one will block all of the others because it was drawn first. You need to sort the objects in your scene. Also, Canvas.ZIndex is only relevant in 2D. Jordan "znelson" <znelson@gmail.com> wrote in message news:1173327242.575443.324630@h3g2000cwc.googlegroups.com... >I solved the problem by removing and re-adding the Model3DGroup to the > main group. This forces the geometry to render on top of the other > children. > > For future reference, I modified this in ListBox3D.cs: > > private ListBox3DItem GetFrontmostItem() > { > ListBox3DItem current = this.Items[_FrontmostItemIndex] as > ListBox3DItem; > > // force the object to render in front of everything else > // by adding it on top of the other children each time > _ModelItems.Children.Remove(current.ItemGroup); > _ModelItems.Children.Add(current.ItemGroup); > > return current; > } > > Hope this saves someone else a bit of trouble! > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Canvas as VisualBrush on GeometryModel3D : z-index problem That's exactly the problem I was having. Unfortunately the 3D objects are not treated equal when added to the group. The depth buffer you mention is definately taking into consideration the order in which the objects are added to the group. So by adding the object I want to be transparent to everything else in the scene, I have to move it from where it is in the group to the last object in the group. Then all is good. 3D software programs such as Lightwave 3D aren't affected by this. Each object in the scene is on the same level as the next. So if every object is 50% transparent, every object could be seen through any other object. I couldn't imagine having to juggle objects around in a complex scene just to get them to be truly transparent so you can see earlier-added objects through them. Oh well... |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Canvas as VisualBrush on GeometryModel3D : z-index problem It's possible that Lightwave is sorting before drawing or that they are using different depth options than we are. I was referring more to OpenGL, Direct3D, XNA, etc. I forgot to mention that EmissiveMaterial and SpecularMaterial don't touch the depth buffer so if you just use them you'll be fine. However, you might not get the look you're going for. Jordan "znelson" <znelson@gmail.com> wrote in message news:1173835539.439217.310200@b75g2000hsg.googlegroups.com... > That's exactly the problem I was having. Unfortunately the 3D objects > are not treated equal when added to the group. The depth buffer you > mention is definately taking into consideration the order in which the > objects are added to the group. So by adding the object I want to be > transparent to everything else in the scene, I have to move it from > where it is in the group to the last object in the group. Then all is > good. > > 3D software programs such as Lightwave 3D aren't affected by this. > Each object in the scene is on the same level as the next. So if every > object is 50% transparent, every object could be seen through any > other object. I couldn't imagine having to juggle objects around in a > complex scene just to get them to be truly transparent so you can see > earlier-added objects through them. Oh well... > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Panning & Zooming with VisualBrush/Viewbox | Tobias Vandenbempt | Avalon | 1 | 04-26-2007 06:39 AM |
| DrawingBrush .. VisualBrush in UserControl | Ariel | Avalon | 0 | 02-03-2007 12:13 PM |
| VisualBrush of an expander.. | DickyDick | Avalon | 0 | 01-04-2007 03:25 AM |
| which controls in VisualBrush.Visual | alberto.ramacciotti@gmail.com | Avalon | 0 | 06-19-2006 10:34 AM |
| DiffuseMaterial and GeometryModel3D SDK Problem | Roman | Avalon | 4 | 04-21-2006 09:46 PM |