I am trying to import a 3ds file containing a simple plane with a single bitmap texture material. The 3ds file is created in Blender. I have found an old description of how to do that but it does not work. There is no demo that demonstrates this.
Hi Lars,
Does it occur for the current version only? As I remember in 3D Max you need divide your mesh when it big enough into 64k fragments and convert to Editable Mesh before export to 3DS. Then try to import it to GLScene. May be it's possible in Blender or Google SketchUp also.
PW
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am not sure what you mean by version, but I use the newest version of both Blender and
GLScene.
No matter what I do, the textures are not imported when opening a 3ds file. Not only my own files - also models downloaded from the web.
Is texture import from 3ds supposed to work? And, does someone have a demo that actually works? There is no demo in the GLScene source (the 'Mushroom' demo does not demonstrate texture import from the 3ds file)
Lars
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am not adding the texture manually. As far as I understand (see: http://glscene.sourceforge.net/oldsite/faq.htm#300502-1), that should happen automatically if the TGLFreeform is linked to a TGLMaterialLibrary. The faq in the link is very old but it is the only documentation I have been able to find regarding this topic.
I have tried to add the texture manually but that did not work either.
I will try to create a small demo project and post it later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have now created and attached a small demo project demonstrating the problem.
I am not an expert Blender user, but I suspect mapping as part of the problem. When importing the 3ds file I just exported from Blender in Blender the mapping has changed? However, I have not been able to import any 3ds file (various files found on the web) containing textures in GLScene/GLFreeform?
Lars,
It seems that something wrong with your ground.3ds. May be scale it in blender. I've attached a UsersDemo with 3ds models and included your files. Your ground.jpg with buildings appears at two sides of cube.3ds and teapot.3ds.
PW
I can see that it works when choosing Z axis for planar mapping. I can't say that I fully understand your code but it is obvious that it requires a lot of code to make it work?
My original impression from reading the very sparse documentation was that loading and mapping of textures would happen automatically. I guess the conclusion is that it does not work like that, and loading textures to a freeform imported from 3ds is not a trivial task. In this case the model is a simple plane with a single texture - imagine a complex model with multiple textures.
If it was possible to load a 3ds file with textures automatically, all the modeling and texture mapping could be done in a modeling tool (Blender, 3D Studio Max, Solids Works, AutoCad, etc.), and then imported in GLScene.
At the moment only solid color materials are working. That will do for me for now but textures would be fantastic!
Lars
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
there is nothing wrong with your sample code (Freeform.zip), GLScene manage with extreme simplicity the loading of meshes with textures and you got it right.
The only problem is in your mesh file (ground.3ds) and in particular the UV mapping projection applied to it that seems to be "spherical" instead of "cubic".
Please refer to the Blender documentation to know how to apply the correct UV mapping projection.
I have now spent a few hours of my weekend learning how texture mapping works in Blender. Thanks to your suggestion I knew what to look for! Because of my limited knowledge of modeling in Blender I had set the texture mapping to 'Generated'. That works when rendering in Blender, but not when exporting to 3DS. The trick is to use UV mapping, which is simple. I have attached an updated working demo project.
I am trying to import a 3ds file containing a simple plane with a single bitmap texture material. The 3ds file is created in Blender. I have found an old description of how to do that but it does not work. There is no demo that demonstrates this.
FGLMaterialLibrary := TGLMaterialLibrary.Create(Self);
FGLFreeform := TGLFreeform.Create(Self);
FGLFreeform.Material.BlendingMode := bmTransparency;
FGLFreeform.MaterialLibrary := FGLMaterialLibrary;
FGLFreeform.UseMeshMaterials := True;
FGLFreeform.LoadFromFile('PathToFile.3ds')
The bitmap is a jpeg file. No errors are thrown, and the freeform simply shows a solid color?
What am I doing wrong?
Lars
Hi,
I'm not on my development PC at the moment but from memory you should also set
FGLFreeForm.Material.Texture.Enabled
to True to activate textures.
I have now added FGLFreeForm.Material.Texture.Enabled := True
Now the plane is a solid blue on one side and transparent on the other? The texture is not visible.
Has anyone been able to create an object with an image texture in Blender, save it as *.3ds, and then import it in GLScene?
Hi Lars,
Does it occur for the current version only? As I remember in 3D Max you need divide your mesh when it big enough into 64k fragments and convert to Editable Mesh before export to 3DS. Then try to import it to GLScene. May be it's possible in Blender or Google SketchUp also.
PW
Hi Pavel
I am not sure what you mean by version, but I use the newest version of both Blender and
GLScene.
No matter what I do, the textures are not imported when opening a 3ds file. Not only my own files - also models downloaded from the web.
Is texture import from 3ds supposed to work? And, does someone have a demo that actually works? There is no demo in the GLScene source (the 'Mushroom' demo does not demonstrate texture import from the 3ds file)
Lars
Having code, mesh and texture at hand could be of help. I would suggest attaching everything to the topic as a ZIP file.
Are you actually adding the texture inside the Material Library?
I am not adding the texture manually. As far as I understand (see: http://glscene.sourceforge.net/oldsite/faq.htm#300502-1), that should happen automatically if the TGLFreeform is linked to a TGLMaterialLibrary. The faq in the link is very old but it is the only documentation I have been able to find regarding this topic.
I have tried to add the texture manually but that did not work either.
I will try to create a small demo project and post it later.
I have now created and attached a small demo project demonstrating the problem.
I am not an expert Blender user, but I suspect mapping as part of the problem. When importing the 3ds file I just exported from Blender in Blender the mapping has changed? However, I have not been able to import any 3ds file (various files found on the web) containing textures in GLScene/GLFreeform?
Lars,
It seems that something wrong with your ground.3ds. May be scale it in blender. I've attached a UsersDemo with 3ds models and included your files. Your ground.jpg with buildings appears at two sides of cube.3ds and teapot.3ds.
PW
Lars,
All is ok for your model and jpg if you choose Z axes for planar mapping. See attachment.
PW
Last edit: Pavel Vassiliev 2015-05-22
Hi Pavel
Thanks a LOT for the effort!
I can see that it works when choosing Z axis for planar mapping. I can't say that I fully understand your code but it is obvious that it requires a lot of code to make it work?
My original impression from reading the very sparse documentation was that loading and mapping of textures would happen automatically. I guess the conclusion is that it does not work like that, and loading textures to a freeform imported from 3ds is not a trivial task. In this case the model is a simple plane with a single texture - imagine a complex model with multiple textures.
If it was possible to load a 3ds file with textures automatically, all the modeling and texture mapping could be done in a modeling tool (Blender, 3D Studio Max, Solids Works, AutoCad, etc.), and then imported in GLScene.
At the moment only solid color materials are working. That will do for me for now but textures would be fantastic!
Lars
Hi Lars,
there is nothing wrong with your sample code (Freeform.zip), GLScene manage with extreme simplicity the loading of meshes with textures and you got it right.
The only problem is in your mesh file (ground.3ds) and in particular the UV mapping projection applied to it that seems to be "spherical" instead of "cubic".
Please refer to the Blender documentation to know how to apply the correct UV mapping projection.
Regards.
BobRob.
Last edit: Bob Robertson 2015-05-29
Hi Bob
I have now spent a few hours of my weekend learning how texture mapping works in Blender. Thanks to your suggestion I knew what to look for! Because of my limited knowledge of modeling in Blender I had set the texture mapping to 'Generated'. That works when rendering in Blender, but not when exporting to 3DS. The trick is to use UV mapping, which is simple. I have attached an updated working demo project.
Now the import in GLScene works as expected!
Thanks again
Lars