MD2 loader/animator/drawing class is here!

BlitzMax Forums/OpenGL Module/MD2 loader/animator/drawing class is here!

ozak(Posted 2005) [#1]
Yep. I cleaned it up, added comments, made it even simpler.
Just include the file and you can just Load and Render.
It's that easy. My simple (updated) texture class is there too.
Includes a zip containing sample code as well as both classes. The sample draws and animates the cool Warhammer 40k Space Marine model :)

Get it at http://www.furi.dk/blitzmax


BlitzSupport(Posted 2005) [#2]
Excellent... and if you change the OpenFile line in MD2Model.Load to include "littleendian::" it compiles and runs on OS X as well.
Local FileHandle:TStream = OpenFile("littleendian::" + FileName)

My understanding is that .MD2 uses little-endian byte ordering, whereas the Mac uses big-endian ordering so needs them switched; this change makes no difference to the little-endian PC.


ozak(Posted 2005) [#3]
Oh yeah. It did this in my java version and just forgot. Fixed and uploaded.
(Java always uses big endian on all platforms. Bless those guys :)


REDi(Posted 2005) [#4]
This is excellent ozak, thank u very much.
I don't suppose you fancy doing a light class as well? ;D


ozak(Posted 2005) [#5]
I might, although I have plenty of other stuff I want to do too (collision, culling, cameras, shaders etc :)


BlitzSupport(Posted 2005) [#6]
I tried IncBin'ing the MD2 model but it failed... I thought it was an IncBin bug, but Mark pointed out that it failed because IncBin'd files can only be read, whereas OpenFile tries to open for reading and writing.

If you change to ReadFile or ReadStream you can then IncBin models into your executables, which is nice!


LeisureSuitLurie(Posted 2005) [#7]
Coolness.


DaY(Posted 2005) [#8]
ozak why not make a small 3d engine in opengl for us to use just sommet simple md2 is already done just terrain , Objects , Collision, lighting
;)

DaY


ozak(Posted 2005) [#9]
Hehe yeah. I'd sure you'd like that, but I'm a busy man :)

I changed the load code to use ReadStream, I can't however figure out how to use and URL with ReadStream("littleendian::" + FileName) since the littleendian string expects a string to be added to another string and if I convert the URL to a string then what's the point?
Perhaps some of you guys can help me out :)


BlitzSupport(Posted 2005) [#10]

I can't however figure out how to use and URL with ReadStream("littleendian::" + FileName) since the littleendian string expects a string to be added to another string and if I convert the URL to a string then what's the point?


Not quite sure what you mean here... if you leave it the way it is, ie. ReadStream("littleendian::" + FileName), it should work fine, whether the file is external or IncBin'd into the executable. Any file that's passed to it will be read in little endian byte order.


ozak(Posted 2005) [#11]
I wanted to load from an URL which is not possible (as far as I can see) when using ReadStream("littleendian::" + url)