Home >> Python >> Panda3D Lighting and Camera
from direct.showbase.ShowBase import ShowBase from direct.showbase.Loader import Loader from panda3d.core import * base = ShowBase( ) loader = Loader( base ) model = loader.loadModel( "cube.dae" ) model.reparentTo( render ) model.setPos( 0, 10, -1 ) model.setHpr( -90, 0, 0 ) model.setScale( 2 ) plight = PointLight( 'plight' ) plight.setColor(VBase4(0.8, 0.8, 0.3, 1)) plnp = render.attachNewNode(plight) plnp.setPos(0, 5, 3) render.setLight(plnp) base.run( )
dlight = DirectionalLight( 'dlight' ) dlight.setColor( VBase4( 0.8, 0.8, 1.0, 1 ) ) dlight.setDirection( Vec3( -1, 1, -1 ) ) dlnp = render.attachNewNode( dlight ) render.setLight(dlnp)
ambientLight = AmbientLight("ambientLight") ambientLight.setColor(Vec4(0.95, 0.95, 0.95, 1)) alnp = render.attachNewNode( ambientLight ) render.setLight( alnp )
base.cam # 標準のカメラ
camera2 = Camera( "camera2" ) # カメラは、レンズと共に lens = PerspectiveLens( ) # 投影するのはレンズ camera2.setLens( lens ) cameraNodePath = NodePath( camera2 ) # カメラには、ノードパスが必要
lens.setViewVector( 0, 5, 0, 0, 0, 1 ) # 向きのベクトルと上向きのベクトル cameraNodePath.setPos( 0, -16, 0 ) # 位置
lens.setViewHpr( VBase3( hue, pitch, roll ) ) # 角度で向きを設定 cameraNodePath.lookAt( model, Vec3( 0, 0, 1 ) ) # 対象と上向きで回転角度を設定
base.cam.setPos( 0, -10, 0 ) # 標準カメラの位置を設定 base.cam.lookAt( 0, 0, 0 ) # 表示対象となる位置を設定
lens = OrthographicLens() # 平行投影 lens.setFilmSize(20, 15) # 横、縦のフィルムサイズ(フィート) lens.setNearFar(-5000, 5000) # 投影する間隔のy座標の値(標準は-1000, 1000) base.cam.node().setLens(lens)
Panda 3d Texture | Python | Python 3d Animation |