HOW TO DEVELOP APPLICATIONS

How to develop an application in anyflo language
How to make communicate several anyflos
How to link with anyflo
How to exchange information between a C program and anyflo
How chaining several applications

















































How to develop an application in anyflo language

Anyflo language, close to C but less restrictive, can develop rapidly interactive graphics applications by conventional programming.
By downloading the mime application you get a complete example of a complex program written in anyflo showing, among other things, how to build a human body, how to use various sensors, how to generate neural networks and how to use them to build a virtual mime (unfortunately, this application runs on an older version from 2009 and is not complete ...).

How to make communicate several anyflos

On the same machine
On multiple machines

On the same machine

The easiest way is through shared memory.
Example: click on shared_memory.js launching 4 anyflos in different windows:
WshShell.Run("anyflo.exe env=env ima=ima1 lan=\"shared_memory_serveur()\" x=420 y=300 orx=0 ory=0");
WshShell.Run("anyflo.exe env=env ima=ima1 lan=\"shared_memory_help()\" x=420 y=300 orx=0 ory=380");
WshShell.Run("anyflo.exe env=env ima=ima1 lan=\"shared_memory_client1()\" x=420 y=300 orx=440 ory=0");
WshShell.Run("anyflo.exe env=env ima=ima1 lan=\"shared_memory_client2()\" x=420 y=300 orx=440 ory=380");

calling respectively functions:
shared_memory_serveur()
shared_memory_help()
shared_memory_client1()
shared_memory_client2()

On multiple machines

Use sockets TCP or UDP.

How to link with anyflo

Functions by default
Particular functions
Functions written in C language

Functions by default

       Default basic operations (such as perspective, illumination calculations, mappings, textures, ...) are handled automatically by the program, the user is limited to provide parameters to algorithms "wired" in the software.
         But among these parameters include the ability to pass function names (anyflo written language) to be executed instead of these algorithms.

Particular functions

Ces exemples ne fonctionneront que lorsque le type 2 d´affichage aura été implémenté. Exemple 1: Mise en perspective
         Remplace l´algorithme de projection perspective conique par celui décrit dans la fonction de nom toto. Une telle fonction contiendra:
toto()
{
         p1=poi; /* Affecte à la variable p1 les coordonnées 3D du point traité */
         p2=fonction(p1); /* Calcul par l´utilisateur de la perspective de p1 */
         validate pers(p2); /* Passe la valeur ainsi calculée au programme */
}
Exemple 2: Texture
LIBRE vol(1)="toto";
         Affecte au volume 1 la LIBRE 3D décrite dans la fonction de nom toto. Une telle fonction contiendra:
toto()
{
         p1=poi; /* Affecte à la variable p1 les coordonnées 3D du point traité */
         k1=col; /* Affecte à la variable k1 la couleur du point traité */
         n1=normal; /*Affecte à la variable n1 la normal au point traité*/
         k2=fonction(p1,k1,n1); /* Calcul par l´utilisateur de la nouvelle couleur */
         col(k2); /* Passe la valeur ainsi calculée au programme */
}

Exemple:
1) Construire une ball et lui affecter une LIBRE 3D procédurale:
         ini ini vol; /* Initialise les flags, supprime tous les volumes */
         ball(100,12); /* Construit une ball de radius 100 et de 12parallèles */
         illum vol 1=3,1; /* Modèle de PHONG */
         LIBRE vol(1)="toto"; /* Texture procédurale */
2) Écrire la fonction de LIBRE toto: toto()
{
         p=poi ;
/* p = point affiché */
         x=p[0];y=p[1];z=p[2]; /* Coordonnées absolues du point */
/* Calculer la couleur en fonction des coordonnées */
         r=abs(sin(2*PI*x/100));
         v=abs(sin(2*PI*y/237));
         b=abs(sin(2*PI*z/312));
         col(r,v,b);
/* Affecter la couleur */
3) Afficher:
         yes illum LIBRE; /* Valider les flags */
         screen;displ vol; /* Afficher */
}

Functions written in C language

How to link anyflo
         File utilb.c located in the directory utilb.c anyflo provides an interface to the C programming language with trivial examples.
         Just change some of these functions, compile and link (executable named anyflo.exe is then built):
     UNIX: do <>make in the directory of the environment.
     WIDOWS: launch Visual C++ and click on file, then Open Workspace, click on anyflo.dsw in anyflo.
Warning: anyflo was developed in Visual C + + version 6.0 and can only be changed with this version of the compiler. All files *. C modifiable are located in the folder anyflo.
Example 1: managing interaction
Functions _F_0(), _F_1(), _F_2(), _F_3(), _F_4() and _F_5() of file utilb.c double functions interaction func(i,"fi"), they are executed in the following order:
_F_0();f0();
_F_1();f1();
_F_2();f2();
_F_3();f3();
_F_4();f4();
_F_5();f5();
Example 2: adds commandes or new application
Function EVALUER_2(long *pd0, long *pd_eg, long *suite, long *end) of file utilb.c:
pd0 ->coding command line.
pd_eg: -> =expresion if assignment.
[suite, end]: is a free buffer.

Add commands

Principe
         in file initb.h are the names of files describing environments:
         enva.h,koma.h,mesa.h for interpreter.
         envb.h,komb.h,mesb.h for anyflo.
We can add more:
         envc.h,komc.h,mesc.h
Provided:
1) Create files:
         envc.h containing the application-specific initializations
         komc.h containing descriptions of commands added
         mesc.h containing the messages transmitted by the application
         defc.h containing the defines (practically command names in uppercase)
2) Change the function EVALUER_2 () File utilb.c there in encoding processing of these commands
Example          Given to add the command:
         com0(datas)
1) Change komc.h:
|0: com0
0,-1,0,1
.
2) Change function EVALUER_2() of file utilb.c.

Link a program written in C with the interpreter

Principle
         In file initb.h are the names of files describing environments:
         enva.h,koma.h,mesa.h for the interpreter.
         envb.h,komb.h,mesb.h for anyflo.
If we replace the environment anyflo
         envb.h,komb.h,mesb.h
by another
         envc.h,komc.h,mesc.h
we will link any application to the interpreter.
For that do:
1) Create files:
         envc.h containing the application-specific initializations
         komc.h containing descriptions of commands added
         mesc.h containing the messages transmitted by the application
         defc.h containing the defines (practically command names in uppercase)
         glbc.h containing declarations and global variables to include in the file application.c containing main ()
         extc.h containing references to global variables and included in all application files
         initc.c containing function initb
With * argv pointing strings of argc launch parameters.
In this function all initializations are performed:
       exec.c containing function EVALUER_1()

How to exchange information between a C program and anyflo

       This will be the case, for example, the driver of a sensor (camera, motion capture, KINET, etc. ..). The simplest is to go through the shared memory (on the same machine) or by TCP or UDP sockets (on several machines or a network).
       We find, for example, the source (very simple) mem_part.c a driver can operate indifferently as a server or customer it may very well be anyflo.
       Be found in the distribution file:
              mem_part.exe: serveur executable envoyant des caractères
              file mem_part.js on which you must click to launch the driver.
              driver.js launching anyflo file that reads and executes the function driver.func: the characters typed in the server window appear on the screen.
              WARNING: only one MEM simple device type can be declared.

How chaining several applications

Just call interaction func(6,"F6") with function:
f6()
{
       system("prog.js");exit;
}

with file prog.js of the form:
f();
function f() {
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("anyflo.exe env=env lan=\"prog()\"");
}
the same method cane be used in function prog.func for chaining an other program prog2, and so on.