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] 2
  ignore  |  Print  
  Removing Strips and Fans From MD2 Exporter  (Read 5355 times)
0 Members and 1 Guest are viewing this topic.
Offline arkdm

Junior Member




Go Pooh on yourself


« Posted 2006-06-05 02:41:32 »

Ok - I have a strange question. Not even sure if this is possible but I'll give it a go:

The md2 exporter for blender is not working properly, and hasn't been working properly for the past few years. The result is due to using strips and fans, and I am curious to see if we can get the MD2 Importer to work without using strips and fans?

If Kev, etc. could get it working without them, it would be a HUGE help to me and the many others who are trying to import MD2's. Is it possible?

Thanks!

 
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2006-06-05 03:03:20 »

Since you asked so nicely Smiley - can you post an example model with which the MD2 importer fails and I'm sure we can work out a way round the issue.

Kev

Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #2 - Posted 2006-06-05 03:59:30 »

Maybe I wasn't clear. There's nothing wrong with the MD2 Importer you wrote(in fact I think it is a godsend if you ask me). But the way the Blender MD2 Exporter is programmed right now, the geometry of the model gets messed up when using strips and fans. There's something wrong with the exporter code and they haven't been to expedient in fixing it Smiley. I was hoping we could get the md2 importer to not use them so the geometry would be fine again.

As an example model, I've been using marvin the good ol' martian enclosed in your sample. Try importing it into blender, then exporting it as an md2.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2006-06-05 04:03:54 »

Yeah, I got ya - I don't have blender or any knowledge on how to use it - if you could just post your imported then exported version of marvin I can work from there.

Kev

EDIT: No worries, got blender etc.

Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2006-06-05 05:21:07 »

Ok, just done some hacking tonight and it seems we can get the model to display correctly from a MD2 exported from blender. The current version of the model loader assumes that the GLCommands stored at the MD2 model are correct and uses them for rendering. Unfortunately the blender exported completely buggers these up.

So, locally I've hacked in a change that reads the triangles direct from the body of the MD2 and hey presto - we have a proper model.

Haven't got time to firm this up yet - hopefully tomorrow.

Xith maintainers - are we interested in keeping both versions of the loading code intact - or just centralising on the version that works with blender? (since it'll work for other models also).

Pros: We have backwards compatibility just in case there are any quirks
Cons: Two paths of code to support - one of which is redundant.

Kev

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2006-06-05 11:43:43 »

Xith maintainers - are we interested in keeping both versions of the loading code intact - or just centralising on the version that works with blender? (since it'll work for other models also).

Pros: We have backwards compatibility just in case there are any quirks
Cons: Two paths of code to support - one of which is redundant.
First, great job Kev. But if the Blender MD2 exporter is still supported by someone maybe it's just easier to fix it.
Anyway, I suggest (I can do so if you agree) building a jar containing the old version (non-blender compatible) and commit the blender-compatible version to the CVS so it'll be just fine for 0.8

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2006-06-05 14:55:31 »

I presume if someone with the required skills could fix the MD2 exporter they would have done it already? Apparantly its only a python script - looks pretty crappy as language to me but I'm sure it suits someone out there Smiley

If it makes more sense to wait for someone to fix it there - lets do that Smiley

Kev

Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #7 - Posted 2006-06-05 15:36:14 »

I believe that there's something wrong with Blender internally in the way that it processes glcommands(according to the author of the exporter). Bug reports have been submitted but there hasn't been anything done about it.

Kev you're a friggin genius. Let me know when you have everything firmed up. I can't wait to import Md2's!
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #8 - Posted 2006-06-05 18:04:17 »

Here it is:

http://www.cokeandcode.com/xith/xith-md2-0.2.0.zip

If someone could apply it in the right place that'd be great. Smiley

- Collapsed all the geometry into one triangle array (rather than strips and fans) - if Xith is using buffers intenerally this should be faster
- Added some stuff to parse triangles and texture coordinates from the body of the MD2
- Removed GLCommand classes since we're not using them now
- Remove MD2Loader2  - collapsed its functionality into MD2Loader.
      a) Because I couldn't read MD2Loader2
      b) Because it seems pointless just to have it a number 2 for the sake of it
      c) Because theres no way to use MD2 usefully using the "Scene" interface (which is now noted in the docs)

Seems to work with the models I tested, including import/export from blender. However, theres an additional problem with blender it seems - the normals are stripped on export - so there lighting doesn't look right. I've left a the computeNormals() line in the source to show one way of resolving this  - however, this gives a very faceted look rather than the smoothed look normally associated with MD2s Smiley

Test included - seems to work on the MD2s (lit and unlit) that I've got locally. Let me know if you have additional issues.

Kev

Offline croft

Junior Member




Java, Java, Java


« Reply #9 - Posted 2006-06-05 21:53:10 »

http://www.cokeandcode.com/xith/xith-md2-0.2.0.zip

If someone could apply it in the right place that'd be great. Smiley

Who is going to be doing that?

- Collapsed all the geometry into one triangle array (rather than strips and fans) - if Xith is using buffers intenerally this should be faster


Dang.  I just spent the last two weeks modifying the COLLADA import/export to use trifans and tristrips so that it could accept the MD2 Loader geometries.

- Remove MD2Loader2  - collapsed its functionality into MD2Loader.
      a) Because I couldn't read MD2Loader2
      b) Because it seems pointless just to have it a number 2 for the sake of it
      c) Because theres no way to use MD2 usefully using the "Scene" interface (which is now noted in the docs)


Recently we replaced MD2Loader with MD2Loader2 and renamed it MD2Loader.

I see that your new MD2Loader extends LoaderBase.  That is just what I need to support DefaultLoader:
http://earth.whoola.com:8080/javadoc/xith-tk/org/xith3d/loaders/ext/DefaultLoader.html

David Wallace Croft / www.CroftSoft.com / (214) 636-3790 m / Advanced Java Game Programming
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #10 - Posted 2006-06-06 01:12:09 »

Quote
Who is going to be doing that?

Dang.  I just spent the last two weeks modifying the COLLADA import/export to use trifans and tristrips so that it could accept the MD2 Loader geometries.

Well to be honest, take it or leave it - I couldn't give a flying ferret either way.

Kev

Offline croft

Junior Member




Java, Java, Java


« Reply #11 - Posted 2006-06-06 02:32:40 »

Kevin Glass,

Well to be honest, take it or leave it - I couldn't give a flying ferret either way.

I think you misinterpreted my message.  When I asked, "Who is going to be doing that?", I did not mean "Kevin Glass, you should do it as you should not expect anyone else to do it for you."  I meant "Which of us regulars is going to integrate Kevin Glass's latest contribution?  If no one responds within a day or two, I will volunteer to do it."

David Wallace Croft / www.CroftSoft.com / (214) 636-3790 m / Advanced Java Game Programming
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #12 - Posted 2006-06-06 10:37:41 »

http://www.cokeandcode.com/xith/xith-md2-0.2.0.zip

If someone could apply it in the right place that'd be great. Smiley
I could. I refactored the loaders a while ago and the CVS is very different (package names) from last releases so I don't want to let anybody get into troubles because of my changes (unless I disappear suddenly..)

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #13 - Posted 2006-06-18 22:50:51 »

Thanks for your help kev! Still having some problems though. I wasn't sure where to put the code you placed, so I tried sticking it in a new folder and putting that in my classpath. Compiles fine, but I get this error when trying to run:

1  
2  
3  
4  
5  
C:\xith3d\xith3d-0.7.1\xith3d>java -cp libs/xith3d.jar;C:\xith3d\third-party\thi
rd-party\vecmath\vecmath.jar;C:\xith3d\third-party\third-party\jogl\jogl.zip;cla
sses;c:/xith3d/md2loader2/xith-md2.jar org.xith3d.gsg.HelloXith3D
Exception in thread "main" java.lang.NoClassDefFoundError: org/xith3d/loaders/md
2/util/ModelLoadingException


Any ideas? Thanks!
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #14 - Posted 2006-06-19 00:24:27 »

Or you could just do this in blender:

Tab to go into Edit mode, A to select all vertices, Cntrl + T to triangulify

Out comes nice neat triangles...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #15 - Posted 2006-06-19 02:32:31 »

I tried that. It was already made of triangles unfortunately. Thanks for the interest though!
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #16 - Posted 2006-06-19 14:17:26 »

Or you could just do this in blender:

Tab to go into Edit mode, A to select all vertices, Cntrl + T to triangulify

Out comes nice neat triangles...
But it gives you twice as much polygons.. bad for performances it's annoying as my 3D artists mostly uses quads and I'm obliged to convert all to triangles, losing some performances (cause OBJ and MD2 supports Quads only).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #17 - Posted 2006-06-19 14:29:24 »

For reference neither MD2 or OBJ support only Quads. Infact, MD2 only supports triangles. Triagulation in most cases wouldn't any effect on performance since alot of cards render quads as two triangles anyway - so all trigulation would do for you would make your geometry data explcit.

However, more to the point. Triagulation in blender would have absolute no effect on the MD2 exporter - it generates a set of triangles based on the current geometry. It might help the exporter I suppose (?) but certainly wouldn't fix the issue that the data exported from blender in the GLCommands at the end of the MD2 is plain wrong - so the loader had to be changed to use the body triangles.

As to the problem with the exception not being found. I'm not sure which version of the loader you were using originally - if you're using the now official version the class that isn't found isn't used in it. I think maybe you've been using an old version up to this point - time to move to the next one.

Since I'm not a Xith developer I need someone to integrate the changes I made into the real code - I don't want to be fixing this issue (if there is an issue?) against the wrong source code since that seems to have caused problems above. If there are any problems or when the integration is complete posting here would be helpful.

@arkdm - sorry not to be more help right now. Seems we're so nearly there Smiley

Kev

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #18 - Posted 2006-06-19 14:34:41 »

For reference neither MD2 or OBJ support only Quads. Infact, MD2 only supports triangles
You're right I mean that they support triangles only ^^
Triagulation in most cases wouldn't any effect on performance since alot of cards render quads as two triangles anyway - so all trigulation would do for you would make your geometry data explcit.
Ah ok.
However, more to the point. Triagulation in blender would have absolute no effect on the MD2 exporter - it generates a set of triangles based on the current geometry. It might help the exporter I suppose (?)
You're right. It won't export if it contains quads.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #19 - Posted 2006-06-19 14:48:45 »

Na, actually you can support Quads in OBJ files. Its just loaders I generally write don't Smiley Triangles used to be cheaper to render than quads in the good ole' days </old_git>

Kev

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #20 - Posted 2006-06-19 15:06:32 »

Na, actually you can support Quads in OBJ files. Its just loaders I generally write don't Smiley Triangles used to be cheaper to render than quads in the good ole' days </old_git>

Kev
Ahm okay. Anyway OBJ is only interesting for static objects (I use them for 3D menus) so that's not where performance is really taking a hit.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #21 - Posted 2006-06-19 17:32:34 »

Do you know where I could find the newest version of the loader? I checked the tk but that vers. still had the ModelLoader exception etc.

@kev - You've been extremely helpful!
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #22 - Posted 2006-06-19 18:11:58 »

Quote
Ahm okay. Anyway OBJ is only interesting for static objects (I use them for 3D menus) so that's not where performance is really taking a hit.

Again, interestingly, OBJs are often used as keyframes - take the old Poser model format for instance. Also, I seem to remember Magicosm actually used raw OBJ keyframes with morphing between nodes - hmm, I think.

Kev

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #23 - Posted 2006-06-20 09:21:28 »

Quote
Ahm okay. Anyway OBJ is only interesting for static objects (I use them for 3D menus) so that's not where performance is really taking a hit.

Again, interestingly, OBJs are often used as keyframes - take the old Poser model format for instance. Also, I seem to remember Magicosm actually used raw OBJ keyframes with morphing between nodes - hmm, I think.

Kev
Yes indeed I know c_lilian use them that way with the Morph node... It's an interesting way to go BUT :
- In the OBJ Blender exporter I can make it export one .OBJ file per frame which is fine but if my animation goes on 200 frames then I have 200 Obj files to mind with and I have to delete manually useless ones (those which are not keyframes, just transitional-frames).
- What's the point of using OBJ keyframes vs MD2 models ? I heard MD2 was less precise due to values in bytes.. Is it really important ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #24 - Posted 2006-06-20 14:26:59 »

You'd have to ask someone who has used OBJs as keyframes. I suspect its something to do with personal project workflow.

Kev

Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #25 - Posted 2006-06-20 15:54:37 »

OBJ are quite different from MD2 ;
- MD2 are very imprecise, it is not important for RTS little characters, it is for bigger one (it waves a bit when they walk, ...),
- MD2 do not provide satisfying normals in most case (just a rough look-up, you need to generate them),
- MD2 do not support indexed geometry which is not satisfying performance wise
- MD2 are limited to a single object with single texture

On the other side, using OBJ as morph target is not perfect either since you have a bit more informations to store outside of the .obj files ; animation name, object name used as keyframe, keyframes and lengths.

Collada gives all the needed feature for exchanging this type of animations. I hope that it will stop the neverending debate around file formats.

              Vincent
Online kevglass

JGO Kernel


Medals: 166
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #26 - Posted 2006-06-20 16:01:59 »

Quote
Collada gives all the needed feature for exchanging this type of animations. I hope that it will stop the neverending debate around file formats.


I seriously doubt it Wink

Kev

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #27 - Posted 2006-06-21 15:10:37 »

Well I don't use MD2 for now because the Blender export script is crappy ("Error : check console", it said.. heh I'm not a python guy you know..).

I don't use COLLADA for now because the Blender export script doesn't support anims (and in fact doesn't work at all on my computer).

So I'll give OBJ a try.. if it's satisfactory maybe I'll do something like a tool for bundling OBJ anims in a .JAR file with keyframes timestamps, anims names, textures and all that stuff. Could be pretty good as the Blender OBJ exporter is quite solid.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arkdm

Junior Member




Go Pooh on yourself


« Reply #28 - Posted 2006-06-26 00:02:45 »

Still having problems with the exporter unfortunately. I've tried both removing the ModelLoaderException, and copying the old files into their place in the loader, nothing works: I still recieve the same errors as before.

Anyone know how to get around this?
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #29 - Posted 2006-06-26 17:25:41 »

You are just trying to compile the new MD2 code and it doesn't work ?
Hmm I forgot to include this code for 0.8.0 but the next time I work on a release I'll see what's the problem.

(Hmm are you sure it's the ModelLoaderException class ? I only see ModelLoadingException in the CVS..)

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Pages: [1] 2
  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 (37 views)
2014-09-24 16:13:29

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

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

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

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

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

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

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

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

BurntPizza (52 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!