Home » Samples

Samples

This page contains different examples of uses, tests and other code that you can download to verify how this development library works and see the source code it uses.

A few initial concepts …

A few initial concepts …

RTGA
Real-time graphic application.
Continuous Coupled Model
Typical model used for the development of an RTGA (single-thread).
Discreet Decoupled Model
Model proposed for the development of an RTGA (single-thread).
RT-DESK
Discreet simulation core with synchronised real time for managing an RTGA implemented with the Discreet Model.
Graphic render (Rnd)
Time the application uses to draw a scene or frame.
Update (Upd)
Time the application uses to develop each aspect of each of its objects.
Idle (Idl)
“Unused or excess” application time. Time that the application is simply waiting for Rnd or Upd to be executed.

The principal intention of all the demos displayed here is to show the virtues of the Discreet Model compared to the Continuous Model. The Continuous Model suffers a coupling between Rnd and Upd that can cause excess rendering (more than 60 fps) and the undersampling or oversampling of different aspects of each object of the application. There are occasions when an object must update its position for example every 0.001 ms (e.g. a bullet) and another object only needs to be updated every 40 ms (e.g. an object that has been thrown).

LimModCont-e1389627135494
Discreet Mode makes the execution time of any aspect of any object of the application within the same execution thread fully independent, which enables it to optimise the CPU use. In addition, this guarantees a high accuracy in the evolution of the virtual world due as Discreet Mode manages discreet events in simulation time.

Cont_vs_Dis-300x209
NOTE: To avoid excess rendering, graphics cards use V-Sync, so the scene will be drawn in an independent execution thread synchronised to the V-Sync signal. But this only achieves the decoupling of the graphic render, the other aspects of each of the objects continues to be coupled. But in these demos, to be able to better appreciate the decoupling of Discreet Mode, we recommend disabling the vertical synchronisation of the V-Sync card graphics.

Teapots

This demo shows the case of up to 25 teapots rotating on the screen and a light that revolves around them. Each teapot is represented by approximately 3000 triangles. The idea consists of modifying the behaviour of any aspect of the application in the execution time and we can see the coupled behaviour of Continuous Mode and the decoupled behaviour of Discreet Mode.

ImgDemoTeteras-150x150

Game of Life

This demo implements an array of the game of life. This array comprises 25600 cells (160 x 160) and it is implemented in Continuous Mode and Discrete Mode. This demo aims to show the high precision of Discrete Mode in both the moment and order of execution of each cell.

The idea is to show the ability of RT-DESK to be able to share the calculation power very efficiently between the different cells of a Cellular PLC, guaranteeing accurate execution, without errors, at the moment of execution of each of its cells.

ImgDemoGL-150x150

Colliding Balls

This demo consists of a box containing balls and these balls bounce off each other without going beyond the box limits. To avoid missing collisions, every time a ball travels a distance equivalent to its diameter, it must check possible collisions. This implies that the frequency for the execution of the update method in each ball depends on the speed of the ball. Each ball begins with a certain position and speed. The position is calculated through a simple equation depending on time and speed. The speed decreases every time the ball touches a wall of the box.
If two lines of balls are formed and the balls in one of the lines travel in the opposite direction to the balls in the other line, we get two lines of balls that continually collide and bounce off each other. The idea is to show how the runtime of an application with Continuous Mode can unpredictably fail whereas Discrete Mode guarantees a correct simulation.

ImgDemoBalls-150x150

Space Invaders

This demo is an interpretation of the classic videogame “Space Invaders”. The game is implemented in Continuous Mode and Discrete Mode and it is developed in 3D, although you can also play in 2D. The implementation of this game has an academic approach so we do not use any physics engine. We have used three different types of techniques to detect collisions and they have different levels of configuration through html files.
This game is programmed so that all its objects update (execute their own update method) depending on the speed at any moment of the game. That is, the update frequency of a bullet is higher than a spacecraft. It is possible to activate a game mode in which spacecraft break their formation and bounce off each other at different speeds.
It is interesting to note how Discrete Mode always runs properly, unlike Continuous Mode, which sometimes unpredictably fails during the execution, and does not properly perform as expected.

4_L1_dis_byFrame-150x150 4_L5_bounce_dis-150x150

Author: Vicente Broseta Toribio (vibroto<at>doctor<dot>upv<dot>es)