Texture Mapped 3d Link Model (from zelda OOT)
Click and drag to rotate the model. Let go of the mouse to render it.
Press space to toggle Rendering Mode.
If the program detects that your PC is too slow to handle realtime mode (ie. the render breaks) at the current Resolution, it will switch it off. If you want to re-enable it, increase the Poly Resolution first.
Realtime Cube: http://scratch.mit.edu/projects/10536676/
To Import your own model:
Export the model as a .obj file (make sure all faces are triangulated) from a 3d modelling program like Blender. Click "See Inside" on this project, click "import model" then right click the "OBJ" list that appears. On the context menu, select "import" and choose your obj file. Click the "import model" button again to read the file.
To import your own texture, first convert it at:
Then do the same as above, but instead on the "Textures" list and instead importing a .txt file containing the output of the converter. Press "D" and type in the width and height of the texture as asked.
Credit to Nintendo for Link model and texture.
5/6/13 - Added Flat Shaded mode.
4/6/13 - Implemented Perspective Correct Texturing. Press space to toggle. Affects performance a little.
3/6/13 - Improved Performance, Fixed bug with Texture Co-ordinates, Triangles now correctly draw offscreen, Removed duplicate code, cut down on calculations for the same output performed more than once.
NEW: Backface culling. The model can now be rendered fast enough for the render process to not exceed the maximum time for a custom block to execute. It may cause some artifacts though.
The code includes lots of unrolled loops and duplicated code to save doing things twice or with excessive calculation, so the code is pretty messy.
Since this is affine texture mapping, the texturing will look funky when used on perspective transforms (you can see this on the first Playstation). This is the simplest form of texture mapping though, so it makes sense to implement this first.
As you can see, this is way too slow to be practical. The framerate could be increased a lot by doing backface culling, which I might copy over from my racetrack project.
I'm going to try this on a more advanced model, but it'll probably be a a like render instead of realtime.