summaryrefslogtreecommitdiff
path: root/legacy/ephysics/doc
diff options
context:
space:
mode:
authorRicardo de Almeida Gonzaga <ricardo@profusion.mobi>2012-09-14 22:04:56 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-09-14 22:04:56 +0000
commit134d52aa9d0f9aaaab230c0dfd28411ab3295021 (patch)
tree0bbf7e7d851445ce4d3f018d62b0a9ca2198fd8c /legacy/ephysics/doc
parente302c3d27e15faf881a613d89836e0cbad917596 (diff)
ephysics: add a new example doc: Velocity -
test_velocity.c Patch by: Ricardo de Almeida Gonzaga <ricardo@profusion.mobi> SVN revision: 76695
Diffstat (limited to 'legacy/ephysics/doc')
-rw-r--r--legacy/ephysics/doc/examples.dox116
1 files changed, 116 insertions, 0 deletions
diff --git a/legacy/ephysics/doc/examples.dox b/legacy/ephysics/doc/examples.dox
index 169a069e24..c40fb5c64c 100644
--- a/legacy/ephysics/doc/examples.dox
+++ b/legacy/ephysics/doc/examples.dox
@@ -9,6 +9,7 @@
9 * @li @ref tutorial_ephysics_collision_filter 9 * @li @ref tutorial_ephysics_collision_filter
10 * @li @ref tutorial_ephysics_delete_body 10 * @li @ref tutorial_ephysics_delete_body
11 * @li @ref tutorial_ephysics_constraint 11 * @li @ref tutorial_ephysics_constraint
12 * @li @ref tutorial_ephysics_velocity
12 */ 13 */
13 14
14/** 15/**
@@ -598,3 +599,118 @@
598 * @example test_constraint.c 599 * @example test_constraint.c
599 */ 600 */
600 601
602/**
603 * @page tutorial_ephysics_velocity EPhysics - Velocity
604 *
605 * The purpose of this example is to demonstrate the EPhysics Velocity usage -
606 * The code adds a small bouncing ball on the ground and responding to users
607 * events by making it jump - applying a central impulse on it and showing its
608 * velocity and acceleration.
609 *
610 * We'll see in this example how to get EPhysics_Body Linear and Angular
611 * velocity and acceleration.
612 *
613 * For this example we'll have an EPhysics_World and one basic EPhysics_Body,
614 * we'll apply impulses that follows user events, it were already covered in
615 * @ref tutorial_ephysics_bouncing_ball
616 *
617 * @section add-velstruct Velocity Data Struct
618 * @dontinclude test_velocity.c
619 *
620 * While in this example we'll be working with a struct to hold some objects
621 * in our code. For clarity sake we present you the struct declaration in the
622 * following block.
623 *
624 * @skip struct _Velocity_Data {
625 * @until };
626 *
627 * @section add-callbacks Adding the Callbacks
628 *
629 * Calling ephysics_body_event_callback_add()
630 * will register a callback to a type of physics body event.
631 *
632 * @ref EPHYSICS_CALLBACK_BODY_UPDATE : called after every physics iteration.
633 * In other words, will be called after each world tick.
634 *
635 * @skipline ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_
636 * @skipline _update_vel_cb
637 *
638 * @ref EPHYSICS_CALLBACK_BODY_STOPPED : called when a body is found to be
639 * stopped. In other words, when the body is not moving anymore.
640 *
641 * @skip ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_BODY_ST
642 * @until );
643 *
644 * See
645 * @ref _EPhysics_Callback_Body_Type
646 * for more event types.
647 *
648 * @section add-velcb Velocity Function
649 *
650 * The callback function will be called on every physics iteration to show the
651 * linear and angular velocity and acceleration.
652 *
653 * Here we're declaring the necessary variables to calculate acelerations and
654 * delta time. And checking if its the first time to return before shows
655 * informations about the velocity.
656 *
657 * @dontinclude test_velocity.c
658 *
659 * @skip _update_vel_cb(void *data,
660 * @until EINA_TRUE;
661 *
662 * Get the delta time to use it soon to calculate the acceleration on every
663 * physics iteration.
664 *
665 * @skip time_now = ecore_time_get();
666 * @until time_now;
667 *
668 * Note in this part we get the angular and linear velocities.
669 *
670 * @skip vaz = ephysics_body
671 * @until &vy);
672 *
673 * We need to handle the velocity using delta time to have the acceleration
674 * on every tick. Check if its the first time to return before shows
675 * informations about the velocity because we dont have the old aceletations
676 * and then the calculation of this informations will be wrong.
677 *
678 * Here we calculate the aceletarions using this formula:
679 *
680 * (velocity - old_velocity) / delta_time;
681 *
682 * @skip aaz = (vaz -
683 * @until return;
684 *
685 * Turning data into text, to pass it to edje shows on screen.
686 *
687 * @skip snprintf(buff,
688 * @until "linear_acc", buff);
689 * @skip snprintf(buff,
690 * @until "angular_acc", buff);
691 * @skipline }
692 *
693 * Here we finish the example. The full source code can be found at
694 * @ref test_velocity_c.
695 *
696 */
697
698 /**
699 * @page test_velocity_c test_velocity.c
700 *
701 * @section ephysics-test-h ephysics_test.h
702 * @include ephysics_test.h
703 *
704 * @section test-velocity-c test_velocity.c
705 * @dontinclude test.c
706 *
707 * @skip test_clean
708 * @until }
709 *
710 * @skip test_win_add
711 * @until }
712 *
713 * @include test_velocity.c
714 *
715 * @example test_velocity.c
716 */