public void Apply(NUD nud) { Matrix4 rotXBy90 = Matrix4.CreateRotationX(0.5f * (float)Math.PI); float scale = 1f; bool hasScale = float.TryParse(scaleTB.Text, out scale); bool checkedMeshName = false; bool fixMeshName = false; bool hasShownShadowWarning = false; foreach (NUD.Mesh mesh in nud.Nodes) { if (BoneTypes[(string)boneTypeComboBox.SelectedItem] == BoneTypes["None"]) { mesh.boneflag = 0; } if (!checkedMeshName) { checkedMeshName = true; if (Collada.HasInitialUnderscoreId(mesh.Text)) { fixMeshName = DialogResult.Yes == MessageBox.Show("Detected mesh names that start with \"_###_\". Would you like to fix this?\nIt is recommended that you select \"Yes\".", "Mesh Name Fix", MessageBoxButtons.YesNo); } } if (fixMeshName) { mesh.Text = Collada.RemoveInitialUnderscoreId(mesh.Text); } foreach (NUD.Polygon poly in mesh.Nodes) { if (BoneTypes[(string)boneTypeComboBox.SelectedItem] == BoneTypes["None"]) { poly.polflag = 0; } if (smoothNrmCB.Checked) { poly.SmoothNormals(); } // Set the vertex size before tangent/bitangent calculations. if (poly.vertSize == (int)NUD.Polygon.VertexTypes.NormalsHalfFloat) // what is this supposed to mean? { poly.vertSize = 0; } else { poly.vertSize = BoneTypes[(string)boneTypeComboBox.SelectedItem] | VertexTypes[(string)vertTypeComboBox.SelectedItem]; } poly.CalculateTangentBitangent(); int vertSizeShadowWarning = (int)NUD.Polygon.BoneTypes.HalfFloat | (int)NUD.Polygon.VertexTypes.NormalsTanBiTanHalfFloat; if (!hasShownShadowWarning && poly.vertSize == vertSizeShadowWarning) { MessageBox.Show("Using \"" + (string)boneTypeComboBox.SelectedItem + "\" and \"" + (string)vertTypeComboBox.SelectedItem + "\" can make shadows not appear in-game.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); hasShownShadowWarning = true; } if (stageMatCB.Checked) { poly.materials.Clear(); poly.materials.Add(NUD.Material.GetStageDefault()); } foreach (NUD.Vertex v in poly.vertices) { //Scroll UVs V by -1 if (transUvVerticalCB.Checked) { for (int i = 0; i < v.uv.Count; i++) { v.uv[i] = new Vector2(v.uv[i].X, v.uv[i].Y + 1); } } // Flip UVs if (flipUVCB.Checked) { for (int i = 0; i < v.uv.Count; i++) { v.uv[i] = new Vector2(v.uv[i].X, 1 - v.uv[i].Y); } } // Halve vertex colors if (vertColorDivCB.Checked) { for (int i = 0; i < 3; i++) { v.color[i] = v.color[i] / 2; } } // Set vertex colors to white. if (vertcolorCB.Checked) { v.color = new Vector4(127, 127, 127, 127); } // Rotate 90 degrees. if (rotate90CB.Checked) { v.pos = Vector3.TransformPosition(v.pos, rotXBy90); v.nrm = Vector3.TransformNormal(v.nrm, rotXBy90); } // Scale. if (scale != 1f) { v.pos = Vector3.Multiply(v.pos, scale); } } } } // Wait until after the model is rotated. nud.GenerateBoundingSpheres(); }