Okay, mostly converted the mesh and roam classes to c#
before i can continue further, i need to construct the base cube. But the direction of vertices is different in this guys opengl implementation and unitys.
below is the opengl vertices and triangles for a basic cube, but it doesnt work in unity. Anybody can see why?
const int CUBE_VERTICES = 8;
const int CUBE_TRIANGLES = 12;
float[] fCube = new float[CUBE_VERTICES*3]{-0.57735f, 0.57735f, 0.57735f, 0.57735f, 0.57735f, 0.57735f, 0.57735f, -0.57735f, 0.57735f, -0.57735f, -0.57735f, 0.57735f, -0.57735f, 0.57735f, -0.57735f, 0.57735f, 0.57735f, -0.57735f, 0.57735f, -0.57735f, -0.57735f, -0.57735f, -0.57735f, -0.57735f};
int[] nCube = new int[CUBE_TRIANGLES*3]{ 1, 0, 3, 3, 2, 1, 5, 6, 7, 7, 4, 5, 0, 1, 5, 5, 4, 0, 3, 7, 6, 6, 2, 3, 0, 4, 7, 7, 3, 0, 1, 2, 6, 6, 5, 1};
for(int i = 0; i < fCube.Length; i+=3) {
verticesN[i].x = fCube[i];
verticesN[i].y = fCube[i+1];
verticesN[i].z = fCube[i+2];
//verticesN[i] = Spherical (vertices[i], 2.0F);
}
m.Clear();
m.vertices = verticesN;
m.triangles = nCube;
m.RecalculateNormals();
Another question:
How can i extend unity vector3 class? Any simple example please? Not necessary for this one, but it would be nice to know.