ElementSortingHelper.cs help

Anonymous 9 years ago 0
This discussion was imported from CodePlex

Rogad wrote at 2014-02-23 02:08:

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 :)

Rogad wrote at 2014-02-23 14:58:

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"/>

objo wrote at 2014-02-23 21:39:

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.

Rogad wrote at 2014-02-23 22:16:

Thanks Objo,

Hmm how would I do the Model3DCollection then ?

Rogad wrote at 2014-02-24 00:30:

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.