• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python soya.init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中soya.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:spiderbit,项目名称:canta,代码行数:35,代码来源:editor.py


示例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()
开发者ID:deavid,项目名称:soyamirror,代码行数:11,代码来源:ms3d2soya.py


示例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()
开发者ID:deavid,项目名称:pyworlds,代码行数:12,代码来源:worlds.py


示例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)
开发者ID:tewe,项目名称:canta,代码行数:52,代码来源:core_init.py


示例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)
开发者ID:deavid,项目名称:soyamirror,代码行数:13,代码来源:__init__.py


示例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)
开发者ID:deavid,项目名称:soyamirror,代码行数:14,代码来源:__init__.py


示例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
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:15,代码来源:soya-basic1.py


示例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)
开发者ID:deavid,项目名称:pyworlds,代码行数:17,代码来源:worlds.py


示例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)
开发者ID:deavid,项目名称:soyamirror,代码行数:19,代码来源:bbomber.py


示例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()
开发者ID:spiderbit,项目名称:canta,代码行数:41,代码来源:movable_camera.py


示例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
开发者ID:bombela,项目名称:AbstractEZ430,代码行数:31,代码来源:demo.py


示例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())
开发者ID:deavid,项目名称:soyamirror,代码行数:31,代码来源:LevelXML.py


示例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.
开发者ID:deavid,项目名称:soyamirror,代码行数:30,代码来源:ode-collision-8-terrain.py


示例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)
开发者ID:deavid,项目名称:soyamirror,代码行数:31,代码来源:gui-2.py


示例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()

开发者ID:deavid,项目名称:soyamirror,代码行数:28,代码来源:demo.py


示例16: test_default

	def test_default(self):
		if soya.inited:
			self.skip('Soya is already initialised')
		soya.init("test default init")
		self.assertNotEqual(self.stdout.getvalue(), '')
		self.assertEqual(self.stderr.getvalue(), '')
开发者ID:deavid,项目名称:soyamirror,代码行数:6,代码来源:unittest_init.py


示例17: __init__

 def __init__(self, w, h, fullscreen, title):
     openglBase.OpenGLBase.__init__(self, w, h, fullscreen, title)
     soya.init()
     self.scene = soya3d.World()
开发者ID:Ripsnorta,项目名称:pyui2,代码行数:4,代码来源:openglSoya.py


示例18: render

def render(models, title, num_moments, is3d, rotate):
    "Render given list of models."

    # Note that we view from the positive z-axis, and not from the
    # negative y-axis. This should make no difference since the
    # element dofs are symmetric anyway and it plays better with
    # the default camera settings in Soya.

    # Initialize Soya
    soya.init(title)

    # Create scene
    scene = soya.World()
    scene.atmosphere = soya.Atmosphere()
    if title == "Notation":
        scene.atmosphere.bg_color = (0.0, 1.0, 0.0, 1.0)
    else:
        scene.atmosphere.bg_color = (1.0, 1.0, 1.0, 1.0)

    # Not used, need to manually handle rotation
    #label = Label3D(scene, text=str(num_moments), size=0.005)
    #label.set_xyz(1.0, 1.0, 1.0)
    #label.set_color((0.0, 0.0, 0.0, 1.0))

    # Define rotation
    if is3d:
        class RotatingBody(soya.Body):
            def advance_time(self, proportion):
                self.rotate_y(2.0 * proportion)
    else:
        class RotatingBody(soya.Body):
            def advance_time(self, proportion):
                self.rotate_z(2.0 * proportion)

    # Select type of display, rotating or not
    if rotate:
        Body = RotatingBody
    else:
        Body = soya.Body

    # Add all models
    for model in models:
        body = Body(scene, model)

    # Set light
    light = soya.Light(scene)
    if is3d:
        light.set_xyz(1.0, 5.0, 5.0)
    else:
        light.set_xyz(0.0, 0.0, 1.0)
    light.cast_shadow = 1
    light.shadow_color = (0.0, 0.0, 0.0, 0.5)

    # Set camera
    camera = soya.Camera(scene)
    camera.ortho = 0
    p = camera.position()
    if is3d:
        if rotate:
            camera.set_xyz(-20, 10, 50.0)
            camera.fov = 2.1
            p.set_xyz(0.0, 0.4, 0.0)
        else:
            camera.set_xyz(-20, 10, 50.0)
            camera.fov = 1.6
            p.set_xyz(0.3, 0.42, 0.5)
    else:
        if rotate:
            camera.set_xyz(0, 10, 50.0)
            camera.fov = 2.6
            p.set_xyz(0.0, 0.0, 0.0)
        else:
            camera.set_xyz(0, 10, 50.0)
            camera.fov = 1.7
            p.set_xyz(0.5, 0.4, 0.0)
    camera.look_at(p)
    soya.set_root_widget(camera)

    # Handle exit
    class Idler(soya.Idler):
        def end_round(self):
            for event in self.events:
                if event[0] == QUIT:
                    print("Closing plot, bye bye")
                    sys.exit(0)

    # Main loop
    idler = Idler(scene)
    idler.idle()
开发者ID:doru1004,项目名称:FFC,代码行数:89,代码来源:plot.py


示例19:

# -*- indent-tabs-mode: t -*-

#!/usr/bin/env python

import sys, os

import soya
import soya.pudding as pudding

soya.init(width = 1024, height = 768)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))

# initialise pudding
pudding.init()

scene = soya.World()

sword_model = soya.Model.get("sword")
sword = soya.Body(scene, sword_model)
sword.x = 1
sword.rotate_y(90.)

# one line rotation :)
sword.advance_time = lambda p: sword.rotate_y(5.*p)

light = soya.Light(scene)
light.set_xyz( .5, 0., 2.)

camera = soya.Camera(scene)
camera.z = 3.
开发者ID:deavid,项目名称:soyamirror,代码行数:30,代码来源:pudding-input-1.py


示例20: another

# -*- indent-tabs-mode: t -*-

INTRO = """
  This tutorial show the use of the hit function.
  If define, this function is called when the body collide with another (pushable or not)
  It usefull to trigger action when body hit's each other
"""

import sys, os
import soya



soya.init("collision-5-hit_func",width=1024,height=768)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))

print INTRO

class SpeakingHead(soya.Body):
	head_model = soya.Model.get("caterpillar_head")
	def __init__(self,parent,name):
		soya.Body.__init__(self,parent,self.head_model)
		self.name = name
	def hit(self,*args,**kargs):
		print "<%s> outch I'm hit !"%self.name



# create world
scene = soya.World()
# getting the head model
开发者ID:deavid,项目名称:soyamirror,代码行数:31,代码来源:ode-collision-5-hit_func.py



注:本文中的soya.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python soya.set_root_widget函数代码示例发布时间:2022-05-27
下一篇:
Python datetime_utils.datetime函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap