<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Deltatime ?]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 21/02/2011 at 09:23, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Guys,</p>
<p dir="auto">I'm going to write a deltatime plugin and i need a global variable which represents the previous frame of the scene.<br />
But this doesn't work:</p>
<pre><code>global prevframe  
if frame is not prevframe:  
  pass  
</code></pre>
<p dir="auto">The console tells me that prevframe is not defined.</p>
<p dir="auto">Any idea how to to this ?</p>
<p dir="auto">Thanks, nux</p>
]]></description><link>http://developers.maxon.net/forum/topic/5520/5539_deltatime-</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 04:14:19 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/5520.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 May 2018 17:51:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:42 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 07:37, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Thanks,</p>
<p dir="auto">I'm always looking for code snippets to learn from. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f37a.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--beer" style="height:23px;width:auto;vertical-align:middle" title=":beer:" alt="🍺" /></p>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25725</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25725</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:42 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 07:15, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hehe testing goes over studieng <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=":wink:" alt="😉" /><br />
Great work. !</p>
<p dir="auto">I think i found out, why Python told me the variables was not initialiesed.<br />
My code was:</p>
<pre><code>  
global prevtime  
  
def main() :  
   global prevframe  
   //do stuff  
   prevframe = frame  
</code></pre>
<p dir="auto">But it works fine with simply adding this:</p>
<pre><code>  
global prevframe  
prevframe = 0         ## Adding this, it works  
  
def main() :  
     global prevframe  
     //do stuff  
     prevframe = frame  
</code></pre>
<p dir="auto">Actually I don't get the sense why it must be defined once before it can be changed. But, it works fine <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">If you may want the Code i was working on, here it is. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--smile" style="height:23px;width:auto;vertical-align:middle" title=":smile:" alt="😄" /></p>
<p dir="auto"><a href="http://www.file-upload.net/download-3237033/TP-Planar-Gravity.c4d.html" target="_blank" rel="noopener noreferrer nofollow ugc">TP Planar Gravity - Py4D</a></p>
]]></description><link>http://developers.maxon.net/forum/post/25724</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25724</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:41 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 07:05, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">lol.<br />
Even a blind squirrel finds a nut once in a while. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=":wink:" alt="😉" /></p>
<p dir="auto">The thought process in my head was this:<br />
You need to have a global variable in order to override it. But python doesn't let you assign a value to a variable with the word "global" in front of it. Which causes definition errors later on.<br />
So I sort of cheated.<br />
I created a standard variable and defined it with a value.<br />
Then later on. I told python to treat it as a global variable in the main section.</p>
<p dir="auto">The fact that it worked was a complete accident. And I have no idea if this is the proper way to do it.</p>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25723</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25723</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:41 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:41 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 06:15, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">OMG it works !! :OOO Thanks man <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
But I don't get why it suddenly does ! O.o But, anyway, thanks. I'll try to implement this now and come back with problems for sure <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f602.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--joy" style="height:23px;width:auto;vertical-align:middle" title=":joy:" alt="😂" /></p>
<p dir="auto">Thanks haha <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>http://developers.maxon.net/forum/post/25722</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25722</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:41 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:41 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 14:16, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">I'll give it a try tomorrow, thanks <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
But I think it won't work .. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--confused" style="height:23px;width:auto;vertical-align:middle" title=":/" alt="😕" /><br />
AFAIK this tells you that the variable has not been initialised (or None ?)</p>
<pre><code>  
prevframe = 0   
  
def main() :   
  global prevframe   
  print prevframe   
</code></pre>
<p dir="auto">what makes me think, that the global - expression resets the variable first ..<br />
But anyway, I'll give it a try !</p>
<p dir="auto">I'm new to it, too. Started learning 2 days ago. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /></p>
<p dir="auto">Cheers and thanks,<br />
nux</p>
]]></description><link>http://developers.maxon.net/forum/post/25721</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25721</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:41 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:40 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 14:16, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">I think I understand the problem now. Forgive me ..... I'm a bit dense sometimes. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f60a.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--blush" style="height:23px;width:auto;vertical-align:middle" title=":blush:" alt="😊" /></p>
<p dir="auto">Your last bit of coffee code is what made me understand the problem.<br />
So I'm going to use it as the basis for my python example.<br />
Give this code a try and see if it solves your global variable problem:</p>
<pre><code>import c4d  
  
prevframe = 0  
  
def main() :  
  global prevframe  
  time = doc.GetTime()  
  frame = time.GetFrame(doc.GetFps())  
  
  if not prevframe:  
   prevframe = 0  
    
  if frame == prevframe+1:  
   prevframe = prevframe +1  
   print "The Timeline is playing"  
  
  if frame == prevframe:  
   print "not playing"  
   
  if frame &lt; prevframe:  
   print "Playing backwards"  
</code></pre>
<p dir="auto">Please bear in mind that I am <strong><em>very</em></strong> new to Python. And I only know enough to be dangerous at this point.</p>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25720</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25720</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:40 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:39 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 13:07, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">So I'll try to explain it to you. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">In your Code, the main stuff will only be executed if the active frame is greater than 10.<br />
That's not what I want. Finally, i want to use it with particles. But i did some stuff in coffee like this, too.</p>
<p dir="auto">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:</p>
<pre><code>sph.SetAbsPos(INIT_POS+c4d.Vector(frame*100,0,0))   
</code></pre>
<p dir="auto">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 ?</p>
<p dir="auto">So the new position must be calculated depending on its actual position.</p>
<pre><code>  
sph.SetAbsPos(sph.GetAbsPos()+c4d.Vector(100,0,0))   
</code></pre>
<p dir="auto">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)<br />
Lets look at some values, i think they can show it better <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<pre><code>  
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   
</code></pre>
<p dir="auto">But the problem of Simulating is, it gets calculated even if the timeline is *not* moved, because of the editoredraw.<br />
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 <em>which contains the <strong>last obtained</strong></em> frame, not frame-1. If frame != prevframe+1, it must be because the user slides in the timeline or something.</p>
<p dir="auto">But now, back to the Origin of the hole problem:<br />
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.</p>
<p dir="auto">In coffee i could do it like this:</p>
<pre><code>  
var prevframe;   
main() {   
if(!prevframe) prevframe = 0;    //Really missing this in Python :-(   
var frame = doc-&gt;GetTime()-&gt;GetFrame(doc-&gt;GetFps());   
  
if (frame == prevframe+1) {   
    println("The Timeline is playing");   
}   
if (frame == prevframe) {   
     println("not playing");   
}   
if (frame &lt; prevframe) {   
     println("Playinh backwards");   
}   
  
prevframe = frame;   
}   
</code></pre>
<p dir="auto">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 ?</p>
<p dir="auto">I hope you could uderstand what I mean .. Really difficult to explain <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":(" alt="😞" /><br />
Especially when beeing on a mobile device x/</p>
]]></description><link>http://developers.maxon.net/forum/post/25719</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25719</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:39 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:39 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 12:44, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Why are you redefining the global variable in the main section after it's already been defined?<br />
When I use this code. The if statement works as expected. And only executes if the scrubber is located beyond frame 10.</p>
<pre><code>import c4d  
global prevframe  
  
def main() :  
  prevframe = 10  
  frame = doc.GetTime().GetFrame(doc.GetFps()) #Gets the frame the scrubber is on  
  if frame &gt; prevframe:  
   print "true"  
</code></pre>
<p dir="auto">From there any other kind of code can be written to test the location of the scrubber. In relation to the the other frames.<br />
Including the usage of:  doc.GetMinTime().GetFrame(fps) &amp; doc.GetMaxTime().GetFrame(fps).<br />
And they all seem to work fine for me.</p>
<p dir="auto">I'm confused about what the heck you're doing. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f635.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--dizzy_face" style="height:23px;width:auto;vertical-align:middle" title=":dizzy_face:" alt="😵" /><br />
Hopefully someone else with more experience will understand it better than me. Good Luck.</p>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25718</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25718</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:39 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:39 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 11:51, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hehe, of course I didn't write the whole Code in here, but thanks anyway Scott. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /><br />
This was just an example how i tried to do it. The Fullcode looks something like this, on a Generator or Tag.</p>
<pre><code>import c4d   
  
global prevframe   
prevframe = 0   
  
def main() :   
  frame = doc.GetTime().GetFrame(doc.GetFps())   
  
  if frame &gt; prevframe:   
      pass    # The Stuff i want to do with the Deltatime   
  
  global prevframe   
  prevframe = frame   
</code></pre>
<p dir="auto">Setting the Prevframe to Frame-1 makes no Sense actually in Case i want to check if the actual frame is really next to the previous frame. So i can figure out if the timeline is playing. If I replace the commwnt for example with this:</p>
<pre><code>  
op.SetAbsPos(op.GetAbsPos()*2)   
</code></pre>
<p dir="auto">The object will moved even the timeline is not playing, because of the Editorupdate and the Deltatime if-expression doesnt work .. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /></p>
<p dir="auto">cheers, nux</p>
]]></description><link>http://developers.maxon.net/forum/post/25717</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25717</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:39 GMT</pubDate></item><item><title><![CDATA[Reply to Deltatime ? on Wed, 09 May 2018 17:51:39 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 22/02/2011 at 10:57, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">AFAIK. You can't go directly to getting frame info.<br />
You have to first call the baseTime class using doc.GetTime(). Then from there you can proceed and get access to the frame data.</p>
<pre><code>import c4d  
from c4d import gui  
  
def main() :  
  global previousframe #The frame to the left of the time scrubber  
  
  time = doc.GetTime()    
  frame = time.GetFrame(doc.GetFps())  
  previousframe = frame -1   
  print previousframe  
  
  
if __name__=='__main__':  
  main()  
</code></pre>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25716</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25716</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:39 GMT</pubDate></item></channel></rss>