How to correctly load .obj and .3ds in an HelixViewPort3D?

Anonymous 9 years ago 0
This discussion was imported from CodePlex

zoras1986 wrote at 2013-06-05 16:59:

Hello everyone,
i know that this has been a solved issue, but i cannot get out of this mess.
I have tried all the possibilities that i found over internet, but i cannot figure out why some objects are loaded well and some others not. I tried three different ways...I post some code:
FileModelVisual3D Mymodel= new FileModelVisual3D();
Mymodel.source = MODELS[i]; //where MODELS[i] is a string with the path of the model, let's //say C:/fish.obj
view1.Children.Add(Mymodel);//where view1 is my helixviewport3d
so i try:
Model3DGroup modelGroup = ModelImporter.Load(MODELS[i]);
GeometryModel3D Mymodel = (GeometryModel3D)modelGroup.Children[0];
newVisual = new ModelVisual3D { Content = MyModel }; //or Content = modelGroup;
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
then i try:
var reader = new StudioReader();
Model3D MyModel = reader.Read(path); //where path is the object path
newVisual = new ModelVisual3D { Content = MyModel };
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
i tried also:
ObjReader reader2 = new ObjReader();
Model3DGroup modelGroup = reader2.Read(MODELS[i]);
GeometryModel3D _objRead = (GeometryModel3D)modelGroup.Children[0];
newVisual = new ModelVisual3D { Content = _objRead};
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
and obviously i'have tried also the loading directly from xaml, without any significant results :(
also i tried what have been described here https://helixtoolkit.codeplex.com/discussions/354077, meaning the loading from stream, but without any success...

No one of this method is working for me :( i cannot see well all the models that i find both in the helix samples both on internet. The best result that i've obtained, till now, is with the use of the second method (create a ModelGroup3D and show it through the use of a ModelVisual3D, that will be the helixViewPort children...

Can someone told me what i'm doing wrong? Could someone give me a piece of code that is actually working? because i've searched over the internet and all i read is that everyone could get this fantastic tool to work but me :'(

have a nice day and thanks in advance...:)

objo wrote at 2013-06-08 07:30:

Do you have lights in your scene? I think your code using ModelVisual3D looks ok.
I recommend setting a breakpoint on line 527 in StudioReader.cs, then you can check if the texture is loaded correctly!
Textures are not supported when loading from a stream.