本文整理汇总了Python中soya.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
soya.init()
#soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
# Creates the scene.
scene = soya.World()
# Creates a camera.
camera = soya.Camera(scene)
camera.set_xyz(0.0, 0.0, 4.0)
camera.fov = 100.0
# Creates a dragdrop world.
world = Editor(scene, camera)
# Adds some bodys with different models, at different positions.
red = soya.Material(); red .diffuse = (1.0, 0.0, 0.0, 1.0)
green = soya.Material(); green.diffuse = (0.0, 1.0, 0.0, 1.0)
blue = soya.Material(); blue .diffuse = (0.0, 0.0, 1.0, 1.0)
soya.Body(world, soya.cube.Cube(None, red ).to_model()).set_xyz(-1.0, -1.0, 1.0)
soya.Body(world, soya.cube.Cube(None, green).to_model()).set_xyz( 0.0, -1.0, 0.0)
soya.Body(world, soya.cube.Cube(None, blue ).to_model()).set_xyz( 1.0, -1.0, -1.0)
soya.Body(world, soya.sphere.Sphere().to_model()).set_xyz(1.0, 1.0, 0.0)
# Adds a light.
light = soya.Light(scene)
light.set_xyz(0.0, 0.2, 1.0)
soya.set_root_widget(camera)
# Main loop
soya.MainLoop(scene).main_loop()
示例2: main
def main():
soya.init()
soya.path.append(os.path.abspath(os.path.dirname(sys.argv[0])))
print soya.path
filename = sys.argv[1]
world = decode_ms3d(open(filename))
model = world.to_model()
model.filename=sys.argv[2]
model.save()
示例3: init
def init(width = 1020,height = 760,title="PyWorlds (Soya3D)",create_basic=True):
global scene,mainloop,pyworlds_engine
pyworlds_engine = "soya"
soya.init(width=width, height= height,title=title)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
scene = pyworlds.basics.scene.scene
mainloop=soya.MainLoop(scene)
scene.mainloop=mainloop
scene.round_duration=.04
mainloop.round_duration=.04
if create_basic:
init_basicscene()
示例4: _init_game_engine
def _init_game_engine(self):
"""Initialize soya game engine, append our paths to soya's paths,
create the scene and set up a camera.
"""
# Hide window manager's resizability
# features (maximise, resize, ...):
RESIZEABLE = False
soya.init(title=self.window_title, \
width=self.config['screen'].as_int('resolution_x'),
height=self.config['screen'].as_int('resolution_y'), \
fullscreen=int(self.config['screen'].as_bool('fullscreen')), \
resizeable=RESIZEABLE, sound=False)
# Enable/disable soya's auto (blender model) importer:
soya.AUTO_EXPORTERS_ENABLED = True
# Append some paths:
# * themes/[selected theme name]/media
# TODO: append paths for all themes in themes/,
# so we can change the theme at runtime (?)...
# * songs/[song name]/media
default_path = os.path.join(self.app_dir, 'media', 'themes', \
'default', 'media')
soya.path.append(default_path)
theme_path = os.path.join(self.app_dir, 'media', 'themes', \
self.widget_properties['theme']['main'], 'media')
soya.path.append(theme_path)
self.root_world = soya.World()
self.widget_properties['root_world'] = self.root_world
# set up a camera:
self.camera = soya.Camera(self.root_world)
### CAMERA TESTS ###
moveable = False
rotating = False
if moveable:
from lib.cameras.movable_camera import MovableCamera
self.camera = MovableCamera(self.app_dir, self.parent_world)
if rotating:
from lib.cameras.spinning_camera import SpinningCamera
cube = soya.Body(self.root_world, soya.cube.Cube().to_model())
cube.visible = 0
self.camera = SpinningCamera(self.root_world, cube)
### END CAMERA TESTS ###
self.camera.set_xyz(0.0, 0.0, 15.0)
self.light = soya.Light(self.root_world)
self.light.set_xyz(0.0, 7.7, 17.0)
示例5: edit_material
def edit_material(self, window):
if not soya.inited: soya.init("Soya Editor")
ed = soya.editor.material.MaterialEditor(self, window)
def on_activate(event = None):
global CURRENT
if CURRENT: CURRENT.deactivate()
ed.activate()
CURRENT = ed
window.bind("<FocusIn>" , on_activate)
示例6: edit_world
def edit_world(self, window):
if not self.parent:
if not soya.inited: soya.init("Soya Editor")
ed = soya.editor.world.WorldEditor(self, window)
def on_activate(event = None):
global CURRENT
if CURRENT: CURRENT.deactivate()
ed.activate()
CURRENT = ed
window.bind("<FocusIn>" , on_activate)
示例7: setup
def setup(self):
soya.init("Loopy Demo", *self.resolution)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
scene = soya.World()
sword_model = soya.Shape.get("sword")
sword = soya.Volume(scene, sword_model)
sword.x = 1.0
sword.rotate_lateral(90.0)
light = soya.Light(scene)
light.set_xyz(0.5, 0.0, 2.0)
self.camera = soya.Camera(scene)
self.camera.z = 2.0
示例8: init_pudding
def init_pudding(width = 1020,height = 760,title="PyWorlds (Soya3D)", options = {}):
global root,viewport,camera,scene,mainloop, pyworlds_engine
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
pyworlds_engine = "pudding"
import soya.pudding as pudding
soya.init(width=width, height= height, title=title)
pudding.init()
scene = pyworlds.basics.scene.scene
mainloop=pudding.main_loop.MainLoop(scene)
scene.mainloop=mainloop
scene.round_duration=.04
mainloop.round_duration=.04
if 'nobasics' not in options: init_basicscene()
soya.set_root_widget(pudding.core.RootWidget(width = width,height = height))
if 'nochild' not in options: soya.root_widget.add_child(camera)
示例9: __init__
def __init__(self):
tofu4soyapudding.GameInterface.__init__(self)
soya.init()
pudding.init()
self.player_character = None
# Creates a traveling camera in the scene, with a default look-toward-nothing
# traveling.
self.camera = soya.TravelingCamera(scene)
self.camera.back = 70.0
self.camera.add_traveling(soya.FixTraveling(soya.Point(), soya.Vector(None, 0.0, 0.0, 10.0)))
self.root = pudding.core.RootWidget(width = 640, height = 480)
soya.set_root_widget(self.root)
soya.root_widget.add_child(self.camera)
pudding.ext.fpslabel.FPSLabel(soya.root_widget, position = pudding.TOP_RIGHT)
示例10: main
def main():
DEBUG = 1
import sys
import os
import soya.cube
# init soya in resizable window:
soya.init('MovableCamera Module', 1024, 768, 0)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', '..', 'media', 'themes', 'kiddy', 'media'))
# set the root scene:
scene = soya.World()
# set up the light:
light = soya.Light(scene)
light.set_xyz(0.0, 0.7, 1.0)
# set up the camera:
camera = MovableCamera(app_dir = '.', parent_world = scene, debug = DEBUG)
camera.set_xyz(0.0, 0, 10.0)
# a test cube in the background:
test_cube_world = soya.cube.Cube()
test_cube_world.model_builder = soya.SolidModelBuilder()
test_cube = soya.Body(scene, test_cube_world.to_model())
test_cube.rotate_y(45.0)
test_cube.rotate_x(45.0)
atmosphere = soya.SkyAtmosphere()
atmosphere.bg_color = (1.0, 0.0, 0.0, 1.0)
atmosphere.ambient = (0.5, 0.5, 0.0, 1.0)
atmosphere.skyplane = 1
atmosphere.sky_color = (1.0, 1.0, 0.0, 1.0)
atmosphere.cloud = soya.Material(soya.Image.get('cloud.png'))
scene.atmosphere = atmosphere
# set our root widget:
soya.set_root_widget(camera)
# start soya main loop:
soya.MainLoop(scene).main_loop()
示例11: except
time.sleep(0.01)
try:
self.motion = False
motion = watch.getMotion()
self.motion = motion
except (RuntimeError):
print "Watch not connected ?"
def stop(self):
self.running = False
motionThread = MotionThread()
motionThread.start()
# Initialisation
soya.init(width = 1024, height = 768, sound = 0, title = "ez430 Demo")
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
# Creates a scene.
scene = soya.World()
class AbsDegree:
def __init__(self):
self.absdegree = 0
def update(self, new):
r = new - self.absdegree
self.absdegree = new
return r
#Classe Demo
示例12: RacingLevelReader
r = RacingLevelReader(options.filename, verbose=options.verbose, level=racing.Level)
setModuleScene = racing
elif options.snowballz:
import snowballz
r = SnowballzLevelReader(options.filename, verbose=options.verbose, level=snowballz.Level)
setModuleScene = snowballz
else:
r = LevelReader(options.filename, verbose=options.verbose)
r.save(options.output)
if not options.view:
print "done."
else:
soya.init(title="LevelXML", width=1024, height=768)
soya.set_use_unicode(1)
scene = soya.World()
if setModuleScene:
setModuleScene.scene = scene
level = soya.World.get(options.output)
scene.add(level)
camera = r.get_camera(scene=scene)
camera.back = 500.0
soya.set_root_widget(widget.Group())
示例13:
INTRO = """
You can also collide with terrain
"""
import sys, os
from random import choice, gauss as normalvariate, randint, random, expovariate
import soya
import soya.widget
from soya import Vector
soya.init("ode-collision-8-terrain",width=1024,height=768)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
print INTRO
scene = soya.World()
# Gets the image "map1.png" from the tutorial data dir, and create the terrain
# from this image. The image dimension must be power of 2 plus 1 : (2 ** n) + 1.
terrain = soya.Terrain(scene)
print "setting terrain's image"
terrain.from_image(soya.Image.get("map3.png"))
# By default, the terrain height ranges from 0.0 (black pixels) to 1.0 (white pixels).
# Here, we multiply the height by 4.0 so it ranges from 0.0 to 4.0.
示例14:
# 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
import sys, os, os.path, random
import soya, soya.gui
import soya.widget
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
soya.init(width = 640, height = 480)
red = soya.Material()
red.diffuse = (1.0, 0.0, 0.0, 1.0)
root = soya.gui.RootLayer(None)
import soya.cube
scene = soya.World()
light = soya.Light(scene)
light.set_xyz(0.5, 0.0, 2.0)
camera = soya.Camera(scene)
camera.z = 2.0
camera.partial = 1
cube = soya.cube.Cube(scene, red)
cube.advance_time = lambda proportion: cube.rotate_lateral(proportion)
示例15: Level
cerealizer.register(Action)
cerealizer.register(Mobile)
cerealizer.register(Level , soya.cerealizer4soya.SavedInAPathHandler(Level ))
cerealizer.register(Player, soya.cerealizer4soya.SavedInAPathHandler(Player))
if mode == "server":
try: os.mkdir("/tmp/tofu_data")
except: pass
try: os.mkdir("/tmp/tofu_data/players")
except: pass
try: os.mkdir("/tmp/tofu_data/levels")
except: pass
soya.path.insert(0, "/tmp/tofu_data")
LEVEL = Level()
LEVEL.filename = "demo"
LEVEL.save()
elif mode == "client":
soya.init("Soya & Tofu demo", 320, 240)
tofu_enet.HOST = "127.0.0.1"
tofu_enet.LOGIN = sys.argv[2]
main_loop = tofu_enet.MainLoop(soya.World())
main_loop.main_loop()