private void reconstructMaterial1(Material mat, int offset, Dictionary <Dictionary <int, int>, ByteBuffer> rename_pool, int max_bone) { var rename = new Dictionary <int, int>(); int acc = 0; for (int j = offset; j < mat.face_vert_count; j += 3) { int acc_prev = acc; acc = renameBone1(rename, mat.face_vert_offset + j + 0, acc); acc = renameBone1(rename, mat.face_vert_offset + j + 1, acc); acc = renameBone1(rename, mat.face_vert_offset + j + 2, acc); if (acc > max_bone) { RenderList mat_new = buildNewMaterial(mat, offset, j, rename, rename_pool, acc_prev); RenderLists.Add(mat_new); reconstructMaterial1(mat, j, rename_pool, max_bone); return; } } RenderList mat_new2 = buildNewMaterial(mat, offset, mat.face_vert_count, rename, rename_pool, max_bone); RenderLists.Add(mat_new2); }
public override void SetupShellSurface() { // create buffers for render Log.Debug("Ruly", "Setup ShellSurface - the number of VertNormUv is " + VertNormUv.Length.ToString()); ByteBuffer buf = ByteBuffer.AllocateDirect(VertNormUv.Length * sizeof(float)); buf.Order(ByteOrder.NativeOrder()); base.VertNormUvBuffer = buf.AsFloatBuffer() as FloatBuffer; base.VertNormUvBuffer.Put(VertNormUv); base.VertNormUvBuffer.Position(0); Log.Debug("Ruly", "Setup ShellSurface - the number of Index is " + Index.Length.ToString()); buf = ByteBuffer.AllocateDirect(Index.Length * sizeof(short)); buf.Order(ByteOrder.NativeOrder()); base.IndexBuffer = buf.AsShortBuffer() as Java.Nio.ShortBuffer; base.IndexBuffer.Put(Index); base.IndexBuffer.Position(0); Log.Debug("Ruly", "Setup ShellSurface - the number of Bone is " + Bones.Length.ToString()); foreach (var i in Bones) { RenderBones.Add(new RenderBone() { bone = i, matrix = new float[16], matrix_current = new float[16], quaternion = new double[4], updated = false }); } Log.Debug("Ruly", "Setup ShellSurface - the number of Materials is " + Materials.Length.ToString()); foreach (var i in Materials) { var r = new RenderList() { material = new Material() { diffuse_color = i.diffuse_color, power = i.power, specular_color = i.specular_color, emmisive_color = i.emmisive_color, toon_index = i.toon_index, edge_flag = i.edge_flag, face_vert_count = i.face_vert_count, texture = i.texture, sph = i.sph, spa = i.spa, face_vert_offset = i.face_vert_offset }, face_vert_count = i.face_vert_count, face_vert_offset = i.face_vert_offset, bone_num = i.bone_num, weight = ByteBuffer.AllocateDirect(VertNormUv.Length / 8 * 3), bone_inv_map = i.bone_inv_map }; r.weight.Order(ByteOrder.NativeOrder()); r.weight.Put(i.weight); r.weight.Position(0); Log.Debug("RMC", "texture in material: " + i.texture); RenderLists.Add(r); } // IK = IKs; IK = null; // ad-hock toon_name = ToonNames; // clearnup buffers VertNormUv = null; Index = null; Log.Debug("Ruly", "Setup ShellSurface - finish."); }