MD2 Loader + Animation - Texturing

BlitzMax Forums/OpenGL Module/MD2 Loader + Animation - Texturing

Nennig(Posted 2005) [#1]
Hi guys,

I have been working on a translation of a Java MD2 loader, found on the net, into a Blitzmax version.
It works great besides the texturing part. Being a newbie in opengl I thought it was time to ask for help.

I am posting my code below. If you manage to texture the model correctly please post an updated version of the code so that we can all benefit from it.


You can move the camera around the animated model using the arrow keys. You will have to find a MD2 model and update the model path aswell as the texture path in the code in the New Method of the MD2 type.

Thanks for your help
bye
Nennig




Nennig(Posted 2005) [#2]
Hi all,

After being obsessed one full day at work with this texture problem, I finallly figured out the solution.

Find yourself an MD2 model and enjoy it in Blitzmax!

Nennig







Nennig(Posted 2005) [#3]
Just a screenshot....




LarsG(Posted 2005) [#4]
This doesn't look half bad..
I'm gonna take try to take a look at this later.. :)


Nennig(Posted 2005) [#5]
I did and post a minor change in the code above to the setFrameRange method. So that you can play only a selected portion of the frames of your model.

Hope you find it useful.

Nennig


BlitzSupport(Posted 2005) [#6]
Nice work!


ozak(Posted 2005) [#7]
Ahh. An (almost) direct port of my java MD2 code.
Thanks dude. Now I won't have to do it :)

I still think it's the easiest most readable MD2 loader/player ever ;)


BlitzSupport(Posted 2005) [#8]
How cool... welcome Ozak!


ozak(Posted 2005) [#9]
Thanks :)

Actually the fancy hardcoded pixel flipping trick is not needed.

Just replace


For i=0 To numTexCoords-1
	uvs[i*2]=Float ReadShort(fichier)/ skinWitdh
	uvs[(i*2)+1]=1-Float ReadShort(fichier)/ skinHeight
Next 


with


For i=0 To numTexCoords-1
	uvs[i*2]=Float ReadShort(fichier)/ skinWitdh
	uvs[(i*2)+1]=Float ReadShort(fichier)/ skinHeight
Next 



I'll post a seperate MD2 Model file loader/drawer that can just be included as well as a simple texture helper later if I get the time:)


Nennig(Posted 2005) [#10]
Hello ozak,

Thanks to you. I had very much fun translating your code :-)
Thanks for the code update as well.


ozak(Posted 2005) [#11]
No problem :)
I posted the simple Texture helper btw.
It works well with the MD2 sample. I'm hoping to seperate the MD2 loader/drawer into a seperate class file as well as including normal generation + collision + faster drawing using vertex buffers soon :)