2
* @page ephysics_examples EPhysics Examples
5
* @li @ref tutorial_ephysics_bouncing_ball
6
* @li @ref tutorial_ephysics_bouncing_text
7
* @li @ref tutorial_ephysics_camera
8
* @li @ref tutorial_ephysics_camera_track
9
* @li @ref tutorial_ephysics_collision_detection
10
* @li @ref tutorial_ephysics_collision_filter
11
* @li @ref tutorial_ephysics_delete_body
12
* @li @ref tutorial_ephysics_constraint
13
* @li @ref tutorial_ephysics_forces
14
* @li @ref tutorial_ephysics_growing_balls
15
* @li @ref tutorial_ephysics_gravity
16
* @li @ref tutorial_ephysics_logo
17
* @li @ref tutorial_ephysics_rotating_forever
18
* @li @ref tutorial_ephysics_velocity
19
* @li @ref tutorial_ephysics_shapes
20
* @li @ref tutorial_ephysics_sleeping_threshold
21
* @li @ref tutorial_ephysics_slider
25
* @page tutorial_ephysics_bouncing_ball EPhysics - Bouncing Ball
27
* The purpose of this example is to show how to write an simple application -
28
* as the name suggests - with a small ball bouncing on the ground and
29
* responding to users events by making it jump - applying a central impulse on
32
* @image html bouncing_ball.png
33
* @image latex bouncing_ball.eps
35
* We'll guide you on defining a EPhysics world, defining its render geometry
36
* and the physics limiting boundaries, you'll learn how to add EPhysics bodies
37
* and how to associate it to evas objects. We also explain how to change
38
* restitution and friction properties. We see how to apply central impulse on
39
* a EPhysics_Body by implementing an elementary input event callback and
40
* calling the proper function.
42
* @section test-structure A test struct
43
* @dontinclude ephysics_test.h
45
* While in this example we'll be working with a struct to hold some objects in
46
* our code. For clarity sake we present you the struct declaration in the
50
* @skip struct _Test_Data
53
* @section world-new World Initialization
54
* @dontinclude test_bouncing_ball.c
56
* Calling ephysics_world_new()
57
* will create a new physics world with its collision configuration, constraint
58
* solver, broadphase interface and dispatcher.
60
* The default gravity is set to -9.81. It's possible to stop a running world
61
* but its default status is running. Take a look at
62
* ephysics_world_running_set() for further informations about world running
65
* @skipline ephysics_world_new
67
* @section render-geometry Render geometry
69
* By setting the render geometry you tell ephysics the dimensions of rendered
70
* area to be take on account by default updates.
72
* By default it starts with null x, y, z, width, height and depth. Initially
73
* there's no physics limits but - as we'll see later in this example -
74
* boundaries can be added by issuing either ephysics_body_top_boundary_add(),
75
* ephysics_body_bottom_boundary_add(), ephysics_body_left_boundary_add() and
76
* ephysics_body_right_boundary_add().
78
* While setting the worlds render geometry the first parameter is our just
79
* created world, the following parameters indicate the x, y, z, width, height
80
* and depth of our area of interest.
82
* @skip ephysics_world_render_geometry_set
85
* @section boundaries Adding boundaries
87
* Boundaries are physics limits added by EPhysics which you can use to limit
88
* the area where your objects can move around. Bear in mind that those
89
* boundaries are created by EPhysics taking in account the render geometry you
90
* have previously defined by calling ephysics_world_render_geometry_set().
92
* In our example we start by adding a bottom boundary. This EPhysics_Body
93
* represents a physics limit under the world render geometry.
95
* The second line states the restitution factor for that bottom boundary, and
96
* the third line its friction. These changes will make our ball to bounce
97
* whenever it hits the ground.
99
* @skip ephysics_body_bottom_boundary_add
100
* @until ephysics_body_friction_set
102
* Then we add a right boundary limiting the physics world on the left side, we
103
* also change its restitution and friction factors but with a smaller value,
104
* we don't want to make it bounce as much as it is when hits the ground.
106
* @skip ephysics_body_right_boundary_add
107
* @until ephysics_body_friction_set
109
* We also add a left boundary taking the same considerations for right
112
* @skip ephysics_body_left_boundary_add
113
* @until ephysics_body_friction_set
115
* One of this examples requirements is to make the ball jump after a specific
116
* user event, so the ball can suffer an impulse for any direction.
118
* With an upper impulse we don't want our ball to fly all over there, we want
119
* to limit its upper movements, it's intended to limit the ball movement
120
* within a box, it should not leave the render geometry area, for that purpose
121
* we must define a top boundary.
123
* @skipline ephysics_body_top_boundary_add
124
* @dontinclude test_bouncing_ball.c
126
* @section world-populate Adding a ball
128
* Since we have defined the physics limits with our boundaries it's time to
129
* add some fun. Here we add a ball as an elementary image widget and tell
132
* After setting the file that will be used as the image's source of our elm
133
* image we move it to the center of render geometry and resize it to 70x70
134
* pixels and show it.
136
* @skip elm_image_add
137
* @until evas_object_show
139
* The evas object is just set and we must tell EPhysics about it, creating the
140
* EPhysics_Body representing our ball and associating it to the just created
143
* Once the ball has been moved to the center of render geometry it should
144
* start falling after associating it to the EPhysics_Body. By default its mass
145
* is initially set to 1 kilo, but it can be changed by calling
146
* ephysics_body_mass_set(). Bear in mind that if you change its mass to 0
147
* kilos it becomes a static body and will not move at all, the body will
148
* remain fixed in the initial position.
150
* In the following code the first line adds a circle body, then we associate
151
* the evas object to EPhysics_Body, EPhysics will map every changes on physics
152
* object simulation to its evas object. Some restitution and friction factors
155
* @skip ephysics_body_cylinder_add
156
* @until ephysics_body_friction_set
158
* @section jumping-ball Making it jump
160
* The next step is to give us the ability to make our ball to jump - actually
161
* apply some impulse whenever a key has been pressed. Then we add a elementary
162
* input callback to the window widget.
164
* @skipline elm_object_event_callback_add
166
* @dontinclude test_bouncing_ball.c
168
* The jumping callback implementation consists on handling only key up events
169
* and discarding any other input event we get. We're interested on keyboard
170
* events only. All the operations done in the following lines are done on
171
* sphere EPhysics_Body previously created.
173
* We mainly use the ephysics_body_central_impulse_apply() function. This
174
* function applies an impulse on the center of a body.
176
* Once pressed \<Up> key it applies a central impulse of 0 kilos on X axis,
177
* 10 kilos on Y and 0 kilos on Z - so the ball is forced up.
179
* If \<Down> key has been pressed we apply an impulse of 0 kilos on X axis,
180
* -10 kilos on Y and 0 kilos on Z - here the ball is forced down.
182
* In the case of \<Right> key pressing it's applied an impulse of 10 kilos on X
183
* axis, 0 kilos on Y and 0 kilos on Z - which applies a force to the right side.
184
* But if the key being pressed is \<Left> the opposite is done, and an impulse
185
* of -10 kilos is applied on X, 0 kilos on Y and 0 kilos on Z - and the ball is
186
* forced to the left.
191
* Here we finish the very simple bouncing ball example. The full source code
192
* can be found at @ref test_bouncing_ball_c.
197
* @page test_bouncing_ball_c test_bouncing_ball.c
200
* @include ephysics_test.h
202
* @section test-bouncing-ball-c test_bouncing_ball.c
203
* @dontinclude test.c
207
* @skip test_data_new
213
* @include test_bouncing_ball.c
216
* @example test_bouncing_ball.c
220
* @page tutorial_ephysics_bouncing_text EPhysics - Bouncing Text
222
* The purpose of this example is to demonstrate the EPhysics_Body binding to
223
* a text (Evas_Object)
225
* @image html bouncing_text.png
226
* @image latex bouncing_text.eps
228
* For this example we'll have an EPhysics_World and one basic EPhysics_Body.
230
* The basic concepts like - initializing an EPhysics_World, render geometry,
231
* physics limiting boundaries, were already covered in
232
* @ref tutorial_ephysics_bouncing_ball
234
* @section add-text Creating the text
235
* @dontinclude test_bouncing_text.c
237
* Create a basic evas_object_text.
239
* @skipline Evas_Object *text;
244
* @section add-textbody Creating the body
246
* Create a simple EPhysics_Body.
248
* Note that we use ephysics_body_geometry_set() to define its size because
249
* the evas_object has a different size that we want to represent physically.
250
* The text may have accent or letters like j and g.
252
* @skipline text_body =
253
* @skip ephysics_body_geometry_set(text_body
256
* @section text-binding Binding
257
* @dontinclude test_bouncing_text.c
259
* After creating the body and the text, now we need to bind them.
261
* We set the last parameter as EINA_FALSE because in this example we don't
262
* want to set the physics body position to match evas object position.
264
* @skipline ephysics_body_evas_object_set
266
* Here we finish the example. The full source code can be found at
267
* @ref test_bouncing_text_c.
272
* @page test_bouncing_text_c test_bouncing_text.c
275
* @include ephysics_test.h
277
* @section test-bouncing_text-c test_bouncing_text.c
278
* @dontinclude test.c
283
* @skip test_data_new
289
* @include test_bouncing_text.c
291
* @example test_bouncing_text.c
295
* @page tutorial_ephysics_camera EPhysics - Camera
297
* The purpose of this example is to demonstrate the EPhysics_Camera usage.
299
* The EPhysics_Camera facilitates the usage of scenarios bigger than the
300
* viewport, that's because the EPhysics handles the position of objects
303
* @image html camera.png
304
* @image latex camera.eps
306
* For this example we'll have an EPhysics_World, two distant EPhysics_Bodys,
307
* one with an impulse to collide each other and an EPhysics_Camera that
308
* follows the moving body using an animator.
310
* The basic concepts like - initializing an EPhysics_World, render geometry,
311
* physics limiting boundaries, add an Ephysics_Body, associate it to evas
312
* objects, change restitution, friction and impulse properties, were
314
* @ref tutorial_ephysics_bouncing_ball
316
* @section add-camstruct Camera Data Struct
317
* @dontinclude test_camera.c
319
* While in this example we'll be working with a struct to hold some objects
320
* in our code. For clarity sake we present you the struct declaration in the
323
* @skip struct _Camera_Data {
328
* To move the camera in this example, we'll use an animator.
330
* @skipline camera_data->animator = ecore_animator_add
332
* In the animators function, we'll have to create a specific type of variable:
333
* @ref EPhysics_Camera
334
* And also get the worlds rendered area width to define a limit to the camera.
336
* @dontinclude test_camera.c
338
* @skip _camera_move_cb(void *data
339
* @until &w, NULL, NULL);
341
* Every world has a camera, so here we get this camera used by our
344
* @skipline camera = ephysics_world_camera_get
346
* Here we get the cameras position to after set the position based on previous.
348
* @skipline ephysics_camera_position_get(camera
350
* Here we check if the camera reached the end of scenario (define the limit
351
* to the camera) then we stop the animator, else we move the camera + 2
352
* pixel positions to the right.
354
* @skip if (x + w > WIDTH * 2)
355
* @until ephysics_camera_position_set(camera, x, y
358
* # Updating the floor
360
* Here we'll use 2 floor images to give the impression of an infinite ground.
362
* Calling ephysics_world_event_callback_add()
363
* will register a callback to a type of physics world event.
365
* @ref EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED : called if the camera position
366
* changed on physics simulation tick.
368
* @skip ephysics_world_event_callback_add(world,
369
* @until _camera_moved_cb, camera_data);
371
* In the function, we just get the cameras position to know how much
372
* the camera moved and move the same value to the floor passing it as
373
* delta_x to the function, note that we use an old_x variable to do this
375
* @dontinclude test_camera.c
377
* @skip _camera_moved_cb(void *data
380
* Here we get the floors position and plus the delta_x value to move the
381
* floor in the same "velocity".
383
* @dontinclude test_camera.c
385
* @skip _update_floor
386
* @until fx = x + delta
388
* We use 2 floor images because whenever one exits the screen by the left
389
* side, another is being shown, when it happens the one which exit the screen
390
* is sent to the right side, entering into an infinite loop, giving the
391
* impression of an infinite ground image. Its important to note that we need
392
* to use the fx to don't gap the images.
394
* @skip if (fx < -FLOOR_WIDTH
397
* Here we finish the example. The full source code can be found at
398
* @ref test_camera_c.
403
* @page test_camera_c test_camera.c
406
* @include ephysics_test.h
408
* @section test-camera-c test_camera.c
409
* @dontinclude test.c
417
* @include test_camera.c
419
* @example test_camera.c
423
* @page tutorial_ephysics_camera_track EPhysics - Camera Track
425
* The purpose of this example is to demonstrate the EPhysics_Camera Track
428
* The EPhysics_Camera facilitates the usage of scenarios bigger than the
429
* viewport, that's because the EPhysics handles the position of objects
432
* @image html camera_track.png
433
* @image latex camera_track.eps
435
* For this example we'll have an EPhysics_World, one main EPhysics_Body that
436
* will be tracked by an EPhysics_Camera on three ways, horizontal, vertical
437
* and full tracking. Also nine EPhysics_Bodys with mass 0, that will be used
438
* as scenario in order to our main body change its position on x and y axes
439
* when passes through this scenario.
441
* The basic concepts like - initializing an EPhysics_World, render geometry,
442
* physics limiting boundaries, add an Ephysics_Body, associate it to evas
443
* objects, change restitution, friction and impulse properties, were
445
* @ref tutorial_ephysics_bouncing_ball
447
* @section add-trkstruct Track Data Struct
448
* @dontinclude test_camera_track.c
450
* While in this example we'll be working with a struct to hold some objects
451
* in our code. For clarity sake we present you the struct declaration in the
454
* @skip struct _Track_Data {
459
* In this example we'll use 3 kinds of tracking, to change this values we'll
460
* have an Elementary spinner widget and handle it on this function.
462
* Every world has a camera, so here we get this camera used by our
465
* @skip _track_apply(Track_Data *track
466
* @until camera = ephysics_world_camera_get(track_data->base.world
468
* Here we'll get the elm_spinner value to the tracking base on this
474
* Here we'll set the camera to track the body, when a body is tracked,
475
* the camera will move automatically, following this body. It will keeps the
476
* body centralized on rendered area. If it will be centralized horizontally
477
* and / or vertically depends if parameters horizontal and vertical are set
478
* to EINA_TRUE, in this case we based these values on elm_spinner.
480
* @skip ephysics_camera_body_track(camera, body
483
* # Updating the floor
485
* Here we'll use 2 floor images to give the impression of an infinite ground.
487
* Calling ephysics_world_event_callback_add()
488
* will register a callback to a type of physics world event.
490
* @ref EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED : called if the camera position
491
* changed on physics simulation tick.
493
* @skip ephysics_world_event_callback_add(world,
494
* @until _camera_moved_cb, track_data);
496
* In the function, we'll get the cameras position to know how much the camera
497
* moved and move the same value to the floor passing it as delta_x to the
498
* function, note that we use an old_x variable to do this calculation.
500
* We'll get also if the body is being tracked on x and y axes. If the body
501
* isn't being tracked on x axis the floors x position won't change, delta_x
504
* @dontinclude test_camera_track.c
506
* @skip _camera_moved_cb(void *data
509
* Here we get the floors position and plus the delta_x value to move the
510
* floor in the same "velocity".
512
* @dontinclude test_camera_track.c
514
* @skip _update_floor
515
* @until fx = x + delta
517
* We use 2 floor images because whenever one exits the screen by the left
518
* side, another is being shown, when it happens the one which exit the screen
519
* is sent to the right side, entering into an infinite loop, giving the
520
* impression of an infinite ground image. Its important to note that we need
521
* to use the fx to don't gap the images.
523
* Note that the fy is being defined considering its offsets, -20 is to the
524
* floor image be above the floor, thus having an border above the collision
525
* point, +40 is the render area height, to offset the cameras y, basically
526
* to draw in the correct position in the canvas.
528
* @skip if (fx < -FLOOR_WIDTH
531
* Here we finish the example. The full source code can be found at
532
* @ref test_camera_track_c.
537
* @page test_camera_track_c test_camera_track.c
540
* @include ephysics_test.h
542
* @section test-camera-track-c test_camera_track.c
543
* @dontinclude test.c
551
* @include test_camera_track.c
553
* @example test_camera_track.c
557
* @page tutorial_ephysics_collision_detection EPhysics - Collision Detection
559
* The purpose of this example is to demonstrate the EPhysics Collision
560
* Detection usage - The code adds two balls, one with impulse and the second
561
* with a collision detection callback, to show an effect.
563
* @image html collision_detection.png
564
* @image latex collision_detection.eps
566
* For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys,
567
* we'll apply an impulse in one of then and the other will be stopped
568
* "waiting" for a collision.
570
* The basic concepts like - initializing an EPhysics_World, render geometry,
571
* physics limiting boundaries, add an Ephysics_Body, associate it to evas
572
* objects, change restitution, friction and impulse properties, were
574
* @ref tutorial_ephysics_bouncing_ball
576
* @section add-collstruct Collision Data Struct
577
* @dontinclude test_collision_detection.c
579
* While in this example we'll be working with a struct to hold some objects
580
* in our code. For clarity sake we present you the struct declaration in the
583
* @skip struct _Collision_Data {
586
* # Adding the Callback
588
* Calling ephysics_body_event_callback_add()
589
* will register a callback to a type of physics body event.
591
* @ref EPHYSICS_CALLBACK_BODY_COLLISION : called just after the collision has
592
* been actually processed by the physics engine. In other words, to be
593
* notified about a collision between two physical bodies.
595
* @skip ephysics_body_event_callback_add(collision_data->sphere
599
* @ref _EPhysics_Callback_Body_Type
600
* for more event types.
602
* @section add-collcb Collision Function
604
* The callback function will filter the collision to be sure if that body is
605
* which we want and then show the effect.
607
* First we need to create a specific variable type to get collision infos:
608
* @ref EPhysics_Body_Collision
610
* @dontinclude test_collision_detection.c
612
* @skip _collision_cb
613
* @until int x, y, z;
615
* Now we want to know which body collides with and filter it.
617
* @skip contact_body =
620
* We just get the collision position, move the impact effect to this
621
* coordinate and send a signal to edje to show it.
623
* @skip ephysics_body_collision_position_get
624
* @until "ephysics_test");
627
* Here we finish the example. The full source code can be found at
628
* @ref test_collision_detection_c.
633
* @page test_collision_detection_c test_collision_detection.c
636
* @include ephysics_test.h
638
* @section test-collision_detection-c test_collision_detection.c
639
* @dontinclude test.c
647
* @include test_collision_detection.c
649
* @example test_collision_detection.c
653
* @page tutorial_ephysics_collision_filter EPhysics - Collision Filter
655
* The purpose of this example is to demonstrate the EPhysics Collision Filter
656
* usage - The code adds four balls in 2 rows and 2 columns, two on each
657
* collision group, the collision only happens when the balls are in the
658
* same group (row),to make it easier, balls in the same group has the same
661
* @image html collision_filter.png
662
* @image latex collision_filter.eps
664
* For this example we'll have an EPhysics_World and four basic EPhysics_Bodys,
665
* we'll apply an impulse on then and see what happens when they're in other
668
* The basic concepts like - initializing an EPhysics_World, render geometry,
669
* physics limiting boundaries, add an Ephysics_Body, associate it to evas
670
* objects, change restitution, friction and impulse properties, were
672
* @ref tutorial_ephysics_bouncing_ball
675
* @dontinclude test_collision_filter.c
677
* We'll use two arrays (color and size) to distinguish the groups.
679
* @skip _world_populate
682
* The balls declaration was placed into a For loop, just to simplify the
683
* coding and divide them in two groups.
685
* @skip for (i = 0; i < 4
688
* Note in this part we divide the balls in two groups by color (row).
690
* @skipline ephysics_body_collision_group_add(fall_body
692
* The impulse will be applied in only 1 ball per group, in this case:
694
* The 1st row 2nd column ball will be applied an impulse to the
695
* left (-300kg * p/s).
697
* The 2nd row 1st column ball will be applied an impulse to the
698
* right (300kg * p/s).
700
* And then saving the body into a list.
702
* @skip if (column + row == 1
706
* Here we finish the example. The full source code can be found at
707
* @ref test_collision_filter_c.
712
* @page test_collision_filter_c test_collision_filter.c
715
* @include ephysics_test.h
717
* @section test-collision_filter-c test_collision_filter.c
718
* @dontinclude test.c
723
* @skip test_data_new
729
* @include test_collision_filter.c
731
* @example test_collision_filter.c
735
* @page tutorial_ephysics_delete_body EPhysics - Delete Body
737
* The purpose of this example is to demonstrate the EPhysics Callbacks usage -
738
* The code adds two balls, one with impulse and the second with a collision
739
* detection callback, to delete the body.
741
* For this example we'll have an EPhysics_World and two basic EPhysics_Bodys,
742
* we'll apply an impulse in one of then and the other will be stopped
743
* "waiting" for a collision.
745
* The basic concepts like - initializing an EPhysics_World, render geometry,
746
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
747
* objects, change restitution, friction and impulse properties, were already
749
* @ref tutorial_ephysics_bouncing_ball
752
* @dontinclude test_delete.c
754
* Calling ephysics_body_event_callback_add()
755
* registers a callback to a given EPhysics_Body event type.
757
* We'll use two types:
759
* @ref EPHYSICS_CALLBACK_BODY_DEL : called when a body deletion has been issued
760
* and just before the deletion actually happens. In other words, to know that
761
* body has been marked for
762
* deletion. Typically to free some data associated with the body.
764
* @skipline ephysics_body_event_callback_add(sphere_body1,
765
* @skip EPHYSICS_CALLBACK_BODY_DEL
768
* The callback function will receive the collision_data and free some data
769
* associated with the body.
771
* @dontinclude test_delete.c
773
* @skip _del_cb(void *data,
776
* @ref EPHYSICS_CALLBACK_BODY_COLLISION : called just after the collision has
777
* been actually processed by the physics engine. In other words, to be notified
778
* about a collision between two physical bodies.
780
* @skip ephysics_body_event_callback_add(collision_data->sphere,
783
* The callback function will get the collision body and check if its body is
784
* equal to which we want to delete.
786
* @dontinclude test_delete.c
788
* @skip _collision_cb(void *data,
792
* @ref _EPhysics_Callback_Body_Type
793
* for more event types.
795
* Here we finish the example. The full source code can be found at
796
* @ref test_delete_c.
801
* @page test_delete_c test_delete.c
804
* @include ephysics_test.h
806
* @section test-delete-c test_delete.c
807
* @dontinclude test.c
814
* @include test_delete.c
816
* @example test_delete.c
820
* @page tutorial_ephysics_constraint EPhysics - Constraint
822
* The purpose of this example is to demonstrate the EPhysics Constraint usage -
823
* The code apply a constraint between two cubes.
825
* For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.
827
* The basic concepts like - defining an EPhysics_World, render geometry,
828
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
829
* objects, change restitution, friction and impulse properties, were
831
* @ref tutorial_ephysics_bouncing_ball
833
* You can use also a slider constraint:
834
* @ref tutorial_ephysics_slider
836
* @section add-constraint Adding a constraint
837
* @dontinclude test_constraint.c
839
* Constraint is a specific type of variable in EPhysics.
841
* @skipline EPhysics_Constraint
843
* Here we're working with a point-to-point constraint, its purpose is to join
844
* two bodies limiting their movements based on specified anchors.
846
* After we create our 2 EPhysics_Bodys, now we'll add a constraint between
847
* them and setting an anchor to first body's Y using a p2p constraint
850
* @skip constraint = ephysics_constraint_p2p
853
* Here we finish the example. The full source code can be found at
854
* @ref test_constraint_c.
859
* @page test_constraint_c test_constraint.c
862
* @include ephysics_test.h
864
* @section test-constraint-c test_constraint.c
865
* @dontinclude test.c
870
* @skip test_data_new
876
* @include test_constraint.c
878
* @example test_constraint.c
882
* @page tutorial_ephysics_forces EPhysics - Forces
884
* The purpose of this example is to demonstrate the EPhysics Force usage -
885
* The code applies force over two cubes.
887
* @image html forces.png
888
* @image latex forces.eps
890
* For this example we'll have an EPhysics_World with gravity setted to zero,
891
* and two basic EPhysics_Bodys.
893
* The basic concepts like - defining an EPhysics_World, render geometry,
894
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
895
* objects, change restitution, friction and impulse properties, were
897
* @ref tutorial_ephysics_bouncing_ball
899
* @section add-force Adding a Force
900
* @dontinclude test_forces.c
902
* We apply a force over the first body to change its linear and angular
903
* accelerations. Applying a force to a body will lead it to change its
904
* velocity gradually.
906
* Note that in this blue cube we use an offset to apply the force, the two
907
* last parameters are responsible to set a relative position to apply the
908
* force.In other words, the force applied with an offset will make the body
909
* rotates. Otherwise (0, 0, 0) the force would be applied on the center of the
910
* body, in this case its recommended use the
911
* ephysics_body_central_force_apply();
913
* @skipline ephysics_body_force_apply(box_body1
915
* Here we apply a central force over the second body avoiding affect the
916
* angular acceleration (rotate).
918
* @skipline ephysics_body_central_force_apply(box_body2
920
* We can also get all the forces applied over a body, including gravity, but
921
* in this case we setted to zero.
923
* @dontinclude test_forces.c
925
* @skipline ephysics_body_forces_get(
927
* Here we finish the example. The full source code can be found at
928
* @ref test_forces_c.
933
* @page test_forces_c test_forces.c
936
* @include ephysics_test.h
938
* @section test-forces-c test_forces.c
939
* @dontinclude test.c
944
* @skip test_data_new
950
* @include test_forces.c
952
* @example test_forces.c
956
* @page tutorial_ephysics_growing_balls EPhysics - Growing Balls
958
* The purpose of this example is to demonstrate the dynamically growing
959
* and shrinking of an EPhysics_Body - The code applies the growth of a ball
960
* and the shrink of another.
962
* @image html growing_balls.png
963
* @image latex growing_balls.eps
965
* For this example we'll have an EPhysics_World and three EPhysics_Bodys
966
* with different sizes associated with an evas_object.
968
* The basic concepts like - defining an EPhysics_World, render geometry,
969
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
970
* objects, change restitution, friction and impulse properties, were
972
* @ref tutorial_ephysics_bouncing_ball
974
* @section add-growshrink Adding the growing/shrinking
975
* @dontinclude test_growing_balls.c
977
* In this example we'll use a timer to handle the callback function.
979
* @skipline test_data->data = ecore_timer_add
981
* In this callback, we'll pass through a list with 3 balls and apply the
982
* growth and the shrink between the limit we'll set. Note that the variable
983
* i receives different values on each iteration (-1, 0, 1). For the first
984
* iteration it will decrease the size variable, the second will keep the
985
* same value, and the last one will increase the size variable.
987
* @dontinclude test_growing_balls.c
989
* @skip _grow_cb(void *data
990
* @until return EINA_TRUE;
993
* Here we finish the example. The full source code can be found at
994
* @ref test_growing_balls_c.
999
* @page test_growing_balls_c test_growing_balls.c
1002
* @include ephysics_test.h
1004
* @section test-growing-balls-c test_growing_balls.c
1005
* @dontinclude test.c
1010
* @skip test_data_new
1013
* @skip test_win_add
1016
* @include test_growing_balls.c
1018
* @example test_growing_balls.c
1022
* @page tutorial_ephysics_gravity EPhysics - Gravity
1024
* The purpose of this example is to demonstrate the EPhysics Gravity usage -
1025
* The code apply gravity in an EPhysics_World with two cubes in movement.
1027
* @image html no_gravity.png
1028
* @image latex no_gravity.eps
1030
* For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.
1032
* The basic concepts like - defining an EPhysics_World, render geometry,
1033
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
1034
* objects, change restitution, friction and impulse properties, were
1035
* already covered in
1036
* @ref tutorial_ephysics_bouncing_ball
1038
* Concepts like velocity and sleeping threshold were already
1040
* @li @ref tutorial_ephysics_velocity
1041
* @li @ref tutorial_ephysics_sleeping_threshold
1043
* @section add-gravity Setting Gravity
1044
* @dontinclude test_no_gravity.c
1046
* Here we set gravity on 3 axes (x, y, z) to (0, 0, 0). Gravity will act
1047
* over bodies with mass over all the time.
1049
* @skipline ephysics_world_gravity_set
1051
* @section add-stopbody Stopping a Body
1052
* @dontinclude test_no_gravity.c
1054
* We're using a button to call this function that receives test_data to stop
1057
* Stop angular and linear body movement, its equivalent to set linear velocity
1058
* to 0 on both axis and angular velocity to 0 as well.
1060
* @skip _stop(void *data
1064
* Here we finish the example. The full source code can be found at
1065
* @ref test_no_gravity_c.
1070
* @page test_no_gravity_c test_no_gravity.c
1073
* @include ephysics_test.h
1075
* @section test-no-gravity-c test_no_gravity.c
1076
* @dontinclude test.c
1081
* @skip test_data_new
1084
* @skip test_win_add
1087
* @include test_no_gravity.c
1089
* @example test_no_gravity.c
1093
* @page tutorial_ephysics_logo EPhysics - Logo
1095
* The purpose of this example is to demonstrate the EPhysics_Logo.
1097
* For this example we'll have an EPhysics_World.
1099
* The basic concepts like - initializing an EPhysics_World, render geometry,
1100
* physics limiting boundaries, were already covered in
1101
* @ref tutorial_ephysics_bouncing_ball
1103
* @section add-logostruct Logo Data Struct
1104
* @dontinclude ephysics_logo.c
1106
* While in this example we'll be working with a struct to hold some objects
1107
* in our code. For clarity sake we present you the struct declaration in the
1110
* @skip struct letter_desc {
1113
* @section add-lett Adding the letters
1114
* @dontinclude ephysics_logo.c
1116
* To add the letters we'll use this function that creates the shadow, light
1117
* and letter images.
1119
* @skip _letter_add(Evas *evas
1122
* In this loop we'll use the function letter_add using the falling_letters
1123
* declared in logo data struct.
1125
* @skip for (i = 0; i < EINA_C_ARRAY
1126
* @until (image, &w, &h);
1128
* Place image and light on top, above what the viewport can show, to fall
1131
* @skip evas_object_move(image, x,
1132
* @until evas_object_move(light, x, -h * (i + 1) - 50);
1134
* Place shadow below the hit-line: FLOOR_Y, centered at image.
1136
* @skipline evas_object_move(shadow, x + CENTER(w, sh_w
1138
* Here we set the letters padding and add letter body using the function
1139
* below and setting its friction.
1141
* @skip x += falling_letters[i].padd
1144
* Here we call another function that will be common to the circle body as
1145
* well, note that we add a callback that will be explained later.
1146
* @dontinclude ephysics_logo.c
1148
* @skip _letter_body_box_add(EPhysics_World *world
1151
* This function is used to create the body setting its properties. Note that
1152
* we disable its angular movement (rotation) on Z axis to this letters don't
1154
* @dontinclude ephysics_logo.c
1156
* @skip _letter_body_setup_common(EPhysics_Body *body
1159
* In this callback function that we added to our letter body we'll update its
1162
* First we'll update the body, get its image geometry and set the floor
1163
* distance based on images height.
1165
* @dontinclude ephysics_logo.c
1167
* @skip _update_box_cb(void *data
1168
* @until floor_distance = FLOOR_Y - h;
1170
* As long as the letter approaches the floor, its shadow is darker, with bigger y.
1172
* @skip if (y > SH_THRESHOLD)
1174
* @skipline alpha = 255 * (y - SH_THRESHOLD)
1176
* And with bigger x -- its proportional to x / WIDTH, but varies from 100 to
1179
* @skip pos_x = (double) x /
1180
* @until PROP_GET(pos_x, 100, 255);
1182
* Note that the box shadow is not resized, just moved. And here set also the
1185
* @skip evas_object_move(shadow, x +
1186
* @until alpha, alpha);
1188
* As long as the letter approaches the floor, its lighter, with bigger x and y.
1190
* @skipline evas_object_move(light, x
1191
* @skipline alpha = (y <= 0) ? 0 : y * 255
1192
* @skip alpha = alpha * (x - OFFSET_X + 80)
1195
* @section add-lettere Adding the letter E
1197
* Here we'll add the last letter, "E" is a circle that comes rolling on
1200
* First we use the letter_add function, set its shadow color and get
1203
* @skip _letter_add(evas, "E", &image
1204
* @until evas_object_image_size_get(image, &w, &h);
1206
* Place image and light above the floor and to the left of viewport, to comes
1209
* @skip evas_object_move(image, -w - 1, FLOOR_Y
1210
* @until evas_object_move(light, -w - 1, FLOOR_Y - h + 1);
1212
* Place the shadow below the hit-line: FLOOR_Y centered at image.
1214
* @skipline evas_object_move(shadow, -w - 1 + CENTER(w, sh_w)
1216
* Here we create the body using body_circle function and enable its rotation
1219
* @skip letter_body = _letter_body_circle_add
1220
* @until letter_body, EINA_TRUE);
1222
* Make the "E" logo get into the viewport by applying a horizontal force.
1224
* @skipline ephysics_body_central_impulse_apply(letter_body
1226
* Here we use the letter_body_setup_common to create the body and set its
1227
* properties, note that we add a callback that will be explained below.
1228
* @dontinclude ephysics_logo.c
1230
* @skip _letter_body_circle_add(EPhysics_World *world
1233
* In this callback function that we added to our "E" letter body we'll update
1234
* its light and shadow.
1236
* First we'll update the body and get its image geometry.
1238
* @dontinclude ephysics_logo.c
1240
* @skip _update_circle_cb(void *data
1241
* @until geometry_get(image, &x, &y, &w, &h);
1243
* As long as the letter approaches the floor, its lighter, with bigger x.
1245
* @skip evas_object_move(light, x
1246
* @until alpha, alpha);
1248
* Use the same map from image to the light (rotate it).
1250
* @skip map = evas_object_map_get(image
1251
* @until light, EINA_TRUE);
1253
* As long as the letter approaches the floor, its shadow is darker, with
1256
* @skip evas_object_image_size_get(shadow,
1257
* @until alpha, alpha);
1259
* When the letter "E" passes the viewport, we send it to the begin again to
1260
* collide with the other letters.
1262
* @skip if (x > E_THRESHOLD)
1265
* Here we finish the example. The full source code can be found at
1266
* @ref ephysics_logo_c.
1271
* @page ephysics_logo_c ephysics_logo.c
1273
* @section ephysics-logo-c ephysics_logo.c
1274
* @include ephysics_logo.c
1276
* @example ephysics_logo.c
1280
* @page tutorial_ephysics_rotating_forever EPhysics - Rotating Forever
1282
* The purpose of this example is to demonstrate the EPhysics Rotate usage -
1283
* The code applies different ways to rotate an EPhysics_Body, such as torque,
1284
* torque impulse and rotation set.
1286
* For this example we'll have an EPhysics_World with gravity setted to zero,
1287
* and four basic EPhysics_Bodys.
1289
* The basic concepts like - defining an EPhysics_World, render geometry,
1290
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
1291
* objects, change restitution, friction and impulse properties, were
1292
* already covered in
1293
* @ref tutorial_ephysics_bouncing_ball
1295
* @section add-rotate Rotating
1296
* @dontinclude test_rotating_forever.c
1298
* For the first body we'll apply a torque impulse to make it rotate around Z
1299
* axis (rotate on x-y plane). Will make the body rolls on clockwise rotation,
1300
* if the value is negative, the impulse will be on counter clockwise.
1302
* @skipline ephysics_body_torque_impulse_apply(body, 0, 0, 1);
1304
* For the second body we'll use an offset to apply the force, the three
1305
* last parameters are responsible to set a relative position to apply the
1306
* force.In other words, the force applied with an offset will make the body
1307
* rotates and move around the other cubes.
1309
* @skipline ephysics_body_impulse_apply(body, 30, 0
1311
* For the third body we'll use a timer to rotate the body and a callback to
1314
* @skip timer = ecore_timer_add(1, _rotate_cb
1315
* @until _del_cb, timer);
1317
* @dontinclude test_rotating_forever.c
1318
* @skip _del_cb(void *data
1321
* In the function we'll get the body rotation on z axis in degrees and handle
1322
* it increasing 5 degrees on its position on z axis on each tick of the timer.
1324
* @dontinclude test_rotating_forever.c
1325
* @skip _rotate_cb(void *data
1328
* For the forth body we'll use 2 timers, but before that, we'll apply an
1329
* initial torque, changing the body angular acceleration and a callback to
1330
* delete the timers we'll add.
1332
* @skipline ephysics_body_torque_apply(body, 0, 0, 2
1333
* @skipline ephysics_body_event_callback_add(body,
1334
* @skipline EPHYSICS_CALLBACK_BODY_DEL,
1335
* @skipline _del_torque_cb, cube);
1337
* Just the callback function to delete the timers.
1339
* @dontinclude test_rotating_forever.c
1340
* @skip _del_torque_cb(void *data
1343
* As we commented we'll use 2 timers, one to increase the torque and
1344
* another to stop the torque, cleaning the forces related to the body.
1346
* @skip timer = ecore_timer_add(3, _increase
1347
* @until "stop_timer", timer);
1349
* In the increase function we'll apply a torque over the body, changing
1350
* its angular acceleration, it will leads to a change on angular velocity
1351
* over time. We're using a timer to increase the angular acceleration on
1352
* each tick of the timer.
1354
* @dontinclude test_rotating_forever.c
1355
* @skip _increase_torque_cb(void *data
1358
* In the stop function we'll clear all the forces applied to the body,
1359
* setting its linear and angular acceleration to zero. We're using this
1360
* timer to "control" the body velocity, since we are increasing it by
1361
* another timer. Note that we set the acceleration to zero not the
1364
* @skip _stop_torque_cb(void *data
1367
* Here we finish the example. The full source code can be found at
1368
* @ref test_rotating_forever_c.
1373
* @page test_rotating_forever_c test_rotating_forever.c
1376
* @include ephysics_test.h
1378
* @section test-rotating-forever-c test_rotating_forever.c
1379
* @dontinclude test.c
1384
* @skip test_data_new
1387
* @skip test_win_add
1390
* @include test_rotating_forever.c
1392
* @example test_rotating_forever.c
1396
* @page tutorial_ephysics_velocity EPhysics - Velocity
1398
* The purpose of this example is to demonstrate the EPhysics Velocity usage -
1399
* The code adds a small bouncing ball on the ground and responding to users
1400
* events by making it jump - applying a central impulse on it and showing its
1401
* velocity and acceleration.
1403
* We'll see in this example how to get EPhysics_Body Linear and Angular
1404
* velocity and acceleration.
1406
* For this example we'll have an EPhysics_World and one basic EPhysics_Body,
1407
* we'll apply impulses that follows user events, it were already covered in
1408
* @ref tutorial_ephysics_bouncing_ball
1410
* @section add-velstruct Velocity Data Struct
1411
* @dontinclude test_velocity.c
1413
* While in this example we'll be working with a struct to hold some objects
1414
* in our code. For clarity sake we present you the struct declaration in the
1417
* @skip struct _Velocity_Data {
1420
* # Adding the Callbacks
1422
* Calling ephysics_body_event_callback_add()
1423
* will register a callback to a type of physics body event.
1425
* @ref EPHYSICS_CALLBACK_BODY_UPDATE : called after every physics iteration.
1426
* In other words, will be called after each world tick.
1428
* @skipline ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_
1429
* @skipline _update_vel_cb
1431
* @ref EPHYSICS_CALLBACK_BODY_STOPPED : called when a body is found to be
1432
* stopped. In other words, when the body is not moving anymore.
1434
* @skip ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_BODY_ST
1438
* @ref _EPhysics_Callback_Body_Type
1439
* for more event types.
1441
* @section add-velcb Velocity Function
1443
* The callback function will be called on every physics iteration to show the
1444
* linear and angular velocity and acceleration.
1446
* Here we're declaring the necessary variables to calculate acelerations and
1447
* delta time. And checking if its the first time to return before shows
1448
* informations about the velocity.
1450
* @dontinclude test_velocity.c
1452
* @skip _update_vel_cb(void *data,
1455
* Get the delta time to use it soon to calculate the acceleration on every
1456
* physics iteration.
1458
* @skip time_now = ecore_time_get();
1461
* Note in this part we get the angular and linear velocities.
1463
* @skip ephysics_body_angular_velocity_get
1464
* @until &vy, NULL);
1466
* We need to handle the velocity using delta time to have the acceleration
1467
* on every tick. Check if its the first time to return before shows
1468
* informations about the velocity because we don't have the old aceletations
1469
* and then the calculation of this informations will be wrong.
1471
* Here we calculate the aceletarions using this formula:
1473
* (velocity - old_velocity) / delta_time;
1475
* @skip aaz = (vaz -
1478
* Turning data into text, to pass it to edje shows on screen.
1480
* @skip snprintf(buff,
1481
* @until "linear_acc", buff);
1482
* @skip snprintf(buff,
1483
* @until "angular_acc", buff);
1486
* Here we finish the example. The full source code can be found at
1487
* @ref test_velocity_c.
1492
* @page test_velocity_c test_velocity.c
1495
* @include ephysics_test.h
1497
* @section test-velocity-c test_velocity.c
1498
* @dontinclude test.c
1503
* @skip test_win_add
1506
* @include test_velocity.c
1508
* @example test_velocity.c
1512
* @page tutorial_ephysics_shapes EPhysics - Shapes
1514
* The purpose of this example is to demonstrate the EPhysics Shapes
1515
* usage - The code creates two EPhysics_Bodys using a custom shape.
1517
* @image html shapes.png
1518
* @image latex shapes.eps
1520
* For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.
1522
* The basic concepts like - defining an EPhysics_World, render geometry,
1523
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
1524
* objects, change restitution, friction and impulse properties, were
1525
* already covered in
1526
* @ref tutorial_ephysics_bouncing_ball
1528
* @section add-shape Adding a Shape
1529
* @dontinclude test_shapes.c
1531
* Shapes are used to create bodies with shapes that differ from primitive
1532
* ones, like box and circle.
1534
* A shape consists in a group of points, the vertices of the body to be
1535
* created later with ephysics_body_shape_add(). You can also save and load
1538
* We'll have to create a specific type of variable:
1539
* @ref EPhysics_Shape
1541
* @skip _world_populate(Test_Data
1542
* @until Evas_Object *pentagon,
1544
* First we add an image we want to add an EPhysics_Body to have a reference
1545
* to after set the points (vertices).
1547
* @skip pentagon = elm_image_add
1548
* @until evas_object_show(pentagon);
1550
* Here we create a new shape, note that the returned shape initially
1551
* doesn't has points set, so its requiered to set vertices.
1553
* @skipline pentagon_shape =
1555
* Now we're setting the shape points (vertices) basing on the image that
1556
* we added, two vertices form a link between them, an edge, so with some
1557
* vertices is possible to create polygons, in this case a pentagon.
1559
* @skip ephysics_shape_point_add(pentagon_shape
1560
* @until , 21/35., 1, 1);
1562
* Here we create a new physics body using a custom shape. The center of mass
1563
* will be the center of the shape. Its collision shape will be the convex
1564
* shape that has all the points (and edges) we added to this shape before.
1566
* @skip pentagon_body = ephysics_body_shape_add
1567
* @until ephysics_body_restitution_set(pentagon_body, 1);
1569
* Here we just delete the custom shape (not the body) after used to create
1570
* the wanted bodies, it's required to delete it. It won't be deleted
1571
* automatically by ephysics at any point, even on shutdown.
1573
* @skipline ephysics_shape_del(pentagon_shape
1575
* In the example we add another shape with the same process we just used,
1576
* but with different image and points.
1578
* @dontinclude test_shapes.c
1580
* @skip ephysics_shape_point_add(hexagon_shape
1581
* @until 18, 60, 10);
1583
* Here we finish the example. The full source code can be found at
1584
* @ref test_shapes_c.
1589
* @page test_shapes_c test_shapes.c
1592
* @include ephysics_test.h
1594
* @section test-shapes-c test_shapes.c
1595
* @dontinclude test.c
1600
* @skip test_data_new
1603
* @skip test_win_add
1606
* @include test_shapes.c
1608
* @example test_shapes.c
1612
* @page tutorial_ephysics_sleeping_threshold EPhysics - Sleeping Threshold
1614
* The purpose of this example is to demonstrate the EPhysics Sleeping
1615
* Threshold usage - The code apply sleeping threshold in two cubes.
1617
* For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.
1619
* The basic concepts like - defining an EPhysics_World, render geometry,
1620
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
1621
* objects, change restitution, friction and impulse properties, were
1622
* already covered in
1623
* @ref tutorial_ephysics_bouncing_ball
1625
* Concept of velocity were already covered in
1626
* @ref tutorial_ephysics_velocity
1628
* @section add-maxsleeping Adding Max Sleeping Time
1629
* @dontinclude test_sleeping_threshold.c
1631
* Setting the max sleeping time determines how long(in seconds) a rigid body
1632
* under the linear and angular threshold is supposed to be marked as sleeping.
1634
* @skipline ephysics_world_max_sleeping_time_set
1636
* @section add-sleeping Adding a Sleeping Threshold
1637
* @dontinclude test_sleeping_threshold.c
1639
* Here we set EPhysics_Bodys linear and angular sleeping threshold. These
1640
* factors are used to determine whenever a rigid body is supposed to
1641
* increment the sleeping time.
1643
* After every tick the sleeping time is incremented. After reaching the max
1644
* sleeping time the body is market to sleep, that means the rigid body is to
1647
* @skipline ephysics_body_sleeping_threshold_set(sphere_body1
1649
* @skipline ephysics_body_sleeping_threshold_set(sphere_body2
1651
* We can get the EPhysics_Bodys linear and angular sleeping threshold as well.
1653
* @skipline ephysics_body_sleeping_threshold_get(sphere_body1
1655
* @skipline ephysics_body_sleeping_threshold_get(sphere_body2
1657
* @section add-damping Adding a Damping
1658
* @dontinclude test_sleeping_threshold.c
1660
* Here we set EPhysics_Bodys linear and angular damping values.The damping is
1661
* a force synchronous with the velocity of the object but in opposite
1662
* direction - like air resistance.
1664
* @skipline ephysics_body_damping_set(sphere_body1
1666
* @skipline ephysics_body_damping_set(sphere_body2
1668
* Here we finish the example. The full source code can be found at
1669
* @ref test_sleeping_threshold_c.
1674
* @page test_sleeping_threshold_c test_sleeping_threshold.c
1677
* @include ephysics_test.h
1679
* @section test-sleeping-threshold-c test_sleeping_threshold.c
1680
* @dontinclude test.c
1685
* @skip test_data_new
1688
* @skip test_win_add
1691
* @include test_sleeping_threshold.c
1693
* @example test_sleeping_threshold.c
1697
* @page tutorial_ephysics_slider EPhysics - Slider
1699
* The purpose of this example is to demonstrate the EPhysics Slider constraint
1700
* usage - The code applies slider on three cubes.
1702
* @image html slider.png
1703
* @image latex slider.eps
1705
* For this example we'll have an EPhysics_World, and four basic
1708
* The basic concepts like - defining an EPhysics_World, render geometry,
1709
* physics limiting boundaries, add an EPhysics_Body, associate it to evas
1710
* objects, change restitution, friction and impulse properties, were
1711
* already covered in
1712
* @ref tutorial_ephysics_bouncing_ball
1714
* You can use also a P2P (point to point) constraint:
1715
* @ref tutorial_ephysics_constraint
1717
* @section add-slider Adding a Slider
1718
* @dontinclude test_slider.c
1720
* Slider is a constraint that will limit the linear and angular moving of
1723
* We'll add three sliders on the cubes, starting with the highest purple.
1725
* First we need to create a specific variable type to get EPhysics_Body
1726
* constraint and create a new slider constraint passing the body which we
1727
* want as parameter.
1729
* @skipline EPhysics_Constraint *constr
1731
* @skipline constraint = ephysics_constraint_slider_add(box_body2
1733
* Here we define the linear moving limits of the slider constraint, in this
1734
* case we just set moving limit down on Y axis (under), but if we wanted we
1735
* could set left, right and above also.
1737
* @skip ephysics_constraint_slider_linear_limit_set(constraint, 0,
1740
* Here we set the angular moving limits of the slider constraint. The angular
1741
* moving limits is defined in degrees and will limit the moving on Z axis, in
1742
* this case we just set the clockwise direction, but if we wanted we could
1743
* set the counter clockwise direction also.
1746
* @skipline ephysics_constraint_slider_angular_limit_set(constraint, 0, 45
1748
* When this cube falls by the gravity, the slider constraint will act limiting
1749
* its linear and angular movings, giving the impression that its hanging.
1751
* For the next two cubes is the same process.
1753
* Now we set the slider constraint of the highest blue and lowest purple,
1754
* limiting moving limits to the left on X axis and applying an impulse
1755
* to the left where the two cubes will be limited by the slider constraint
1758
* @skip constraint = ephysics_constraint_slider_add(box_body3
1759
* @until box_body3, -240, 0, 0);
1761
* @skip constraint = ephysics_constraint_slider_add(box_body4
1762
* @until box_body4, -600, 0, 0);
1764
* Here we finish the example. The full source code can be found at
1765
* @ref test_slider_c.
1770
* @page test_slider_c test_slider.c
1773
* @include ephysics_test.h
1775
* @section test-slider-c test_slider.c
1776
* @dontinclude test.c
1781
* @skip test_data_new
1784
* @skip test_win_add
1787
* @include test_slider.c
1789
* @example test_slider.c