Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JOGL .x loader  (Read 4317 times)
0 Members and 1 Guest are viewing this topic.
Offline DanK

Junior Member




Javver games rock yawel!


« Posted 2004-08-28 18:54:23 »

OK, it's not perfect, beautiful, and probably only works for some models (I haven't tested it much yet), but at least for one model it works fine, so here it is.

xloader site

The demo should be able to load and display any static .x model, vertex colors aren't used in the demo and only texture information is implemented for materials (the information is there, I just chose not to implement it for the demo). Let me know if it's useful to anyway.

Offline Jacko

Junior Member





« Reply #1 - Posted 2004-08-28 21:26:16 »

You beat me to it. Been working on one of these myself. Will have to try yours in the morning (coz its getting a bit late now!)
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #2 - Posted 2004-08-28 22:39:58 »

How far do you plan to take your loader, as I've stated skeleton code and animation is probably as far as I'd go, are you planning to write a 100% complete .x loader (such as support custom templates and such)?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #3 - Posted 2004-08-28 23:04:12 »

BTW, do you have a .x models you could share for testing purposes, I'm having a hard time finding any on the web. I could convert one but I'm hoping to find one written by a different program in case I'm relying on formatting that may not be 100% reliable. The model provided in my demo was written with gameSpaceLight.

Online kevglass

JGO Kernel


Medals: 171
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2004-08-29 05:45:47 »

Nice work! Could we have a webstart demo to show us its beauty?

Kev

Offline Jacko

Junior Member





« Reply #5 - Posted 2004-08-29 11:59:40 »

The formatting is what has given me the most grief really. I have the models from the DX9 SDK download, and I have some models exported from 3d modeller. Its been quite hard to make them compatible. I havent got as far as considering animation. I did find the Irrlicht engine to be a useful reference for a way to write a loader.
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #6 - Posted 2004-08-29 12:40:11 »

This page contains useful information about the .x file format and you may find it useful.

http://astronomy.swin.edu.au/~pbourke/geomformats/directx/

I hadn't planned to setup a webstart demo since the important part (loading the model) isn't a visual aspect of the program, but I can set that up.

Webstartable demo, also linked from the site but easier to find here.

Offline ribot

Junior Member




Ribot - mobile UI specialist


« Reply #7 - Posted 2004-09-04 07:14:12 »

I would just like to report that the webstart .xloader works without fault under Mac OS X 10.3.5, Java 1.4.2 Update 1.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline Jacko

Junior Member





« Reply #8 - Posted 2004-09-04 15:25:15 »

Just a quick example of a different type of format for an X file to have. The difference is in how the Materials are referenced. Any suggestions on how to parse something like this welcome!

xof 0303txt 0032

Material LovelyGreenMaterial {
0.588235;0.850980;0.780392;1.000000;;
3.200000;
0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
}

Frame Box01 {

FrameTransformMatrix {
 1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000;;
}

Mesh  {
 8;
 -25.000000;0.000000;-25.000000;,
 25.000000;0.000000;-25.000000;,
 -25.000000;0.000000;25.000000;,
 25.000000;0.000000;25.000000;,
 -25.000000;50.000000;-25.000000;,
 25.000000;50.000000;-25.000000;,
 -25.000000;50.000000;25.000000;,
 25.000000;50.000000;25.000000;;
 12;
 3;0,3,2;,
 3;3,0,1;,
 3;4,7,5;,
 3;7,4,6;,
 3;0,5,1;,
 3;5,0,4;,
 3;1,7,3;,
 3;7,1,5;,
 3;3,6,2;,
 3;6,3,7;,
 3;2,4,0;,
 3;4,2,6;;

 MeshMaterialList  {
  1;
  12;
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0;
  { LovelyGreenMaterial }
 }
}
}
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #9 - Posted 2004-09-05 06:26:25 »

I think just about any variable can be handled like that, where the actual template is defined in some arbitrary location, so you could have something like this...

xof 0303txt 0032

float Zero {
0.00000;
}

Material LovelyGreenMaterial {
0.588235;0.850980;0.780392;1.000000;;
3.200000;
{Zero};{Zero};{Zero};;
{Zero};{Zero};{Zero};;
}

I believe the above is considered OK for a .x file, basically it probably means any time I grab something I expect to be a variable, I should check to see if there is a { or } in it and if so assume it's a variable reference.

To handle this within the current code of my loader, I would probably create a Vector in XModelData called templates, and whenever I ran into a template (such as Material) in the main parser I would call my parseMaterial function but pass it a null for the object it'd normally store things in (MeshObject in this case), when the object is about to store the new material it'd check if the MeshObject was null and if it was, it'd automatically stick the new object into the templates Vector.

Back to finding a { or } when I expect a variable, when this happens I can go through the list of template objects looking for one with a matching name, and if one isn't found, I would then look through the rest of the data tree for a matching name. I know that for a variable to be referenced by a name like that it has to be defined in the file before it's used, I'm not sure if it's particular about heirarchy or if all variable names are supposed to be unique in the file. Anyway, I don't think this would be a big issue to support this format feature, depending on the below stuff. The page I linked to for format information actually uses a similar object as an example (which I hadn't noticed before today) so it's probably pretty common to have some stuff defined globally.


Things to know before I try to implement this.

Can two different materials (most likely inside different Mesh or Frame sections) have the same name, or are the variable names intended to be unique?

Assuming names are unique, in a multi mesh object, should the second mesh that is defined be able to make reference to the first meshes materials by name, or should it only be able to reference those materials defined globally (such as the example posted above).

Can a variable be defined anywhere, or just globally or can a material be defined inside frame (or for example inside animationset)? I'm praying it's global only.

Can any variable be a reference to a pre-defined variable (I believe yes, but I haven't tested this out).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #10 - Posted 2004-09-05 06:34:34 »

Just a note but gamespacelight didn't like it when I tried my { Zero } example with the transform matrix. That could mean that it's not necessary to watch out for variables referenced by name all the time, or that you can't define a variable like I did using a primative type.

Offline snaga

Senior Newbie




Java games rock!


« Reply #11 - Posted 2004-12-19 06:46:31 »


Hey!

great thing! Smiley

I hope you've found your way to load animation, bones, weights... Smiley

Probably is the hardest part (I am not a coder)

You have sample character animated x models at psionic3d.co.uk
Totally free (there are other per pay, of course)

Also, you have an x model in Irrlicht main package (but beware, it has a keyframe every frame, which is not usual, -nor clever for a game- , it is so as was though for a quick game, in md2 format, as you know, md2 it's not dealed with bones keyframes)  at irrlicht.sf.net

The irrlicht engine author made an x loading code for it. You may ask him for help about it, he's a very gentle person. Or at least, you may see the code he used for it, as a clue.

Please....please...make it in a license of the type that could jME java game engine use it... I'm an artist (worked already in some companies) planning to develop a game with a great java coder friend of mine... We can't make a big game as we're only two, but we plan to do that little with quality...

The x boned and weighted format would be really great to have...Most packages have export of x, via free plugins. (Maya, Max, XSI(I have this), Character Fx, Lightwave, Hash AM(comercial plugin), Blender, and many others have it...)

I think it'd benefit jME and any Java engine a lot...

Offline snaga

Senior Newbie




Java games rock!


« Reply #12 - Posted 2004-12-19 07:10:27 »


BTW, the dwarf included in...(a bit embarrased about it) ... Irrlicht engine... I made it. It was made as a joke for some friends that wanted to code a mini game in some days, southpark-like characters in medieval times...a joke. (and a really quick/dirty made)

So , the model is a bit crappy, but served Niko (Irrlicht author) for his testing and coding.

I have also helped a lot with conversions, explanations, tutorials, in those open source engine forums, about the x format, how to make the exports (artist side, only) , and many, but many 3d related questions, as I have been several years, and made this somewhat my profession to make a living of it. And I like to think that I can sometimes if time allows(lately it doe snot allow so much, sadly), give some help.

I helped making the x exporter for Blender (and now it works)  , and with the testing/art side help for the Urgh engine, that also made a great work to allow import of x files into his engine.

is the most spread way to import animated character files in 3d packages. And it works in any platform, mac,  linux, win...

Offline whome

Junior Member




Carte Noir Java


« Reply #13 - Posted 2004-12-20 19:34:17 »

1) I had to tweak a demo code to make it compile.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public class Main {
 public static void main( String[] args ) {
    try {
      JFrame testFrame = new JFrame(); // **1** added JFrame variable
   ....


public class RenderingCanvas implements      GLEventListener, KeyListener {      
  Object gllock = new Object();   //**2** added instance
 GLCanvas canvas;
   ...


Then few comments about the source code.

2) Using Vector, not ArrayList
XModel has Vector instance, not ArrayList. Is it really necessary to use a java1.1 Vector instance here. It's a implicitly synchronized list.
1  
2  
3  
4  
5  
      public class XModelData {
         ...
         public Vector FrameModelList = new Vector();
         ...
      }


Same applies to FrameModel class.

3) loader is lowercased class name
"com.gufbal.dan.xLoader.loader" is lowercased. Probably should be "com.gufbal.dan.xLoader.Loader" name.

Offline DanK

Junior Member




Javver games rock yawel!


« Reply #14 - Posted 2005-01-03 13:29:27 »

I hadn't been checking my yahoo mail lately (oops) and didn't notice people were paying attention to this thread again.

My use of Vector was a matter of being familiar with it, and it's 'safe', and despite being synchronized I never felt that it was making a big impact on speed.

On the package name, I'm not sure why I didn't cap it, I read suns naming convention thingy sometime around 1997 or 1998 and while I always tried to use the conventions, I um, probably haven't ever read it again since the first time (not to mention I'm damn sloppy anyway).

Probably the most important thing is, I have not made any improvements, changes, or what not to this chunk of code in at least 6 months, and since I've actually stopped developing games in java (despite now being the best time ever to be doing it thanks to java-gaming.org and a few others) it's not likely to get much else done to it by me. The code is free to use, and if anyone wants to take it over in a more official capacity I can set it up so that they have access to the website that it's currently hosted on, or change the pages to point to their own web site of choice. To insure a prompt response mail me dan -AT- gufbal com . I'm off to go make note of this on the website.

Offline DanK

Junior Member




Javver games rock yawel!


« Reply #15 - Posted 2005-02-20 04:41:33 »

I've updated the loader, I no longer have a demo available for it, jogl makes my new computer angry so a demo will most likely use LWJGL or JME (over LWJGL) if I write one.

This version should handle the inlined materials without a problem, posted by jacko so long ago, as well as inlined meshes (and inlined frames... necessary for animation). This version also reads in the AnimationSet, AnimationKey and Animation portion of the files. Skeletal animation is possible, however the .x format is a little vague on what a bone is, basically every frame seems to be considered a bone (even a static model will have a frame... presumably just a main bone to the dx engine).

Anyway, thought I'd mention the update here, to my knowledge no one is actually using this for anything (including myself haha) but possibly someone has used it for reference purposes. A small note, loader.java has been changed to Loader.java, but I haven't bothered to change my Vectors to arraylists...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (40 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!