/// <summary> /// ボーン選択の配列を得ます。 /// </summary> /// <param name="sub_mesh">サブメッシュ</param> /// <param name="selected_node">選択ボーン</param> /// <returns>ボーン選択の配列</returns> static int[] ClipBoneSelections(TSOSubMesh sub_mesh, TSONode selected_node) { int[] clipped_boneSelections = new int[sub_mesh.maxPalettes]; for (int numPalettes = 0; numPalettes < sub_mesh.maxPalettes; numPalettes++) { TSONode tso_node = sub_mesh.GetBone(numPalettes); clipped_boneSelections[numPalettes] = (selected_node == tso_node) ? 1 : 0; } return(clipped_boneSelections); }
/// <summary> /// スキン変形行列の配列を得ます。 /// </summary> /// <param name="sub_mesh">サブメッシュ</param> /// <returns>スキン変形行列の配列</returns> public Matrix[] ClipBoneMatrices(TSOSubMesh sub_mesh) { Matrix[] clipped_boneMatrices = new Matrix[sub_mesh.maxPalettes]; for (int numPalettes = 0; numPalettes < sub_mesh.maxPalettes; numPalettes++) { TSONode tso_node = sub_mesh.GetBone(numPalettes); TMONode tmo_node; if (nodemap.TryGetValue(tso_node, out tmo_node)) { clipped_boneMatrices[numPalettes] = tso_node.offset_matrix * tmo_node.combined_matrix; } } return(clipped_boneMatrices); }
/// <summary> /// メッシュを読み込みます。 /// </summary> public void Read(BinaryReader reader) { this.name = reader.ReadCString().Replace(":", "_colon_").Replace("#", "_sharp_"); //should be compatible with directx naming conventions reader.ReadMatrix(ref this.transform_matrix); this.unknown1 = reader.ReadUInt32(); UInt32 mesh_count = reader.ReadUInt32(); this.sub_meshes = new TSOSubMesh[mesh_count]; for (int i = 0; i < mesh_count; i++) { TSOSubMesh sub_mesh = new TSOSubMesh(); sub_mesh.Read(reader); this.sub_meshes[i] = sub_mesh; } }
public static void Write(BinaryWriter bw, TSOSubMesh item) { bw.Write(item.spec); bw.Write(item.bone_index_LUT.Count); foreach (uint i in item.bone_index_LUT) { bw.Write(i); } bw.Write(item.vertices.Length); for (int i = 0; i < item.vertices.Length; i++) { Write(bw, ref item.vertices[i]); } }
private void DrawSubMeshForWireFrame(Figure fig, TSOFile tso, TSOSubMesh sub_mesh) { device.SetRenderState(RenderStates.FillMode, (int)FillMode.WireFrame); //device.RenderState.VertexBlend = (VertexBlend)(4 - 1); device.SetStreamSource(0, sub_mesh.vb, 0, 52); tso.SwitchShader(sub_mesh); effect.SetValue(handle_LocalBoneMats, fig.ClipBoneMatrices(sub_mesh)); int npass = effect.Begin(0); for (int ipass = 0; ipass < npass; ipass++) { effect.BeginPass(ipass); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, sub_mesh.vertices.Length - 2); effect.EndPass(); } effect.End(); }
private void DrawSubMeshForWeightHeating(Figure fig, TSOSubMesh sub_mesh) { device.SetRenderState(RenderStates.FillMode, (int)FillMode.Solid); //device.RenderState.VertexBlend = (VertexBlend)(4 - 1); device.SetStreamSource(0, sub_mesh.vb, 0, 52); effect.Technique = "BoneCol"; effect.SetValue("PenColor", new Vector4(1, 1, 1, 1)); effect.SetValue(handle_LocalBoneMats, fig.ClipBoneMatrices(sub_mesh)); effect.SetValue(handle_LocalBoneSels, ClipBoneSelections(sub_mesh, selected_node)); int npass = effect.Begin(0); for (int ipass = 0; ipass < npass; ipass++) { effect.BeginPass(ipass); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, sub_mesh.vertices.Length - 2); effect.EndPass(); } effect.End(); }
/// <summary> /// スキン変形行列の配列を得ます。 /// </summary> /// <param name="sub_mesh">サブメッシュ</param> /// <returns>スキン変形行列の配列</returns> public Matrix[] ClipBoneMatrices(TSOSubMesh sub_mesh) { Matrix[] clipped_boneMatrices = new Matrix[sub_mesh.maxPalettes]; for (int numPalettes = 0; numPalettes < sub_mesh.maxPalettes; numPalettes++) { TSONode tso_node = sub_mesh.GetBone(numPalettes); TMONode tmo_node; if (nodemap.TryGetValue(tso_node, out tmo_node)) clipped_boneMatrices[numPalettes] = tso_node.offset_matrix * tmo_node.combined_matrix; } return clipped_boneMatrices; }
/// <summary> /// シェーダ設定を切り替えます。 /// </summary> /// <param name="sub_mesh">切り替え対象となるサブメッシュ</param> public void SwitchShader(TSOSubMesh sub_mesh) { Debug.Assert(sub_mesh.spec >= 0 && sub_mesh.spec < sub_scripts.Length, string.Format("mesh.spec out of range: {0}", sub_mesh.spec)); SwitchShader(sub_scripts[sub_mesh.spec].shader); }
public TSOPair(Vertex a, TSOSubMesh sub_mesh) { this.a = a; this.sub_mesh = sub_mesh; }