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."); }
public override void SetupShellSurface() { // create buffers for render // ByteBuffer buf = ByteBuffer.AllocateDirect (Vertex.Length * sizeof(float)); // buf.Order (ByteOrder.NativeOrder ()); // base.VertexBuffer = buf.AsFloatBuffer() as FloatBuffer; // base.VertexBuffer.Put (Vertex); // base.VertexBuffer.Position (0); // // buf = ByteBuffer.AllocateDirect (Normal.Length * sizeof(float)); // buf.Order (ByteOrder.NativeOrder ()); // base.NormalBuffer = buf.AsFloatBuffer() as Java.Nio.FloatBuffer; // base.NormalBuffer.Put (Normal); // base.NormalBuffer.Position (0); // // buf = ByteBuffer.AllocateDirect (Uv.Length * sizeof(float)); // buf.Order (ByteOrder.NativeOrder ()); // base.UvBuffer = buf.AsFloatBuffer() as Java.Nio.FloatBuffer; // base.UvBuffer.Put (Uv); // base.UvBuffer.Position (0); ByteBuffer buf = ByteBuffer.AllocateDirect(Vertex.Length / 3 * 8 * sizeof(float)); buf.Order(ByteOrder.NativeOrder()); base.VertNormUvBuffer = buf.AsFloatBuffer() as FloatBuffer; for (int i = 0; i < Vertex.Length / 3; i++) { base.VertNormUvBuffer.Put(Vertex[i * 3 + 0]); base.VertNormUvBuffer.Put(Vertex[i * 3 + 1]); base.VertNormUvBuffer.Put(Vertex[i * 3 + 2]); base.VertNormUvBuffer.Put(Normal[i * 3 + 0]); base.VertNormUvBuffer.Put(Normal[i * 3 + 1]); base.VertNormUvBuffer.Put(Normal[i * 3 + 2]); base.VertNormUvBuffer.Put(Uv[i * 2 + 0]); base.VertNormUvBuffer.Put(Uv[i * 2 + 1]); } base.VertNormUvBuffer.Position(0); 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); foreach (var i in Bone) { RenderBones.Add(new RenderBone() { bone = i, matrix = new float[16], matrix_current = new float[16], quaternion = new double[4], updated = false }); } CreateRenderList(); // clearnup buffers Vertex = null; Normal = null; Uv = null; Weight = null; Index = null; }