How to add a processed 3D agitator for a 3D spiral

I have a set of procedural images that I would like to add as billboards to my 3D spiral application.

Currently my application is as follows:

public partial class _3DControl
{
    HelixViewport3D hVp3D;
    public _3DControl()
    {
        InitializeComponent();
        createView();
    }

    public void createView()
    {
        hVp3D = new HelixViewport3D();
        var lights = new SunLight();
        lights.Altitude=40;
        lights.Ambient=0.4;
        this.Content = hVp3D;
        hVp3D.Children.Add(lights);
        this.Show();
    }

    public void  UploadBillboard(BitmapImage im, System.Windows.Media.Media3D.Point3D position,double width,double height)
    { 
        //create material 
        var mat = MaterialHelper.CreateImageMaterial(im, 0);
        var bboard = new BillboardVisual3D();
        bboard.Material = mat;

        //set coordinates 
        bboard.Position = position;
        bboard.Width = width;
        bboard.Height = height;

        //add the billboard 
        hVp3D.Children.Add(bboard);
    }

However, when I call the function to add a billboard:

           HelixLinker.GetHelix().UploadBillboard(((Bitmap)e).bitmapToBitmapImage(), 
new System.Windows.Media.Media3D.Point3D(0, 0, 0), 100, 100);

Then I see that nothing has been added, any idea what I'm doing wrong?

I also tried with the RectangleVisual3D class.

public void UploadRect(BitmapImage im, System.Windows.Media.Media3D.Point3D position, double width, double height)
        {
            var mat = MaterialHelper.CreateImageMaterial(im, 0);
            var bboard = new RectangleVisual3D ();
            bboard.Material = mat;
            bboard.Width = width;

            hVp3D.Children.Add(bboard);
        }

Which, if it is done in the same way, will lead to a (perspective) image enter image description here, but in this case the material will not be correctly installed.

. , BillboardVisual3D - , -, " ", , , .

+4
1

0? .

:

//create material 
var mat = MaterialHelper.CreateImageMaterial(im);

Edit:

, . :

:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        CreateBilboard();
    }

    private void CreateBilboard()
    {
        BitmapImage im = new BitmapImage(new System.Uri(@"C:\Users\Public\Pictures\Sample Pictures\Lighthouse.jpg"));

        var mat = MaterialHelper.CreateImageMaterial(im, 1);
        var bboard = new BillboardVisual3D();
        bboard.Material = mat;

        var position = new System.Windows.Media.Media3D.Point3D(0, 0, 0);
        var width = 100;
        var height = 100;


        //set coordinates 
        bboard.Position = position;
        bboard.Width = width;
        bboard.Height = height;

        //add the billboard 
        viewPort.Children.Add(bboard);
    }
}

XAML:

<Window x:Class="BillboardImageMaterialDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf" 
        Title="BillboardImageMaterialDemo" Height="480" Width="640">
    <Grid>
        <ht:HelixViewport3D x:Name="viewPort" ZoomExtentsWhenLoaded="True">
            <!-- Remember to add some lights -->
            <ht:SunLight/>
        </ht:HelixViewport3D>
    </Grid>
</Window>

:

Bildboard with the lighthouse

+3

All Articles