iDevGames Forums
.md2 OpenGL - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: .md2 OpenGL (/thread-2645.html)



.md2 OpenGL - stijnschoor - May 7, 2008 10:52 AM

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


.md2 OpenGL - ThemsAllTook - May 7, 2008 11:52 AM

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.


.md2 OpenGL - stijnschoor - May 8, 2008 12:31 AM

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?


.md2 OpenGL - backslash - May 8, 2008 05:11 AM

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.


.md2 OpenGL - stijnschoor - May 8, 2008 05:34 AM

sorry the url is videotutorialsrock.com/ (notice the "s")
I will looking for a libraby called Z7


.md2 OpenGL - ThemsAllTook - May 8, 2008 05:52 AM

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_tutorial/textures/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.


.md2 OpenGL - OneSadCookie - May 8, 2008 10:01 AM

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.


.md2 OpenGL - stijnschoor - May 12, 2008 11:20 AM

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?


.md2 OpenGL - backslash - May 12, 2008 12:11 PM

Your file isn't where your app expects it to be. Read this:
http://blog.onesadcookie.com/2007/12/finding-your-apps-files.html


.md2 OpenGL - stijnschoor - May 18, 2008 03:41 AM

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


.md2 OpenGL - ThemsAllTook - May 18, 2008 08:01 AM

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.


.md2 OpenGL - OneSadCookie - May 18, 2008 12:35 PM

Another random thing google probably doesn't find: http://onesadcookie.com/svn/MD2/Resources/Ruby/MD2.rb


.md2 OpenGL - SethWillits - May 18, 2008 04:15 PM

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


.md2 OpenGL - green_ghost - Jun 21, 2008 06:01 PM

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