Problem Blender 3D: Texture won't display?

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
Hello,

I am editing a model in Blender 3D just changing a colour on a piece of mesh, then when I place into the Orbiter folder and try it out, the primary image texture doesn't load in the simulator.

The texture renders fine in the program, clearly something extra hasn't been done or is lost in the export task.

I have blender 2.63 with the latest plugin for it.
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
The Blender exporter saves the images into a subfolder where you put your mesh. You have to convert them to DDS files if not already done by Blender (there is a way to write DDS) and then put the textures into the "Textures" folder, respecting what is written in the end of your mesh (you can open it with notepad to check)
 

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
The Blender exporter saves the images into a subfolder where you put your mesh. You have to convert them to DDS files if not already done by Blender (there is a way to write DDS) and then put the textures into the "Textures" folder, respecting what is written in the end of your mesh (you can open it with notepad to check)

When I loaded the mesh file, the image was there automatically. When I saved it as the same file name it was originally as a mesh file, there was no second dds?

Don't I just place the Mesh file into the mesh folder, and then the file just looks for the texture in the textures folder?
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
It tries to look for the textures, but if there isn't textures at the right places, they doesn't show on the model.
Try to move the tex folder Blender created at export (the folder is named <maesh_name>tex) to the Orbiter Textures folder.
 

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
I can see what you mean by having the blend file and the dds file together. When you export it, the folder is created.

As for the blend file is there anything specific that must be done to keep the texture on the model? Must the camera and default light as well as the cube be in the file for export? I guess not...
 

Raven

New member
Joined
Jul 4, 2011
Messages
46
Reaction score
0
Points
0
One of the slight problems with using the Blender .msh plugin...
An easy fix is to open the. msh with Notepad++ or similar text editor, scroll to the end, and you should see something similar to this:
MyModeltex\MyModel1.dds
MyModeltex\MyModel2.dds
...
Assuming your textures are already in the Orbiter directory, change your texture info to this:
CorrectFolder*\MyModel1.dds
CorrectFolder\MyModel2.dds
...

*If your textures are 'loose' in Orbiter\Textures or \Textures2, remove this bit.

Blender always creates a new texture folder every time you export a .msh, they're just copies if you already have textures. You can delete them, they just take up hard drive space. If these are the original textures, then follow Solarliner's directions above.
Good luck, hope this helps you get it sorted.

Almost forgot: Make sure to either de-select or delete Blender's camera and lamps, they can cause errors during export. Also remember: The .msh plugin will only export objects that are currently selected.
 
Last edited:

jangofett287

Heat shield 'tester'
Joined
Oct 14, 2010
Messages
1,150
Reaction score
13
Points
53
When importing a mesh, the script expects it to be in an orbiter install, ie: Orbiter/Meshes, and will look in ../textures (Orbiter/Textures in this example) for the .dds files.
 

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
Yes, both the mesh and the dds are in the Orbiter folder, I'm editing it all from there.

Export MSH Operator'''
bl_idname="export_mesh.msh"
bl_label="Export MSH"
bl_descriptiom="Export an Orbiter mesh (.msh)"

filename_ext=".msh"

filepath= StringProperty(name="File Path", description="Filepath of exported MSH file", maxlen=1024, default="")
convert_coords= BoolProperty(name="Convert coordinates", description="Convert coordinates between right-handed and left-handed systems ('yes' highly recomended)", default=True)
apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object", default=False)
delete_orphans = BoolProperty(name="Delete orphan vertices", description="Delete orphan vertices (Recommender if you get 'List index out of range' error)", default=False)


def execute(self,context):
print("Export execute")
export_msh(self.filepath,self.convert_coords,self.apply_modifiers,self.delete_orphans)

".format(v[2][0],1-v[2][1]))
file.write("\n")
for f in faces:
file.write("{} {} {}\n".format(f[0],f[1],f[2]))
#write other sections
print("===Materials summary====")
print(mtrls)
print("===Textures summary=====")
print(txtrs)
#===Write MATERIALS section=====
file.write("MATERIALS {}\n".format(len(mtrls))) #just mtrls sorted by values
temp_m=sorted(mtrls.items(),key=lambda x: x[1])
for m in temp_m:
file.write("{}\n".format(m[0]))

for m in temp_m:
file.write("MATERIAL {}\n".format(m[0]))

mat=bpy.data.materials[m[0]]
dc=mat.diffuse_color
file.write("{} {} {} {}\n".format(dc[0],dc[1],dc[2],mat.alpha))
file.write("{} {} {} {}\n".format(dc[0],dc[1],dc[2],mat.alpha))
sc=mat.specular_color
file.write("{} {} {} {} {}\n".format(sc[0],sc[1],sc[2],mat.specular_alpha,mat.specular_hardness))
file.write("{} {} {} {}\n".format(dc[0]*mat.emit,dc[1]*mat.emit,dc[2]*mat.emit,mat.alpha))
#=====Write TEXTURES section ======
file.write("TEXTURES {}\n".format(len(txtrs)))

v=os.path.split(filepath)
mshdir=v[0]
mshname=os.path.splitext(v[1])[0]
texdir=mshname+"tex"
texpath=os.path.join(mshdir,texdir)

temp_t=sorted(txtrs.items(),key=lambda x: x[1])
for t in temp_t:
tex=bpy.data.textures[t[0]]
img_fp=tex.image.filepath

tex_fname=""

if img_fp=="Untitled": #new name from tex name
tex_fname=tex.name+"."+tex.image.file_format.lower()
tex.image.save_render(os.path.join(texpath,tex_fname))
else: #image file is already saved on disk
tex_fname=os.path.split(img_fp)[1]
if tex.image.file_format=="":#if no format (dds) it will be saved as png.
tex_fname=os.path.splitext(tex_fname)[0]+".png"
tex.image.save_render(os.path.join(texpath,tex_fname))

file.write("{}\n".format(ntpath.join(texdir,os.path.splitext(tex_fname)[0]+".dd

This is before the first piece I posted.

I got the export error about a file having no path and it stated to find export mesh which is at the end of the py plugin.
 

Attachments

  • blenderExporterror.JPG
    blenderExporterror.JPG
    103.2 KB · Views: 22
Last edited:

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
Could it be related to this ? :

http://www.orbiter-forum.com/showthread.php?p=424330&postcount=164

I had the same problem, my solution is to move my textures directory out of my blender mesh directory.
For exemple if my .blend is in my "picture" directory i put my "msehtex" directory directly in Orbiter/textures/ and then i re-link all my textures in blender from this new position, and i don't have any more problem like this.
 

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
Well, I haven't saved my file as a .blend. I am opening it directly from .msh and it is already linked in blender to the dds file.
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
Are you refering to the code or the image in blender? I'm well aware of the code being the code and not an error.

I posted my message before you edited it and then the coded text was part of the exporter code.

Now in the image you have the actual error.
 

RacerX

Donator
Donator
Joined
Jan 3, 2012
Messages
303
Reaction score
9
Points
18
Location
in a field
I always just open the mesh file with notepad ++ and scroll all the way down to the end of the file and there is your path change to /texture_name.dds OR give it its own folder ie model_name/texture_name.dds. drop. msh file in meshes and textures and. dds files in textures or textures/your_model_name folder
 
Last edited:

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
An alternative way of just changing the color/colour on a mesh piece is just by opening the mesh file in notepad.

That would save the bother of going through Blender for editing.

I found that out only yesterday night.:hmm:
 

richfororbit

Active member
Joined
Jul 8, 2013
Messages
611
Reaction score
26
Points
43
Location
Greater London
Yes, Orbiter msh files are human readable. You will certainly need to edit them by hand to do minor changes.

Is there a color number reference? I was able to change a grey colored window to white. So if I want a black color.

The number codes are available with each mesh piece at the bottom, how ever there are several lines.


Code:
0.502 0.502 0.502 1.000
0.502 0.502 0.502 1.000
0.898 0.898 0.898 1.000
0 0 0 1

All the mesh files vary in color numbers, some are just one line.
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
OrbiterSDK\Doc\3dmodel.pdf deals with mesh format.
Page 6 is materials part of it.
 
Top