summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorRicardo de Almeida Gonzaga <ricardo@profusion.mobi>2012-10-04 22:37:25 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-04 22:37:25 +0000
commitbd9c06c5f57ff4b816cecdef9531cb86b93abd69 (patch)
tree532b4db4985838d4d19ef5c57e82fda6d340f851 /legacy
parent079b6c94c3d6acdf3ca5be5ae6c0711e9fade07d (diff)
ephysics: add a new example doc: Rotating Forever -
test_rotating_forever.c Patch by: Ricardo de Almeida Gonzaga <ricardo@profusion.mobi> SVN revision: 77450
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ephysics/doc/examples.dox117
1 files changed, 117 insertions, 0 deletions
diff --git a/legacy/ephysics/doc/examples.dox b/legacy/ephysics/doc/examples.dox
index 6e0df16..7b7693b 100644
--- a/legacy/ephysics/doc/examples.dox
+++ b/legacy/ephysics/doc/examples.dox
@@ -14,6 +14,7 @@
14 * @li @ref tutorial_ephysics_forces 14 * @li @ref tutorial_ephysics_forces
15 * @li @ref tutorial_ephysics_growing_balls 15 * @li @ref tutorial_ephysics_growing_balls
16 * @li @ref tutorial_ephysics_gravity 16 * @li @ref tutorial_ephysics_gravity
17 * @li @ref tutorial_ephysics_rotating_forever
17 * @li @ref tutorial_ephysics_velocity 18 * @li @ref tutorial_ephysics_velocity
18 * @li @ref tutorial_ephysics_shapes 19 * @li @ref tutorial_ephysics_shapes
19 * @li @ref tutorial_ephysics_sleeping_threshold 20 * @li @ref tutorial_ephysics_sleeping_threshold
@@ -1095,6 +1096,122 @@
1095 * @example test_no_gravity.c 1096 * @example test_no_gravity.c
1096 */ 1097 */
1097 1098
1099 /**
1100 * @page tutorial_ephysics_rotating_forever EPhysics - Rotating Forever
1101 *
1102 * The purpose of this example is to demonstrate the EPhysics Rotate usage -
1103 * The code applies different ways to rotate an EPhysics_Body, such as torque,
1104 * torque impulse and rotation set.
1105 *
1106 * For this example we'll have an EPhysics_World with gravity setted to zero,
1107 * and four basic EPhysics_Bodys.
1108 *
1109 * The basic concepts like - defining an EPhysics_World, render geometry,
1110 * physics limiting boundaries, add an EPhysics_Body, associate it to evas
1111 * objects, change restitution, friction and impulse properties, were
1112 * already covered in
1113 * @ref tutorial_ephysics_bouncing_ball
1114 *
1115 * @section add-rotate Rotating
1116 * @dontinclude test_rotating_forever.c
1117 *
1118 * For the first body we'll apply a torque impulse to make it rotate around Z
1119 * axis (rotate on x-y plane). Will make the body rolls on clockwise rotation,
1120 * if the value is negative, the impulse will be on counter clockwise.
1121 *
1122 * @skipline ephysics_body_torque_impulse_apply(body, 1);
1123 *
1124 * For the second body we'll use an offset to apply the force, the two
1125 * last parameters are responsible to set a relative position to apply the
1126 * force.In other words, the force applied with an offset will make the body
1127 * rotates and move around the other cubes.
1128 *
1129 * @skipline ephysics_body_impulse_apply(body, 30, 0
1130 *
1131 * For the third body we'll use a timer to rotate the body and a callback to
1132 * delete it.
1133 *
1134 * @skip timer = ecore_timer_add(1, _rotate_cb
1135 * @until _del_cb, timer);
1136 *
1137 * @dontinclude test_rotating_forever.c
1138 * @skip _del_cb(void *data
1139 * @until }
1140 *
1141 * In the function we'll get the body rotation on z axis in degrees and handle
1142 * it increasing 5 degrees on its position on z axis on each tick of the timer.
1143 *
1144 * @dontinclude test_rotating_forever.c
1145 * @skip _rotate_cb(void *data
1146 * @until }
1147 *
1148 * For the forth body we'll use 2 timers, but before that, we'll apply an
1149 * initial torque, changing the body angular acceleration and a callback to
1150 * delete the timers we'll add.
1151 *
1152 * @skipline ephysics_body_torque_apply(body, 2
1153 * @skipline ephysics_body_event_callback_add(body,
1154 * @skipline EPHYSICS_CALLBACK_BODY_DEL,
1155 * @skipline _del_torque_cb, cube);
1156 *
1157 * Just the callback function to delete the timers.
1158 *
1159 * @dontinclude test_rotating_forever.c
1160 * @skip _del_torque_cb(void *data
1161 * @until }
1162 *
1163 * As we commented we'll use 2 timers, one to increase the torque and
1164 * another to stop the torque, cleaning the forces related to the body.
1165 *
1166 * @skip timer = ecore_timer_add(3, _increase
1167 * @until "stop_timer", timer);
1168 *
1169 * In the increase function we'll apply a torque over the body, changing
1170 * its angular acceleration, it will leads to a change on angular velocity
1171 * over time. We're using a timer to increase the angular acceleration on
1172 * each tick of the timer.
1173 *
1174 * @dontinclude test_rotating_forever.c
1175 * @skip _increase_torque_cb(void *data
1176 * @until }
1177 *
1178 * In the stop function we'll clear all the forces applied to the body,
1179 * setting its linear and angular acceleration to zero. We're using this
1180 * timer to "control" the body velocity, since we are increasing it by
1181 * another timer. Note that we set the acceleration to zero not the
1182 * velocity.
1183 *
1184 * @skip _stop_torque_cb(void *data
1185 * @until }
1186 *
1187 * Here we finish the example. The full source code can be found at
1188 * @ref test_rotating_forever_c.
1189 *
1190 */
1191
1192 /**
1193 * @page test_rotating_forever_c test_rotating_forever.c
1194 *
1195 * @section ephysics-test-h ephysics_test.h
1196 * @include ephysics_test.h
1197 *
1198 * @section test-rotating-forever-c test_rotating_forever.c
1199 * @dontinclude test.c
1200 *
1201 * @skip test_clean
1202 * @until }
1203 *
1204 * @skip test_data_new
1205 * @until }
1206 *
1207 * @skip test_win_add
1208 * @until }
1209 *
1210 * @include test_rotating_forever.c
1211 *
1212 * @example test_rotating_forever.c
1213 */
1214
1098/** 1215/**
1099 * @page tutorial_ephysics_velocity EPhysics - Velocity 1216 * @page tutorial_ephysics_velocity EPhysics - Velocity
1100 * 1217 *