Posts Tagged ‘mesh’

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.

Generating a Scene with the Wii Opera SDK

Tuesday, April 22nd, 2008

Bevelled Cubes

There will almost never be a case where a graphical scene contains only one object, so this article shows how to combine multiple mesh objects into one scene for drawing to the canvas.  Here it is assumed that the canvas is already set up and the meshes are ready for importing.  This code could be placed inside an animation loop.

Obviously some kind of code is needed to animate the scene; otherwise, it would just be a static image. For this example (pulled from a shadow casting demo), an angle increments through the bounds of a circle:

angle += 1; if(angle>360) angle -= 360;

Then the first object gets imported to a triangle buffer, a bevelled cube:

ThreeDee.LoadMesh(mesh_block);

(more…)

Creating 3D Meshes for the Internet Channel

Monday, April 21st, 2008

Many programs that are used for 3D mesh models, like MilkShape, can export as ASCII raw files, which contain a header of the mesh’s name followed by a set of floating point vertices for each triangle per line. A mesh of such type lacks and color or texture information. Below is an example of a cube object exported as a raw file:

Cube
-100 100 100 -100 -100 100 100 100 100
-100 -100 100 100 -100 100 100 100 100
100 100 100 100 -100 100 100 100 -100
100 -100 100 100 -100 -100 100 100 -100
100 100 -100 100 -100 -100 -100 100 -100
100 -100 -100 -100 -100 -100 -100 100 -100
-100 100 -100 -100 -100 -100 -100 100 100
-100 -100 -100 -100 -100 100 -100 100 100
-100 100 -100 -100 100 100 100 100 -100
-100 100 100 100 100 100 100 100 -100
-100 -100 100 -100 -100 -100 100 -100 100
-100 -100 -100 100 -100 -100 100 -100 100

(more…)