Page 1 of 1

Blender camera export

PostPosted: Mon Apr 26, 2010 4:34 am
by Curious guy
Hi:
Since for my proyect I need octane to do flythrough animation I created a python script for blender that saves the camera position on each frame and then runs octane for each position.

Usage:
- Export your .obj file as you would normally do.
- Import into octane, change all settings you need to render your scene and save into a .ocs file.
- Open your blender original scene, copy the script below and paste it into blender's text editor, change all necessary Variables (fully explained in script).
- Hit Alt + p over the text editor.
- Check the console, the last line should read "export finished", if not, it will show where the error is.
- Run the .bat file
- Return a couple of hour later to see your results :D.

The script:
Code: Select all
#Octane export camera script, writes a bat that launches octane several times for animations
#Thanks to Dave Jarvis, for the inspiration
#Made by CGgap in blendeartist, Curious Guy in Octane forums
#Known issues:
#            -The export bat is generated in the disk root
#            -octane has to close every time a image is rendered
#            -Camera and camera target cant be parented

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

import Blender

print "export started"

################################# VARIABLES #####################################
# Put your camera name where Camera is:
cam = Blender.Object.Get('Camera')
# Put your camera target name where target is:
camt = Blender.Object.Get("target")
# Write your osc full path here, watch out for \a, \n, \r, \t and others \something! and watch for spaces!
oscfile = "C:\est/enim.ocs"
# Write your octane path here:
octpath = "C:\Program Files/3D/Octane Render 1.021 x64"
# Write the path where you want to create your export file: (for some reason I can't get the file out of C:\)
path = "C:/octaneexport.bat"
# Mesh object name (in octane)
mesh = "anim_000001.obj"
# Write how you want to call your rendered images
IM = "C:\IM/test"
# Number of maximum samples:
samples = "300"
# Set your starting and ending frame:
firstFrame = 1
lastFrame = 360
##################################################################################

f = file(path, 'w')

f.writelines("cd "+octpath+"\n")

for frame in range( firstFrame, lastFrame+1, 1 ):
   f.writelines("octane -m "+mesh+" --cam-pos-x "+str(cam.LocX)+" --cam-pos-y "+str(cam.LocZ)+" --cam-pos-z "+str(cam.LocY*-1)+" --cam-target-x "+str(camt.LocX)+" --cam-target-y "+str(camt.LocZ)+" --cam-target-z "+str(camt.LocY*-1)+" -o "+IM+str(frame)+" -s "+samples+" -e "+oscfile+'\n')
   print "exported frame: "+str(frame)
   print "Camera coordinates: "+str(cam.LocX)+", "+str(cam.LocY)+", "+str(cam.LocZ)
   print "Target coordinates: "+str(camt.LocX)+", "+str(camt.LocY)+", "+str(camt.LocZ)
   Blender.Set( 'curframe', frame )

f.close()

print "export finished"


Limitations:
- The export bat is generated in the disk root
- Octane has to close every time a image is rendered (Radiance: There is a way to avoid this?)
- Camera and camera target can't be parented (actually i'm not sure of this)

Maybe I will also add blender to octane conversion lens and changing .obj file between frames.

Here is a little example:
anim.zip
(44.5 KiB) Downloaded 346 times


Ok, it's staring to get late here, must go to bed

Cheers

Re: Blender camera export

PostPosted: Mon Apr 26, 2010 8:24 am
by radiance
Hi,

Thanks, but we also have a blender script that's more full featured, which we'll post on the forums today or tomorrow...

Radiance

Re: Blender camera export

PostPosted: Mon Apr 26, 2010 1:56 pm
by Curious guy
Great then, less work for me :mrgreen:

Re: Blender camera export

PostPosted: Sun May 02, 2010 9:03 pm
by xsippo
Thank you "curious guy"!
Radiance: any news about the exporter for blender?

Thank you.
xsippo

Re: Blender camera export

PostPosted: Mon May 03, 2010 7:59 am
by radiance
xsippo wrote:Thank you "curious guy"!
Radiance: any news about the exporter for blender?

Thank you.
xsippo


we're updating all exporters to comply with the new spec for the 2.2 release, so it should be available just after 2.2 is out,
but it's not me writing it so i'm not %100 sure. it will be available soon.

Radiance

Re: Blender camera export

PostPosted: Fri May 28, 2010 4:48 pm
by vinz
thanks curious :)

i'm wondering if an export script with all options is/will available?

Re: Blender camera export

PostPosted: Fri May 28, 2010 4:50 pm
by vinz
thanks curious :)

that's a good new radiance any approximate eta ?

Re: Blender camera export

PostPosted: Fri May 28, 2010 4:55 pm
by radiance
the commercial version contains a complete octane plugin/exporter for blender.
look on our features page, below.

(it's a different script, it has nothing to do with this thread)

Radiance

Re: Blender camera export

PostPosted: Fri May 28, 2010 5:10 pm
by vinz
Great !! , sorry for the mistake :oops:
:D

Re: Blender camera export

PostPosted: Tue Jun 15, 2010 4:30 am
by aloysiuscarl
My preferred way to add Python scripts to Blender is to avoid the .blender/scripts folder altogether and create a blenderScripts folder in your Home folder.
The open Blender, go to the User Preferences window, click on the "File Paths" tab and look for the "Python Scripts" field, on v.2.49 in the second column.