![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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) |
| | 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) |
| | 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) |
| | 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![]() |