Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: 7 Mar 2007 18:40:39 -0800,    group: microsoft.public.windows.developer.winfx.avalon        back       


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?

..
date: 7 Mar 2007 18:40:39 -0800   author:   znelson

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.
date: 7 Mar 2007 18:48:44 -0800   author:   znelson

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!
date: 7 Mar 2007 20:14:02 -0800   author:   znelson

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"  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!
>
date: Mon, 12 Mar 2007 14:49:24 -0700   author:   Jordan Parker [MSFT]

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...
date: 13 Mar 2007 18:25:39 -0700   author:   znelson

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us