Another Texture Problem - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Viewer3ds and Ab3d.Reader3ds (https://forum.ab4d.com/forumdisplay.php?fid=5)
+--- Thread: Another Texture Problem (/showthread.php?tid=56)
Another Texture Problem - Bryan Gabric - 08-26-2010
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.
RE: Another Texture Problem - abenedik - 08-27-2010
I find this very strange.
Are you sure that the texture file is in the same folder as the 3ds file (C:/Documents and Settings/p00009656/Desktop/3d Models).
The Reader3ds automatically searches for the texture files in the same folder (if TexturesPath is not set). So it should be enough to put the texture files in the same folder as 3ds file and call ReadFile method.
Sometimes the cause of such problems is that the texture file names in 3ds file are stored only with 8 characters. So if your texture file name is longer than 8 characters, the file would not be found by Reader3ds because in 3ds file the file names is truncated.
Such problems can be found by setting ThrowMissingTextureException to true. In this case the Reader3ds would throw an Reader3ds.MissingTextureException exception with missing file name. This way you can get the file name that is causing problems and display it.
The following code displays the missing file name and than reads the 3ds file again with ThrowMissingTextureException set to false (the code sample is from the help file for the ThrowMissingTextureException property):
I would advice you to use the code and check if the file is really present.
RE: Another Texture Problem - Bryan Gabric - 08-27-2010
Thanks that worked great! I did some digging and found that if i use:
it works great. however if i skip the model3dgroup and just use:
it no longer displays the textures.
RE: Another Texture Problem - abenedik - 08-28-2010
Obviously you are calling the ReadFile method with the same parameters in both cases - so from Reader3ds perspective the same code is executed.
Maybe the problem is that in the first case you also add the light to the modelGroup (as seen from the code in your first post). Maybe you have forgotten to add the light to the Viewport1 in the second case (this can be also done in xaml where you have defined the Viewport1).
RE: Another Texture Problem - Bryan Gabric - 08-28-2010
Yea that's it. Without adding the "modelGroup" the lights I added have no reference to the model at all. In effect I've added lights to a model3Dgroup that is never added to the Viewport and only exist in the code behind. A stupid mistake but, at least I understand whats going on now. The textures were always there but, my lights where missing.