ElementSortingHelper.cs help

Feb 23, 2014 at 1:08 AM
I'm having some issues with overlapping transparent layers.

After a long search I eventually found that I need to order my rendering.

Objo, I found this ElementSortingHelper.cs file and it's similar to other scripts I have seen.

I was wondering if this was a stab at ordering the rendering so that transparent textures get rendered in the right order.

Could you give me an example of how to use it please if that is what it does ?

I see this in the code :
public static void AlphaSort(Point3D cameraPosition, Model3DCollection models, Transform3D worldTransform)
I am stuck on what to use for 'worldTransform'.

My Helix Viewport is called 'myView' and I can get as far as :
Visual3DCollection mymodels = (Visual3DCollection)myView.Children;
ElementSortingHelper.AlphaSort(myView.Camera.Position, mymodels, ???)
But what should go in the '???'

Thanks for taking a look :)
Feb 23, 2014 at 1:58 PM
Edited Feb 23, 2014 at 1:59 PM
In case it helps here is my code for my Helix View port...
        <Grid HorizontalAlignment="Left" Height="517" Margin="241,10,0,0" VerticalAlignment="Top" Width="559">
            <HelixToolkit:HelixViewport3D x:Name="myView" ZoomExtentsWhenLoaded="True" Margin="10" Grid.RowSpan="2">
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF4987D3" Offset="0.993"/>
                        <GradientStop Color="White" Offset="0.007"/>
                <!-- Remember to add light to the scene -->
                <ModelVisual3D x:Name="scene"/>
                <!-- You can also add elements here in the xaml -->
                <HelixToolkit:GridLinesVisual3D Width="8" Length="8" MinorDistance="1" MajorDistance="1" Thickness="0.01"/>
Feb 23, 2014 at 8:39 PM
The 'world' transform should be the total transform of the Visual3D containing the models. Note that the second argument should be a Model3DCollection.
In your case, I think you can use Transform3D.Identity for the transform.
Feb 23, 2014 at 9:16 PM
Thanks Objo,

Hmm how would I do the Model3DCollection then ?
Feb 23, 2014 at 11:30 PM
I think I figured out the model thing. I only have one model in my scene called 'current'. So I did this :
        private void Button_Click_4(object sender, RoutedEventArgs e)
            Model3DCollection mymodels = new Model3DCollection();
            ElementSortingHelper.AlphaSort(myView.Camera.Position, mymodels, Transform3D.Identity);    
It does nothing, but I am not entirely sure if my usage is correct.