My .obj file loader
From critical_regions.h in MSL headers:
/*
* Notes
* -----
*
* What we need in certain areas of the library is the ability to "lock"
* certain critical regions of code against reentrance by preemptive
* threads. For example, when fopen searches for an unused FILE struct, it
* would be unfortunate if another thread "found" the same struct before the
* first one could mark it as in-use.
*
* Because the mechanisms used to manage critical regions will vary widely
* depending on the underlying hardware and/or system software, *all*
* details about how critical regions are locked and released are kept
* hidden. Instead, we define a finite number of critical regions that are
* of interest to us and leave the details of how they are managed invisible.
*/
My guess is that it is similar to HLock or FSLock.
As for _MSL_CDECL, I'm pretty sure it's ignored, but the other fgets had it, and I just threw it in to be safe.
/*
* Notes
* -----
*
* What we need in certain areas of the library is the ability to "lock"
* certain critical regions of code against reentrance by preemptive
* threads. For example, when fopen searches for an unused FILE struct, it
* would be unfortunate if another thread "found" the same struct before the
* first one could mark it as in-use.
*
* Because the mechanisms used to manage critical regions will vary widely
* depending on the underlying hardware and/or system software, *all*
* details about how critical regions are locked and released are kept
* hidden. Instead, we define a finite number of critical regions that are
* of interest to us and leave the details of how they are managed invisible.
*/
My guess is that it is similar to HLock or FSLock.
As for _MSL_CDECL, I'm pretty sure it's ignored, but the other fgets had it, and I just threw it in to be safe.
Thanks kBerg, I've found your class very useful.
I've been working with Danlab to make a game. Unfortunantly, we haven't been able to find tools for mac for modeling game type model formats. Md2 would be way better for games, but we just couldn't find a mac tool to create the models. We ended up using .obj files because Danlab could export them from cinema 4D. I took your code and ported it to obj-c. Then I added a nice texture class for loading textures from basically any file format (though alpha is only supported in .tga). Then I added keyframe animation support. You feed it multiple files and it basically interpolates the vertex, normal, and texture data. Its worked out pretty well.
![[Image: fishies.jpg]](http://homepage.mac.com/solidmag/fishies.jpg)
You'll probably get to see a demo of our engine soon!
Thanks again.
I've been working with Danlab to make a game. Unfortunantly, we haven't been able to find tools for mac for modeling game type model formats. Md2 would be way better for games, but we just couldn't find a mac tool to create the models. We ended up using .obj files because Danlab could export them from cinema 4D. I took your code and ported it to obj-c. Then I added a nice texture class for loading textures from basically any file format (though alpha is only supported in .tga). Then I added keyframe animation support. You feed it multiple files and it basically interpolates the vertex, normal, and texture data. Its worked out pretty well.
![[Image: fishies.jpg]](http://homepage.mac.com/solidmag/fishies.jpg)
You'll probably get to see a demo of our engine soon!
Thanks again.
Quote:Originally posted by ghettotek
did anyone happen to port this to Obj-C? im having a hell of a time doing it for some reason.
Yeah, see above post

Its actually obj-c++ though. But I think if I change it from .mm to .m it'll work fine, I just kept it that way so I could actually test while it was in intermediate stages.
Quote:Originally posted by Holmes
<snip...>
Wow, that looks pretty cool

It's great to hear the code's been useful, and I look forward to seeing what your engine is capable of.
<edit>I recall hearing someone talk about using .obj files in conjunction with .mtn (motion?) files or somesuch for animation purposes. If that's the case, there may exist a somewhat standard or supported format for animating .obj meshes, similar to how .mtl files can be used to provide texture data? However, the most comprehensive site on the format which I could find contains nothing on this subject.
http://astronomy.swin.edu.au/~pbourke/geomformats/obj/</edit>
On a side note, I am unable to find any critical_regions header to include; is this part of the developer tools, or is this a Darwin source kind of thing? So far simply removing those macro's has worked for me, but I hesitate to post any new code if it's going to cause wierd problems for people.
Critical Regions is an MSL thing. There might be some kind of exclusive access mechanism on Darwin's FILEs you could use instead, otherwise just don't worry about it -- it's only an issue if multiple threads are trying to read from the same FILE* simultaneously, which sounds like a recipe for disaster in any case!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Display Lists and Obj. File Loader Problems | merrill541 | 0 | 1,655 |
Oct 17, 2008 06:42 PM Last Post: merrill541 |
|

