Material won't load

Apr 26, 2012 at 5:27 AM

Hi,

I created a project, added reference to the Helixtoolkit.Wpf project, and took a sphere from the EarthDemo. I placed the png file in the folder which contains the bin, obj and properties folder. The application uses Kinect input, so the user can manipulate the sphere using Kinect.

However materials do not show up when I run the application. Below is the code for the sphere. Please let me know what am I missing in using materials on sphere.

<h:HelixViewport3D x:Name="helixViewport3D1"  InfiniteSpin="True" ZoomExtentsWhenLoaded="True">
            <h:DefaultLights />
            <h:SphereVisual3D Radius="1" Material="{h:ImageMaterial TimeZones2008.png}" ThetaDiv="45" PhiDiv="30" Fill="#FF802121" />
        </h:HelixViewport3D>

thanks

Gautam

Coordinator
Apr 26, 2012 at 6:16 AM

I think your Fill property overrides the Material property. Remove the Fill setting. And make sure the png file is included as Content in your project.

Apr 26, 2012 at 6:48 AM

Thanks for the help! The material is loading. File was in the wrong location. Fill settings did not affect the texture. 

One more question: The transparency which has been applied on the cloud.jpg, is not working. I copied the exact code.

I tried replacing jpg with a PNG file, but it didn't work. If the Binding in removed in the XAML, then the texture loads correctly, but without transparency. 

public static readonly DependencyProperty CloudsProperty = DependencyProperty.Register(
            "Clouds", typeof(Material), typeof(MainWindow), new UIPropertyMetadata(null));

this.Clouds = MaterialHelper.CreateImageMaterial("clouds.jpg", 0.5);

public Material Clouds
        {
            get
            {
                return (Material)this.GetValue(CloudsProperty);
            }

            set
            {
                this.SetValue(CloudsProperty, value);
            }
        }


<h:SphereVisual3D Radius="1.05" Material="{Binding Clouds}" ThetaDiv="90" PhiDiv="45"/>