Bonjour, suite à une migration de langage de delphi vers python, je dois ré-écrire mes classes ce qui me procure l'occasion de découvrir le langage et son aspect objet.
Malheureusement tout ne colle pas encore et même, pas grand chose ne fonctionne avec cette classe CCamera


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class CPoint3D(object):
	def __init__(self, x =0, y=0, z=0):
		self.x = x
		self.y = y
		self.z = z
 
 
 
class CCamera(object):
 
	def __init__(self):
 
		self.eye = CPoint3D()
		self.up = CPoint3D()
		self.center = CPoint3D()
 
		self.speed = 0
		self.SetUp()
		self.SetEye()
		self.SetCenter()
		self.SetSpeed()
 
 
	def SetUp(self, x=0, y=1, z=0):		
		self.up.x = x
		self.up.y = y
		self.up.z = z
 
	def SetEye(self, x=3, y=4, z=3):		
		self.eye.x = x
		self.eye.y = y
		self.eye.z = z		
 
	def SetCenter(self, x=0, y=0, z=0):		
		self.center.x = x
		self.center.y = y
		self.center.z = z
 
	def SetSpeed(self, vitesse =0.6):		
		self.speed = vitesse
 
 
 
	def Focalize(self):
		gluLookAt(self.eye.x, self.eye.y, self.eye.z,
						 self.center.x, self.center.y, self.center.z,
						 self.up.x, self.up.y, self.up.z)
 
 
 
	def Distance(self, distance = 0):
 
		norme = sqrt( (self.eye.x-self.center.x)**2 + 
							   (self.eye.z-self.center.z)**2  +  
							   (self.eye.y-self.center.y)**2  )
 
		self.eye.x += (self.distance/self.norme) * (self.center.x - self.eye.x) 
		self.eye.y += (self.distance/self.norme) * (self.center.y - self.eye.y)
		self.eye.z += (self.distance/self.norme) * (self.center.z - self.eye.z)
 
		norme = sqrt( (self.eye.x-self.center.x)**2 + 
							(self.eye.z-self.center.z)**2  +  
							(self.eye.y-self.center.y)**2  )
 
		self.center.x += (self.distance/self.norme) * (self.center.x - self.eye.x) 
		self.center.y += (self.distance/self.norme) * (self.center.y - self.eye.y)
		self.center.z += (self.distance/self.norme) * (self.center.z - self.eye.z)							
 
 
 
	def ComputeRotationY(self, angle =0):
 
		angle /= (180 * 3.1416)
 
		self.SetCenter( (self.center.x - self.eye.x) * cos(angle) + self.eye.x - (self.center.z - self.eye.z) * sin(angle),
								self.center.y,
								(self.center.x - self.eye.x) * sin(angle) + self.eye.x -  (self.center.z - self.eye.z) * cos(angle)  )
 
 
 
	def ComputeRotationXZ(self, angle =0):
 
		angle /= (180 * 3.1416)
 
		P = CPoint3D(  (self.center.x - self.eye.x), 
								(self.center.z - self.eye.z), 
								(self.center.y - self.eye.y)   )					
 
		r  = sqrt(  P.x**2 + P.y**2 + P.z**2  )
		q = atan(P.y/P.x)
		t  = acos(P.z/r) + angle
 
		if (  (P.x <= 0) and (P.y >= 0)  ):
			q += 3.1416
		else:
			q += -3.1416
 
		P = ( r*sin(t)*cos(q) + self.eye.x,  
				 r*sin(t)*sin(q) + self.eye.z, 
				 r*cos(t) + self.eye.y    )
 
 
		self.SetCenter(P.x, P.z, P.y)
Voilà mon erreur, que je ne comprends pas du tout :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
  File "/build/buildd/python2.5-2.5.1/Modules/_ctypes/callbacks.c", line 206, in 'calling callback function'
  File "/home/mrgecko/BravePython/Snaky/Pyhko.py", line 210, in MouseMotion
    FirstCam.ComputeRotationXZ(roty * FirstCam.speed)
  File "/home/mrgecko/BravePython/Snaky/CCamera.py", line 117, in ComputeRotationXZ
    self.SetCenter(P.x, P.z, P.y)		
AttributeError: 'tuple' object has no attribute 'x'

Quelqu'un a une idée svp ?