Blender to Celestia in 2013


(zelif) #1

I want to export a model made in Blender to Celestia space simulator. Celestia supports 3DS files and Blender can export 3DS but there is a problem.
After the export, only the meshes without any material or texture are visible. Meshes with materials or textures become completely invisible in Celestia.
Do I really have to use huge(6,5GB) proprietary Autodesk 3DS Max to fix my model for Celestia? Or is there any open source alternative?


(zelif) #2

I got some progress. Autodesk 3DS Max did not import Blenders 3DS exported files at all.
Finally I got my model to Celestia like that: Blender export to .dae, import to Sketchup and then 3ds export from Sketchup.


(Ran13) #3

no… you have to know the limitations of the 3DS format.

The 3ds format is a very old (early 90’s) format that was the native format of 3D Studio.
3D Studio was the DOS-based precursor to 3dstudio Max.
Due to its age, it has some very serious limitations when used with modern software.

Your likely problem is that the 3ds format stores material and texture names and references in the old DOS 8.3 (eight characters in the name, followed by a “.”, then a three character extension, like bmp, jpg, etc.

If your material names, or texture file references have long file names, &/or paths, on export they are truncated (shortened) to meet the DOS 8.3 naming requirements of the 3ds format. (e.g. a texture reference such has “LightColoredWood.jpg” will get changed to “LightC~1.jpg”… same with material names, although I think the allotted number of characters is a bit higher due to the lack of an extension.)

The end result is, when you load the 3ds file with these shortened names, the app will not be able to find a file call “LightC~1.jpg” because it doesn’t exist.

Since 3ds is a requirement of your engine, I suggest renaming your materials and textures prior to export to make sure this limitation is met.

Additional limitations:

  • All meshes must be made of triangles.
  • All texture filenames are limited to the 8.3 DOS format.
  • The number of vertices and polygons per mesh is limited to 65536.
  • Accurate vertex normals cannot be stored in the .3ds file. Instead “smoothing groups”[SUP][/SUP] are used so that the receiving program can recreate a (hopefully good) representation of the vertex normals. This is still a hold-over legacy for many animation programs today which started in the 1980s (3DS MAX, Lightwave and trueSpace still use smoothing groups, and Maya did up to v2.51).
  • Object, light and camera names are limited to 10 characters. Material names are limited to 16 characters.
  • Directional light sources are not supported.

(JohnVV) #4

old post but
Blender 2.49b has a plugin to export to the Celestia “cmod” format
it is a ASCII output
BUT
if you grab the Celestia 1.61 -svn ( celestia 1.7.0) code there is a nice tool “cmodview” that will import the ascii cmod and save as a binary format cmod

the SVN celestia checkout builds just fine with gcc 4.7

the python script for 2.49b


#!BPY

"""
Name: 'CMOD-mesh (.cmod)...new'
Blender: 240
Group: 'Export'
Tooltip: 'cmod exporter'
"""
import Blender
from Blender import *
import sys

global MTL_DICT

MTL_DICT = {}


def write_obj(filepath):
        out = file(filepath, 'w')
        object = Blender.Object.GetSelected()[0] 
        #mesh = object.getData()
        mesh = Mesh.Get(object.name)
        mesh.transform(object.matrix)
        mesh.calcNormals()
        a = 0
        b = 0
        c = 0
        d = 0

        # file header need to add real materials vertexdesc is dangerous may not have uvcoords
        out.write('#celmodel__ascii

')
        out.write('material
')
        out.write('diffuse 0.878431 0.878431 0.878431
')
        out.write('end_material

')
        out.write('mesh
')
        out.write('vertexdesc
')
        out.write('position f3
')
        out.write('normal f3
')
        out.write('texcoord0 f2
')
        out.write('end_vertexdesc

')
        
        
        #counter for vertice desc
        #This part goes thru the list twice counting for a the verts 1,2,3 and 0,1,2
        #it counts the number of triangles to build.
        for face in mesh.faces:
        d = 0
            for vert in face.verts:
           if d > 2:
            a +=3
            d +=1
           else:
            a +=1
            d +=1
        out.write( 'vertices %i
' % (a))

        # writes a line for verts 2,3,0 and 0,1,2.
        for face in mesh.faces:
            d = 0
            for vert in face.verts:
        if d > 2:
            out.write( '%f %f %f %f %f %f' % (face.verts[2].co.x, face.verts[2].co.y, face.verts[2].co.z, face.verts[2].no.x, face.verts[2].no.y, face.verts[2].no.z,))
            out.write( ' %f %f
' % (face.uv[2].x, face.uv[2].y))
            out.write( '%f %f %f %f %f %f' % (face.verts[d].co.x, face.verts[d].co.y, face.verts[d].co.z, face.verts[d].no.x, face.verts[d].no.y, face.verts[d].no.z,))
            out.write( ' %f %f
' % (face.uv[d].x, face.uv[d].y))
            out.write( '%f %f %f %f %f %f' % (face.verts[0].co.x, face.verts[0].co.y, face.verts[0].co.z, face.verts[0].no.x, face.verts[0].no.y, face.verts[0].no.z,))
            out.write( ' %f %f
' % (face.uv[0].x, face.uv[0].y))
        else:
            out.write( '%f %f %f %f %f %f' % (face.verts[d].co.x, face.verts[d].co.y, face.verts[d].co.z, face.verts[d].no.x, face.verts[d].no.y, face.verts[d].no.z,))
            out.write( ' %f %f
' % (face.uv[d].x, face.uv[d].y))
            
        d +=1
        out.write( '

trilist %i %i
' % (b, a))
        #write the triangle list 12 per line
        while b < a:
            if c <= 12:
               if b <= a:
                  out.write( '%i ' % (b))
                  b +=1
                  c +=1
               else:
                  out.write( '
' )
            else:
                out.write( '
' )
                c = 0
        out.write( '

end_mesh' )                
        out.close()
Blender.Window.FileSelector(write_obj, "Export", Blender.sys.makename(ext='.cmod' ))



(sheath35) #5

Hello community!

I hope someone can help me with this problem, I haven’t been able to solve it and I tryed a lot of things.

I finally managed to create a model with blender that uses external textures and to properly export it to 3ds (lets call it new model). And I also have some working models downloaded from the Celestia motherlode (working models). Here it comes the erratic behavior:

If I select any working spacecraft when loading Celestia, it shows it without problems. If I switch then to the new model while running, it works and I can alternate them. There is a kind of transparency applied to the new model that depends on the moment of switch between spacecrafts. (looks like if the working spacecraft was transmitting one of its parameters at that moment to the new model). If I load celestia with the new model selected directly. It is shown completly transparent so I cant see it. once this is done, it seems to store this property because the only way to show again the new model is to replace the 3ds and textures by the original ones and not load celestia with the new model selected.

I also tried converting to cmod and it is still fully transparent.

I am afraid that I am using or not using some properties of the materials that when converted to 3ds produce errors. For example being transparent depending on the incident light or something like that. I also tried disabling alpha chanel. It is very strange that depending on the behavior it shows it or not and with different transparencies. And also, that corrupts the 3ds/texture files so they wont work again even doing the good process.

Thanks a lot to anyone trying to help me with this. It is very important for my project to have a custom spacecraft model.

regards,

Edit: Solved thanks to the post talking about Sketchup. Design in Blender-export to callada .dae including textures-import into Sketchup-export to .3ds.

Thank you all and specially to zelif for its comments about Sketchup :slight_smile: