New povray exporter- working but alpha

Hi, heres a simple povray exporter- I cant get the camera rotation working- see line 30-

file.write('  rotate  <%s, %s, %s>
' % (euler[0]*-1, euler[1], euler[2]*-1))

Im interested in a simple povray exporter that dosent need to be configured like Povanim- just ‘Render my scene’!

I know its never that simple but I can be idealistic.

Problems I have-
*Smoothing (currently all smoothd)
*No vertex colour support in Povray???
*Generaly fiddling with converting matrix objects into povrays user friendly values.

Havent even looked at materials yet.

from Blender import *

# Apply Transform  #
def apply_transform(vert, matrix):
	vertCopy = Mathutils.CopyVec(vert)
	return Mathutils.VecMultMat(vertCopy, matrix)

def save_pov(filename):
  file = open(filename, "w")
  scene = Scene.GetCurrent()
  def exportCamera():
    camera = scene.getCurrentCamera()
    matrix = camera.getMatrix('worldspace')
    rotMat = matrix.rotationPart()
    euler = rotMat.toEuler()
    print euler
    lookatVec = apply_transform(Mathutils.Vector([0,0,-10]), matrix)
    file.write('camera {
    file.write('  location  <0, 0, 0>
    file.write('  look_at  <0, 0, -1>
    file.write('  direction <0, 0, 1.0>
    file.write('  rotate  <%s, %s, %s>
' % (euler[0]*-1, euler[1], euler[2]*-1))
    file.write('  translate <%s, %s, %s>
' % (matrix[3][0], matrix[3][1], matrix[3][2]))
  def exportLamps():
    # Get all lamps
    for ob in Object.Get():
      if ob.getType() != 'Lamp':
      lamp = ob.getData()
      loc = ob.getMatrix('worldspace')[3]
      file.write('light_source { <%s, %s, %s> color red %s green %s blue %s }
' % (loc[0], loc[1], loc[2],  lamp.col[0],lamp.col[1],lamp.col[2]))

  def exportMeshs():
    # Get all meshs
    for ob in Object.Get():
      if ob.getType() != 'Mesh':
      m = ob.getData()
      if len(m.verts) == 0: # Make sure there is somthing to write.
        continue #dont bother with this mesh.
      matrix = ob.getMatrix('worldspace')
      file.write('mesh2 {
      file.write('  vertex_vectors {
      file.write('    %s' % (len(m.verts))) # vert count
      for v in m.verts:
        vTx = apply_transform(, matrix)
    <%s,%s,%s>' % (vTx[0], vTx[1], vTx[2])) # vert count
      file.write('  normal_vectors {
      file.write('    %s' % (len(m.verts))) # vert count
      for v in m.verts:
        vnTx = apply_transform(, matrix)
    <%s,%s,%s>' % (vnTx[0], vnTx[1], vnTx[2])) # vert count
      file.write('  face_indices {
      file.write('    %s' % (len(m.faces))) # faces count
      for f in m.faces:
    <%s,%s,%s>' % (m.verts.index(f.v[0]), m.verts.index(f.v[1]), m.verts.index(f.v[2]))) # vert count
      file.write('  pigment {rgb 1}


Window.FileSelector(save_pov, 'Export Povray')

# import os
# os.system('povray +P +X +D0 -V /share/povray-3.6/scenes/d.pov')

# os.system('povray +W700 +H700 +P +X +D0 -V /share/povray-3.6/scenes/d.pov' )

You make a great mistake : povanim does not need to be configured.
And if you put the two parts of the script in the .blender/scripts folder,
you can just push the button “export to file” .

So i think you waste your time on complex problems.
As an exporter, a good one, exists yet, why don’t you
work on a more useful tool than a poor copy ?

dOES POVRAY SUPPORT Vertex colours?

use povanim , you will see if…

As i have said : you loose your time trying to make an exporter for a soft you seem to do not know the possibilities at all.

just continue ur work cambo it’s a so good idea …
i’ve once try povanim and it looks like a boeing dashboard !
if u could make a simplier version of a good exporter it’ll be great for me !

lOOK- I had a look at the mesh2 docs, theres no reference to vert colours- Im interested in weather they can me exported or not-

Why Im coding this-

I have never coded a render exporter before- The whole precess interests me.

Id like to streamline the process of exporting for rendering- There are missing python commands IMHO for exporting to a renderer (being able to turn text into a mesh for eg)

I want a povray exporter that ‘Just takes my scene and renders it in povray’
It will use blenders settings where possible (lamps, materials, radiosity etc)

I want to be able to open almot any blend file and simply Render povray.
This may ommit some special povray features- for the moment this dosent worry me. povray is a nice fast raytracerm, simple support is fine.

I can do some C coding- If my povray exporter needs any hooks or extra functionality I can add it.- This is a big resion for writing an exporter-
Like a ‘How can I improve b:python for render export’

I still cant get your script working.
It tells me that some ini file is missing, I can render all the sample scenes so I think its povanim at fault.

lots of I’s anyhow what do all YOU think abt this :slight_smile:

  • Cam

If you are really interested by the whole process why don’t you try to write an exporter for at least one of these 3 renders :

Too hard ?

hey JMS why not leave the kid alone, i’m sure there was a time when you were just entering python so if he wants to start off here let him. he’s learning which is more then i can say about alot of people who just show up and say they want a script done.

i’m sure when cambo’s done he’ll move on to other things but for now he’s doing this.


sorry jms… I like your scripts, your the scriptdev nr1… but my word.