Oh right, and fix the same for initializing the Body!
soya.Body.__init__(self, parent, soya.cube.Cube(soya.Body, color))
On Mon, Apr 14, 2008 at 1:29 PM, snaipperi [EMAIL PROTECTED] wrote:
The constructor of a class must be __init__, not _init_
.class Cube(soya.Body):
.
. #Constructor
. def __init__(self, parent):
That should fix it,
Matti
On Mon, Apr 14, 2008 at 7:01 AM, g p [EMAIL PROTECTED] wrote:
I've been having problems animating rotation. I modelled my simple program
after the tutorial with the rotating sword. I played around with it a
little
bit more, but still can't get it work.
In my program, I'm trying to spin a cube:
#Soya initialization
import sys, os, os.path, random, soya, soya.cube
soya.init(Cube Test)
# Emissive color of the cube
color = soya.Material()
color.emissive = (1.0, 0.0, 0.0, 0.0)
# World creation
scene = soya.World()
# Classes
class Cube(soya.Body):
#Constructor
def _init_(self, parent):
soya.Body._init_(self, parent, soya.cube.Cube(soya.Body, color))
self.speed = soya.Vector(self, 0.0, 0.0, -0.2)
#rotation speed around y axis
self.rotation_speed = 0.0
def begin_round(self):
soya.Body.begin_round(self)
self.rotation_speed = random.uniform(-25.0, 25.0) #computes the new
rotation speed
#as a random angle between -25 and 25 degrees
def advance_time(self, proportion):
soya.Body.advance_time(self, proportion)
self.rotate_y(proportion * self.rotation_speed)
self.add_mul_vector(proportion, self.speed)
#creates a cube
cube1 = Cube(scene)
# Camera setup
camera = soya.Camera(scene)
camera.set_xyz(0.0, 0.0, 4.0)
camera.fov = 100.0
soya.set_root_widget(camera)
# Main
soya.MainLoop(scene).main_loop()
This program creates a window, but doesn't render anything, and then ends
with an error. Here is the error:
line 37, in advance_time
self.add_mul_vector(proportion, self.speed)
AttributeError: 'Cube' object has no attribute 'speed'
* Soya3D * Quit...
any insight would be great!
___
Soya-user mailing list
Soya-user@gna.org
https://mail.gna.org/listinfo/soya-user
___
Soya-user mailing list
Soya-user@gna.org
https://mail.gna.org/listinfo/soya-user