<< はじめてのFujiyama Renderer その24 戻る はじめてのFujiyama Renderer その26 >>

はじめてのFujiyama Renderer その25

POV-Ray記事を参考に積み木をつくってみた。
参考サイト
http://monge.tec.fukuoka-u.ac.jp/cg_PovRay/box06A+6B.html

povsp8.jpg

以下はPythonサンプル例です。

#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/

from colorinc import si

import fujiyama

#si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py 0 20 20 0 0 0
si.SetSampleProperty3('cam1', 'rotate', -45, 0, 0, 0)
si.SetSampleProperty3('cam1', 'translate', 0, 20, 20, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 10, 0)

si.SetProperty1('cam1', 'fov', 42)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', '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', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 4)

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')
si.NewMesh('cube_mesh', '../mesh/cube.mesh')


#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

#ObjectInstance
j=1
K=-5
bxname=[]
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Blue_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K,1.6,3)

K=K+1.75
j+=1

j=7
K=-3
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'ForestGreen_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,4.6,3)

K=K+1.75
j+=1

j=12
K=-2
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Orange_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,7.6,3)

K=K+1.75
j+=1

j=16
K=-1
while(K<4):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Coral_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,10.6,3)

K=K+1.75
j+=1


#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
for i in bxname:
si.AddObjectToGroup('group1', i)

for i in bxname:
si.AssignObjectGroup(i, '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 2, 2)

#Rendering
si.RenderScene('ren1')

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

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

<< はじめてのFujiyama Renderer その24 戻る はじめてのFujiyama Renderer その26 >>