private static void TransformAndAddVec3(List <Vec3> list, Vec3 input, CopyAndTransformVert xform) { Vec3 result; xform(input, out result); list.Add(result); }
public static CSGModel ModelFromBMD(BasicModelData input, Mat4 xform) { List <Vec3> verts = new List <Vec3>(); List <VInfo> vinfos = new List <VInfo>(); CopyAndTransformVert vx = VertexTransformationByMat4(xform); CopyAndTransformVInfo vi = BMDVInfoTransformationByMat4(xform); for (int i = 0; i < input.a_vert.Length; i++) { TransformAndAddVec3(verts, new Vec3 { x = input.x[input.a_vert[i]], y = input.y[input.a_vert[i]], z = input.z[input.a_vert[i]] }, vx); TransformAndAddVec3(verts, new Vec3 { x = input.x[input.b_vert[i]], y = input.y[input.b_vert[i]], z = input.z[input.b_vert[i]] }, vx); TransformAndAddVec3(verts, new Vec3 { x = input.x[input.c_vert[i]], y = input.y[input.c_vert[i]], z = input.z[input.c_vert[i]] }, vx); TransformAndAddVInfo(vinfos, new BMDVInfo { material = nextMaterial, uv = new Vec2 { x = input.u[input.a_uv[i]], y = input.v[input.a_uv[i]] }, normal = new Vec3 { x = input.nx[input.a_norm[i]], y = input.ny[input.a_norm[i]], z = input.nz[input.a_norm[i]] } }, vi); TransformAndAddVInfo(vinfos, new BMDVInfo { material = nextMaterial, uv = new Vec2 { x = input.u[input.b_uv[i]], y = input.v[input.b_uv[i]] }, normal = new Vec3 { x = input.nx[input.b_norm[i]], y = input.ny[input.b_norm[i]], z = input.nz[input.b_norm[i]] } }, vi); TransformAndAddVInfo(vinfos, new BMDVInfo { material = nextMaterial, uv = new Vec2 { x = input.u[input.c_uv[i]], y = input.v[input.c_uv[i]] }, normal = new Vec3 { x = input.nx[input.c_norm[i]], y = input.ny[input.c_norm[i]], z = input.nz[input.c_norm[i]] } }, vi); } nextMaterial++; return(new CSGModel(verts, vinfos)); }
private static void TransformAndAddVec3(List<Vec3> list, Vec3 input, CopyAndTransformVert xform) { Vec3 result; xform(input, out result); list.Add(result); }