PDA

View Full Version : Monkey3D demo


akb825
2006.04.09, 04:46 PM
I have mentioned my current project a few times, but now it's time for me to reveal it. I am working on an API called Monkey3D and an accompanying utility, Monkey Modeler. In a nutshell, Monkey Modeler loads 3D models in obj format, will let you add such things as additional textures, select texture generation modes, generate a shadow mesh (basically a version of the mesh with flat normals as well as 0-length quads of every edge so it can be easily extruded to form a shadow volume; note that this only works if every object in the model is closed; also, you can choose to create a shadow mesh for only certain objects in the model), and add collision surfaces. (supported surfaces include boxes, spheres, capped cylinders, and rays) All these are now completed, and afterwards I will add the ability to create skeletons and animations to the models, then save the skeletons and animations separately to bind to different models.

Here's a couple of screenshots from the modeler.

http://www.akb825.com/images/modeler%201.png
http://www.akb825.com/images/modeler%202.png

The API will load the files you want, call a function you provide to load the included textures (it's also very easy to bind your own textures), and draw the models. You can choose to draw only parts of the model, use vertex shaders, and tell it to draw the shadow portion of the model. You can also test for collisions between models and other collision surfaces you create. It includes a completely working version of the ODE library within the API (I also got the trimesh portion of it included! I had to add about 900 namespace resolutions to get it to compile, though), and I use it to handle collisions. You can, of course, use the physics portions of it as well. Later, I will add the ability to open and bind the skeleton and animation files, as well as the functions to animate each object.

For a complete list of features, you can visit the page on my website (http://www.akb825.com/monkey3D.php).

Now for the demonstration.

Demo download (http://www.akb825.com/downloads/Monkey3D%20demo.zip)

I have created an application to demonstrate the various capabilities so far. You can control it by selecting one of the movement modes and using the mouse or arrow keys to move around. You can also press 't' to translate, 'r' to rotate, and 'z' to zoom if you don't want to move. (scroll wheel always zooms) You can also use a check box to enable vertex shaders (if they are available on your computer) and to use VBOs.

The application has 3 sections:
First section demonstrates two models with built-in textures, with the relative path saved with the models. It also demonstrates shadows. When vertex shaders are enabled, check the sow shadows box to see them in action. It also sports self-shadowing.

Here are some screens of the first section with shadows in case you can't see them.

http://www.akb825.com/images/shadow%201.png
http://www.akb825.com/images/shadow%202.png

The second section demonstrates collision detection. The 4 objects represent the collision detection surfaces of the same size and orientation. You can check the box to move the selected object, and select an object from the table. Here's a screen of that.

http://www.akb825.com/images/collisions.png

The last section demonstrates the ability to save tex-gen settings, as well as the ability to emulate them in vertex shaders. Whenever you provide a vertex shader, you provide just the base shader, pass that in to a function along with a model, and it adds the particular parts it needs to handle each of the texgen modes selected. All the shaders are held in an array.

To load the cubemap, I loaded the images into a texture object and had a 2-line loop to add it to the model: all I did was set the texture object and dimension for each object in the model. Here's a screen for that section.

http://www.akb825.com/images/cube%20map.png

This demo is a universal binary, and hopefully everything will load fine on Intel Macs. It will only work on Mac OS X 10.4 or higher. I tried to lipo myself a 10.3.9 universal binary, but unfortunately it throws nonsensical errors in the ODE library (such as needs , or ) before a numerical constant in the declaration of a parameter for a function) when linking to any SDK except for the universal one. I hope to have the final version available of the API and utility for 10.3.9 if I can ever figure that one out.

KittyMac
2006.04.09, 10:14 PM
Looking good :cool:

Out of curiosity... is this planned for open source, shareware, commercial?

akb825
2006.04.09, 11:05 PM
It will be open source through the GNU license. This will likely be my last free piece of software, though, since after this I plan on making shareware games. (this will be the building blocks of what I make in the future, and I feel that it would be nice to provide others with these building blocks since they are extremely useful. Also, with it open source, it makes it easy to modify it how you please)

BTW, can someone with an Intel Mac confirm that it does work? I put in all my byte-swapping (I keep it in little endian, in fact, since Macs are going Intel and I also plan on releasing the API for Windows and maybe Linux), and I think I got them all, but I can't be completely certain.

Edit: I just updated the executable, since I just realized that the cube map doesn't work because I forgot to resolve the paths to the current directory. (since I opened those textures manually, and XCode automatically sets the current directory for the system calls when your run it from the build directory) It is fixed and uploaded now.

PowerMacX
2006.04.10, 12:23 AM
Pretty interesting! I think I downloaded the first version, with the cube map bug so I'll download it again. Oh, and I made this (http://www.wirelesshamster.com/cosas/model_tools.png) quick mockup of an alternate look for the "Model Tools" window, if you want to take a look. :)

Bachus
2006.04.10, 03:04 AM
Very cool. Good thing it's open-source, allowing for easy updates/extensions/upgrades/etc. I'd want to import more than just .obj for instance. I'll be keeping an eye on this.

akb825
2006.04.10, 04:01 AM
Pretty interesting! I think I downloaded the first version, with the cube map bug so I'll download it again. Oh, and I made this (http://www.wirelesshamster.com/cosas/model_tools.png) quick mockup of an alternate look for the "Model Tools" window, if you want to take a look. :)
Thanks, I'll have to look into the new style. Perhaps when I'm done I'll ask around to see if anybody can add things they want that I either didn't think of or couldn't get in. For example, I couldn't for the life of me get undo to work properly from using the panel to edit; it just refused to show up in the undo queue when accessing the document's undo manager. Fortunately it's straight forward enough so far that it isn't that huge of a loss, hopefully it will continue that way when I get animations implemented... Either way, it is something I'd like to implement if possible, but I would have to admit that I don't know all the ins and outs of cocoa interfaces.

Another thing I forgot to mention is that the API is written in straight C. Since ODE also has a C interface, it will support C and any C derivative.

unknown
2006.04.10, 12:08 PM
Looking great, is there a way to make the shaders run in software?
Cant wait to see more of this!
Especially bone based animations :D

akb825
2006.04.10, 12:36 PM
Looking great, is there a way to make the shaders run in software?
Cant wait to see more of this!
Especially bone based animations :D
If you go into the NIB file, you can select the OpenGL view and choose to do software rendering. That *should* let the shaders run in software. BTW, is the shader box shaded out? I have it check the extension string to see if the extension is present, but it didn't seem to work last time I tried to do that.

akb825
2006.04.12, 02:41 AM
In case anybody's still reading this thread, I managed to fix my problem with getting my app to compile for 10.3.9 (it turns out that my pre-compiled header was automatically includes the carbon files, which in every SDK except for the universal SDK #defines _L which is used a few times in ODE), so I lipoed myself a Universal Binary that supports 10.3.9. (in case you don't have Tiger and want to try it out)

akb825
2006.06.02, 10:54 PM
I uploaded a new demo, that includes several changes:
Added a framerate counter
changed my method of drawing hard shadows, so they look more natural
added a soft shadow option (finally got that working! took me for ever to find a method to do it correctly with stencil shadows, too)

This demo now requires Tiger or higher. To run soft shadows, you need to have a Radeon 9550+, or NVidia 5200+.

Here's some screens of the new soft shadows if you can't run them.
http://akb825.com/images/soft%20shadow%201.png
http://akb825.com/images/soft%20shadow%202.png

KittyMac
2006.06.08, 03:47 PM
Just gave it a shot. When I enable soft shadows, the entire view goes white. Changing any options after the view goes white has no effect. On a PowerBook w/ a ATI Mobility Radeon 9700.

akb825
2006.06.08, 03:53 PM
Thanks for the info. I guess I'll test every aspect of the shaders and compare them with the arekkusu's GL info page. Strange that it doesn't return after you turn off the options, though.

akb825
2006.06.08, 11:38 PM
I switched a few things around (that made it so I had one less texture copy and one less draw), but I couldn't find any attribute about the shaders that doesn't meet up with the limits of your class of video card. You can still see if it happened to fix a strange problem, though. BTW, what version of OS X do you have? It uses FBOs, so it won't work before 10.4.3. (of course, if it wasn't, it would likely crash due to not finding the function...)