/usr/share/doc/python-soya-doc/examples/multiple-cameras-1.py is in python-soya-doc 0.14-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- indent-tabs-mode: t -*-
# Soya 3D tutorial
# Copyright (C) 2005 Jean-Baptiste LAMY
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# This shows how to use 2 cameras simultaneously.
import soya, soya.cube, soya.sphere, soya.widget
soya.init()
# Creates 2 worlds, one with a cube and the other with a sphere.
w1 = soya.World()
w2 = soya.World()
w1.atmosphere = soya.Atmosphere()
w2.atmosphere = soya.Atmosphere()
w2.atmosphere.bg_color = 0.5, 0.0, 0.3, 1.0
soya.cube.Cube(w1)
soya.sphere.Sphere(w2)
# Create a normal camera in w1.
c1 = soya.Camera(w1)
c1.z = 12
# By default, Soya automatically adapt the camera's viewport to fill the whole screen.
# If you want to use multiple cameras, you must inhibits this by overriding Camera.resize.
class FixedViewportCamera(soya.Camera):
def __init__(self, parent, left, top, width, height):
soya.Camera.__init__(self, parent)
self.set_viewport(left, top, width, height)
def resize(self, left, top, width, height):
pass
# Create a FixedViewportCamera in w2, and put this second rendering in the upper right
# corner of the screen.
# Notice that viewport dimension are given in pixels (soya.get_screen_width and
# soya.get_screen_height will probably be usefull for you :-).
c2 = FixedViewportCamera(w2, 400, 20, 220, 100)
c2.z = 12
# We set the camera c2 as "partial", i.e. a camera that doesn't clear the whole screen.
c2.partial = 1
g = soya.widget.Group()
g.add(c1)
g.add(c2)
soya.set_root_widget(g)
soya.MainLoop().main_loop()
|