THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/02/2011 at 13:07, xxxxxxxx wrote:
So I'll try to explain it to you. :)
In your Code, the main stuff will only be executed if the active frame is greater than 10.
That's not what I want. Finally, i want to use it with particles. But i did some stuff in coffee like this, too.
Imagine the following: A sphere's position is moved every frame about 100 on x. Of course i could calculate it with a formula like this:
sph.SetAbsPos(INIT_POS+c4d.Vector(frame*100,0,0))
But this is not simulation, its simple calculation. The spheres Position is beeing set by its initial position. If afterwards another calculation moves the sphere in a completely different direction, the next frame: the sphere is still on its position beeing calculated by its initial position. Can you follow me ?
So the new position must be calculated depending on its actual position.
sph.SetAbsPos(sph.GetAbsPos()+c4d.Vector(100,0,0))
If now afterwards another "force" moves the Sphere, the next frame: the effect of this force is still there. (Sorry for my bad english xD)
Lets look at some values, i think they can show it better :)
Force 1 pulls the sphere about 100 in x per frame
Force 2 pulls the sphere about 500 in y to frame 2
The order how the forces are applied is given. with "order" I mean the order in the code. e
example for Force 2 after Force 1:
InitPos = sph.GetAbsPos()
def main() :
ApplyForce1()
ApplyForce2()
------------------
Calculating the Spheres Position with a Formula, applying Force 2 after Force 1
Frame 0: 0, 0, 0
Frame 1: 100, 0, 0
Frame 2: 200, 500, 0
Frame 3: 300, 0, 0
Frame 4: 400, 0, 0
Calculating the Spheres position with a Formula, applying Force 2 before Force 1
Frame 0: 0, 0, 0
Frame 1: 100, 0, 0
Frame 2: 200, 0, 0
Frame 3: 300, 0, 0
Frame 4: 400, 0, 0
SIMULATING THE SPHERES POSITION, the order of forces is unimportant
Frame 0: 0, 0, 0
Frame 1: 100, 0, 0
Frame 2: 200, 500, 0
Frame 3: 300, 500, 0
Frame 4: 400, 500, 0
But the problem of Simulating is, it gets calculated even if the timeline is *not* moved, because of the editoredraw.
So i have to check if the Timeline is really playing. I need a variable frame which contains the active frame, and a variable prevframe which contains the last obtained frame, not frame-1. If frame != prevframe+1, it must be because the user slides in the timeline or something.
But now, back to the Origin of the hole problem:
To edit global variables i must call "global [variablename]". *but* doing this deinitialises the variable first, so its kinda less than None, and my previously saved frame is just nothing.
In coffee i could do it like this:
var prevframe;
main() {
if(!prevframe) prevframe = 0; //Really missing this in Python :-(
var frame = doc->GetTime()->GetFrame(doc->GetFps());
if (frame == prevframe+1) {
println("The Timeline is playing");
}
if (frame == prevframe) {
println("not playing");
}
if (frame < prevframe) {
println("Playinh backwards");
}
prevframe = frame;
}
When want to edit a global variable in python, it just gets edited locally, after that it gets set to its original value. How the hell to do it like in Coffee ? How to edit global variables ?
I hope you could uderstand what I mean .. Really difficult to explain :(
Especially when beeing on a mobile device x/