Posts Tagged ‘texture’

Wii Opera SDK - New Mesh Format

Friday, July 18th, 2008

Most of the code migration to the new version 3.x of the Wii Opera SDK is complete.  One of the big changes is the format for mesh arrays.  The format is as follows:

Mesh[triangle][x1,y1,z1, x2,y2,z2, x3,y3,z3, r,g,b, texture, shading]

Mesh[triangle][x1,y1, x2,y2, x3,y3, r,g,b, texture, shading]

As you may notice, this new format opens the door to mesh arrays with mixed type triangles, meaning that both textured and flat-shaded triangles can inhabit the same mesh. Let me take a moment to explain what the two added values are:

texture: This refers to the element number of a texture image array, which if defined elsewhere.  By placing a negative value here, it flags the SDK to use the RGB colors instead of a texture. If a non-negative value is given but no texture array is passed to the SDK, the triangle will also be flat-shaded.

shading: This is more of an internal value than anything, used by shading and fading.  It contains a value in the interval [-1, 1].  This value can also be set manually to add brightness effects to the triangle.

I will be updating the documentation and further migrating code over the next few days.  All example webpages are updated to make use of the new code already.

How to Texture-Map Triangles in a Canvas

Tuesday, April 29th, 2008

Textured triforce

Some who are curious as to how it was possible to achieve texture-mapping in an HTML5 canvas probably already took a peek at the code in the Wii Opera SDK only to see that it has been optimized into obfuscation. Thus, I’ve decided to write an article to explain the technique, starting with the basics.

The triangle definition

The triangles are defined in the same manner as they are in the flat shading part of the SDK and are fully compatible with any meshes (discarding color information) until the final drawing step.  For developers who wish to hard code the triangle coordinates, they are defined in a standard computer floating point coordinate system where X is positive rightward; Y is positive downward; and Z is positive outward.  The triangles have nine numerical values, which are three coordinate sets, counterclockwise.  Normally there are three final values for the RGB flat shading colors, but these get replaced in the final step by an image object reference. Note that this image object can be of any size, but Opera’s speed decreases as the image size increases, and there is no need, anyways, for large textures in an Internet browser environment.
(more…)

Triangle Texture-Mapping Now in the Wii Opera SDK

Monday, April 28th, 2008

I’ve just finished adding triangle texture-mapping to the Draw class of the Wii Opera SDK and have placed a demo at http://wiioperasdk.com/texturemap.html. Since the canvas object lacks support for 3D at the moment, I had to use some trickery by rotating the coordinate system then drawing horizontal scanlines, but it works fairly well, aside from some minor glitches.  Don’t expect any high-speed fully 3D games to be playable in the Internet Channel, but it will make for some nice demos and simple animations.