Lines Matching refs:self
33 def __init__(self, name, description, children):
34 self.name = name
35 self.description = description
36 self.children = children
39 def __init__(self):
144 def __init__(self):
147 def uniformVec4(self, count, mn, mx):
154 def uniformBVec4(self, count):
160 # def uniform(self,
229 def __init__(self, x):
230 self.x = x
232 def applyUnary(self, func): return Scalar(func(self.x))
233 def applyBinary(self, func, other): return Scalar(func(self.x, other.x))
235 def isEqual(self, other): assert isinstance(other, Scalar); return (self.x == other.x)
237 def expandVec(self, val): return val
238 def toScalar(self): return Scalar(self.x)
239 def toVec2(self): return Vec2(self.x, self.x)
240 def toVec3(self): return Vec3(self.x, self.x, self.x)
241 def toVec4(self): return Vec4(self.x, self.x, self.x, self.x)
242 def toUVec2(self): return UVec2(self.x, self.x)
243 def toUVec3(self): return UVec3(self.x, self.x, self.x)
244 def toUVec4(self): return UVec4(self.x, self.x, self.x, self.x)
245 def toMat2(self): return Mat.fromScalar(2, 2, float(self.x))
246 def toMat2x3(self): return Mat.fromScalar(2, 3, float(self.x))
247 def toMat2x4(self): return Mat.fromScalar(2, 4, float(self.x))
248 def toMat3x2(self): return Mat.fromScalar(3, 2, float(self.x))
249 def toMat3(self): return Mat.fromScalar(3, 3, float(self.x))
250 def toMat3x4(self): return Mat.fromScalar(3, 4, float(self.x))
251 def toMat4x2(self): return Mat.fromScalar(4, 2, float(self.x))
252 def toMat4x3(self): return Mat.fromScalar(4, 3, float(self.x))
253 def toMat4(self): return Mat.fromScalar(4, 4, float(self.x))
255 def toFloat(self): return Scalar(float(self.x))
256 def toInt(self): return Scalar(int(self.x))
257 def toUint(self): return Uint(int(self.x))
258 def toBool(self): return Scalar(bool(self.x))
260 def getNumScalars(self): return 1
261 def getScalars(self): return [self.x]
263 def typeString(self):
264 if isinstance(self.x, bool):
266 elif isinstance(self.x, int):
268 elif isinstance(self.x, float):
273 def vec4Swizzle(self):
276 def __str__(self):
277 return str(self.x).lower()
279 def __float__(self):
280 return float(self.x)
282 def length(self):
283 return Scalar(abs(self.x))
285 def distance(self, v):
287 return Scalar(abs(self.x - v.x))
289 def dot(self, v):
291 return Scalar(self.x * v.x)
293 def normalize(self):
294 return Scalar(glslSign(self.x))
296 def abs(self):
297 if isinstance(self.x, bool):
298 return Scalar(self.x)
300 return Scalar(abs(self.x))
302 def __neg__(self):
303 return Scalar(-self.x)
305 def __add__(self, val):
309 return Scalar(self.x + val.x)
311 def __sub__(self, val):
312 return self + (-val)
314 def __mul__(self, val):
316 return Scalar(self.x * val.x)
318 return Vec2(self.x * val.x, self.x * val.y)
320 return Vec3(self.x * val.x, self.x * val.y, self.x * val.z)
322 return Vec4(self.x * val.x, self.x * val.y, self.x * val.z, self.x * val.w)
326 def __div__(self, val):
328 return Scalar(self.x / val.x)
330 return Vec2(self.x / val.x, self.x / val.y)
332 return Vec3(self.x / val.x, self.x / val.y, self.x / val.z)
334 return Vec4(self.x / val.x, self.x / val.y, self.x / val.z, self.x / val.w)
339 def __init__(self, x):
341 self.x = x
343 def typeString(self):
346 def abs(self):
347 return Scalar.abs(self).toUint()
349 def __neg__(self):
350 return Scalar.__neg__(self).toUint()
352 def __add__(self, val):
353 return Scalar.__add__(self, val).toUint()
355 def __sub__(self, val):
356 return self + (-val)
358 def __mul__(self, val):
359 return Scalar.__mul__(self, val).toUint()
361 def __div__(self, val):
362 return Scalar.__div__(self, val).toUint()
373 def isEqual(self, other):
375 return (self.getScalars() == other.getScalars())
377 def length(self):
378 return Scalar(math.sqrt(self.dot(self).x))
380 def normalize(self):
381 return self * Scalar(1.0 / self.length().x)
383 def swizzle(self, indexList):
384 inScalars = self.getScalars()
388 def __init__(self):
391 def __eq__(self, other):
392 return self.isEqual(other)
394 def __ne__(self, other):
395 return not self.isEqual(other)
398 def __init__(self, x, y):
400 self.x = x
401 self.y = y
403 def applyUnary(self, func): return Vec2(func(self.x), func(self.y))
404 def applyBinary(self, func, other): return Vec2(func(self.x, other.x), func(self.y, other.y))
406 def expandVec(self, val): return val.toVec2()
407 def toScalar(self): return Scalar(self.x)
408 def toVec2(self): return Vec2(self.x, self.y)
409 def toVec3(self): return Vec3(self.x, self.y, 0.0)
410 def toVec4(self): return Vec4(self.x, self.y, 0.0, 0.0)
411 def toUVec2(self): return UVec2(self.x, self.y)
412 def toUVec3(self): return UVec3(self.x, self.y, 0.0)
413 def toUVec4(self): return UVec4(self.x, self.y, 0.0, 0.0)
414 def toMat2(self): return Mat2(float(self.x), 0.0, 0.0, float(self.y));
416 def toFloat(self): return Vec2(float(self.x), float(self.y))
417 def toInt(self): return Vec2(int(self.x), int(self.y))
418 def toUint(self): return UVec2(int(self.x), int(self.y))
419 def toBool(self): return Vec2(bool(self.x), bool(self.y))
421 def getNumScalars(self): return 2
422 def getScalars(self): return [self.x, self.y]
424 def typeString(self):
425 if isinstance(self.x, bool):
427 elif isinstance(self.x, int):
429 elif isinstance(self.x, float):
434 def vec4Swizzle(self):
437 def __str__(self):
438 if isinstance(self.x, bool):
439 return "bvec2(%s, %s)" % (str(self.x).lower(), str(self.y).lower())
440 elif isinstance(self.x, int):
441 return "ivec2(%i, %i)" % (self.x, self.y)
442 elif isinstance(self.x, float):
443 return "vec2(%s, %s)" % (self.x, self.y)
447 def distance(self, v):
449 return (self - v).length()
451 def dot(self, v):
453 return Scalar(self.x*v.x + self.y*v.y)
455 def abs(self):
456 if isinstance(self.x, bool):
457 return Vec2(self.x, self.y)
459 return Vec2(abs(self.x), abs(self.y))
461 def __neg__(self):
462 return Vec2(-self.x, -self.y)
464 def __add__(self, val):
466 return Vec2(self.x + val, self.y + val)
468 return Vec2(self.x + val.x, self.y + val.y)
472 def __sub__(self, val):
473 return self + (-val)
475 def __mul__(self, val):
479 return Vec2(self.x * val.x, self.y * val.y)
481 def __div__(self, val):
483 return Vec2(self.x / val.x, self.y / val.x)
486 return Vec2(self.x / val.x, self.y / val.y)
488 def boolAny(self): return Scalar(self.x or self.y)
489 def boolAll(self): return Scalar(self.x and self.y)
490 def boolNot(self): return Vec2(not self.x, not self.y)
493 def __init__(self, x, y):
496 Vec2.__init__(self, x, y)
498 def typeString(self):
501 def __str__(self):
502 return "uvec2(%i, %i)" % (self.x, self.y)
504 def abs(self):
505 return Vec2.abs(self).toUint()
508 def __init__(self, x, y, z):
510 self.x = x
511 self.y = y
512 self.z = z
514 def applyUnary(self, func): return Vec3(func(self.x), func(self.y), func(self.z))
515 def applyBinary(self, func, other): return Vec3(func(self.x, other.x), func(self.y, other.y), func(self.z, other.z))
517 def expandVec(self, val): return val.toVec3()
518 def toScalar(self): return Scalar(self.x)
519 def toVec2(self): return Vec2(self.x, self.y)
520 def toVec3(self): return Vec3(self.x, self.y, self.z)
521 def toVec4(self): return Vec4(self.x, self.y, self.z, 0.0)
522 def toUVec2(self): return UVec2(self.x, self.y)
523 def toUVec3(self): return UVec3(self.x, self.y, self.z)
524 def toUVec4(self): return UVec4(self.x, self.y, self.z, 0.0)
525 def toMat3(self): return Mat3(float(self.x), 0.0, 0.0, 0.0, float(self.y), 0.0, 0.0, 0.0, float(self.z));
527 def toFloat(self): return Vec3(float(self.x), float(self.y), float(self.z))
528 def toInt(self): return Vec3(int(self.x), int(self.y), int(self.z))
529 def toUint(self): return UVec3(int(self.x), int(self.y), int(self.z))
530 def toBool(self): return Vec3(bool(self.x), bool(self.y), bool(self.z))
532 def getNumScalars(self): return 3
533 def getScalars(self): return [self.x, self.y, self.z]
535 def typeString(self):
536 if isinstance(self.x, bool):
538 elif isinstance(self.x, int):
540 elif isinstance(self.x, float):
545 def vec4Swizzle(self):
548 def __str__(self):
549 if isinstance(self.x, bool):
550 return "bvec3(%s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower())
551 elif isinstance(self.x, int):
552 return "ivec3(%i, %i, %i)" % (self.x, self.y, self.z)
553 elif isinstance(self.x, float):
554 return "vec3(%s, %s, %s)" % (self.x, self.y, self.z)
558 def distance(self, v):
560 return (self - v).length()
562 def dot(self, v):
564 return Scalar(self.x*v.x + self.y*v.y + self.z*v.z)
566 def cross(self, v):
568 return Vec3(self.y*v.z - v.y*self.z,
569 self.z*v.x - v.z*self.x,
570 self.x*v.y - v.x*self.y)
572 def abs(self):
573 if isinstance(self.x, bool):
574 return Vec3(self.x, self.y, self.z)
576 return Vec3(abs(self.x), abs(self.y), abs(self.z))
578 def __neg__(self):
579 return Vec3(-self.x, -self.y, -self.z)
581 def __add__(self, val):
583 return Vec3(self.x + val, self.y + val)
585 return Vec3(self.x + val.x, self.y + val.y, self.z + val.z)
589 def __sub__(self, val):
590 return self + (-val)
592 def __mul__(self, val):
596 return Vec3(self.x * val.x, self.y * val.y, self.z * val.z)
598 def __div__(self, val):
600 return Vec3(self.x / val.x, self.y / val.x, self.z / val.x)
602 return Vec3(self.x / val.x, self.y / val.y, self.z / val.z)
606 def boolAny(self): return Scalar(self.x or self.y or self.z)
607 def boolAll(self): return Scalar(self.x and self.y and self.z)
608 def boolNot(self): return Vec3(not self.x, not self.y, not self.z)
611 def __init__(self, x, y, z):
614 Vec3.__init__(self, x, y, z)
616 def typeString(self):
619 def __str__(self):
620 return "uvec3(%i, %i, %i)" % (self.x, self.y, self.z)
622 def abs(self):
623 return Vec3.abs(self).toUint()
626 def __init__(self, x, y, z, w):
628 self.x = x
629 self.y = y
630 self.z = z
631 self.w = w
633 def applyUnary(self, func): return Vec4(func(self.x), func(self.y), func(self.z), func(self.w))
634 def applyBinary(self, func, other): return Vec4(func(self.x, other.x), func(self.y, other.y), func(self.z, other.z), func(self.w, other.w))
636 def expandVec(self, val): return val.toVec4()
637 def toScalar(self): return Scalar(self.x)
638 def toVec2(self): return Vec2(self.x, self.y)
639 def toVec3(self): return Vec3(self.x, self.y, self.z)
640 def toVec4(self): return Vec4(self.x, self.y, self.z, self.w)
641 def toUVec2(self): return UVec2(self.x, self.y)
642 def toUVec3(self): return UVec3(self.x, self.y, self.z)
643 def toUVec4(self): return UVec4(self.x, self.y, self.z, self.w)
644 def toMat2(self): return Mat2(float(self.x), float(self.y), float(self.z), float(self.w))
645 def toMat4(self): return Mat4(float(self.x), 0.0, 0.0, 0.0, 0.0, float(self.y), 0.0, 0.0, 0.0, 0.0, float(self.z), 0.0, 0.0, 0.0, 0.0, float(self.w));
647 def toFloat(self): return Vec4(float(self.x), float(self.y), float(self.z), float(self.w))
648 def toInt(self): return Vec4(int(self.x), int(self.y), int(self.z), int(self.w))
649 def toUint(self): return UVec4(int(self.x), int(self.y), int(self.z), int(self.w))
650 def toBool(self): return Vec4(bool(self.x), bool(self.y), bool(self.z), bool(self.w))
652 def getNumScalars(self): return 4
653 def getScalars(self): return [self.x, self.y, self.z, self.w]
655 def typeString(self):
656 if isinstance(self.x, bool):
658 elif isinstance(self.x, int):
660 elif isinstance(self.x, float):
665 def vec4Swizzle(self):
668 def __str__(self):
669 if isinstance(self.x, bool):
670 return "bvec4(%s, %s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower(), str(self.w).lower())
671 elif isinstance(self.x, int):
672 return "ivec4(%i, %i, %i, %i)" % (self.x, self.y, self.z, self.w)
673 elif isinstance(self.x, float):
674 return "vec4(%s, %s, %s, %s)" % (self.x, self.y, self.z, self.w)
678 def distance(self, v):
680 return (self - v).length()
682 def dot(self, v):
684 return Scalar(self.x*v.x + self.y*v.y + self.z*v.z + self.w*v.w)
686 def abs(self):
687 if isinstance(self.x, bool):
688 return Vec4(self.x, self.y, self.z, self.w)
690 return Vec4(abs(self.x), abs(self.y), abs(self.z), abs(self.w))
692 def __neg__(self):
693 return Vec4(-self.x, -self.y, -self.z, -self.w)
695 def __add__(self, val):
697 return Vec3(self.x + val, self.y + val)
699 return Vec4(self.x + val.x, self.y + val.y, self.z + val.z, self.w + val.w)
703 def __sub__(self, val):
704 return self + (-val)
706 def __mul__(self, val):
710 return Vec4(self.x * val.x, self.y * val.y, self.z * val.z, self.w * val.w)
712 def __div__(self, val):
714 return Vec4(self.x / val.x, self.y / val.x, self.z / val.x, self.w / val.x)
716 return Vec4(self.x / val.x, self.y / val.y, self.z / val.z, self.w / val.w)
720 def boolAny(self): return Scalar(self.x or self.y or self.z or self.w)
721 def boolAll(self): return Scalar(self.x and self.y and self.z and self.w)
722 def boolNot(self): return Vec4(not self.x, not self.y, not self.z, not self.w)
725 def __init__(self, x, y, z, w):
728 Vec4.__init__(self, x, y, z, w)
730 def typeString(self):
733 def __str__(self):
734 return "uvec4(%i, %i, %i, %i)" % (self.x, self.y, self.z, self.w)
736 def abs(self):
737 return Vec4.abs(self).toUint()
741 def __init__ (self, numCols, numRows, scalars):
743 self.numCols = numCols
744 self.numRows = numRows
745 self.scalars = scalars
759 def get (self, colNdx, rowNdx):
760 assert 0 <= colNdx and colNdx < self.numCols
761 assert 0 <= rowNdx and rowNdx < self.numRows
762 return self.scalars[colNdx*self.numRows + rowNdx]
764 def set (self, colNdx, rowNdx, scalar):
765 assert 0 <= colNdx and colNdx < self.numCols
766 assert 0 <= rowNdx and rowNdx < self.numRows
767 self.scalars[colNdx*self.numRows + rowNdx] = scalar
769 def toMatrix (self, numCols, numRows):
771 for col in range(0, min(self.numCols, numCols)):
772 for row in range(0, min(self.numRows, numRows)):
773 res.set(col, row, self.get(col, row))
776 def toMat2 (self): return self.toMatrix(2, 2)
777 def toMat2x3 (self): return self.toMatrix(2, 3)
778 def toMat2x4 (self): return self.toMatrix(2, 4)
779 def toMat3x2 (self): return self.toMatrix(3, 2)
780 def toMat3 (self): return self.toMatrix(3, 3)
781 def toMat3x4 (self): return self.toMatrix(3, 4)
782 def toMat4x2 (self): return self.toMatrix(4, 2)
783 def toMat4x3 (self): return self.toMatrix(4, 3)
784 def toMat4 (self): return self.toMatrix(4, 4)
786 def typeString(self):
787 if self.numRows == self.numCols:
788 return "mat%d" % self.numRows
790 return "mat%dx%d" % (self.numCols, self.numRows)
792 def __str__(self):
793 return "%s(%s)" % (self.typeString(), ", ".join(["%s" % s for s in self.scalars]))
795 def isTypeEqual (self, other):
796 return isinstance(other, Mat) and self.numRows == other.numRows and self.numCols == other.numCols
798 def isEqual(self, other):
799 assert self.isTypeEqual(other)
800 return (self.scalars == other.scalars)
802 def compMul(self, val):
803 assert self.isTypeEqual(val)
804 return Mat(self.numRows, self.numCols, [self.scalars(i) * val.scalars(i) for i in range(self.numRows*self.numCols)])
807 def __init__(self, m00, m01, m10, m11):
808 Mat.__init__(self, 2, 2, [m00, m10, m01, m11])
811 def __init__(self, m00, m01, m02, m10, m11, m12, m20, m21, m22):
812 Mat.__init__(self, 3, 3, [m00, m10, m20,
817 def __init__(self, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):
818 Mat.__init__(self, 4, 4, [m00, m10, m20, m30,