static void lib3ds_io_read_vector(Lib3dsIo io, Lib3dsVertex v) { Debug.Assert(io != null); v.x = lib3ds_io_read_float(io); v.y = lib3ds_io_read_float(io); v.z = lib3ds_io_read_float(io); }
public static void lib3ds_vector_max(float[] c, Lib3dsVertex a) { if (a.x > c[0]) { c[0] = a.x; } if (a.y > c[1]) { c[1] = a.y; } if (a.z > c[2]) { c[2] = a.z; } }
public static void lib3ds_vector_min(float[] c, Lib3dsVertex a) { if (a.x < c[0]) { c[0] = a.x; } if (a.y < c[1]) { c[1] = a.y; } if (a.z < c[2]) { c[2] = a.z; } }
public static void lib3ds_vector_make(Lib3dsVertex c, float x, float y, float z) { c.x=x; c.y=y; c.z=z; }
public static void lib3ds_vector_normal(float[] n, Lib3dsVertex a, Lib3dsVertex b, Lib3dsVertex c) { lib3ds_vector_normal(n, a.ToArray(), b.ToArray(), c.ToArray()); }
static void lib3ds_io_write_vector(Lib3dsIo io, Lib3dsVertex v) { lib3ds_io_write_float(io, v.x); lib3ds_io_write_float(io, v.y); lib3ds_io_write_float(io, v.z); }
public static void lib3ds_vector_make(Lib3dsVertex c, float x, float y, float z) { c.x = x; c.y = y; c.z = z; }
private Lib3dsVertex CreateNormalize(Lib3dsVertex p1, Lib3dsVertex p2, Lib3dsVertex p3) { Lib3dsVertex v1 = new Lib3dsVertex(); Lib3dsVertex v2 = new Lib3dsVertex(); Lib3dsVertex rnt = new Lib3dsVertex(); v1.x = (p1.x - p3.x); v1.y = (p1.y - p3.y); v1.z = (p1.z - p3.z); v2.x = (p3.x - p2.x); v2.y = (p3.y - p2.y); v2.z = (p3.z - p2.z); rnt.x = v1.y * v2.z - v1.z * v2.y; rnt.y = v1.z * v2.x - v1.x * v2.z; rnt.z = v1.x * v2.y - v1.y * v2.x; return rnt; }
public static void lib3ds_vector_copy(Lib3dsVertex dst, Lib3dsVertex src) { dst.x=src.x; dst.y=src.y; dst.z=src.z; }
public static void lib3ds_vector_max(float[] c, Lib3dsVertex a) { if(a.x>c[0]) c[0]=a.x; if(a.y>c[1]) c[1]=a.y; if(a.z>c[2]) c[2]=a.z; }
public Lib3dsVertex(Lib3dsVertex v) { x=v.x; y=v.y; z=v.z; }
public static void lib3ds_vector_sub(float[] c, Lib3dsVertex a, Lib3dsVertex b) { lib3ds_vector_sub(c, a.ToArray(), b.ToArray()); }
public static void lib3ds_vector_copy(Lib3dsVertex dst, Lib3dsVertex src) { dst.x = src.x; dst.y = src.y; dst.z = src.z; }
public static void lib3ds_vector_copy(Lib3dsVertex dst, float[] src) { dst.x = src[0]; dst.y = src[1]; dst.z = src[2]; }
// Multiply a point by a transformation matrix. // // Applies the given transformation matrix to the given point. With some // transformation matrices, a vector may also be transformed. // // \param c Result. // \param m Transformation matrix. // \param a Input point. public static void lib3ds_vector_transform(float[] c, float[,] m, Lib3dsVertex a) { c[0] = m[0, 0] * a.x + m[1, 0] * a.y + m[2, 0] * a.z + m[3, 0]; c[1] = m[0, 1] * a.x + m[1, 1] * a.y + m[2, 1] * a.z + m[3, 1]; c[2] = m[0, 2] * a.x + m[1, 2] * a.y + m[2, 2] * a.z + m[3, 2]; }
// Multiply a point by a transformation matrix. // // Applies the given transformation matrix to the given point. With some // transformation matrices, a vector may also be transformed. // // \param c Result. // \param m Transformation matrix. // \param a Input point. public static void lib3ds_vector_transform(float[] c, float[,] m, Lib3dsVertex a) { c[0]=m[0, 0]*a.x+m[1, 0]*a.y+m[2, 0]*a.z+m[3, 0]; c[1]=m[0, 1]*a.x+m[1, 1]*a.y+m[2, 1]*a.z+m[3, 1]; c[2]=m[0, 2]*a.x+m[1, 2]*a.y+m[2, 2]*a.z+m[3, 2]; }
public static void lib3ds_vector_min(float[] c, Lib3dsVertex a) { if(a.x<c[0]) c[0]=a.x; if(a.y<c[1]) c[1]=a.y; if(a.z<c[2]) c[2]=a.z; }
static void lib3ds_io_read_vector(Lib3dsIo io, Lib3dsVertex v) { Debug.Assert(io!=null); v.x=lib3ds_io_read_float(io); v.y=lib3ds_io_read_float(io); v.z=lib3ds_io_read_float(io); }
public static void lib3ds_vector_copy(Lib3dsVertex dst, float[] src) { dst.x=src[0]; dst.y=src[1]; dst.z=src[2]; }
public Lib3dsVertex(Lib3dsVertex v) { x = v.x; y = v.y; z = v.z; }
static void mesh_dump(Lib3dsMesh mesh) { Debug.Assert(mesh!=null); Console.WriteLine(" {0} vertices={1} faces={2}", mesh.name, mesh.nvertices, mesh.nfaces); Console.WriteLine(" matrix:"); matrix_dump(mesh.matrix); Lib3dsVertex p=new Lib3dsVertex(); Console.WriteLine(" vertices (x, y, z, u, v):"); for(int i=0; i<mesh.nvertices; i++) { LIB3DS.lib3ds_vector_copy(p, mesh.vertices[i]); Console.Write(" {0,10:F5} {1,10:F5} {2,10:F5}", p.x, p.y, p.z); if(mesh.texcos!=null) Console.Write(" {0,10:F5} {1,10:F5}", mesh.texcos[i].s, mesh.texcos[i].t); Console.WriteLine(); } Console.WriteLine(" facelist:"); for(int i=0; i<mesh.nfaces; i++) Console.WriteLine(" {0,4} {1,4} {2,4} flags:{3:X} smoothing:{4:X} material:\"{5}\"\n", mesh.faces[i].index[0], mesh.faces[i].index[1], mesh.faces[i].index[2], mesh.faces[i].flags, mesh.faces[i].smoothing_group, mesh.faces[i].material); }