> have a look here:
> http://cvs.gna.org/viewcvs/soya/soya/tutorial/multiple-cameras-1.py?rev=1.1&content-type=text/vnd.viewcvs-markup

Hi dunk.

Thanks a lot. Now I don't understand why I get two different views: (the
perspective is different, why?)

Marc

----------------

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):
  camera=MyCamera(scene,0,0.5,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()

Reply via email to