File: ode-join.py

package info (click to toggle)
soya-doc 0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 15,264 kB
  • ctags: 1,039
  • sloc: python: 4,334; makefile: 9; sh: 5
file content (61 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (2)
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
# -*- indent-tabs-mode: t -*-

import sys, os

import soya
from soya import Vector


soya.init("first ODE test",width=1024,height=768)

soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))


#create world

ode_world = soya.World()
#scene = ode_world
scene = soya.World(ode_world)
#activate ODE support



sword_model = soya.Model.get("sword")

sword = soya.Body(scene,sword_model)
sword.ode = True
sword.x = 1.0
sword.z = -5

blade = soya.BoxedMass(0.00005,50,5,1)
pommeau = soya.SphericalMass(50,0.5)
pommeau.translate((25,0,0))
sword.mass = blade+pommeau

joint = soya.BallJoint(sword)



def v (x,y,z):
	return soya.Vector(sword,x,y,z)
sword.add_force(v(10,200,0),v(25,0.001,0.002))
sword.add_force(v(0,60,0),v(0,25,0.5))
sword.add_force(v(0,0,-2303*5),v(-25,0.0001,0.0001))

scene.turn_x = 34
scene.turn_y = 23
scene.turn_z = 12

light = soya.Light(scene)
light.set_xyz(0, 0, 15)

camera = soya.Camera(scene)
camera.set_xyz(1,1,15)


scene.set_xyz(0.5,0.5,-5)

ode_world.gravity = Vector(ode_world,0,-5,0)
soya.set_root_widget(camera)
ml = soya.MainLoop(ode_world)
ml.main_loop()