Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

WebGL effort

Information, contacts and source code for ports to Linux, Windows, etc.

Moderators: winston, another_commander

User avatar
kanthoney
Commodore
Commodore
Posts: 281
Joined: Thu Nov 07, 2013 10:21 pm

Re: WebGL effort

Post by kanthoney »

Is this any good?
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

kanthoney wrote:
Is this any good?
Not sure.

$ python pltojs.py /usr/local/src/oolite/Resources/Config/shipdata.plist shipdata.json
Traceback (most recent call last):
File "pltojs.py", line 22, in <module>
if __name__ == "__main__": main()
File "pltojs.py", line 11, in main
plistObject = plistlib.readPlist(sys.argv[1])
File "/usr/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/usr/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0


From what I can guess from the help file, the python library plistlib only reads the XML version.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: WebGL effort

Post by cim »

There's a large number of nodejs modules to parse plists, most of which would probably work with in-browser JS with minimal modifications
https://www.npmjs.com/search?q=plist

(Probably quite a few of them only work with XML or Binary rather than OpenStep format plists, but you might get lucky)
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

There are now only two models but that's because I rewrote quite a few things (in preparation for multi-textures models notably) and now the data conversion process is a bit more involved.

Until I find out how to convert the plist into JSON automatically, I do it manually (it's not too hard, fortunately). I also need to insert the mesh into the "model" entry. I will focus on doing things on a very few number of ships.

I can now read data such as a the "custom view" quaternions. I created a drop-down menu to select them. Interestingly enough I don't quite get the expected view, which means there is a coordinate system mismatch somewhere.

Image

EDIT: Ok apparemment les quaternions dans les fichiers plist sont au format W X Y Z et non X Y Z W comme dans glMatrix.
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

Ok I now understand how to put several ships in the scene their own attitude/position parameters.

Image

I should soon be able to tackle displacements.

I made this part in a different html page:

http://grondilu.github.io/oolite/
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

I got a first prototype of the compass working.

Image

http://grondilu.github.io/oolite/test-compass.html
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

OK, first try at controlling speed:

http://grondilu.github.io/oolite/test-coriolis.html

Image

Setting the matrices in the correct order and stuff was quite a headache. As a matter of fact I proceeded a bit by trial-and-error at some point so to be honest I'm not entirely sure everything is fine, but it seems OK.

Docking is obviously quite difficult without the scanner, not to mention the lack of fine tuning in the controls. But even with just the compass it seems doable.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: WebGL effort

Post by Norby »

grondilu wrote:
the lack of fine tuning in the controls
Nice minigame, I can "dock" without problems from any angles, just I feel myself in an Anaconda and missing the return to zero of pitch/roll when I release the keys.
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

First attempt at drawing stars:

Image

http://grondilu.github.io/oolite/test-coriolis.html

I used the Hipparcos catalog and drew the stars as points on a large (1Mm but I could use any value) sphere around the observer.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: WebGL effort

Post by cim »

Looking good.
grondilu wrote:
I used the Hipparcos catalog and drew the stars as points on a large (1Mm but I could use any value) sphere around the observer.
"Sphere of fixed stars" is about how Oolite does it. Ours is only at 75km - but is drawn first in the scene with depth-buffering disabled, so appears to be behind everything.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6574
Joined: Wed Feb 28, 2007 7:54 am

Re: WebGL effort

Post by another_commander »

grondilu wrote:
First attempt at drawing stars:

Image

http://grondilu.github.io/oolite/test-coriolis.html

I used the Hipparcos catalog and drew the stars as points on a large (1Mm but I could use any value) sphere around the observer.
Can I have a laser so I can pew-pew the station?

Jokes aside, I like a lot where this is going. And the flight model as it is right now is interesting, too. It kind of feels Newtonian, but I find it very challenging.

Looking forward to the full game. ;-)
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

cim wrote:
Looking good.
grondilu wrote:
I used the Hipparcos catalog and drew the stars as points on a large (1Mm but I could use any value) sphere around the observer.
"Sphere of fixed stars" is about how Oolite does it. Ours is only at 75km - but is drawn first in the scene with depth-buffering disabled, so appears to be behind everything.
Interestingly enough, I wrote a projection matrix especially for stars, with the far plane at the infinite (that's actually possible, because mat4.perspective has a limit for f -> infinity), so I could put the actual stellar distances in real units, and it'd still work. That'd be unnecessary since no parallax would be visible, but still.


PS. Just checked by setting the radius at 1e15m. Still works. Oops, sorry, I was not looking at the local branch. 1e15m is too big for some reason. Not sure why yet.
Last edited by grondilu on Thu Jul 09, 2015 10:36 am, edited 3 times in total.
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

another_commander wrote:
Jokes aside, I like a lot where this is going. And the flight model as it is right now is interesting, too. It kind of feels Newtonian, but I find it very challenging.
I suspect it's because you were looking at the compass too much, and it may still have bugs. (I've just made a few fixes but it's not tested much).
grondilu
Competent
Competent
Posts: 48
Joined: Sat Jun 27, 2015 2:48 pm

Re: WebGL effort

Post by grondilu »

If I try very hard to put the stars on an astronomical distance (say 1e15m), first I get nothing if I try with Float32Array. If instead I try with a Float64Array, I get an interesting artifact :

Image

The stars seem to align on particular directions in the sky. I suspect it's because of the lack of precision in the trigonometric functions.
Post Reply