Neverwinter Nights model loader

I have ported my NWN (Neverwinter Nights, http://nwn.bioware.com/) loader from java3d to jme3. It is still very rough at the edges, in some cases port was non-trivial, in other cases original code was not as good as I remember it :wink:



What is working:

  • loading ascii models with tga textures
  • emitters (particle effects) - only subset of those, but 90% of things should look ok
  • orientation-based animations for normal models and for emitters
  • metallic highlights on armors



    What is not working yet (and used to work in java3d version):
  • terrain tiles with walkmesh
  • most probably transparency for colored vertices in some models



    What was never working
  • binary models
  • nwn dds textures
  • wings/tails and bone-base animations
  • more exotic emitter features (linked/lightning one being most notable)



    You can get the code from

    https://nwn-j3d.svn.sourceforge.net/svnroot/nwn-j3d/jme3-nwn/trunk



    To get the loader working, you will need something like

    [java]

    assetManager.registerLocator(“c:\devel\nwn\models”, FileLocator.class);

    assetManager.registerLoader(NwnModelLoader.class, “mdl”);



    ControllableModelPrototype cmp = new ControllableModelPrototype(assetManager, “Doomknight.mdl”);

    ControllableModel model = cmp.createModel();

    Node node = model.getMainNode();

    rootNode.attachChild(node);

    [/java]



    and the you can play around with things like model.playAnimation(“1hslashr”,false);



    I will try to prepare some kind of test application (webstart ?) to show some capabilities this weekend, for now it is only for people who are familiar with NWN already.
4 Likes

Sweet! What license are the NWN models under?


abies said:(...)
I will try to prepare some kind of test application (webstart ?) to show some capabilities this weekend, for now it is only for people who are familiar with NWN already.

The best way to ensure wide adoption and better chance of continued development is by making it a jMP plugin:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:jmonkeyplatform#development

I’m using custom animation and particle system (not sure if it is a problem) and not yet implemented all save/load routines from Saveable interface - I suppose Saveable would be required to be a part of normal model loading scheme ?



As far as license is concerned, it depends.



For playing around, there are quite a few models available at Bioware site. I would not suggest to redistribute them for commercial reasons.

For even more playing around and/or private use, grab a copy of Diamond edition of NWN - for around $5 you get full game (which you may find interesting even now :slight_smile: and hundreds of good quality, animated models/textures etc. Redistributing those is probably complete no go.

For reuse in public projects, there is a repository of free models at nwvault. Especially CEP pack is interesting (http://nwvault.ign.com/View.php?view=Hakpaks.Detail&id=7849) - it contains best-of-the-breed models and they are free to be used as far as I know.

Just a small video of the models in action:



Video link



Sorry for the bad quality, but I’m quite new to all that youtube stuff.

It’s so much fun to see a jME3 scene come so easily together :slight_smile:



Couple things about youtube:

  1. You can easily embed videos here, so long as you add some text underneath to avoid a bug.
  2. Apparently your video was “unlisted”, which I think is why you can’t just paste the plain URL to embed it. (I tried to embed it but it didn’t work, hence the edit to your thread).



    What’s this “Virtual Mat work”?

I made it unlisted on purpose, it is very much work in progress so far - I want to make some more impressive demo before making it searchable.



Virtual Mat is my current hobby project, idea is to play Pen&Payper RPG games with friends over the net (as I’m away from my previous gaming group), using Skype + my program. I tried MapTool some time ago, but seems to be bit dead atm. Wizards of the Coast are doing something, but it looks very old-school - they are trying to recreate what map-tool was 4 years ago



I’ll post some more info about VMat in ‘announcements’ forum when there will be something more to show, for now it was just to present that NWN model loader is usable :slight_smile:

Oh, this looks awesome! Why exactly did you have to implement a custom animation system? jME2 had lots of different systems and we want to void that in jME3 if possible. Maybe we can adapt some parts of your system or extend the existing one?

Yeah its looking like an actual game! Probably a first in jME3 :stuck_out_tongue:

But yeah I am curious about the animation and particle system, is there anything we can do to make those systems more suitable for your use? Or is it because they are not documented well enough?

Just added metallic highlights on armor to svn. Shader programming is not that hard if you have google at hand :wink:



As for why I have not used particle system and animation from jme3:



Most important point is that I got it working right in java3d version of loader and there are some non-trivial things there. I wanted first to get it working in same way, before trying to change the logic. Now, as things are working, I can consider really porting them to jme3 systems, but:



Animation - in NWN, most of the models are not using bone animation system, but hierarchical nodes. Each part (hand, forearm, head, sword etc) are separate, ‘immutable’ objects, which are just rotating around joints. This had a major benefit of being very fast in old days, as it was possible to offload all transforms to GPU (and skinning required CPU help back then).

From what I have seen in jme3, animation is very much bone/skin specific. I do not think there is much in common, except AnimChannel - I had to create almost the same API in AnimationBehavior. Still, AnimChannel has things like affectedBones - so even if API is similar, it is still very much oriented towards existing solution.

Said that, some of the newer NWN models are using bone/skin animation for some of their parts and there is a big chance I will use jme3 system at that time (but still, embedded in my current one).



As far as particle system is concerned, it was just too complicated to try to map all the concepts at one go :slight_smile: Still, there are some things missing from jme3 particle system. I will try to list them - please correct me if I’m missing something

  • two gravity systems - one which is always world-down and second which is center of emitter
  • bigger control about particle spawn - you can specify width of random angle and size of emitter ‘face’
  • particle ‘animation’ system along the texture; in jme3 I think there is only way to select random phase, not progress through them ?
  • aligned-to-y axis particles, which allow to reuse it for on-ground markings (kind of billboard inside particle)
  • motion blur (not sure if it is yet working in jme3 port, was working in java3d) - particles are elongated along the speed axis



    Some of those things would be trivial to add to jme3 (spawn control for example), things like motion blur would require bit more changes. Still, I see a lot more chances for covergence here than in animation system, as there is nothing inherently different in the approaches.
Each part (hand, forearm, head, sword etc) are separate, ‘immutable’ objects, which are just rotating around joints. This had a major benefit of being very fast in old days, as it was possible to offload all transforms to GPU (and skinning required CPU help back then).

This sounds very similar to a bone system, except every vertex is only effected by one bone, right? This should be compatible with the current system. Every object is assigned one joint, then all of them are added to the AnimControl. and the skeleton is essentially the hierarchy of nodes.

- bigger control about particle spawn – you can specify width of random angle and size of emitter ‘face’
- particle ‘animation’ system along the texture; in jme3 I think there is only way to select random phase, not progress through them ?
- aligned-to-y axis particles, which allow to reuse it for on-ground markings (kind of billboard inside particle)
- motion blur (not sure if it is yet working in jme3 port, was working in java3d) – particles are elongated along the speed axis

I think jME3 supports all of those.
The particle spawn is done using emission shapes (you can specify particles to emit in a box shape for example)
Animation is possible throughout the life time of a particle (using a 3x3 image and advancing through the images)
Aligning to Y axis, not sure what that means but on ground markings you can do using setFacingDirection() with UP vector.
Motion blur is also supported by making particles face velocity.
All of these features are used in the TestExplosionEffect demo, I recommend you check it out as it really shows how to use the particle system.

For the bones stuff - it should probably work, I might try it out when I’ll be implementing skin/bone animation for dragons.



As far as particles are concerned - it seems I have missed a lot of possibilities when browsing the code. Regarding ‘motion blur’ - in NWN, length of the particle is dependent on it’s speed, is it the same in jme3 particle system ?



In any case, it was fastest for me to just port existing java3d system (even if I had to struggle a lot with world-to-model transforms, still not sure if I got everything right). I might consider porting the things one by one to more idiomatic jme3, when I have working thing to compare against - but to be honest, priority for me now will be mostly getting Virtual Mat to bit more usable shape.

Another video, this time with ‘forcefield’ selection mode (this time in HD quality).



I’m shocked how easy this ‘forcefield’ effect was with jme3. Just find all Geometry nodes for model, get the mesh out of them, create another Geometry with same mesh but transparent material, setLocalScale to 1.2, add to same parent node as original geometry, done. Benefit here is that transforms are not done on geometries themselves, but on parent nodes, which is a side effect of implementation, but comes useful now.

1 Like

Good work so far!!

This is really neat

Nice work!



Do you know about http://darkmmo.worldwizards.net ? Maybe there are some things you can reuse. I think there is a binary model loader.

Thanks - I had no idea about darkmmo. From very brief glance on their code, they seem to be more advanced on tiles/walkmesh things, but probably lacking in emitter/particles things. I could see some synergies :wink: They seem to have very well developed non-model management (all other kind of nwn-related files).



Only thing I could see as possible issue is licensing - I will have to think more about it before starting to use their code.

Maybe https://jnwn.dev.java.net/ is useful as well, but it’s very old.

madlion said:
Nice work!

Do you know about http://darkmmo.worldwizards.net ? Maybe there are some things you can reuse. I think there is a binary model loader.

madlion said:
Maybe https://jnwn.dev.java.net/ is useful as well, but it's very old.

Those projects are the same. Or well, they're by the same developer. @jeffpk has been moving through a handful of different development platforms, from at least Java3D -> jME2 -> Ardor3D -> O3D.

His agenda seems like it might merge nicely with what @abies has going on here though. He's clearly a talented guy, so I'd definitely try getting in touch with him to see what he's up to these days if I were you. I'm very curious myself, so I'll gladly contact him if you don't wanna :P
erlend_sh said:
Those projects are the same. Or well, they're by the same developer. "jeffpk" has been moving through a handful of different development platforms, from at least Java3D -> jME2 -> Ardor3D -> O3D.

Oh yes ofcourse your right! I didn't remember this. To bad he left the use of jme.

I loaded some of the NWN models with @abies code.
Here it is:
[video]http://youtu.be/a8GwvxA51ag[/video]