[cgkit-commits] cgkit2/doc/tutorials/animation animation.txt,1.1.1.1,1.2
Brought to you by:
mbaas
From: Matthias B. <mb...@us...> - 2004-12-19 21:26:27
|
Update of /cvsroot/cgkit/cgkit2/doc/tutorials/animation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23616/animation Modified Files: animation.txt Log Message: Added code examples and enabled syntax highlighting for code snippets in rst text Index: animation.txt =================================================================== RCS file: /cvsroot/cgkit/cgkit2/doc/tutorials/animation/animation.txt,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** animation.txt 12 Dec 2004 14:32:00 -0000 1.1.1.1 --- animation.txt 19 Dec 2004 21:25:44 -0000 1.2 *************** *** 209,213 **** function that takes a few inputs and creates the desired output value, then you can actually have cgkit create the component for you. You ! only have to provide the function. Here is an example:: # A controller function that takes the average of two vec3 values --- 209,215 ---- function that takes a few inputs and creates the desired output value, then you can actually have cgkit create the component for you. You ! only have to provide the function. Here is an example: ! ! .. code-block:: Python # A controller function that takes the average of two vec3 values *************** *** 255,259 **** By the way, the above example could also have been written using an ! expression:: s3 = Sphere( radius=0.1, material=GLMaterial(diffuse=(1,0,0))) --- 257,263 ---- By the way, the above example could also have been written using an ! expression: ! ! .. code-block:: Python s3 = Sphere( radius=0.1, material=GLMaterial(diffuse=(1,0,0))) *************** *** 274,278 **** class. For the sake of simplicity, we will write the above ``Average`` component without using ``createFunctionComponent()``. Here is the entire ! example:: class Average(Component): --- 278,284 ---- class. For the sake of simplicity, we will write the above ``Average`` component without using ``createFunctionComponent()``. Here is the entire ! example: ! ! .. code-block:: Python class Average(Component): *************** *** 317,321 **** av.output_slot.connect(s3.pos_slot) ! Now we'll walk through the example step by step.:: class Average(Component): --- 323,329 ---- av.output_slot.connect(s3.pos_slot) ! Now we'll walk through the example step by step. ! ! .. code-block:: Python class Average(Component): *************** *** 323,327 **** Every component class has to be subclassed from the ``Component`` base class which already defines a few methods such as the ``iterSlots()`` ! method, for example.:: def __init__(self, name="Average", auto_insert=True): --- 331,337 ---- Every component class has to be subclassed from the ``Component`` base class which already defines a few methods such as the ``iterSlots()`` ! method, for example.: ! ! .. code-block:: Python def __init__(self, name="Average", auto_insert=True): *************** *** 332,336 **** component instance and the second is a flag that determines if the component instance will be added to the scene automatically or not. If ! it's part of the scene, it's visible to other objects.:: # Create the input slots --- 342,348 ---- component instance and the second is a flag that determines if the component instance will be added to the scene automatically or not. If ! it's part of the scene, it's visible to other objects. ! ! .. code-block:: Python # Create the input slots *************** *** 361,365 **** either serve as input or output whereas a procedural slot can only serve as output because its value is procedurally computed. In our ! example, the procedure is the ``computeOutput()`` method.:: # Add the slots to the component --- 373,379 ---- either serve as input or output whereas a procedural slot can only serve as output because its value is procedurally computed. In our ! example, the procedure is the ``computeOutput()`` method. ! ! .. code-block:: Python # Add the slots to the component *************** *** 370,374 **** These three lines add the slots to the component. It's not vital to do so, but it allows other code to find out what slots are available (via ! iterSlots(), for example).:: # Set up slot dependencies --- 384,390 ---- These three lines add the slots to the component. It's not vital to do so, but it allows other code to find out what slots are available (via ! iterSlots(), for example). ! ! .. code-block:: Python # Set up slot dependencies *************** *** 381,385 **** set up these dependencies the output slot would never invalidate its cache and the ``computeOutput()`` method would only be called once and ! then never again.:: def computeOutput(self): --- 397,403 ---- set up these dependencies the output slot would never invalidate its cache and the ``computeOutput()`` method would only be called once and ! then never again. ! ! .. code-block:: Python def computeOutput(self): *************** *** 389,393 **** slot. Note that in this example, the method uses the attribute a and b which have not been created in the constructor. However, they are ! defined nevertheless because of the next three lines:: # Create value attributes --- 407,413 ---- slot. Note that in this example, the method uses the attribute a and b which have not been created in the constructor. However, they are ! defined nevertheless because of the next three lines: ! ! .. code-block:: Python # Create value attributes *************** *** 431,435 **** connected to that event. In our case, it's the ``STEP_FRAME`` event that'll do the trick. This event occurs whenever the time value in the ! timer component is increased. Here is an example:: def spam(): --- 451,457 ---- connected to that event. In our case, it's the ``STEP_FRAME`` event that'll do the trick. This event occurs whenever the time value in the ! timer component is increased. Here is an example: ! ! .. code-block:: Python def spam(): *************** *** 441,445 **** string "Spam & eggs" is continuously printed to the console (one line per frame). Now instead of printing garbage you could just as well ! modify some objects in your scene:: sphere = Sphere() --- 463,469 ---- string "Spam & eggs" is continuously printed to the console (one line per frame). Now instead of printing garbage you could just as well ! modify some objects in your scene: ! ! .. code-block:: Python sphere = Sphere() |