.md2 OpenGL

Apprentice
Posts: 10
Joined: 2008.02
Post: #1
Hello everybody,

I have a question about how to load a md2 file into my C++ Xcode project. I've read a lot of tutorials about md2, but it just won't work. Can somebody here explain it, do I have to include the file in my project? Where do I have to load it?

In advanced thanks

Stijn van der Schoor
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
stijnschoor Wrote:but it just won't work.

If you give us details of what doesn't work, we might be able to help troubleshoot it.

At a very high level, the basic concept is likely to go something like this: You'll include .md2 files in your application bundle, read their contents with standard file I/O APIs, parse the file contents into some sort of internal data structure, then send vertices from that data structure to OpenGL each time you want to render the model.

I don't know any specifics about md2, but these approximate high-level concepts should apply to any 3D model file format.
Quote this message in a reply
Apprentice
Posts: 10
Joined: 2008.02
Post: #3
for example: tutorial 9 from videotutorialrocks.com, it shows how to load a md2 file. I've downloaded the source code and built a Xcode project. But when I run the project I get the following error:

ZeroLink: unknown symbol __Z7loadBMPPKc'

Do you know what this mean?
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #4
Quote:ZeroLink: unknown symbol __Z7loadBMPPKc'
That's a linker error. It means that you have some code somewhere trying to call a function called Z7loadBMPPKc() (it may have arguments) which is not defined anywhere. Since you are not getting a compiler error you probably have it declared in a header somewhere but the function is missing from your code or you have not included the library it is contained in. I'd start by looking for a library called Z7 or similar since that appears to be a prefix.

By the way, the domain videotutorialrocks.com is not registered. Try again if you want anyone to have a look at it for you.
Quote this message in a reply
Apprentice
Posts: 10
Joined: 2008.02
Post: #5
sorry the url is videotutorialsrock.com/ (notice the "s")
I will looking for a libraby called Z7
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #6
The symbol is a bit mangled, but it's referring to a function named loadBMP, which is defined in imageloader.cpp here: http://videotutorialsrock.com/opengl_tut...s/text.php

Make sure this file is compiled in with your program. You'd also be well-served by turning off ZeroLink in Xcode, as you'll get more informative errors earlier that way.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
Code:
keith$ c++filt
__Z7loadBMPPKc
loadBMP(char const*)
^D

As others have said: something in your program is using a C++ function called loadBMP taking a C string, and that function doesn't exist in your program.
Quote this message in a reply
Apprentice
Posts: 10
Joined: 2008.02
Post: #8
Thanks a lot!

The problem is almost solved.

The only error I receive now is:
failed assertion `!input.fail() || !"Could not find file"

Any ideas?
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #9
Your file isn't where your app expects it to be. Read this:
http://blog.onesadcookie.com/2007/12/fin...files.html
Quote this message in a reply
Apprentice
Posts: 10
Joined: 2008.02
Post: #10
Just another question.
In the directory /Developer/Examples/OpenGL/GLUT/GLUTExamples.xcodeproj is an example of how to import models into OpenGL (see Target GLUTMecha). Which file format is used? I found a .dat file, but what does that mean? Are there any tutorials on the web?

Advanced thanks
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #11
A quick look at glutmech.c shows that it's all procedural; no model file is loaded.

Googling for "md2 loader OpenGL" gives me quite a few tutorial links right near the top. Your best bet is probably to look through those and find one that suits your needs.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
Another random thing google probably doesn't find: http://onesadcookie.com/svn/MD2/Resources/Ruby/MD2.rb
Quote this message in a reply
⌘-R in Chief
Posts: 1,260
Joined: 2002.05
Post: #13
Once upon a time this worked perfectly. It still should, but for some reason I can't get it to break on any breakpoints, so I can't figure out why it's not.

If you're still on PPC it should work fine. It seems that on Intel it's still thinking it's on PPC and is byte swapping. The code is pretty clean, so if someone has 10 minutes and get the flippin' debugger to work (I blame SDL) then it'll work just fine.

http://www.sethwillits.com/temp/MD2Loading.zip
Quote this message in a reply
Member
Posts: 35
Joined: 2008.06
Post: #14
At the bottom of the page there is some good C source code for loading md2 format.

http://tfc.duke.free.fr/coding/md2-specs-en.html
Quote this message in a reply
Post Reply