Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Pages: 1 [2]

Author Topic: Outerra Anteworld C++ Plugin API  (Read 4532 times)

fly77

  • Sr. Member
  • ****
  • Posts: 430
Re: Outerra Anteworld C++ Plugin API
« Reply #15 on: September 13, 2019, 01:49:39 pm »

Thanks for the reply. As I wrote on discord I actually managed to compile and run in outerra Republic of texas's  T817 vehicle plugin (yes by using 32 bit).
How about progress with your "plugin loader" menu ?
Logged

andfly

  • Sr. Member
  • ****
  • Posts: 251
Re: Outerra Anteworld C++ Plugin API
« Reply #16 on: September 13, 2019, 02:09:02 pm »

I had missed the fact that you had already found a solution ...
I am pleased to.

Unfortunately ... no progress ...
Every so often, with a little nostalgia, I make some adjustments to the models built in the past and I make small optimizations to the bird routines in C ++, so, just to keep myself in training ...
But I don't find the time to deepen and conclude ...

I look forward to better times ...  ::)
Logged
I do not know the English language. I use Google Translate. I hope it's all understandable.

fly77

  • Sr. Member
  • ****
  • Posts: 430
Re: Outerra Anteworld C++ Plugin API
« Reply #17 on: September 13, 2019, 02:21:08 pm »

Am I asking to much or would you be available to share your c++ VS solution of the birds plugin ? ...an older nonperfect one would be enough..just to learn something
Logged

andfly

  • Sr. Member
  • ****
  • Posts: 251
Re: Outerra Anteworld C++ Plugin API
« Reply #18 on: September 14, 2019, 10:10:43 am »

I am pleased to publish a solution to define global data within Outerra with the ability to write and read them from any vehicle or aircraft model file in Javascript.
Obviously you must use the C ++ language and create a DLL.

I state that I am not a C ++ expert at all.
I only paused to read some manuals and learned the grammar of the language and some rudiments ...
The great fortune was the willingness of Microsoft to make available, for free, the possibility of using Visual Studio at a basic level (and without time limitations) and, above all, the publication of the Example_Plugin of our "great" Uriah (it will not be never thanked enough).
Having this complete and fully functional solution available, it is quite simple to add functions, compile everything, copy the Dll to the program's "plugins" folder and use the new functions by calling them from Javascript.

We think, for example, that we want to have global variables available, useful for transferring data between models, that represent "flags" (integers), numbers (double) and positional data (pos).
Possibly also other data, of any other type ...

In Visual Studio we add, in the plugin.hpp file, the declaration of functions:

ifc_fn int read_flag( int index);
ifc_fn double read_dat(int index);
ifc_fn double3 read_pos(int index);
ecc..ecc...
ifc_fn void wri_flag(int flag, int index);
ifc_fn void wri_dat(double dat, int index);
ifc_fn void wri_pos(double3 pos, int index);

ecc..ecc...

Then, in the plugin.cpp file we declare the global data Arrays (for example 100 variables per type):

int Global_flag [100];
double3 Global_pos [100];
double Global_dat [100];

etc. etc...
(It is useful to declare Arrays because we will retrieve the data by means of their index.)

Then we define the functions (always in plugin.cpp)

//Function read_flag
int example_plugin::read_flag(int index) {
   return Global_flag[index];
}
//Function read_dat
double example_plugin::read_dat(int index) {
   return Global_dat[index];
}
 //Function read_pos
double3 example_plugin::read_pos(int index) {
   return Global_pos[index];
}
ecc..ecc...

//Function wri_flag
void example_plugin::wri_flag(int flag,int index) {
   Global_flag[index]=flag;
}
//Function wri_dat
void example_plugin::wri_dat(double dat,int index) {
   Global_dat[index]=dat;
}
// Function wri_pos
void example_plugin::wri_pos(double3 pos,int index) {
   Global_pos[index]=pos;
}

ecc.. ecc...

At this point, in Javascript, we call our plugin interface (within the function init_vehicle () or initialize ()):
$plugin = this.$query_interface('my::js::example_plugin_interface.get');

Within the update_frame () function we can write or read the value of our global variables with these commands:

$plugin.wri_flag(val,index);
$plugin.wri_dat(val,index);
$plugin.wri_pos(val,index);

val=$plugin.read_flag(index);
val=$plugin.read_dat(index);
val=$plugin.read_pos(index);



Extremely simple ...
So simple that it will make C ++ experts smile for its elementality.

But ... it's not my intention to do programming lessons ...
Simply share a possibility that can widely expand the interaction between the models and their playability.

Since, then, "the appetite comes with eating", once experienced the mechanism ... we will surely want to add more functions, commonly used or personal, that we will always have available.

I hope I have done something pleasant.  :D
Logged
I do not know the English language. I use Google Translate. I hope it's all understandable.

fly77

  • Sr. Member
  • ****
  • Posts: 430
Re: Outerra Anteworld C++ Plugin API
« Reply #19 on: September 14, 2019, 10:40:04 am »

wow andlfy !  This is exactly what I was looking for to start toying around making a proof of concept of a simple outerra game !  :) :) :)
I remember you mentioned this possibility of a plugin to obtain global variables in one of your older posts and I wondered how to do this.
So thanks a lot....finally I can begin trying to use it..As a simple test I probably will try to get several planes on my radarscreen !




« Last Edit: September 14, 2019, 11:02:43 am by fly77 »
Logged

andfly

  • Sr. Member
  • ****
  • Posts: 251
Re: Outerra Anteworld C++ Plugin API
« Reply #20 on: September 14, 2019, 12:11:24 pm »

As I said before ..." l'appetito vien mangiando "

In my plugin I added a fair number of generic personal functions on altitudes, inclinations, rotations, ECEF-LON-LAT conversions, etc. .. plus those specific on flocks of birds ...
The satisfaction of always having them available without having to rewrite them every time ... it's great.

But it is even better to think that this does not affect the normal functioning of Outerra or the functions created by the developers or the program itself, in short ... it does not bother anyone.
The plugin is loaded and the functions remain there, quiet, until you decide to use them ... and only if you know the grammar of their call.

The only precaution is to not exaggerate on the definition of global variables in order not to saturate the memory and cause a drop in performance or crashes ... but with a minimum of attention is a very remote possibility!

Best wishes for the future developments of your work!
Logged
I do not know the English language. I use Google Translate. I hope it's all understandable.
Pages: 1 [2]