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()
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()
# instanciate: test_guipanel = GuiPanel(scene, name, position, scale, rotation, color, DEBUG) # set up the camera: camera = soya.Camera(scene) camera.set_xyz(0.0, 0, 10.0) # set up the light: light = soya.Light(scene) light.set_xyz(0.0, 0.7, 1.0) # a test cube in the background: test_cube_world = soya.cube.Cube() test_cube_world.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) test_cube.y = 2.3 # a test atmosphere: #atmosphere = soya.SkyAtmosphere() #atmosphere.sky_color = (1, 1, 0.8, 1) #scene.atmosphere = atmosphere # set our root widget: soya.set_root_widget(camera) # start soya main loop: soya.MainLoop(scene).main_loop()
def main(): DEBUG = 1 import sys import os #import MovableCamera # init soya in resizable window: soya.init('Canta', 1024, 768, 0) # append our data path: soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', 'data')) # disable soya's auto exporter: soya.AUTO_EXPORTERS_ENABLED = 0 # set the root scene: scene = soya.World() # set up the light: light = soya.Light(scene) #light.set_xyz(1.0, 0.7, 1.0) light.set_xyz(0.0, 0.7, 1.0) # set up the camera: # (uncomment for static camera): camera = soya.Camera(scene) camera.set_xyz(0.0, 0, 10.0) # (uncomment for movable camera): #camera = MovableCamera.MovableCamera(scene) # create 5 animated objects (CANTA letters): # Letter 'C': name = 'Logo_0' position = (-4.0, 0.0, 0.0) scale = (4.0, 3.0, 3.0) rotation = (0.0, 0.0, 0.0) shadow = 1 action = 'Logo_0Damping' test_animodel0 = AniModel( parent_world = scene, name = name, position = position, scale = scale, rotation = rotation, shadow = shadow, action = action, debug = DEBUG ) # Letter 'A': name = 'Logo_1' position = (-3.0, -0.2, 0.0) scale = (1.0, 1.0, 1.0) rotation = (0.0, 0.0, 0.0) shadow = 1 action = 'Logo_1Damping' test_animodel1 = AniModel( parent_world = scene, name = name, position = position, scale = scale, rotation = rotation, shadow = shadow, action = action, debug = DEBUG ) # Letter 'N': name = 'Logo_2' position = (-1.5, 0.9, 0.0) scale = (1.0, 1.0, 1.0) rotation = (0.0, 0.0, 0.0) shadow = 1 action = 'Logo_2Damping' test_animodel2 = AniModel( parent_world = scene, name = name, position = position, scale = scale, rotation = rotation, shadow = shadow, action = action, debug = DEBUG ) # Letter 'T': name = 'Logo_3' position = (0.0, -0.5, 0.5) scale = (1.0, 1.0, 1.0) rotation = (0.0, 0.0, 0.0) shadow = 1 action = 'Logo_3Damping' test_animodel3 = AniModel( parent_world = scene, name = name, position = position, scale = scale, rotation = rotation, shadow = shadow, action = action, debug = DEBUG ) # Letter 'A': name = 'Logo_4' position = (2.0, 0.0, -0.3) scale = (1.5, 1.5, 1.5) rotation = (0.0, 0.0, 0.0) shadow = 1 action = 'Logo_4Damping' test_animodel1 = AniModel( parent_world = scene, name = name, position = position, scale = scale, rotation = rotation, shadow = shadow, action = action, debug = DEBUG ) # set our root widget: soya.set_root_widget(camera) # start soya main loop: soya.MainLoop(scene).main_loop()
#~ j2.attach(ball, pend) #~ j2.anchor = Point(scene, 3, 7.4, 0) #.setAnchor( (3,2,0) ) # '_soya.FixedJoint' object has no attribute 'anchor' j2 = soya.FixedJoint(ball, pend) j2.setFixed() j2.setFeedback(flag=True) # for getFeedback # these seem irrelevant after hinge? ground.pushable = False ground.gravity_mode = False hing.pushable = False hing.gravity_mode = False pole.pushable = False pole.gravity_mode = False print(pole.num_joints, pole.joints) # dir(pole), dir(pole.joints[0])) #~ print(joint1.anchor, joint1.anchor2, joint2.anchor, joint2.anchor2) # bump with init force #~ ball.add_force(soya.Vector(scene,0,ball_density*3000,0)) ball.add_force(soya.Vector(scene, 0, 0, 10000)) #~ pend.add_force(soya.Vector(scene,0,0,5000)) SetLight() SetCamera() SetWindowOverlay() #running soya soya.set_root_widget(root) #(camera); must be root for overlays ml = soya.MainLoop(scene) ml.main_loop()
def _run_soya_mainloop(self): soya.MainLoop(self.scene).main_loop()