Moa Posted November 21, 2009 Posted November 21, 2009 Oh yeah, the atan() vs atan2() stuff. atan2() computes the same result but can handle better input range without failing, therefore I use atan2() for all my work in preference to atan().
RvEYoda Posted November 21, 2009 Author Posted November 21, 2009 (edited) Ok we will have to talk on TS/Vent when im home, do you have time on monday? The error I mentioned is there when I implemented your type of calculation earlier, not just with a spherical earth. But if you say that it works now I will definitely give it a shot and see if I made a mistake! It would be great if it was just that. I definitely would like to have you on the project, but keep in mind that making all classes and packages general are not the first priority. That is low cpu/gpu requirements and support for any resolution and aspect, which is currently quite ok. It turned out for example when using "get-bla, set-bla" methods in the 3d engine that this lowered the performance considerably vs just using public class members and treating some classes just basically as C structs, just a bunch of data. Currently the biggest CPU hog by far is text rendering. I use the Textrenderer class in JOGL but it still eats cpu like mad. The program has <1% on my machine with text disabled but many shapes on screen, but text instantly shoots it up to 2% I say this because I want to be able to run 10-20 AA enabled MFDs on the same computer without any big CPU hit Edited November 21, 2009 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'
RvEYoda Posted November 21, 2009 Author Posted November 21, 2009 (edited) Coordinate/bearing results : Works Excellent Moa ! ( I tested it on my laptop in my hotel room, converted it to LUA and used it to control my radar cursor with ) This is great. I can finally kick out that empirical variant I came up with :P Also you may not know this, but I wrote a dll (two actually) that lets lua detect keystrokes in the background with lockon running. This lets me have lua act on certain events, but more importantly, I can transfer these notifications from lua to LEAVU ( running on a diff computer ) to act on keyboard presses on the game computer. You may find this useful ;) ( And this is already 95% integrated and tested in the Lua exports that I will soon add to the svn rep ) We should get back to the main LEAVU thread Oh yeah, bear in mind when reading the leavu code that it is basically hacked together in a few days atm... it is not the prettiest creation in history :P Edited November 21, 2009 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'
Moa Posted November 21, 2009 Posted November 21, 2009 Coordinate/bearing results : Works Excellent Moa ! ( I tested it on my laptop in my hotel room, converted it to LUA and used it to control my radar cursor with ) Don't forget to have your holiday. Thanks for letting me know it works. This is great. I can finally kick out that empirical variant I came up with :P Also you may not know this, but I wrote a dll (two actually) that lets lua detect keystrokes in the background with lockon running. This lets me have lua act on certain events, but more importantly, I can transfer these notifications from lua to LEAVU ( running on a diff computer ) to act on keyboard presses on the game computer. You may find this useful ;) ( And this is already 95% integrated and tested in the Lua exports that I will soon add to the svn rep ) Will look into it. Does sound useful. We should get back to the main LEAVU thread Oh yeah, bear in mind when reading the leavu code that it is basically hacked together in a few days atm... it is not the prettiest creation in history :P No worries. At least you have this amazing code working, even if limited functionality. I'm happy to help with Javadoc and test cases with the time I have available. It is very interesting that your text rendering is slow. In JRE after 1.6.0_u10 *all* of Java2D is implemented as shaders on your graphics card (that is DirectX/Direct3D on Windows and OpenGL everywhere else). There shouldn't be any software rendering. So it is curious your text is slowing you down. nb. since Java2D is now fully accelerated Swing and the Swing JOGL panel should be faster than their AWT equivalents (and look fantastic using the Nimbus Look&Feel).
RvEYoda Posted November 22, 2009 Author Posted November 22, 2009 (edited) Ok let me clarify. it does not "slow down" as in slow down drawing It increases cpu load from 0% measured to 1-2% measured when adding the Textrenderer object. ( Compared to just rendering primitives ) The GLCanvas works much faster than GLJPanel, especially when resizing the window. I am trying to stay away a bit from Swing at this point. Trying to do as much work as possible in plain old JOGL openGL The Textrenderer is pobably Hardware accellerated, but it seems a bit heavy for our small task.. ( I also remade the animator class to something much smaller ) ... on my other computer it shows 0% :P Could be a win7 or 64bit JRE issue I guess Edited November 22, 2009 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'
Moa Posted November 23, 2009 Posted November 23, 2009 t Ok let me clarify. it does not "slow down" as in slow down drawing It increases cpu load from 0% measured to 1-2% measured when adding the Textrenderer object. ( Compared to just rendering primitives ) The GLCanvas works much faster than GLJPanel, especially when resizing the window. I am trying to stay away a bit from Swing at this point. Trying to do as much work as possible in plain old JOGL openGL The Textrenderer is pobably Hardware accellerated, but it seems a bit heavy for our small task.. ( I also remade the animator class to something much smaller ) ... on my other computer it shows 0% :P Could be a win7 or 64bit JRE issue I guess OpenGL doesn't have to anti-alias lines when you give the anti-alias 'hint', and quite often it doesnt. Use Java2d and you will get hardware antialiasing and especially anti-aliased text (which you can then texture map onto your surface). I personally prefer Swing over AWT because it has more controls, renders more consistently, and is easy to change the Look&Feel (meaning re-skinning your app can be easy). The latest versions of Swing have the correct z-ordering of controls and JoGL surfaces. This is not the case with AWT where you can have issues with popup menus appearing below the drawing surface. There is also the Matisse tool in Netbeans that makes working with Swing much easier. It is worth checking out if you have the time. Swing is certainly a complicated beast for some stuff (tables) but is simpler in many areas than other toolkits, and is also far more powerful than any other toolkit I've tried (WinForms, Gtk+, Qt, Wx, MFC, Xlib, XForms, AWT ...).
RvEYoda Posted November 23, 2009 Author Posted November 23, 2009 (edited) I give no hint calls to OpenGL when I used Java2D drawing GLJPanel through Swing ( using Java 1.4 17 ) I had considerable higher CPU usage than when using GLCanvas which is not through Java2D or swing. Also resizing and other operations went much slower, compared to GLCanvas which is perfectly smooth. I Set up a GLContext not with GUI editor but by manually creating the Canvas, as this allows me to enable true Multisampling OpenGL AA and not just give hints. I tried hints before, but that works like *** :) The GLCanvas with custom OpenGL settings ( like hw AA ) looks like this : public class MfdGui extends java.awt.Frame { private final MFD mfd; protected final GraphicsEngine graphicsEngine; protected final GraphicsBuffer graphicsBuffer; private javax.media.opengl.GLCanvas gljPanel; /** Creates new form NewFrame */ public MfdGui(MFD _mfd) { mfd = _mfd; graphicsBuffer = new GraphicsBuffer(); initComponents(); // Create the OpenGL Canvas with aa GLCapabilities capab = new GLCapabilities(); capab.setNumSamples(8); capab.setSampleBuffers(true); gljPanel = new javax.media.opengl.GLCanvas(capab); gljPanel.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { gLCanvas1MousePressed(evt); } }); java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); add(gljPanel, gridBagConstraints); // Add it to the engine to draw graphicsEngine = new GraphicsEngine( gljPanel, graphicsBuffer ); } Ok bad variable name "gljpanel" cause it isnt such :) Moa can I please speak to you on msn!!! I need advice on so many java things The Textrenderer of JOGL class I'm using is automatically Java2D anti aliased text through OpenGL, with built in caching. Details here Edited November 23, 2009 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'
RvEYoda Posted November 23, 2009 Author Posted November 23, 2009 (edited) I've looked at it again, and. Is it ok if we put the MapProjection class into LEAVU? It looks really good and would make things easier. Ofc you will get credits for it Moa :) Do you also have a method for : If I know my own position. I know bearing and range to target, Can I get his XZ or LatLong ? I require this when computing Mark points ( Where you click on Leavu screen to save coordinates to a marked point ) Edited November 23, 2009 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'
Moa Posted November 23, 2009 Posted November 23, 2009 I've looked at it again, and. Is it ok if we put the MapProjection class into LEAVU? It looks really good and would make things easier. Ofc you will get credits for it Moa :) Do you also have a method for : If I know my own position. I know bearing and range to target, Can I get his XZ or LatLong ? I require this when computing Mark points ( Where you click on Leavu screen to save coordinates to a marked point ) I can do this calculation for you. Will do tonight. The code I gave to you is under GPL v2 or later with me holding individual copyright and I'd also like to assign joint copyright to the LEAVU project (sorry I didn't put the notice in). This is similar to what GNU does. So you can do with it what you wish. Also I suggest LEAVU be placed under GPL v3 or later rather than GPL v2 or later. As it protects LEAVU and downstream developers from later patent assertions. Also, you must use Java 1.6.0_10 or later to get good hardware acceleration. With Java 1.4 you would always get slow benchmarks. It might be worth trying the newer JVM and re-testing the speed. You will get the higher speed without having to deal with horrid AWT etc. I usually have the leavu kenai chat window open when at work so that might be easier than MSN (well for me, since I never remember my MSN password :doh:).
Moa Posted November 23, 2009 Posted November 23, 2009 Further points: 1) We should always be storing degrees (and fractional degrees) rather than x,y since the later depends on the projection used and will almost certainly change in DCS:A10 from the values used in Flaming Cliffs (I haven't looked at the Black Shark coordinate system yet). 2) Use doubles in preference to floats for degrees. While floats can be faster there is no point if you are losing precision in the calculation (and we need quite a few significant digits to represent lat/long down to sub-meter). 3) The calculation to get location given range and bearing from a current location is a simple one using x,y. The logical place to put this is in MapProjection (which is why I offered to do it and write the unit tests to check all the boundary cases, degree wrap-around etc.). 4) Always use the latest and greatest JDK if you can. For example, JDK after 1.6.0_14 have the G1 ('garbage first') collector built in. This collector has reduced pausing and reduced CPU overhead so is definitely worth using for LEAVU (which has a soft-realtime requirement). The brilliant thing about Java is even though Sun have made this massive improvement (similar to the massive internal change to get fully-hardware accelerated Java2D) you code doesn't usually even know the difference (it is a shame Microsoft's offerings don't work like this).
RvEYoda Posted November 23, 2009 Author Posted November 23, 2009 Sry I was wrong, I have Java 1.6.0_17 installed. we really need to talk outside forums. And we need to get this thing rolling, before we talk away weeks :P DCS coordinate system exports same as Lofc 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'
Recommended Posts