Changeset 384
- Timestamp:
- 07/23/09 13:34:15 (12 months ago)
- Location:
- branches/adaptare/trunk/hfall
- Files:
-
- 1 added
- 3 modified
-
Engine/Camera.py (modified) (1 diff)
-
Engine/Object.py (modified) (1 diff)
-
Quaternion.py (modified) (3 diffs)
-
Tree.py (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/adaptare/trunk/hfall/Engine/Camera.py
r377 r384 170 170 normal = VA.crossProduct(VD) 171 171 normal.normalize() 172 plane = Plane(cameraPosition, normal) 173 return plane 172 return Plane(cameraPosition, normal) 174 173 175 174 if string == 'right': 176 175 normal = VB.crossProduct(VC) 177 176 normal.normalize() 178 plane = Plane(cameraPosition, normal) 179 return plane 177 return Plane(cameraPosition, normal) 180 178 181 179 if string == 'top': 182 180 normal = VA.crossProduct(VB) 183 181 normal.normalize() 184 plane = Plane(cameraPosition, normal) 185 return plane 182 return Plane(cameraPosition, normal) 186 183 187 184 if string == 'bottom': 188 185 normal == VC.crossProduct(VD) 189 186 normal.normalize() 190 plane = Plane(cameraPosition, normal) 191 return plane 187 return Plane(cameraPosition, normal) 192 188 193 189 if string == 'near': 194 plane = Plane(axPoint, self.viewVector()) 195 return plane 190 return Plane(axPoint, self.viewVector()) 196 191 197 192 if string == 'far': 198 plane = Plane(auxPoint, -self.viewVector()) 199 return plane 200 193 return Plane(auxPoint, -self.viewVector()) -
branches/adaptare/trunk/hfall/Engine/Object.py
r335 r384 98 98 99 99 self.projection *= m 100 101 -
branches/adaptare/trunk/hfall/Quaternion.py
r377 r384 253 253 @staticmethod 254 254 def dot(Q1, Q2): 255 if isinstance(Q1, Quaternion): 256 if isinstance(Q2, Quaternion): 257 return Q1.x * Q2.x + Q1.y * Q2.y + Q1.z * Q2.z + Q1.w * Q2.w 258 else: 259 raise TypeError("Invalid argument") 260 else: 261 raise TypeError("Invalid argument") 255 return Q1.x * Q2.x + Q1.y * Q2.y + Q1.z * Q2.z + Q1.w * Q2.w 262 256 263 257 @staticmethod … … 266 260 Linearly interpolate each component, then normalize the Quaternion 267 261 """ 268 if isinstance(Q1, Quaternion): 269 if isinstance(Q2, Quaternion): 270 return (Q1 * (1-t) + Q2 * t).normalize() 271 else: 272 raise TypeError("Invalid argument") 273 else: 274 raise TypeError("Invalid argument") 275 262 return (Q1 * (1-t) + Q2 * t).normalize() 276 263 277 264 @staticmethod … … 279 266 """ 280 267 Spherical linear interpolation 281 """ 282 if isinstance(Q1, Quaternion): 283 if isinstance(Q2, Quaternion): 284 285 dot = Quaternion.dot(Q1, Q2) 286 if dot < 0: 287 dot = -dot 288 Q3 = -Q2 289 else: 290 Q3 = Q2 268 """ 269 dot = Quaternion.dot(Q1, Q2) 270 if dot < 0: 271 dot = -dot 272 Q3 = -Q2 273 else: 274 Q3 = Q2 291 275 292 if dot < 0.95: 293 angle = math.acos(dot) 294 w1 = math.sin(angle * (1-t)) / math.sin(angle) 295 w2 = math.sin(angle * t) / math.sin(angle) 296 return Q1 * w1 + Q3 * w2 297 else: 298 # The angle is small. We use linear interpolation 299 Quaternion.LERP(Q1, Q3, t) 300 301 else: 302 raise TypeError("Invalid argument") 303 else: 304 raise TypeError("Invalid argument") 276 if dot < 0.95: 277 angle = math.acos(dot) 278 w1 = math.sin(angle * (1-t)) / math.sin(angle) 279 w2 = math.sin(angle * t) / math.sin(angle) 280 return Q1 * w1 + Q3 * w2 281 else: 282 # The angle is small. We use linear interpolation 283 Quaternion.LERP(Q1, Q3, t)
