Files Structure 3/n
Previous  
       Next
  Povanim  for Blender  
jean-michel soler 2002 - 2004
vide


 
   I
  n
  d
  e
  x


Files Structure 3/n 
(To be translated...one of these days)
Help for rebuilding mesh2 file

The script currently makes it possible to choose between the export of a << shortest >>  file gathering all the meshes data  of one scene except materials (if they are not defined in the texture_list) and a series of files <<namemesh.inc>> placed in a sub directory  "/objects" with the same exception for the materials . 

The script creates at the same time a file <<mesh-filenameblender.comp>> in which the files contening  objects are called as << # include > >:

//povray beta version 3.5
// Povanim export from : tux2d , Meshes

#include "mattux2d.inc"
//Mesh number: 1
#include "povanim/objects/Sphere_008.inc"
//Mesh number: 2
#include "povanim/objects/Sphere_009.inc"
//Mesh number: 3
#include "povanim/objects/Sphere_010.inc"
//Mesh number: 4
#include "povanim/objects/Sphere_011.inc"
//Mesh number: 5
#include "povanim/objects/Sphere_012.inc"
#declare Sphere_008group=object{ Sphere_008
         scale<1.88446377282,1.88446379497,1.88446385396>
         rotate<86.0656155078,1.46359535099e-008,-22.344726755>
         translate<-0.0823496580124,5.80556201935,1.50403165817>
}
#declare Sphere_009group=object{ Sphere_009


The "include" is done with the file bsolute address when the script is used inside blender itself .
In this example,
the address is corresponding  to the development version .
Télecharger le script
 ####################################################
# Script de reconstitution de fichier mesh

# (c) jm soler, Mai 2003
#
# Released as is .
# DOES NOT WORK ON ANIMATION FILE
#
#####################################################

####################################################
# To work correctly the script need to be
# loaded in the blender file which was just exported with povanim
#####################################################

####################################################
# Give the name of the blender file :
#####################################################
file='tux2d'
####################################################
# Result can be found in  'mesh'+file+'.comp'  file
#####################################################

filtre={
"vertex_vectors" : ['', 'verts.inc'],
"normal_vectors" : ['', 'norm.inc'],
"face_indices"   : ['', 'faces.inc'],
"normal_indices" : ['', 'nindice.inc'],
"uv_vectors"     : ['', 'uvco.inc'],
"texture_list"   : ['', 'text_list.inc'],
"uv_indices"     : ['', 'uvind.inc']
}

#----------------------------------------
# for development  : outside  blender 1
# use in blender          0
#---------------------------------------- 
devel=0

#----------------------------------------
# managing  additional directories
#---------------------------------------- 
import os

#----------------------------------------
# to get files' absolute address
#---------------------------------------- 
if devel==0: 
   import sys
   import Blender

   L=sys.path
   ls=Blender.Get('filename')
   ls=Blender.sys.dirname(ls)
   if ls not in sys.path:
      sys.path.append(ls)
else:
   #----------------------------------------
   # development outside blender :blenderfile/py
   #---------------------------------------- 
   ls='..'

#----------------------------------------
# grouped  export  : 1 = yes
#                             0 =  non
#---------------------------------------- 
bloc=0
if bloc==0:
   #---------------------------------------- 
   # everything is put away in the objects  directory
   # we have to control that it exists
   #----------------------------------------
   try:
     os.stat(ls+os.sep+'povanim'+os.sep+'objects')
   except:
     os.mkdir(ls+os.sep+'povanim'+os.sep+'objects')
try:
#if 1==1: 
    #----------------------------------------
    # open and read  target file
    # to get  informations
    # of the  data localization .
    #----------------------------------------
    f=open(ls+os.sep+'povanim'+os.sep+'mesh'+file+'.inc','r')
    contenu=f.readlines()
    f.close()

    f=None
    f_o=None

    #-----------------------------------------
    # Quel que soit le type de regroupement
    # que l'on choisisse, on garde une trace des
    # fichiers que l'on doit importés dans un
    # fichier *.comp
    #------------------------------------------
    f=open(ls+os.sep+'povanim'+os.sep+'mesh'+file+'.comp','w')

    l=0
    nom=''
    nom_objet=''

    #-----------------------------------------
    #  Boucle principale :
    #------------------------------------------
    while l <=len(contenu)-1:
        if contenu[l].find('#declare')!=-1 and contenu[l].find('mesh2')!=-1 :
            #------------------------------------------
            # s'il s'agit d'un fichier unique 
            #------------------------------------------
            if (contenu[l].find('#declare')==-1 and contenu[l].find('mesh2')==-1):
                f.write(contenu[l]+'\n')
            #-------------------------------------------
            # si on veut l'export d'objets séparés
            #-------------------------------------------
            if bloc==0:
               n0=contenu[l].find('#declare')+len('#declare ')
               n1=contenu[l].find(' =')
               nom_objet=contenu[l][n0:n1]
               #---------------------------
               # controle des objets traites
               #---------------------------
               print nom_objet
               #---------------------------
               # ouverture des fichiers objets
               #---------------------------
               f_o=open(ls+os.sep+'povanim'+os.sep+
                   'objects'+os.sep+nom_objet+'.inc','w')
               f_o.write(contenu[l])
               #---------------------------
               # prise en compte des donnes
               # dans le fichier mesh "global"
               #---------------------------
               f.write('#include "'+ls+os.sep+
                          'povanim'+os.sep+'objects'+os.sep+nom_objet+'.inc"\n')

            while contenu[l].find('}')!=0:
                l+=1
                if contenu[l].find('}')!=0 and contenu[l].find('uv_mapping')==-1:
                    d=contenu[l].find('{ #include "')
                    tag=contenu[l][22:d]
                    d1=d+len('{ #include "')
                    #print tag 
                    d2=contenu[l].find(filtre[tag][1])
                    nom=contenu[l][d1:d2]

                    #------------------------------------------
                    # récupérations des données 
                    #------------------------------------------
                    f2=open(ls+os.sep+
                         'povanim'+os.sep+'mesh'+os.sep+nom+filtre[tag][1],'r')
                    fichier_inc=f2.readlines()
                    f2.close()

                    #------------------------------------------
                    # si il s'agit d'un fichier unique 
                    #------------------------------------------
                    if bloc==1:
                       f.write(tag+'{\n')
                       f.writelines(fichier_inc)
                       f.write('}\n // '+tag+'\n')
                    #-------------------------------------------
                    # si on veut l'export d'objets séparés
                    #-------------------------------------------
                    else: 
                       f_o.write(tag+'{\n')
                       f_o.writelines(fichier_inc)
                       f_o.write('}\n // '+tag+'\n')

                    if l> len(contenu):
                        print "arret"
                        break
                else:
                    if bloc==1: 
                       if f!=None and contenu[l].find('}')==-1 :
                          f.write(contenu[l])
                    else: 
                       if f_o!=None and contenu[l].find('}')==-1 :
                          f_o.write(contenu[l])
            #------------------------------------------
            # si il s'agit d'un fichier unique 
            #------------------------------------------
            if bloc==1: 
                f.write('}// fin de '+nom+'\n')
            else:
                #-------------------------------------------
                # si on veut l'export d'objets séparés
                #-------------------------------------------
                f_o.write('} // fin de '+nom+'\n')
        else:
            #------------------------------------------
            # si il s'agit d'un fichier unique 
            #------------------------------------------
            if (contenu[l].find('#declare')==-1 and contenu[l].find('mesh2')==-1) and bloc==0 and contenu[l].find('\n')!=0:
               f.write(contenu[l])

            elif contenu[l].find('mesh2')==-1 and contenu[l].find('\n')!=0:
               f.write(contenu[l])

            if bloc==0:
                #-------------------------------------------
                # si on veut l'export d'objets séparés
                #-------------------------------------------
                if f_o!=None:
                   f_o.close()
        l+=1
    if f!=None: 
        f.close()
except:
    l=""" vous êtes en train d'essayer d'exporter un fichier d'animation ou un ficher contenant une macro"""
    print l
 


 
 
Detail of the different data formats
 
Les sommets sont rangés dans un fichiers mesh/NOMDEFICHIERverts.inc

avec le format suivant:

994,
< 0.08344, 0.01660, -0.86383>,
< 0.16609, 0.03304, -0.85133>,
< 0.24713, 0.04916, -0.83063>,
....

Si le mesh possède des faces lissées les normales pour chaque sommet se trouvent dans un fichier mesh/NOMDEFICHIERnorm.inc:

994, 
< 0.09909, 0.01968, -0.99487>,
< 0.19422, 0.03861, -0.98019>,
< 0.28745, 0.05716, -0.95608>,
....

Les faces sont dans un fichier mesh/NOMDEFICHIERfaces.inc:

1984, 
<868,0,993>,
<993,1,992>,
<993,0,1>,
<992,2,991>,
...

Pour les coordonnées uv c'est un peu plus délicat car chaque face possède ses coordonnées propres et pour éviter les problèmes avec la partie "normales", si un mesh possède au moin une face uvmappée alors toutes les faces ont leur coordonnées créées.  Mais, en gros, c'est le même principe, Les coordonnées sont dans un fichier mesh/NOMDEFICHIERuvco.inc:

5952, 
<0.25000,0.50000>,
<0.28125,0.53125>,
<0.25000,0.53125>,
...

Les indices dans un fichier mesh/NOMDEFICHIERuvind.inc:

1984, 
<0,1,2>,
<0,1,2>+3,
<0,1,2>+6,
<0,1,2>+9,
...




Previous             Nest