Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/02/2011 at 07:38, xxxxxxxx wrote:
Hi folks,
I was wondering how to keep the code active, so to say.
Means that it does not only initialize but is active every frame.
I just want a random movement over time for one particle.
Here is the Code (sorry it's in german for personal learning purposes)
import c4d import random stepSize = 5 tp.AllocParticles(1) v_vector = c4d.Vector() v_vector.x = float(0) v_vector.y = float(0) v_vector.z = float(0) z=0 def haupt(z,v_vector) : while z<10000 : direction = random.randrange (0,8,1) zufallsrichtung (direction) tp.SetPosition(0, v_vector) z += 1 print direction return direction def zufallsrichtung (direction) : if direction == 0: # Norden v_vector.y += stepSize elif direction == 1: # Nordost v_vector.x += stepSize v_vector.y += stepSize elif direction == 2: # Ost v_vector.x += stepSize elif direction == 3: # Südost v_vector.x += stepSize v_vector.y -= stepSize elif direction == 4: # Süd v_vector.y += stepSize elif direction == 5: # Südwest v_vector.x -= stepSize v_vector.y -= stepSize elif direction == 6: # West v_vector.x -= stepSize; elif direction == 7: # Nordwest v_vector.x -= stepSize; v_vector.y += stepSize; def main() : pass haupt(z,v_vector)
import c4d import random
stepSize = 5 tp.AllocParticles(1)
v_vector = c4d.Vector()
v_vector.x = float(0) v_vector.y = float(0) v_vector.z = float(0)
z=0
def haupt(z,v_vector) : while z<10000 : direction = random.randrange (0,8,1) zufallsrichtung (direction) tp.SetPosition(0, v_vector) z += 1 print direction return direction
def zufallsrichtung (direction) :
if direction == 0: # Norden v_vector.y += stepSize
elif direction == 1: # Nordost v_vector.x += stepSize v_vector.y += stepSize elif direction == 2: # Ost v_vector.x += stepSize
elif direction == 3: # Südost v_vector.x += stepSize v_vector.y -= stepSize
elif direction == 4: # Süd v_vector.y += stepSize
elif direction == 5: # Südwest v_vector.x -= stepSize v_vector.y -= stepSize
elif direction == 6: # West v_vector.x -= stepSize;
elif direction == 7: # Nordwest v_vector.x -= stepSize; v_vector.y += stepSize;
def main() : pass
haupt(z,v_vector)
Hope someone can help me out of this tiny problem
On 19/02/2011 at 15:37, xxxxxxxx wrote:
Haha, I've already replied you at tutorials.de. You passed the main-function
On 22/02/2011 at 02:32, xxxxxxxx wrote:
Yes that was the problem, thank you very much