Another Texture Problem
#1
Ok, first off, I think I’m really beginning to like your product. I’m just learning C# so I may be making things more difficult then they need to be. Also, I’m using the evaluation software until I can get enough built to convince my supervisor to buy me the software.

My goal is to be able to load 3ds models at run time. In the end I need to be able to grab a path from an xml file and load the model it points to.

Right now I can load a model and its textures loaded into the project as a resource. The problem comes when I change the path to a hard coded path on the hard drive. I can get the model to load but, the textures do not show up at all. Am I doing something wrong?

on a side note I have no idea how to work "ThrowMissingTextureException" The help file was less then helpful.

Code:
namespace Battleship
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Ab3d.Reader3ds _battleship;

        PerspectiveCamera myPCamera = new PerspectiveCamera();

        // Directional light values.
        private DirectionalLight myDirectionalLight = new DirectionalLight();
    
            
      
        Model3DGroup modelGroup = new Model3DGroup();
      
        public MainWindow()
        {
            InitializeComponent();
        }


        private void myPageLoaded(object sender, EventArgs e)
        {

                        
            _battleship = new Ab3d.Reader3ds();
            
            _battleship.ThrowMissingTextureException = true;

            //Uri uri = new Uri("pack://application:,,,/WpfApplication1;component/models/battleship.3DS", UriKind.Absolute);

            //_battleship.TexturesPath = "pack://application:,,,/WpfApplication1;component/models";

            _battleship.TexturesPath = "C:/Documents and Settings/p00009656/Desktop/3d Models";
            _battleship.ReadFile("C:/Documents and Settings/p00009656/Desktop/3d Models/battleship.3DS", Viewport1);

            //using (Stream stream = Application.GetResourceStream(uri).Stream)
            //{

            //    modelGroup = _battleship.ReadFile(stream, Viewport1, 0);
            //}

            myDirectionalLight.Color = Colors.White;
            myDirectionalLight.Direction = new Vector3D(0, -1, 0);
            modelGroup.Children.Add(myDirectionalLight);


            myPCamera = (Viewport1.Camera as PerspectiveCamera);

            //Set camera viewpoint and properties.
            myPCamera.FieldOfView = 60;
            myPCamera.Position = new Point3D(8000, 2000, 5000);
            myPCamera.LookDirection = new Vector3D(-1, -.2, -.5);
            myPCamera.UpDirection = new Vector3D(0, 1, 0);

        }
      
    }

}




Thanks,
Bryan
  


Messages In This Thread
Another Texture Problem - by Bryan Gabric - 08-26-2010, 04:34 PM
RE: Another Texture Problem - by abenedik - 08-27-2010, 04:43 PM
RE: Another Texture Problem - by Bryan Gabric - 08-27-2010, 05:46 PM
RE: Another Texture Problem - by abenedik - 08-28-2010, 10:25 PM
RE: Another Texture Problem - by Bryan Gabric - 08-28-2010, 10:37 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)