def newVelocity(self, n): """Generate a new random velocity by blending the given direction with a random unit vector, normalizing it, then multiplying by a randomly generated speed. """ randomDirections = Noise.randomVectors((n, 3), type=Float32) randomDirections *= self._directionRandomness randomDirections += self.premultDirection normalize(randomDirections, randomDirections) randomSpeeds = repeat(Noise.randomArray((n, 1), type=Float32, range=self.speedRange), 3, -1) randomDirections *= randomSpeeds return randomDirections
def __init__(self, size=(256,256), seed=None): Texture.Texture.__init__(self) r = Noise.randomArray(size, seed, (0,255), UInt8) self.loadRaw(size, r.tostring(), GL_LUMINANCE, 1) self.setFilter(GL_NEAREST, GL_NEAREST)