Blender camera export

Forums: Blender camera export
Post, discuss and share handy resources like textures, models and HDRI maps in this forum.
Forum rules
Please do not post any material that is copyrighted or restricted from public use in any way. OTOY NZ LTD and it's forum members are not liable for any copyright infringements on material in this forum. Please contact us if this is the case and we will remove the material in question.

Blender camera export

Postby Curious guy » Mon Apr 26, 2010 4:34 am

Curious guy Mon Apr 26, 2010 4:34 am
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
3 x Geforce GTX470 | i7 960 | MB x58 classified 4 way sli | Win 7 64bit | 6Gb | Driver 257.21
Curious guy
Licensed Customer
Licensed Customer
 
Posts: 33
Joined: Mon Feb 22, 2010 4:19 am

Re: Blender camera export

Postby radiance » Mon Apr 26, 2010 8:24 am

radiance Mon Apr 26, 2010 8:24 am
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
Win 7 x64 & ubuntu | 2x GTX480 | Quad 2.66GHz | 8GB
User avatar
radiance
 
Posts: 7633
Joined: Wed Oct 21, 2009 2:33 pm

Re: Blender camera export

Postby Curious guy » Mon Apr 26, 2010 1:56 pm

Curious guy Mon Apr 26, 2010 1:56 pm
Great then, less work for me :mrgreen:
3 x Geforce GTX470 | i7 960 | MB x58 classified 4 way sli | Win 7 64bit | 6Gb | Driver 257.21
Curious guy
Licensed Customer
Licensed Customer
 
Posts: 33
Joined: Mon Feb 22, 2010 4:19 am

Re: Blender camera export

Postby xsippo » Sun May 02, 2010 9:03 pm

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

Thank you.
xsippo
p4 3,4GHz-2Gb Ram-GeForce 220 1Gb-Vista32bit
xsippo
Licensed Customer
Licensed Customer
 
Posts: 2
Joined: Tue Apr 06, 2010 7:53 am
Location: Italy

Re: Blender camera export

Postby radiance » Mon May 03, 2010 7:59 am

radiance Mon May 03, 2010 7:59 am
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
Win 7 x64 & ubuntu | 2x GTX480 | Quad 2.66GHz | 8GB
User avatar
radiance
 
Posts: 7633
Joined: Wed Oct 21, 2009 2:33 pm

Re: Blender camera export

Postby vinz » Fri May 28, 2010 4:48 pm

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

i'm wondering if an export script with all options is/will available?
i7 8700k / 16Gib / GTX980Ti 6GiB / win10x64 1803 / Blender 2.78a / drivers 416.34 + Octane 4.0 Standalone / OctaneBlender
User avatar
vinz
Licensed Customer
Licensed Customer
 
Posts: 230
Joined: Fri Apr 09, 2010 5:00 pm
Location: France

Re: Blender camera export

Postby vinz » Fri May 28, 2010 4:50 pm

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

that's a good new radiance any approximate eta ?
i7 8700k / 16Gib / GTX980Ti 6GiB / win10x64 1803 / Blender 2.78a / drivers 416.34 + Octane 4.0 Standalone / OctaneBlender
User avatar
vinz
Licensed Customer
Licensed Customer
 
Posts: 230
Joined: Fri Apr 09, 2010 5:00 pm
Location: France

Re: Blender camera export

Postby radiance » Fri May 28, 2010 4:55 pm

radiance Fri May 28, 2010 4:55 pm
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
Win 7 x64 & ubuntu | 2x GTX480 | Quad 2.66GHz | 8GB
User avatar
radiance
 
Posts: 7633
Joined: Wed Oct 21, 2009 2:33 pm

Re: Blender camera export

Postby vinz » Fri May 28, 2010 5:10 pm

vinz Fri May 28, 2010 5:10 pm
Great !! , sorry for the mistake :oops:
:D
i7 8700k / 16Gib / GTX980Ti 6GiB / win10x64 1803 / Blender 2.78a / drivers 416.34 + Octane 4.0 Standalone / OctaneBlender
User avatar
vinz
Licensed Customer
Licensed Customer
 
Posts: 230
Joined: Fri Apr 09, 2010 5:00 pm
Location: France

Re: Blender camera export

Postby aloysiuscarl » Tue Jun 15, 2010 4:30 am

aloysiuscarl Tue Jun 15, 2010 4:30 am
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.
aloysiuscarl
 
Posts: 4
Joined: Sat Jun 12, 2010 4:21 am

Return to Resources and Sharing


Who is online

Users browsing this forum: No registered users and 12 guests

Tue Apr 16, 2024 5:19 am [ UTC ]