Jump to content

LEAVU development phase, coding MPCD graphics


RvEYoda

Recommended Posts

Thanks for the pointers. Will take a look. There used to be a project that gave DirectInput access, called "jinput" although it seems abandoned at the moment. Even when I looked at it a few years ago it had some issues (throwing NullPointerExceptions which should not happen in any decent code).

 

I'm also interested in having some Java code working alongside LockOn/DCS (besides LEAVU) so am keen to find a way to make it work - even if it takes a while.

Link to comment
Share on other sites

  • Replies 784
  • Created
  • Last Reply

Top Posters In This Topic

cool,

yeah if you can get those basic things working it java it sure is faster

to develop a java app ;)

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

  • 2 months later...

Just to let you know I am currently moving the project to

Java and OpenGL through JOGL.

 

it is so far in very early development and cannot do much more than

switch between and configure different blank mfd pages,

 

but I got the graphics running, clicks detected and I was able to wrap

my C functions in JNI so that the window does not steal focus from lockon

when clicked...

 

Prototype looks something like this :

 

 

tri.png

 

For JNI I used this as a source :

 

http://stackoverflow.com/questions/386792/in-java-swing-how-do-you-get-a-win32-window-handle-hwnd-reference-to-a-window

 

but that is for old java and I needed to update it like this :

 


#define _AFXDLL
#include "afxwin.h"
#include "windows.h"
#include "Java2Win32.h"
#include "jawt.h"
#include "jawt_md.h"



JNIEXPORT jlong JNICALL Java_leavu_Win32_setNoActivate (JNIEnv *env, jclass cls, jobject comp) {
HMODULE _hAWT = 0;

   HWND hWnd = 0;
   typedef jboolean (JNICALL *PJAWT_GETAWT)(JNIEnv*, JAWT*);
   JAWT awt;
   JAWT_DrawingSurface* ds;
   JAWT_DrawingSurfaceInfo* dsi;
   JAWT_Win32DrawingSurfaceInfo* dsi_win;
   jboolean result;
   jint lock;

   //Load AWT Library
   _hAWT = LoadLibrary(L"jawt.dll");


   if(_hAWT)
   {
       PJAWT_GETAWT JAWT_GetAWT = (PJAWT_GETAWT)GetProcAddress(_hAWT, "JAWT_GetAWT");
       if(JAWT_GetAWT)
       {
           awt.version = JAWT_VERSION_1_4; // Init here with JAWT_VERSION_1_3 or JAWT_VERSION_1_4
           //Get AWT API Interface
           result = JAWT_GetAWT(env, &awt);
           if(result != JNI_FALSE)
           {
               ds = awt.GetDrawingSurface(env, comp);
               if(ds != NULL)
               {
                   lock = ds->Lock(ds);
                   if((lock & JAWT_LOCK_ERROR) == 0)
                   {
                       dsi = ds->GetDrawingSurfaceInfo(ds);
                       if(dsi)
                       {
                           dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
                           if(dsi_win)
                           {
                               hWnd = dsi_win->hwnd;
							CWnd::FromHandle(hWnd)->ModifyStyleEx(0,WS_EX_NOACTIVATE,1);
                           }
                                               else {
                                                       hWnd = (HWND) -1;														
                                               }
                           ds->FreeDrawingSurfaceInfo(dsi);
                       }
                                       else {
                                               hWnd = (HWND) -2;
                                       }
                       ds->Unlock(ds);
                   }
                               else {
                                       hWnd = (HWND) -3;
                               }
                   awt.FreeDrawingSurface(ds);
               }
                       else {
                               hWnd = (HWND) -4;
                       }
           }
               else {
                       hWnd = (HWND) -5;
               }
       }
       else {
               hWnd = (HWND) -6;
       }
   }
   else {
       hWnd = (HWND) -7;
   }
   return (jlong)hWnd;
}


 

Argument is any AWT component. ( I use AWT only, no swing )

Got it running on 64bit jre currently


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

yeah, but it will be a while before we can use the new version, for many reasons.

 

Primarily cause im doing it all again from scratch...:P

  • Like 1

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Yes, I could definitely use a hand.

 

Either from anyone that knows JAVA ( I have an svn rep at kenai called leavu2 ),

or if you can provide pictures of MFDs, MFD pages etc.

 

Or if anyone wants to contribute with artwork that would be cool.

 

Naturally anyone making a contribution would also get the author/dev/contributor stamp :)


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Implemented some hsd details,

GLCanvas instead of Gljpanel (canvas is faster),

AA and some other stuff..

 

leavu2.png

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Glad to see you r using Java. What would you specifically like a hand with Yoda? I could try converting the JNI to JNA so you don't have to copy the DLL around and set the javca.library.path


Edited by Moa
Link to comment
Share on other sites

I tested using JNA to get the HWND, but it succeeded only some times,

some times it gave random integers and sometimes just zero :).

You make some JNA call to get a pointer to the hwnd value, and then

you call ptr.getLong() or ptr.getInt(), however since the pointer is

( my thought of the JNA problem ) returned as a 32bit value and my OS

and JRE is 64bit the pointer value only works in some cases. (where the

32bits are lucky enough to fit the pointer value)

 

If you can make JNA retrieve the HWND and or add WS_NO_ACTIVATE extended

style to a java awt component however, that would be excellent.

But make absolute sure it works 100% of the time in 64bit OS and 32bit OS,

and works with both 64bit jre and 32bit jre.

 

I have use JNA to enable OpenCL ( Open Compute language ) in java at work,

and I believe JNA may have some issues with 64bit pointer values, at least as it is

right now. JNI enables me to link statically and make sure all variables sent and

returned are correct. ( for work I also switched to JNI for using OpenCL in Java. )

 

Also I think we can include both a 64bit and 32bit dll for the final release of LEAVU

and have the library path be configured in some shortcut that is automatically set up.

what is needed is the LEAVU.jar,

the Java2Win32.dll (32 or 64 bit) that I wrote and jawt.dll (32 or 64 bit..i think) from

the JDK lib directory.

 

Like :

 

LEAVU/LEAVU.jar

LEAVU/LEAVU.bat (or similar)

LEAVU/lib/win/X86/Java2Win32.dll

LEAVU/lib/win/X86/jawt.dll

LEAVU/lib/win/X86/jogl.dll

LEAVU/lib/win/X86/gluegen-rt.dll

LEAVU/lib/win/X64/Java2Win32.dll

LEAVU/lib/win/X64/jawt.dll

LEAVU/lib/win/X64/jogl.dll

LEAVU/lib/win/X64/gluegen-rt.dll

 

then either run the bat file to launch it or copy the dlls to windows PATH ( ie windows/system32/ )

 

IF you want to run on linux I will have some files under LEAVU/NATIVE where you must

code your Java2Win32.cpp to make the Java2Win32.dll (yes maybe I should change the name of that file :))

You'll get my windows variant as a reference, but it will of course not compile under linux, so you must

replace the hwnd and extended styles with whatever is necessary

(or you can just have it do nothing if you dont care about WS_NO_ACTIVATE )

 

Little status update :

 

panel.png


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

what about being Multi monitor capable on MP?

" any failure you meet, is never a defeat; merely a set up for a greater come back, "  W Forbes

"Success is not final, failure is not fatal, it is the courage to continue that counts,"  Winston Churchill

" He who never changes his mind, never changes anything," 

MSI z690MPG DDR4 || i914900k|| ddr4-64gb PC3200 || MSI RTX 4070Ti|Game1300w|Win10x64| |turtle beach elite pro 5.1|| ViRpiL,T50cm2|| MFG Crosswinds|| VT50CM-plus rotor Throttle || G10 RGB EVGA Keyboard/MouseLogitech || PiMax Crystal VR || 32 Samsung||

Link to comment
Share on other sites

Leavu 2 has a button saying "Add MFD" which allows any number of MFDs to share

the same data, so that the CPU work load is the same regardless of number of MFDs.

 

The CPU load will increase with number of MFDs only because OpenGL requires one

graphics engine and drawing thread per MFD. ( But they all share the same precached shapes,

so load is quite ok. i get about 1-2% load per MFD on my 2.66 GHz machine at home when locking at 30 fps )

Just put it on a different cpu core than lockon and will have zero effect on game performance.

 

This means to run multiple MFDs of different size works just fine. You just press "new mfd"

here : leavu2.png, and you can resize each MFD

independently of the others ( just drag like a normal window ) . Just add MFD and drag

to the monitor you want it on. It should run on any operating system with a Java VM,

and supports any screen aspect ratio without changes to settings or misshaped objects.

 

No Global exports are needed, so even if lua export turned off

it works 100% fine, since Leavu only uses information from your instruments.

So it asks "what is on my radar", "what is my speed", "what is my position",

"what is my colition". It does never ask "What is player GG's position"


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

No Global Exports needed???

 

IT SOUNDS AWESOME... but im not sure..

 

all i know is that i was disappointed to have setup the LOVP for lockon in order to view gauge information to work locally, and not work on multiplayer because i was informed that most servers turn OFF lua export in order to prevent cheating....

 

but if your application is not feed data from the server, THIS IS INDEED FRIGGIN AWESOME

 

currently i am trying to setup multi monitors.. i just purchased a new card from ATi, because i want to run multi monitor in black shark on Windows 7 with out having to be in Windowed mode..

but im having a difficult time with this radeon HD5770 ( I am NOT liking Eye finity at the moment)

 

you seem to know about .lua stuff... do you know that guy that made a actually physical Balck Shark DATA Link panel?

he has a functional panel that interacts with the virtual cockpit.. im just wondering if the server he joins had .lua export turned off, would his physical data link panel still work?

 

IM HAPPY ABOUT YOUR WORK!!


Edited by hannibal

find me on steam! username: Hannibal_A101A

http://steamcommunity.com/profiles/76561197969447179

Link to comment
Share on other sites

My data link works with global exports turned off.

This is because I write my own datalink server.

 

Each player gets only local lua data like "What is my position".

 

Then each player logs into LEAVU data link server (separate software)

and says "Hi, my name is Yoda, this is my position..."

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Little new update to design changes.

Also implemented network connection with lockon,

so I can get the data I need ( but I just draw test shapes so far )

 

panel.png

  • Like 1

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Basically it would be good to have the buttons look a bit nicer. So buttons and the panels around the display would need some nice shapes/picture.

 

The dimension of the screen must be customizable. You can resize it to anything you want

with any aspect without it becoming strange,

but the button size themselves are fixed. (They only move with changing size of window)

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

hello.

 

your project sounds interesting..

 

can you send me a bitmap/jpeg image of your original photo of your MFD F15 screen?

 

i have sent you a PM,

 

unless your fine with the one on the post.

 

im going to do this in photo shop, so everything can be re-sized, but at the same time, i like to work of your original dimensions...

find me on steam! username: Hannibal_A101A

http://steamcommunity.com/profiles/76561197969447179

Link to comment
Share on other sites

BY the way, is there any option are you able to make the option, to turn on/off the virtual frame with the buttons?

 

your outer frame might be redundant for those who actually have a physically frame with buttons...

i hope your application will all not only turn off the frame, but allow a controller/joystick functions work in conjunction with your buttons (that would have been in your virtual MFD frame)...


Edited by hannibal

find me on steam! username: Hannibal_A101A

http://steamcommunity.com/profiles/76561197969447179

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...