Sorry, I've forgotten to adjust one line
(I've corrected it and marked by "the following line was wrong)
I don't know why the the cameras are looking in different directions.
should'nt both spheres be centered?
I want both cameras to record the same area of the scene(2).
What's wrong?
----------------
import sys,os, os.path, soya, soya, soya.sdlconst, soya.widget, soya.sphere
soya.init()
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
def createscene(color):
scene = soya.World()
scene.atmosphere = soya.Atmosphere()
scene.atmosphere.bg_color = color, 0.0, 1 ,1.0
light = soya.Light(scene)
light.set_xyz(-2.0,15.0, 0.0)
soya.sphere.Sphere(scene)
return scene
scene=createscene(0.1)
scene2=createscene(0.5)
# My Camera class
class MyCamera(soya.Camera):
def resize(self, left, top, width, height):
pass
# xf=0,xt=1 means full width,
# xf=0.5,xt=1 means right half of screen
def __init__(self, parent, xf,xt,yf,yt):
soya.Camera.__init__(self, parent)
self.partial = 1
self.xf, self.xt, self.yf, self.yt = xf, xt, yf, yt
# set viewport
sw=soya.get_screen_width()
sh=soya.get_screen_height()
self.set_viewport(self.xf*sw,self.yf*sh,self.xt*sw,self.yt*sh)
def createCamera(scene,fromX,toXRatio):
# the following line was wrong
camera=MyCamera(scene,fromX,toXRatio,0,1)
camera.set_xyz(0,10,0)
camera.look_at(soya.Point(scene, 0, 0, 0))
return camera
c1=createCamera(scene, 0 , 0.5)
c2=createCamera(scene2, 0.5, 1 )
g = soya.widget.Group()
g.add(c1)
g.add(c2)
soya.set_root_widget(g)
soya.Idler(scene).idle()
_______________________________________________