<< Pythonを使ってRenderManを操る その2 戻る はじめてのFujiyama Renderer その7 >>

はじめてのFujiyama Renderer その6

カメラ周りの視野変換をRenderManで使うplacecam.cを参考に組んでみた。調整が必要ですが何とか動いています。

以下は、Pov-Rayのシーンサンプルを参考に組んでみました。fovの設定もわかりました。

#!/usr/bin/env python

# 2 teapots and 2 bunnies with 1 sphere light
# Copyright (c) 2011-2013 Hiroshi Tsubokawa
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/
import fujiyama

si = fujiyama.SceneInterface()

#plugins
si.OpenPlugin('ConstantShader')
si.OpenPlugin('PlasticShader')

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
#si.SetSampleProperty3('cam1', 'translate', 0, 8, 8, 0)
#si.SetSampleProperty3('cam1', 'rotate', -45, 0, 0, 0)
#Calculate python fujicam.py 0 2 -10 0 1 0
si.SetSampleProperty3('cam1', 'rotate',-5.71, 0.00, 0.00,0)
si.SetSampleProperty3('cam1', 'rotate',0.00, 180.00, 0.00,0)
si.SetSampleProperty3('cam1', 'translate', 0.00, 2.00, -10.00,0)
si.SetProperty1('cam1', 'fov', 25)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', -10, 10, -10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', 10, 10, -10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1)


si.SetProperty1('light1', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .2, .25, .3)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('sphere_mesh', '../mesh/sphere.mesh')

#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)
si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.AssignShader('dome1', 'dome_shader')


distance = 1.5
si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 5, 5, 5)
si.AssignShader('floor1', 'floor_shader')

si.NewObjectInstance('sphere1', 'sphere_mesh')
si.AssignShader('sphere1', 'sphere_shader')
si.SetProperty3('sphere1', 'translate', 0, 1, 0)
#si.SetProperty3('sphere1', 'scale', .5, .5, .5)

#ObjectGroup
si.NewObjectGroup('group1')
si.AddObjectToGroup('group1', 'sphere1')
si.AssignObjectGroup('sphere1', 'shadow_target', 'group1')
si.AssignObjectGroup('floor1', 'shadow_target', 'group1')

#FrameBuffer
si.NewFrameBuffer('fb1', 'rgba')

#Renderer
si.NewRenderer('ren1')
si.AssignCamera('ren1', 'cam1')
si.AssignFrameBuffer('ren1', 'fb1')
si.SetProperty2('ren1', 'resolution', 640, 480)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 12, 12)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../povsphere01.fb')

#Run commands
si.Run()
#si.Print()


povsphere02.jpg
  • -
  • -

<< Pythonを使ってRenderManを操る その2 戻る はじめてのFujiyama Renderer その7 >>