from json to sqlite and custom sql function

Elite Dangerous, has a fairly decent sized data set, and players have done (great work!) a number of different things to scrape data from the application, mainly to help with the woefully poor trading information that the application provides you with… One of the better databases has a web presence at eddb.io the data is available in json format, this has two drawbacks first ascii isn’t the most compact of media and as is often the case with json, data that should be in different tables is munged together into individual responses.

Take for example the stations json, this is an array of all the json responses you’d get from querying each station in turn (assuming there was a live json interface!) this is great except that with each station, you also get a list of its commodity prices, this is data that really should be in its own response ideally, so you’d query for station details then query for an array of commodities at that station, rather than receive all this data bundled together, especially as currently its only available as a data snapshot…

I looked at quite a number of libraries and a number of different languages, and I have to say I was less than impressed with the quality and lack of robustness with a number of solutions (to say the least)

By far the easiest to use and by far the most robust was Python, and I guess I shouldn’t be surprised that for chomping through data and rapid development Python really is a great tool.  The script I ended up creating takes 140mb of json and creates 3 tables and a couple of support tables and bundles them into just over 35mb of sqlite database. (in a little over 10 seconds on my machine)

I chose sqlite as its compact, and from sqlite its easy to spew output either as data in a new format, or for presentation.  While technically a binary format, its very open and very accessible and fairly data dense too.  You might tell I’m a bit of a fan – its kind of a data swiss army knife!

creating a python object from a json file is really (very!) simple

commodities = json.load(open("commodities.json"))

assuming that the json is an array of responses (a fairly typical case) you end up with an iterable list of dict objects, each dict being in effect the fields of each response or record.

While iterating each item it is fairly easy (make work) to pick out foreign table data for later storing in another table, while updating the main table from the json file.

Looking at the whole code for creating the commodities table…

commodities = json.load(open("commodities.json"))
categories = {}

eddb.execute('create table commodities (id,name,ave_price,catid)')

for c in commodities:
    eddb.execute('insert into commodities values (?,?,?,?)', [c.get("id"),c.get("name"),c.get("average_price"),c.get("category_id")])
    cat = c.get("category")
    categories[cat.get("id")] = cat.get("name")
    
conn.commit()

eddb.execute('create table commod_cats (id,name)')
for c in categories:
    eddb.execute('insert into commod_cats values (?,?)',[c,categories[c]])

conn.commit()

Its clear to follow in the first loop that I’m collecting commodity category data as the commodities table is being, while overwriting the same category id potentially every loop is far from idea the impact seem minimal, indeed check the id exists and doing nothing could potentially take the same or more time!

The second loop is then just a case of throwing small amount of data into the support table…

As you can see from the code fragment the syntax of Python is very clear and aided no end by one of its best assets – formatting defines code blocks… this forces even sloppy coders to be neat! (probably why some people hate it!)  Python is also scary fast, much faster than you’d expect it to be, but then its much more than just a “simple” script interpreter if you’re interested this is a great post

Of course the one disadvantage of making a custom script is it will immediately break given any change of data structure, but then it would be a very powerful importer that could intelligently analyse changing data structures and produce something suitable for a typical relational database…

One of the immediate questions I had for the newly parsed data involved distances in three dimensions, now while some SQL guru could probably work out some pure SQL solution (actually probably not as there are little other than basic Math in sqlite)

So now I really do have an excuse to make a custom function (YAY!) while I initially made a prototype in C I could have as easily started in Java as we’ll see later…

The most complex part of a custom function is the actual function itself – actually integrating it using it is really trivial

static void distance3d(sqlite3_context *context, int argc, sqlite3_value **argv) {
    if (argc == 6) {
        double x1 = sqlite3_value_double(argv[0]);
        ... four similar line here!
        double z2 = sqlite3_value_double(argv[5]);

        double result = sqrt( pow(fabs(x1-x2),2) + pow(fabs(y1-y2),2) + pow(fabs(z1-z2),2) );

        sqlite3_result_double(context, result);
        return;
    }
    sqlite3_result_null(context);
}

I’ve removed some of the line to reduce the space this fragment takes up, this is the basic minimum you can get away with and if you’re dealing with strings you’ll have to pay a lot more attention to validating and ensuring you don’t leak, (I could see it being all too easy to cause problems!) The sqlite_ functions are basically self explanatory and are very nicely documented on the sqlite website.

To tell sqlite about it

sqlite3_create_function(db, "distance3d", 6, SQLITE_UTF8, NULL, &distance3d, NULL, NULL);

using is then just like its any other sqlite sql function…

select name,round(distance3d(75.75,48.75,70.75,x,y,z),2) as distance,x,y,z from systems where distance<7

The coordinates used here are for a little known system called Lave… the query will pull out all systems within 7 light years of Lave.  I wonder if you can guess what system is at coordinates 0,0,0 ? 😉

Quite why I assumed a Java sqlite library wouldn’t support custom functions, I don’t know I’m sure…

I used sqlite-jdbc there are other solutions including a pure java port that I really must investigate at a later date…

Java custom functions are more object oriented – you make a class that extends Function, and override / use its methods to achieve your evil designs… for example the value_double(int param); method will get a function parameter as a double value, while the return methods will do just that with values!…

itegrating the function is as simple as calling a static method of Function

Function.create(connection, distance3d.class.getSimpleName(), new distance3d());

So the lesson to take from this is a guess that it is very easy almost trivial to extend sqlite via custom functions and because of its light weight nature its very quick, although not a server architecture – if you’re mainly reading it can me used in even volume web scenarios – of course there are plenty of people who would throw their hands in the arm at the mention of a server-less data back-end but then you have to closely analyse your requirement in every case anyhow…

All in all sqlite has a lot going for it especially in its intended sphere on the desktop, one place where it especially shines is for data transfer to unknown destinations, for example you could make data available in csv format or json format, but then equally why triple your file size and therefore bandwidth requirements… while you can compress csv or json effectively (and smaller than sqlite) neither is a ready to go format, for example you can download a sqlite file, open it in your favourite SQL environment and begin asking questions of the data – immediately.

Posted in Uncategorized | Leave a comment

Shutit from script prototype to initial application

I first introduced a simple script to handle logging off, resetting and shutting down in a simple prototype script a dubbed shutit

Having run this tiny GUI for a while and satisfied how it ran, I decided (mainly for the intellectual exercise) to develop this further and also remove its dependency on the no password setting in sudoers

Because of security concerns it’s not possible to run a GTK application with the setUID bit of its permissions set.  This is good practice because its very hard to adequately audit such a large library as GTK, having a small “helper” application is very much easier to control and audit – while you shouldn’t run screaming from the setUID bit, it should certainly be handled with care.

First of all we’ll look how this helper application is installed and used as this is equally as important as the actual code!

sudo cp shutit-helper /opt/shutit/
sudo chown root /opt/shutit/shutit-helper
sudo chgrp users /opt/shutit/shutit-helper
sudo chmod 6750 /opt/shutit/shutit-helper

the permissions and ownership are specific to how the helper is used

chris@localhost ~ $ ls -l /opt/shutit/shutit-helper 
-rwsr-s--- 1 root users 8021 Jul 7 23:49 /opt/shutit/shutit-helper

put simply only people in the “users” group or root (and hopefully not daemons etc!) can run this application,  people in the user group will in effect be running the helper as if they were root but without needing to enter a password.

however as you will see next the utility of the helper application is very narrow and there are no user supplied configuration… (specifically to reduce issues)

#include <stdio.h>
#include <unistd.h>

int main (int argc, char **argv) {
   // exit silently unless one of two magic parameters is given...
   if (argc==2) {
       if (strcmp(argv[1],"reboot") == 0) {
           printf("reboot\n");
           execl("/sbin/reboot", "reboot", NULL); 
       }
       if (strcmp(argv[1],"poweroff") == 0) {
           printf("poweroff\n");
           execl("/sbin/poweroff", "poweroff", NULL); 
       }
   }
}

Only root or users can use this in the first place and all they can do is call poweroff or reboot, the path for reboot and poweroff commands are hard coded and can in no way be influenced by calling the helper – for example you couldn’t change some config and wipe the OS with only user permissions…

So we now have in place a reasonably secure way for a none root application to poweroff or reboot the system, the next piece in the puzzle is the gui.

I’ve chosen GTK because I’ve used it in the past, but also if you want to throw up a simple gui, then you can do so programatically – without GUI designers, pre-compile parsers etc…

We have a simple config in ~/.config/shutit/shutit.conf

[settings]
logoutCommand = xfce4-session-logout --logout --fast
helper = /opt/shutit/shutit-helper

there is only minimal config checking (so room for improvement there), the glib library (a dependency of GTK) has a handy set of utility calls which makes parsing “ini” type settings into a C struct convenient and easy.

From there its just a case of responding to button events appropriately.  If the logout button is clicked the logout command (from the config) is run,  as this is about logging out a users session, you should only specify a command that’s runnable with the users permissions.  The other responses are basically a case of executing the helper app with an appropriate parameter for the required action.

Notice anywhere that a command is being built from configuration, this is done with the snprintf function. This limits the resulting string to a specified size – in this case the maximum size of the resulting string.

Make sure you read the previous blog post to see how to integrate the application into most application (“start”) menus.

If you have a use for it or are interested in taking it further all the files are here shutit.tar.gz

Posted in Uncategorized | Leave a comment

Integrating beta version of Java with Gentoo

If you’re using Gentoo I think we can dispense with obvious stuff like using sudo to extract a tar ball to /opt ….

While you could make temporary modifications to your PATH for a terminal session things are altogether more comfortable if you can use eselect / java-config to quickly and easily switch between jvm’s and compilers.

java-config stores the VM configurations in /usr/share/java-config-2/vm/ pity its not in /etc but ah well…

its very easy to see from this sample configuration how you can modify it for whatever version / path you need

VERSION="Oracle-Sun JDK 8u_60"
JAVA_HOME="/opt/jdk1.8.0_60"
JDK_HOME="/opt/jdk1.8.0_60"
JAVAC="${JAVA_HOME}/bin/javac"
PATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
ROOTPATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
LDPATH="${JAVA_HOME}/jre/lib/amd64/:${JAVA_HOME}/jre/lib/amd64/native_threads/:${JAVA_HOME}/jre/lib/amd64/xawt/:${JAVA_HOME}/jre/lib/amd64/server/"
MANPATH="/opt/jdk1.8.0_60/man"
PROVIDES_TYPE="JDK JRE"
PROVIDES_VERSION="1.8"
# Taken from sun.boot.class.path property
BOOTCLASSPATH="${JAVA_HOME}/jre/lib/resources.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/jsse.jar:${JAVA_HOME}/jre/lib/jce.jar:${JAVA_HOME}/jre/lib/charsets.jar"
GENERATION="2"
ENV_VARS="JAVA_HOME JDK_HOME JAVAC PATH ROOTPATH LDPATH MANPATH"
VMHANDLE="oracle-jdk8u_60"
BUILD_ONLY="FALSE"

NB I have marked in red any path or version specific entries that you’ll need to change.

Once you have that in place just use eselect / java-config  as you would normally.

Posted in Uncategorized | Leave a comment

from blender to JavaFX (via wavefront obj)

I decided to make a simple hack to import static wavefront OBJ files into JavaFX, and when I say simple and hack I do mean both!

You run my converter like this

java -cp src obj2javafx resources/cube.obj > src/cube.java

you must ensure that you send the output to a java file with the same name as the OBJ file, so cube.obj becomes cube.java …

OBJ files must have triangulated mesh and include normals and texture UV’s additionally make sure it consists of just one group/shape

You then simply include this in your project, using it is quite straight forward

MeshView obj = new MeshView( new cube() );
PhongMaterial mat = new PhongMaterial();
mat.setDiffuseMap(new Image("file:cube.png"));
obj.setMaterial(mat);

bare in mind that something like the default Blender cube which is 1x1x1 will look very very small so will need scaling! (or you can work in larger units in Blender)

When it breaks don’t forget you get to keep both pieces, use at your own risk and consider it public domain.

obj2javafx.java

Enjoy!

Posted in Uncategorized | Leave a comment

Getting rid of *kit, no policykit no consolekit etc etc etc

I’ve always has issue with especially policykit for its arcane config files and lack of a single definitive go document source

who.knows.what.setting.to.change!=unusable

or course next week its probably

blame.the.user.they.dont.know.it.got.changed

and aside anything else all these “essentials” are plain just not necessary and almost certainly do get in the way and make life harder!

As anyone who as installed a minimal cruftless Gentoo install its actually not difficult to avoid things like policykit and consolekit – unlike systemd you don’t even need a simple mask – just keep your eye on what newly installed packages have in their USE flags…

For me there were only a couple of thing’s missing – one was automounting which isn’t a major feature for me pmount-gui and a couple of desktop files to make a mount and unmount menu appear make a trivial replacement.

shutting down and resetting does require a password and while I could easily live with this I decided to make my own logoff menu.

While you can do loads with python and for example gtk, I decided on an even more rapid solution – zenity is a really nice bit of kit…

First off though some ground work

%wheel ALL=(ALL) NOPASSWD: /sbin/reboot, /sbin/poweroff

this means all in the wheel group can use sudo reboot (or poweroff) without need for a password, you may want to change this to specific users or create your own group for this function, its your system all said and done!

The menu script using zenity is really quite an easy and simple bash script

#/bin/bash

int=`zenity --height 240 --list --text ''  --column 'Select...' "Log Out" "Reboot" "Switch Off" `

[[ $int = "Log Out" ]] && xfce4-session-logout --logout --fast 
[[ $int = "Reboot" ]] && sudo reboot
[[ $int = "Switch Off" ]] && sudo poweroff

Its fairly self evident what’s going on here… create a desktop file for it in ~/.local/share/applications also copy /usr/share/applications/xfce4-session-logout.desktop into ~/.local/share/applications then as we don’t want to see it add the following key/value

Hidden=true

and now for the hardest part – editing the xfce menu first you need to copy /etc/xdg/menus/xfce-applications.menu to .config/menu

I’ve always has issue with especially policykit for its arcane config files and lack of a single definitive go document source

who.knows.what.setting.to.change!=unusable

or course next week its probably

blame.the.user.they.dont.know.it.got.changed

and aside anything else all these “essentials” are plain just not necessary and almost certainly do get in the way and make life harder!

As anyone who as installed a minimal cruftless Gentoo install its actually not difficult to avoid things like policykit and consolekit – unlike systemd you don’t even need a simple mask – just keep your eye on what newly installed packages have in their USE flags…

For me there were only a couple of thing’s missing – one was automounting which isn’t a major feature for me pmount-gui and a couple of desktop files to make a mount and unmount menu appear make a trivial replacement.

shutting down and resetting does require a password and while I could easily live with this I decided to make my own logoff menu.

While you can do loads with python and for example gtk, I decided on an even more rapid solution – zenity is a really nice bit of kit…

First off though some ground work

%wheel ALL=(ALL) NOPASSWD: /sbin/reboot, /sbin/poweroff

this means all in the wheel group can use sudo reboot (or poweroff) without need for a password, you may want to change this to specific users or create your own group for this function, its your system all said and done!

The menu script using zenity is really quite an easy and simple bash script

#/bin/bash

int=`zenity --height 240 --list --text ''  --column 'Select...' "Log Out" "Reboot" "Switch Off" `

[[ $int = "Log Out" ]] && xfce4-session-logout --logout --fast 
[[ $int = "Reboot" ]] && sudo reboot
[[ $int = "Switch Off" ]] && sudo poweroff

Its fairly self evident what’s going on here… create a desktop file for it in ~/.local/share/applications also copy /usr/share/applications/xfce4-session-logout.desktop into ~/.local/share/applications then as we don’t want to see it add the following key/value

Hidden=true

and now for the hardest part – editing the xfce menu first you need to copy /etc/xdg/menus/xfce-applications.menu to .config/menus/xfce-applications.menu this allows you to edit the menu without it getting overwritten next update.

immediately after the entry for “about” add your own entry

        <Filename>xfce4-about.desktop</Filename>
        <Filename>shutit.desktop</Filename>

You can see here the shutit.desktop I created for the script – and hopefully thats all there is to it.

So can you really survive without policykit consolekit pulseaudiokit and systemdkit…? well yes basically Gimp, Blender, Lmms, Libre Office, etc all just carry on quite happily AND you have something less mysterious and altogether easier to maintain…

Posted in Uncategorized | Leave a comment

XPS 13 – nice hardware shame about the vendor

IMG_20150626_154054Its nice to see a machine supplied with Linux, especially one that’s both light weight and a good spec.  However its a shame in my opinion that in this case the experience with the particular vendor and the software implementation was decidedly lacking.

There are plenty of nice touches mind, from the feel and look of the carbon fibre surrounding the keyboard, and the aluminium case its definitely obvious that some thought has gone into the physical design of the machine.

Lets get the vendors poor performance out of the way, imagine that your relationship with a vendor begins with you being deliberately deceived.

Their on-line shop makes a big deal of dispatched within 1-3 or 3-5 days (depending on the product) but when they know full well the product won’t reach you for two weeks (yes at least TWO weeks) that really is an obvious deception.  Its not even made clear where the machine is coming from – is it unreasonable to expect final assembly to happen in the same country as the shops domain ?…

But wait even if its from some sweatshop in China it doesn’t take two weeks to get something halfway across the world (seriously you’d be surprised how fast stuff travels now-a-days!!) … My guess is that your property (and by now that’s what it is) is basically sat waiting for enough machines to pile up, to make it economically viable for them to feel it’s worth giving you your property.

I dread to think the work condition of the people who built my machine on a Sunday afternoon…

IMG_20150626_154228I won’t even go into the unprofessional comedy of errors that is customer “support” (being “handled” really makes you feel valued) Enough already!

Just as the keyboard surround and display are well done, on the outside the metal case is of equally good quality, the metal has a nice finish and is easily rigid enough to supply good support to the internals of the machine.

Sadly we must return to the less than satisfactory, that being the software on the machine.  I used to be a fan of Ubuntu, it used to be fast and reliable and you could configure your machine just how you wanted it with ease.  Fast forward some six or so years… oh dear… Now I have a halfway decent OS on the machine I can barely believe the difference…

I strongly objected to the EULA that was sprung on me without warning – so verbose I have no idea what it means and I really should have been obviously and clearly warned, and been able to view the EULA BEFORE purchase.  Fortunately for me as I left the machine unattended for a while, the wife randomly mashed the keyboard… oh well at least I didn’t have to agree to that nonsense…. (Incidently the F12/F2 BIOS menu will allow you to boot install media without having to enter some unexpected legal agreement just so you can use YOUR property)

IMG_20150626_154302Before detailing some of the short comings with the supplied software, I’ve got to mention how portable the machine is – so much more convenient than any other laptop I’ve had – even more so that my wife’s original Eeepc! much thinner a little larger but a whole heap lighter…

Out of the box there are a number of software issues.  A track pad that randomly pauses, a keyboard that randomly repeats characters and random lengthy pauses on boot even hanging on shutdown sometimes !

While I was fairly quickly able to fix these issues by installing and correctly configuring Gentoo, one minor irritation was their choice of wifi card, why oh why would you use a card that isn’t included in the kernel tree? especially when its the machines only networking device… I’d be tempted to drop in a spare Intel card but from the looks of the tear downs they haven’t included standard mounting pillars for the wifi card – very disappointing…

Much less of an issue but still disappointing is that there are only two USB sockets, not a drama but to be honest I think I’d have preferred another USB versus an SD slot…

A good well implemented feature is the BIOS, UEFI seems well implemented and there are some nice features, I’ve seen a few fun posts about making FreeDos boot media to update the BIOS, but that’s not even required.  I was able to simply put the update exe onto the EFI partition and after pressing F12 direct the BIOS update to it… job done… as simple as it should be…

….but yeah why did I have to upgrade to the current BIOS version on a new machine… sadly I think this is symptomatic of the sub par performance of the so called “skunk works”, poor choice of network card aside the lack of up to date BIOS on some machines can only have hampered their less than stellar solutions…

So, will I be using my legal 14 day right to cancel ? well.. actually no, once you spend some time on it you can tame this machine into a really nice bit of kit.

It plays Kerbal Space Program better than than my two and a half year old i5-3210M, the i5-5200 does seem to make a noticeable difference – who’d a thought – progress !

So would I recommend it? well yes and no! If you have some level of skill and can buy it from a bricks and mortar store and take it away there and then and you can get a decent discount – then go for it… eventually its a really nice machine…

Posted in Uncategorized | Leave a comment

Intel HD5500 disable v-sync

I posted some while ago about v-sync and intel GPU’s and I’ve found the same issue and work around as before, just to re-iterate its just ~/.drirc that needs changing and you can use the driconf gui but it will get the driver name wrong… or rather it will use the right driver name however the only driver name that seems to have any effect is dri2 !

here’s the ~/.drirc that I’m currently using on a system with a HD5500

<device screen="0" driver="dri2">
 <application name="Default">
 <option name="vblank_mode" value="0"/>
 </application>
</device>

I have no idea if this is an issue with dri2 or with the Intel driver or driconf, much less where I could report it too…

 

Posted in Uncategorized | Leave a comment

Logic Toy – a logic simulation toy

xorI had an idea for a game, part of which needed a grid based logic simulation, so I wrote a prototype logic engine.  As these things tend to do, it kinda took on a life of its own.  The basic premise is that each edge of a tile (North, East, South and West) can be ONE of nothing, an input or an output.

While Wire “gates” (for connecting things) have only one input then can have multiple outputs to allow branching of a signal.  Cross or bridge gates allow a cross roads, keeping the horizontal and vertical signals separate.  Input gates are the only gate that you can interact with and act as the circuits inputs, you can toggle the state of the input by right clicking it.

While there are still some areas needing work, its already rather functional.  The four images above show a circuit with every permutation of its inputs.  The four logic gates at the top of the circuit (AND x2, NOT, OR) replicate an XOR gate.  As you can see the output matches the output of the XOR logic gate.  This shows that both the XOR gate and also a simple circuit combining different logic gates also works.

logictoypropsEditing a circuit is straight forward, as you can see from the picture, its just a case of selecting where the inputs and outputs are and what logic function should be used.

I’d be interested to hear feedback or ideas, grab it here Enjoy!

Proof 12+7=19!

nibble-adder

 

Posted in Uncategorized | Leave a comment

JavaFX with Ode4J (physics!)

jfxOde4jWell I have to say I was quite disappointed when looking round for a pure Java physics library and I’m most grateful for the quality of Ode4j ! It seems to fit in quite nicely :)

Despite initial misgivings about lambda’s I have to say I’m now a convert!  Not just with JavaFX but take this example of doing a collision callback in ODE

 

Normally you’d do this…

    public void partOfAnUpdateMethod() {
        if (!pause) {
            space.collide(null, nearCallback);
        }    
        ...
    }
        
    private static DNearCallback nearCallback = new DNearCallback() {
        @Override
        public void call(Object data, DGeom o1, DGeom o2) {
            nearCallback(data, o1, o2);
        }
    };
    
    private static void nearCallback (Object data, DGeom o1, DGeom o2) {    
        ...

Not quite as horrid as an anonymous class (embedded in a parameter) but still a little unwieldy! Using a Lambda you can instead do this… (Can you tell I’m not a fan of anonymous classes!)

    public void partOfAnUpdateMethod() {
        if (!pause) {
            space.collide(null, (d,o1,o2)->nearCallback(d,o1,o2));
        }    
        ...
    }
    
    private static void nearCallback (Object data, DGeom o1, DGeom o2) {    
        ...

Now I know the syntax could be better -> doesn’t mean anything in English, and so makes it less accessible to the novice, but I know which code I’d prefer to read and maintain.

I ended up making a nice little PhysObj class to “weld” JavaFX and Ode4J components together.  It builds on my earlier JavaFX work and utilises my Pivot class so you can hang multiple visuals onto it and they will all be effected by the Ode4j body in the PhysObj.

Encapsulating a new shape type (for example a triangle mesh) is just a case of extending PhysObj and should (famous last words?) be fairly trivial, I’ve supplied three extended classes to encapsulate boxes, spheres and cylinders.

And speaking of cylinders I’m guessing this version (of Ode4j) is using the CCD collider by default as cylinders actually collide, and generally behave as you’d expect!  (but I guess that’s a problem from long ago) Indeed with just 24 iterations per step, the simulation was stable and well behaved with 50 odd primitive shapes in proximity enough to give plenty of collisions everything looks good and solid…

Updating the visual objects with their Ode4J counterparts was really simple too, while just copying the whole 4×4 matrix would probably have been more efficient I ended up just using the Ode4J bodies rotational quaternion and position…

One minor issue (and issue is probably a bit strong!) was that Ode4J’s quaternions and vectors don’t have named “gets” like getX,getZ etc but instead have get0(), get2() so I had guess which was W as some people use a W,X,Y,Z order and some use an X,Y,Z,W order… and it was late…

One thing JavaFX should do in future is allow for much tighter and lightweight frameworks and a lot less library path nightmares!

You can grab the full example code here jfxOde4j.tar.gz

Posted in Uncategorized | 2 Comments

JavaFX gui in a 3d scene

javafx3d-gui

Well one thing for sure I like JavaFX GUI coding! Its even easier to use than swing and as you can see above you can just drop a GUI into your 3D scene.  Its so easy to do I won’t even bother running through the code!

The gui just works responding to mouse events as you’d expect without having to do any transforms and/or injecting events as you might have to do when hacking some toolkits together :/ ….

In the sample code I’ve also added some extra matrix utilities the controls are as follows

Dragging rotates the view, holding down shift while clicking an object will show a little gui attached to the object that shows its position numerically (its not editable but it could be, and could actually edit the position easily)

Finally holding the right mouse button down moves the camera forward in the direction it’s facing

You can get the code here jfxGuiTest.tar.gz

Posted in Uncategorized | Leave a comment