also eine verbindung, womit man einmal die geamtheit steuern kann (die sonne ist der ausschlaggebende körper der die erde und den mond mitnimmt). so etwas will ich auch später benutzen um ein gelenkarm zu steuern mit mehreren gelenken.
Code: Alles auswählen
# -*- indent-tabs-mode: t -*-
import sys, os, os.path, soya, soya.sphere, soya.widget, wx, time
soya.init()
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
scene = soya.World()
class CelestialObject(soya.World):
def advance_time(self, proportion):
soya.World.advance_time(self, proportion)
earth.rotate_y(proportion * 1.0)
sun.rotate_y(proportion*0.1)
sun = CelestialObject(scene, soya.Model.get("sun"))
earth = CelestialObject(sun , soya.Model.get("earth"))
earth.x = 1.5
earth1 = CelestialObject(earth , soya.Model.get("moon"))
earth1.x = 0.5
light = soya.Light(scene)
light.set_xyz(0.0, 5.0, 0.0)
camera = soya.Camera(scene)
camera.y = 4.0
camera.look_at(soya.Vector(scene, 0.0, -1.0, 0.0))
soya.set_root_widget(camera)
soya.MainLoop(scene).main_loop()
Code: Alles auswählen
# -*- indent-tabs-mode: t -*-
import sys, os, os.path, soya, soya.widget, wx, time
soya.init("test",640,480)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
scene = soya.World()
modell=soya.Model.get("earth")
head = soya.Body(scene,modell )
light = soya.Light(scene)
light.set_xyz(2.0, 5.0, 0.0)
camera = soya.Camera(scene)
camera.set_xyz(0.0, 15.0, 15.0)
camera.look_at(head)
soya.set_root_widget(soya.widget.Group())
soya.root_widget.add(camera)
soya.MainLoop(scene)
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,pos=(15, 15), size=(150,300))
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
self.timer.Start(30)
panel = wx.Panel(self)
text = wx.StaticText(panel, -1,)
text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
btn = wx.Button(panel, -1, "Close")
self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, btn)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(btn, 0, wx.ALL, 5)
panel.SetSizer(sizer)
def OnTimeToClose(self, evt):
self.Close()
def OnTimer(self, evt):
head.rotate_x (2)
soya.MAIN_LOOP.update()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, "wx-soya")
self.SetTopWindow(frame)
frame.Show(True)
return True
app = MyApp(redirect=True)
app.MainLoop()
def OnTimer(self, evt):
head.rotate_x (2)
soya.MAIN_LOOP.update()
es soll nur der timer vom wx-fenster bestimmend sein.
ich kann diese routinen nicht zum laufen bringen:
sun = CelestialObject(scene, soya.Model.get("sun"))
earth = CelestialObject(sun , soya.Model.get("earth"))
earth.x = 1.5
earth1 = CelestialObject(earth , soya.Model.get("moon"))
earth1.x = 0.5
bzw weiss nicht wie die jetzt in der def vom wx-fenster reingesetzt werden.
diese hilfe brauche ich.
mfg