private Color skintone = Color.White; //Color.FromArgb(247, 224, 200); public void reloadTextures() { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { if (!renderWindow1.RenderEnabled) { reload3D(); return; } xmlChunkDetails details = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; renderWindow1.RenderEnabled = false; DateTime startTime = DateTime.Now; toolStripStatusLabel1.Text = "Reloading Textures..."; statusStrip1.Refresh(); reloadTextures(details); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; toolStripStatusLabel1.Text = "Reloaded Textures in " + duration.Milliseconds + "ms"; renderWindow1.RenderEnabled = true; } }
public void reloadTextures(xmlChunkDetails details) { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { List <string> textures = findDefaultTextures(casPartNew.ageGenderFlag, casPartNew.typeFlag); if (skintone == Color.White) { renderWindow1.loadTexture(KeyUtils.findKey(textures[0]), "skinTexture"); } else { renderWindow1.loadTextureFromBitmap(getSkinTone(KeyUtils.findKey(textures[0])), "skinTexture"); } renderWindow1.loadTexture(KeyUtils.findKey(textures[1]), "skinSpecular"); //renderWindow1.loadTexture(KeyUtils.findKey(textures[2]), "normalMap"); //Don't use the default skin bumpmap texture, but load the bumpmap from the current mesh. foreach (ListViewItem i in lstMeshTGILinks.Items) { if (i.SubItems[1].Text == "NormalMap") { String normalMapKey = i.SubItems[0].Text; Stream tex = KeyUtils.findKey(normalMapKey); renderWindow1.loadTexture(tex, "normalMap"); } } if ((casPartNew.typeFlag & 0x1) == 0x1) { renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingAmbient), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingSpecular), "specularTexture"); } else if ((casPartNew.typeFlag & 0x4) == 0x4) { renderWindow1.loadTexture(KeyUtils.findKey(details.faceOverlay), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.faceSpecular), "specularTexture"); } else { renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingAmbient), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingSpecular), "specularTexture"); } renderWindow1.loadTexture(KeyUtils.findKey(details.Multiplier), "baseTexture"); renderWindow1.loadTexture(null, "stencilA"); //if ((casPartNew.typeFlag & 0x4) == 0x4) //{ //renderWindow1.shaderMode = 1; //} //else //{ //renderWindow1.shaderMode = 0; //} generate3DTexture(details); // We don't need this here since generate3DTexture resets the device anyway //renderWindow1.resetDevice(); } }
private void generate3DTexture(xmlChunkDetails details) { renderWindow1.lblGeneratingTexture.Visible = true; if (!bwGenTexture.IsBusy) { bwGenTexture.RunWorkerAsync(details); } }
private void generate3DTexture() { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { xmlChunkDetails details = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; generate3DTexture(details); } }
private void bwGenTexture_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { xmlChunkDetails details = (xmlChunkDetails)e.Argument; Object[] a = new Object[2]; a[0] = details; a[1] = Render3DTexture(details); e.Result = a; }
public Bitmap Render3DTexture() { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { xmlChunkDetails details = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; return(Render3DTexture(details)); } return(null); }
private Bitmap composeMakeup(xmlChunkDetails details, uint casPartType) { DateTime startTime2 = DateTime.Now; List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.faceOverlay)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask)); List <Stream> textures = KeyUtils.findKey(tempList, 2); DateTime stopTime2 = DateTime.Now; TimeSpan duration2 = stopTime2 - startTime2; Console.WriteLine("Key search time: " + duration2.TotalMilliseconds); if (MadScience.Patterns.isEmptyTexture(details.Multiplier)) { textures[0] = null; } DateTime startTime = DateTime.Now; Bitmap output = null; if (String.IsNullOrEmpty(details.TintColor)) { if (MadScience.Patterns.isEmptyMask(details.Mask) && details.tint.A.enabled != null && details.tint.A.enabled.ToLower() == "true") { output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.tint.A.color)); } else if (MadScience.Patterns.isEmptyMask(details.Mask) || String.IsNullOrEmpty(details.Mask)) { // output = new Bitmap(16, 16); output = PatternProcessor.ProcessMakeupTexture(textures, Color.White); } else { output = PatternProcessor.ProcessMakeupTexture(textures, details.tint.A, details.tint.B, details.tint.C, details.tint.D); } } else if (details.TintColor != null) { output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.TintColor)); } DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Console.WriteLine("Total Makeup Texture generation time: " + duration.TotalMilliseconds); return(output); }
private void showPatternDetails(int designNo) { xmlChunkDetails chunk = (xmlChunkDetails)casPartNew.xmlChunk[designNo]; int i = cmbPatternSelect.SelectedIndex; if (chunk.filename == "CasRgbMask" && i == 3) { grpPatternA.Enabled = false; } else { grpPatternA.Enabled = true; showPatternDetails(chunk.pattern[i]); } }
private void loadStencils(xmlChunkDetails details) { List <Stream> stencils = new List <Stream>(); //Stream[] stencils = new Stream[6]; if (details.Overlay != null && !MadScience.Patterns.isEmptyTexture(details.Overlay)) { stencils.Add(KeyUtils.findKey(details.Overlay)); } if (details.stencil.A.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.A.key)); } if (details.stencil.B.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.B.key)); } if (details.stencil.C.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.C.key)); } if (details.stencil.D.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.D.key)); } if (details.stencil.E.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.E.key)); } if (details.stencil.F.Enabled == "True") { stencils.Add(KeyUtils.findKey(details.stencil.F.key)); } if (stencils.Count == 0) { return; } if (stencils.Count == 1) { renderWindow1.loadTexture(stencils[0], "stencilA"); } if (stencils.Count > 1) { renderWindow1.loadTextureFromBitmap(MadScience.Patterns.mergeStencils(stencils), "stencilA"); } }
public void reload3D() { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { xmlChunkDetails details = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; toolStripStatusLabel1.Text = "Initialising 3d view... please wait..."; statusStrip1.Refresh(); DateTime startTime = DateTime.Now; reload3D(details); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; this.toolStripStatusLabel1.Text = "Loaded 3D in " + duration.Milliseconds + "ms"; } }
private Bitmap Render3DTexture(xmlChunkDetails details) { Bitmap b; if ((casPartNew.typeFlag & 0x4) == 0x4) { //makeup b = composeMakeup(details, casPartNew.clothingType); } else if ((casPartNew.typeFlag & 0x1) == 0x1) { //hair b = composeHair(details); } else { b = composeMultiplier(details); } return(b); }
private Bitmap composeHair(xmlChunkDetails details) { Bitmap patterns = composeMultiplier(details); List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.DiffuseMap)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.ControlMap)); List <Stream> textures = KeyUtils.findKey(tempList, 2); if (MadScience.Patterns.isEmptyTexture(details.DiffuseMap)) { textures[0] = null; } DateTime startTime = DateTime.Now; Bitmap hair = PatternProcessor.ProcessHairTexture(textures, MadScience.Colours.convertColour(details.hair.DiffuseColor), MadScience.Colours.convertColour(details.hair.RootColor), MadScience.Colours.convertColour(details.hair.HighlightColor), MadScience.Colours.convertColour(details.hair.TipColor)); if (patterns.Width < hair.Width) { using (Graphics g = Graphics.FromImage(hair)) { g.DrawImage(patterns, 0, 0, patterns.Width, patterns.Height); } return(hair); } else { using (Graphics g = Graphics.FromImage(patterns)) { g.DrawImage(hair, 0, 0, patterns.Width, patterns.Height); } return(patterns); } }
private void makePatternPreviewThumb() { if (listView1.SelectedItems.Count == 1) { int patternNo = cmbPatternSelect.SelectedIndex; xmlChunkDetails chunk = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; //patternDetails temp = commitPatternDetails(); Console.WriteLine("makePatternPreviewThumb"); //picPatternThumb.Image = Patterns.makePatternThumb(pBrowser.findPattern(temp.key), pBrowser.pDetailsTopFile(temp)); if (chunk.pattern[patternNo].type == "solidColor" && cEnable3DPreview.Checked == false) { picPatternThumb.Image = null; picPatternThumb.BackColor = Colours.convertColour(chunk.pattern[patternNo].Color); } else { picPatternThumb.Image = Patterns.makePatternThumb(chunk.pattern[patternNo]); generate3DTexture(chunk); } picPatternThumb.Visible = true; } }
private void addNewCopyLastToolStripMenuItem_Click(object sender, EventArgs e) { ListViewItem item = new ListViewItem(); item.Text = "Design #" + (listView1.Items.Count + 1).ToString(); if (listView1.Items.Count == 0) lastSelected = -1; // Add a new XML chunk to the casPart xmlChunkDetails chunk = new xmlChunkDetails(); // Copy chunk from casPartSrc index 0 //chunk = (xmlChunkDetails)casPartNew.xmlChunk[listView1.Items.Count - 1].Copy(); chunk = (xmlChunkDetails)OX.Copyable.ObjectExtensions.Copy(casPartNew.xmlChunk[listView1.Items.Count - 1]); casPartNew.xmlChunk.Add(chunk); casPartNew.xmlChunkRaw.Add(""); saveAsToolStripMenuItem.Enabled = true; listView1.Items.Add(item); listView1.Items[listView1.Items.Count - 1].Selected = true; reloadTextures(); }
private void commitPatternDetails(string param, string value) { if (listView1.SelectedItems.Count == 1) { int patternNo = cmbPatternSelect.SelectedIndex; xmlChunkDetails chunk = (xmlChunkDetails)casPartNew.xmlChunk[listView1.SelectedIndices[0]]; Patterns.patternDetails pDetail = chunk.pattern[patternNo]; switch (param) { case "enabled": pDetail.Enabled = value; break; case "linked": pDetail.Linked = value; break; case "key": pDetail.key = value; break; case "type": pDetail.type = value; break; case "name": pDetail.name = value; break; case "filename": pDetail.filename = value; break; case "tiling": pDetail.Tiling = value; break; case "rgbmask": pDetail.rgbmask = value; break; case "bgimage": pDetail.BackgroundImage = value; break; case "specular": pDetail.specmap = value; break; case "Color": pDetail.Color = value; break; case "ColorP0": pDetail.ColorP[0] = value; break; case "ColorP1": pDetail.ColorP[1] = value; break; case "ColorP2": pDetail.ColorP[2] = value; break; case "ColorP3": pDetail.ColorP[3] = value; break; case "ColorP4": pDetail.ColorP[4] = value; break; } } }
private Bitmap Render3DTexture(xmlChunkDetails details) { Bitmap b; if ((casPartNew.typeFlag & 0x4) == 0x4) { //makeup b = composeMakeup(details, casPartNew.clothingType); } else if ((casPartNew.typeFlag & 0x1) == 0x1) { //hair b = composeHair(details); } else { b = composeMultiplier(details); } return b; }
private void saveToDBPF(Database db, ulong instanceId, bool newInstance) { ResourceKey rkey; MemoryStream mem = new MemoryStream(); casPartFile casPF = new casPartFile(); // Do we have new meshes? If so, we need to do some pretty heft modifications. :) string meshName = txtMeshName.Text; NameMap namemap = new NameMap(); ResourceKey namemapKey = new ResourceKey(0x0166038C, 0x00000000, instanceId); if (!String.IsNullOrEmpty(txtMeshLod1.Text) || !String.IsNullOrEmpty(txtMeshLod0.Text)) { keyName bodyBlendFat = new keyName(0x062C8204, 0x0, meshName + "_fat"); keyName bodyBlendFit = new keyName(0x062C8204, 0x0, meshName + "_fit"); keyName bodyBlendThin = new keyName(0x062C8204, 0x0, meshName + "_thin"); keyName bodyBlendSpecial = new keyName(0x062C8204, 0x0, meshName + "_special"); namemap.entries.Add(bodyBlendFat.instanceId, bodyBlendFat.name); namemap.entries.Add(bodyBlendFit.instanceId, bodyBlendFit.name); namemap.entries.Add(bodyBlendThin.instanceId, bodyBlendThin.name); namemap.entries.Add(bodyBlendSpecial.instanceId, bodyBlendSpecial.name); Stream bodyBlendFatStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoFat].ToString(), 0); Stream bodyBlendFitStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoFit].ToString(), 0); Stream bodyBlendThinStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoThin].ToString(), 0); Stream bodyBlendSpecialStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoSpecial].ToString(), 0); // Load in the blend information FacialBlend bodyBlendFatFile = new FacialBlend(bodyBlendFatStream); bodyBlendFatFile.partName = meshName + "_fat"; FacialBlend bodyBlendFitFile = new FacialBlend(bodyBlendFitStream); bodyBlendFitFile.partName = meshName + "_fit"; FacialBlend bodyBlendThinFile = new FacialBlend(bodyBlendThinStream); bodyBlendThinFile.partName = meshName + "_thin"; FacialBlend bodyBlendSpecialFile = new FacialBlend(bodyBlendSpecialStream); bodyBlendSpecialFile.partName = meshName + "_special"; if (debugModeToolStripMenuItem.Checked) { Stream bgeoStream = KeyUtils.findKey(bodyBlendFatFile.blendTgi, 0); bgeoStream.Seek(0, SeekOrigin.Begin); bodyBlendFatFile.blendTgi = new keyName(0x067CAA11, 0x0, meshName + "_fat").ToResourceKey(); db.SetResourceStream(bodyBlendFatFile.blendTgi, bgeoStream); bgeoStream = KeyUtils.findKey(bodyBlendFitFile.blendTgi, 0); bgeoStream.Seek(0, SeekOrigin.Begin); bodyBlendFitFile.blendTgi = new keyName(0x067CAA11, 0x0, meshName + "_fit").ToResourceKey(); db.SetResourceStream(bodyBlendFitFile.blendTgi, bgeoStream); bgeoStream = KeyUtils.findKey(bodyBlendThinFile.blendTgi, 0); bgeoStream.Seek(0, SeekOrigin.Begin); bodyBlendThinFile.blendTgi = new keyName(0x067CAA11, 0x0, meshName + "_thin").ToResourceKey(); db.SetResourceStream(bodyBlendThinFile.blendTgi, bgeoStream); bgeoStream = KeyUtils.findKey(bodyBlendSpecialFile.blendTgi, 0); bgeoStream.Seek(0, SeekOrigin.Begin); bodyBlendSpecialFile.blendTgi = new keyName(0x067CAA11, 0x0, meshName + "_special").ToResourceKey(); db.SetResourceStream(bodyBlendSpecialFile.blendTgi, bgeoStream); } db.SetResourceStream(bodyBlendFit.ToResourceKey(), bodyBlendFitFile.Save()); db.SetResourceStream(bodyBlendFat.ToResourceKey(), bodyBlendFatFile.Save()); db.SetResourceStream(bodyBlendThin.ToResourceKey(), bodyBlendThinFile.Save()); db.SetResourceStream(bodyBlendSpecial.ToResourceKey(), bodyBlendSpecialFile.Save()); // Update the CAS part TGI links with the new VPXY casPartNew.tgi64list[casPartNew.tgiIndexBlendInfoFat] = bodyBlendFat.ToResourceKey(); casPartNew.tgi64list[casPartNew.tgiIndexBlendInfoFit] = bodyBlendFit.ToResourceKey(); casPartNew.tgi64list[casPartNew.tgiIndexBlendInfoThin] = bodyBlendThin.ToResourceKey(); casPartNew.tgi64list[casPartNew.tgiIndexBlendInfoSpecial] = bodyBlendSpecial.ToResourceKey(); keyName proxyFitKey = new keyName(0x736884F1, 0x00000001, meshName + "_fit"); keyName proxyFatKey = new keyName(0x736884F1, 0x00000001, meshName + "_fat"); keyName proxyThinKey = new keyName(0x736884F1, 0x00000001, meshName + "_thin"); keyName proxySpecialKey = new keyName(0x736884F1, 0x00000001, meshName + "_special"); Stream proxyFatStream = KeyUtils.findKey(new ResourceKey(0x736884F1, 0x00000001, casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoFat].instanceId), 0); Stream proxyFitStream = KeyUtils.findKey(new ResourceKey(0x736884F1, 0x00000001, casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoFit].instanceId), 0); Stream proxyThinStream = KeyUtils.findKey(new ResourceKey(0x736884F1, 0x00000001, casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoThin].instanceId), 0); Stream proxySpecialStream = KeyUtils.findKey(new ResourceKey(0x736884F1, 0x00000001, casPartSrc.tgi64list[casPartSrc.tgiIndexBlendInfoSpecial].instanceId), 0); VPXYFile proxyFat = new VPXYFile(proxyFatStream); proxyFat.rcolHeader.internalChunks.Clear(); proxyFat.rcolHeader.internalChunks.Add(proxyFatKey.ToResourceKey()); VPXYFile proxyFit = new VPXYFile(proxyFitStream); proxyFit.rcolHeader.internalChunks.Clear(); proxyFit.rcolHeader.internalChunks.Add(proxyFitKey.ToResourceKey()); VPXYFile proxyThin = new VPXYFile(proxyThinStream); proxyThin.rcolHeader.internalChunks.Clear(); proxyThin.rcolHeader.internalChunks.Add(proxyThinKey.ToResourceKey()); VPXYFile proxySpecial = new VPXYFile(proxySpecialStream); proxySpecial.rcolHeader.internalChunks.Clear(); proxySpecial.rcolHeader.internalChunks.Add(proxySpecialKey.ToResourceKey()); db.SetResourceStream(proxyFatKey.ToResourceKey(), proxyFat.Save()); db.SetResourceStream(proxyFitKey.ToResourceKey(), proxyFit.Save()); db.SetResourceStream(proxyThinKey.ToResourceKey(), proxyThin.Save()); db.SetResourceStream(proxySpecialKey.ToResourceKey(), proxySpecial.Save()); uint customGroup = MadScience.StringHelpers.HashFNV24(meshName); keyName meshLod0 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod0"), meshName + "_lod0"); keyName meshLod0_1 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod0_1"), meshName + "_lod0_1"); keyName meshLod0_2 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod0_2"), meshName + "_lod0_2"); keyName meshLod0_3 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod0_3"), meshName + "_lod0_3"); keyName meshLod1 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod1"), meshName + "_lod1"); keyName meshLod1_1 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod1_1"), meshName + "_lod1_1"); keyName meshLod1_2 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod1_2"), meshName + "_lod1_2"); keyName meshLod1_3 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod1_3"), meshName + "_lod1_3"); keyName meshLod2 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod2"), meshName + "_lod2"); keyName meshLod2_1 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod2_1"), meshName + "_lod2_1"); keyName meshLod2_2 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod2_2"), meshName + "_lod2_2"); keyName meshLod3 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod3"), meshName + "_lod3"); keyName meshLod3_1 = new keyName(0x015A1849, customGroup, (ulong)MadScience.StringHelpers.HashFNV32(meshName + "_lod3_1"), meshName + "_lod3_1"); keyName vpxyKey = new keyName(0x736884F1, 0x00000001, (ulong)customGroup); // Load in the VPXY - we need to modify it. //keyName oldVpxyKey = new keyName((tgi64)casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY]); Stream vpxyStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY].ToString(), 0); if (StreamHelpers.isValidStream(vpxyStream)) { namemap.entries.Add(meshLod0.instanceId, meshName + "_lod0"); namemap.entries.Add(meshLod0_1.instanceId, meshName + "_lod0_1"); namemap.entries.Add(meshLod0_2.instanceId, meshName + "_lod0_2"); namemap.entries.Add(meshLod0_3.instanceId, meshName + "_lod0_3"); namemap.entries.Add(meshLod1.instanceId, meshName + "_lod1"); namemap.entries.Add(meshLod1_1.instanceId, meshName + "_lod1_1"); namemap.entries.Add(meshLod1_2.instanceId, meshName + "_lod1_2"); namemap.entries.Add(meshLod1_3.instanceId, meshName + "_lod1_3"); namemap.entries.Add(meshLod2.instanceId, meshName + "_lod2"); namemap.entries.Add(meshLod2_1.instanceId, meshName + "_lod2_1"); namemap.entries.Add(meshLod2_2.instanceId, meshName + "_lod2_2"); namemap.entries.Add(meshLod3.instanceId, meshName + "_lod3"); namemap.entries.Add(meshLod3_1.instanceId, meshName + "_lod3_1"); namemap.entries.Add(vpxyKey.instanceId, meshName); //keyName proxyFit = new keyName(0x736884F1, 0x00000001, meshName + "_fit"); //keyName proxyFat = new keyName(0x736884F1, 0x00000001, meshName + "_fat"); //keyName proxyThin = new keyName(0x736884F1, 0x00000001, meshName + "_thin"); //keyName proxySpecial = new keyName(0x736884F1, 0x00000001, meshName + "_special"); VPXYFile vpxyfile = new VPXYFile(vpxyStream); vpxyfile.rcolHeader.internalChunks.Clear(); vpxyfile.rcolHeader.internalChunks.Add(vpxyKey.ToResourceKey()); vpxyfile.vpxy.linkEntries.Clear(); if (!String.IsNullOrEmpty(txtMeshLod0.Text)) { // LOD 0 VPXYEntry vpxyE = new VPXYEntry(); if (!String.IsNullOrEmpty(txtMeshLod0_1.Text)) { vpxyE.tgiList.Add(meshLod0_1.ToResourceKey()); } if (!String.IsNullOrEmpty(txtMeshLod0_2.Text)) { vpxyE.tgiList.Add(meshLod0_2.ToResourceKey()); } if (!String.IsNullOrEmpty(txtMeshLod0_3.Text)) { vpxyE.tgiList.Add(meshLod0_3.ToResourceKey()); } vpxyE.tgiList.Add(meshLod0.ToResourceKey()); vpxyfile.vpxy.linkEntries.Add(vpxyE); } if (!String.IsNullOrEmpty(txtMeshLod1.Text)) { // LOD 1 VPXYEntry vpxyE = new VPXYEntry(); if (!String.IsNullOrEmpty(txtMeshLod1_1.Text)) { vpxyE.tgiList.Add(meshLod1_1.ToResourceKey()); } if (!String.IsNullOrEmpty(txtMeshLod1_2.Text)) { vpxyE.tgiList.Add(meshLod1_2.ToResourceKey()); } if (!String.IsNullOrEmpty(txtMeshLod1_3.Text)) { vpxyE.tgiList.Add(meshLod1_3.ToResourceKey()); } vpxyE.tgiList.Add(meshLod1.ToResourceKey()); vpxyfile.vpxy.linkEntries.Add(vpxyE); } if (!String.IsNullOrEmpty(txtMeshLod2.Text)) { // LOD 2 VPXYEntry vpxyE = new VPXYEntry(); if (!String.IsNullOrEmpty(txtMeshLod2_1.Text)) { vpxyE.tgiList.Add(meshLod2_1.ToResourceKey()); } if (!String.IsNullOrEmpty(txtMeshLod2_2.Text)) { vpxyE.tgiList.Add(meshLod2_2.ToResourceKey()); } vpxyE.tgiList.Add(meshLod2.ToResourceKey()); vpxyfile.vpxy.linkEntries.Add(vpxyE); } if (!String.IsNullOrEmpty(txtMeshLod3.Text)) { // LOD 2 VPXYEntry vpxyE = new VPXYEntry(); if (!String.IsNullOrEmpty(txtMeshLod3_1.Text)) { vpxyE.tgiList.Add(meshLod3_1.ToResourceKey()); } vpxyE.tgiList.Add(meshLod3.ToResourceKey()); vpxyfile.vpxy.linkEntries.Add(vpxyE); } vpxyfile.vpxy.keytable.keys.Clear(); // If a Hair or an Accessory then set the vpxy start to 0 else starts at 1 if (checkedListType.GetItemChecked(0) == true || checkedListType.GetItemChecked(4) == true) { vpxyfile.vpxy.numTypeZero = 0; } else { vpxyfile.vpxy.numTypeZero = 1; } vpxyStream = vpxyfile.Save(); //vpxyfile.rcolHeader.internalChunks[0] = proxyFit.ToResourceKey(); //Stream proxyFitFile = vpxyfile.Save(); //vpxyfile.rcolHeader.internalChunks[0] = proxyFat.ToResourceKey(); //Stream proxyFatFile = vpxyfile.Save(); //vpxyfile.rcolHeader.internalChunks[0] = proxyThin.ToResourceKey(); //Stream proxyThinFile = vpxyfile.Save(); //vpxyfile.rcolHeader.internalChunks[0] = proxySpecial.ToResourceKey(); //Stream proxySpecialFile = vpxyfile.Save(); db.SetResourceStream(vpxyKey.ToResourceKey(), vpxyStream); //db.SetResourceStream(proxyFit.ToResourceKey(), proxyFitFile); //db.SetResourceStream(proxyFat.ToResourceKey(), proxyFatFile); //db.SetResourceStream(proxyThin.ToResourceKey(), proxyThinFile); //db.SetResourceStream(proxySpecial.ToResourceKey(), proxySpecialFile); // Update the CAS part TGI links with the new VPXY casPartNew.tgi64list[casPartNew.tgiIndexVPXY] = vpxyKey.ToResourceKey(); keyName bumpMapKey = new keyName(); if (String.IsNullOrEmpty(txtOtherBumpMap.Text) == false) { bumpMapKey = new keyName(txtOtherBumpMap.Text, meshName + "_n"); //kNames.Add(bumpMapKey); Stream bumpMapStream = File.OpenRead(txtOtherBumpMap.Text); if (txtOtherBumpMap.Text != "" && !txtOtherBumpMap.Text.StartsWith("key:")) { db.SetResourceStream(bumpMapKey.ToResourceKey(), bumpMapStream); } bumpMapStream.Close(); } #region Import Mesh LODs if (!String.IsNullOrEmpty(txtMeshLod0.Text.Trim())) { db.SetResourceStream(meshLod0.ToResourceKey(), saveGeom(txtMeshLod0.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod0_1.Text.Trim())) { db.SetResourceStream(meshLod0_1.ToResourceKey(), saveGeom(txtMeshLod0_1.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod0_2.Text.Trim())) { db.SetResourceStream(meshLod0_2.ToResourceKey(), saveGeom(txtMeshLod0_2.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod0_3.Text.Trim())) { db.SetResourceStream(meshLod0_3.ToResourceKey(), saveGeom(txtMeshLod0_3.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod1.Text.Trim())) { db.SetResourceStream(meshLod1.ToResourceKey(), saveGeom(txtMeshLod1.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod1_1.Text.Trim())) { db.SetResourceStream(meshLod1_1.ToResourceKey(), saveGeom(txtMeshLod1_1.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod1_2.Text.Trim())) { db.SetResourceStream(meshLod1_2.ToResourceKey(), saveGeom(txtMeshLod1_2.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod1_3.Text.Trim())) { db.SetResourceStream(meshLod1_3.ToResourceKey(), saveGeom(txtMeshLod1_3.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod2.Text.Trim())) { db.SetResourceStream(meshLod2.ToResourceKey(), saveGeom(txtMeshLod2.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod2_1.Text.Trim())) { db.SetResourceStream(meshLod2_1.ToResourceKey(), saveGeom(txtMeshLod2_1.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod2_2.Text.Trim())) { db.SetResourceStream(meshLod2_2.ToResourceKey(), saveGeom(txtMeshLod2_2.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod3.Text.Trim())) { db.SetResourceStream(meshLod3.ToResourceKey(), saveGeom(txtMeshLod3.Text, bumpMapKey.ToResourceKey())); } if (!String.IsNullOrEmpty(txtMeshLod3_1.Text.Trim())) { db.SetResourceStream(meshLod3_1.ToResourceKey(), saveGeom(txtMeshLod3_1.Text, bumpMapKey.ToResourceKey())); } #endregion } } db.SetResourceStream(namemapKey, namemap.Save()); if (casPartNew != null) { casPF.Save(mem, casPartNew); } else { casPF.Save(mem, casPartSrc); } casPF = null; if (this.loadedCasPart.ToString() == "00000000:00000000:0000000000000000") { rkey = new ResourceKey((uint)0x034AEECB, (uint)0, instanceId, (uint)ResourceKeyOrder.ITG); } else { if (!newInstance) { rkey = this.loadedCasPart; } else { rkey = new ResourceKey((uint)0x034AEECB, (uint)0, instanceId, (uint)ResourceKeyOrder.ITG); } } db.SetResourceStream(rkey, mem); if (casPartNew != null) { // Go through a list of all the keys and see if they are "local" for (int i = 0; i < casPartNew.xmlChunk.Count; i++) { xmlChunkDetails chunk = (xmlChunkDetails)casPartNew.xmlChunk[i]; for (int j = 0; j < 10; j++) { writeLocalResource(db, stencilPool[j].key); } writeLocalResource(db, chunk.Multiplier); writeLocalResource(db, chunk.Overlay); writeLocalResource(db, chunk.hair.RootColor); writeLocalResource(db, chunk.hair.DiffuseColor); writeLocalResource(db, chunk.hair.HighlightColor); writeLocalResource(db, chunk.hair.TipColor); writeLocalResource(db, chunk.hair.ScalpDiffuseMap); writeLocalResource(db, chunk.hair.ScalpControlMap); writeLocalResource(db, chunk.hair.ScalpSpecularMap); writeLocalResource(db, chunk.hair.ScalpAO); writeLocalResource(db, chunk.hair.FaceDiffuseMap); writeLocalResource(db, chunk.hair.FaceControlMap); writeLocalResource(db, chunk.hair.FaceSpecularMap); writeLocalResource(db, chunk.hair.FaceAO); writeLocalResource(db, chunk.Mask); writeLocalResource(db, chunk.SkinSpecular); writeLocalResource(db, chunk.SkinAmbient); writeLocalResource(db, chunk.ClothingSpecular); writeLocalResource(db, chunk.ClothingAmbient); writeLocalResource(db, chunk.PartMask); writeLocalResource(db, chunk.pattern[0].BackgroundImage); writeLocalResource(db, chunk.pattern[1].BackgroundImage); writeLocalResource(db, chunk.pattern[2].BackgroundImage); writeLocalResource(db, chunk.pattern[3].BackgroundImage); writeLocalResource(db, chunk.pattern[0].rgbmask); writeLocalResource(db, chunk.pattern[1].rgbmask); writeLocalResource(db, chunk.pattern[2].rgbmask); writeLocalResource(db, chunk.pattern[3].rgbmask); writeLocalResource(db, chunk.pattern[0].specmap); writeLocalResource(db, chunk.pattern[1].specmap); writeLocalResource(db, chunk.pattern[2].specmap); writeLocalResource(db, chunk.pattern[3].specmap); writeLocalResource(db, chunk.pattern[0].filename); writeLocalResource(db, chunk.pattern[1].filename); writeLocalResource(db, chunk.pattern[2].filename); writeLocalResource(db, chunk.pattern[3].filename); writeLocalResource(db, chunk.faceOverlay); writeLocalResource(db, chunk.faceSpecular); writeLocalResource(db, chunk.ControlMap); writeLocalResource(db, chunk.DiffuseMap); if (newPNGfiles.ContainsKey(i)) { Stream newPNG = File.Open(newPNGfiles[i], FileMode.Open, FileAccess.Read, FileShare.Read); uint thumbGroup = (uint)i; if (useAlternativeToolStripMenuItem.Checked == true) { thumbGroup++; } ResourceKey keyPNG = new ResourceKey(0x626F60CE, thumbGroup, instanceId, (uint)ResourceKeyOrder.ITG); db.SetResourceStream(keyPNG, newPNG); newPNG.Close(); } } } mem.Close(); }
private void generate3DTexture(xmlChunkDetails details) { renderWindow1.lblGeneratingTexture.Visible = true; if (!bwGenTexture.IsBusy) bwGenTexture.RunWorkerAsync(details); }
private void loadStencils(xmlChunkDetails details) { List<Stream> stencils = new List<Stream>(); //Stream[] stencils = new Stream[6]; if (details.Overlay != null && !MadScience.Patterns.isEmptyTexture(details.Overlay)) stencils.Add(KeyUtils.findKey(details.Overlay)); if (details.stencil.A.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.A.key)); if (details.stencil.B.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.B.key)); if (details.stencil.C.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.C.key)); if (details.stencil.D.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.D.key)); if (details.stencil.E.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.E.key)); if (details.stencil.F.Enabled == "True") stencils.Add(KeyUtils.findKey(details.stencil.F.key)); if (stencils.Count == 0) return; if (stencils.Count == 1) renderWindow1.loadTexture(stencils[0], "stencilA"); if (stencils.Count > 1) renderWindow1.loadTextureFromBitmap(MadScience.Patterns.mergeStencils(stencils), "stencilA"); }
private Bitmap composeMakeup(xmlChunkDetails details, uint casPartType) { DateTime startTime2 = DateTime.Now; List<MadScience.Wrappers.ResourceKey> tempList = new List<MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.faceOverlay)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask)); List<Stream> textures = KeyUtils.findKey(tempList, 2); DateTime stopTime2 = DateTime.Now; TimeSpan duration2 = stopTime2 - startTime2; Console.WriteLine("Key search time: " + duration2.TotalMilliseconds); if (MadScience.Patterns.isEmptyTexture(details.Multiplier)) textures[0] = null; DateTime startTime = DateTime.Now; Bitmap output = null; if (String.IsNullOrEmpty(details.TintColor)) { if (MadScience.Patterns.isEmptyMask(details.Mask) && details.tint.A.enabled != null && details.tint.A.enabled.ToLower() == "true") { output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.tint.A.color)); } else if (MadScience.Patterns.isEmptyMask(details.Mask) || String.IsNullOrEmpty(details.Mask)) { // output = new Bitmap(16, 16); output = PatternProcessor.ProcessMakeupTexture(textures, Color.White); } else { output = PatternProcessor.ProcessMakeupTexture(textures, details.tint.A, details.tint.B, details.tint.C, details.tint.D); } } else if (details.TintColor != null) { output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.TintColor)); } DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Console.WriteLine("Total Makeup Texture generation time: " + duration.TotalMilliseconds); return output; }
private Bitmap composeMultiplier(xmlChunkDetails details) { Bitmap[] myPatterns = new Bitmap[1]; DateTime startTime2 = DateTime.Now; List<MadScience.Wrappers.ResourceKey> tempList = new List<MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Multiplier)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask)); List<Stream> textures = KeyUtils.findKey(tempList, 2); if (details.pattern[3].Enabled.ToLower() == "true" && details.filename == "CasRgbaMask") { myPatterns = new Bitmap[4]; } else if (details.pattern[2].Enabled.ToLower() == "true") { myPatterns = new Bitmap[3]; } else if (details.pattern[1].Enabled.ToLower() == "true") { myPatterns = new Bitmap[2]; } PointF[] tilings = new PointF[myPatterns.Length]; for (int i = 0; i < myPatterns.Length; i++) if (details.pattern[i].Enabled.ToLower() == "true") { myPatterns[i] = (Bitmap)Patterns.makePatternThumb(details.pattern[i]); ; tilings[i] = new PointF(1f, 1f); if (details.pattern[i].Tiling != null) { String[] s = details.pattern[i].Tiling.Split(','); if (s.Length == 2) { try { tilings[i].X = Convert.ToSingle(s[0], CultureInfo.InvariantCulture); tilings[i].Y = Convert.ToSingle(s[1], CultureInfo.InvariantCulture); } catch (Exception) { tilings[i] = new PointF(1f, 1f); } } } } DateTime stopTime2 = DateTime.Now; TimeSpan duration2 = stopTime2 - startTime2; Console.WriteLine("Key search time: " + duration2.TotalMilliseconds); DateTime startTime = DateTime.Now; if (MadScience.Patterns.isEmptyTexture(details.Multiplier)) textures[0] = null; Bitmap output; if (MadScience.Patterns.isEmptyMask(details.Mask)) output = PatternProcessor.ProcessSingleChannelTexture( textures, myPatterns[0], tilings[0]); else output = PatternProcessor.ProcessClothingTexture( textures, myPatterns, tilings); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Console.WriteLine("Total Multiplier Texture generation time: " + duration.TotalMilliseconds); return output; }
public void reloadTextures(xmlChunkDetails details) { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { List<string> textures = findDefaultTextures(casPartNew.ageGenderFlag, casPartNew.typeFlag); if (skintone == Color.White) renderWindow1.loadTexture(KeyUtils.findKey(textures[0]), "skinTexture"); else renderWindow1.loadTextureFromBitmap(getSkinTone(KeyUtils.findKey(textures[0])), "skinTexture"); renderWindow1.loadTexture(KeyUtils.findKey(textures[1]), "skinSpecular"); //renderWindow1.loadTexture(KeyUtils.findKey(textures[2]), "normalMap"); //Don't use the default skin bumpmap texture, but load the bumpmap from the current mesh. foreach (ListViewItem i in lstMeshTGILinks.Items) { if (i.SubItems[1].Text == "NormalMap") { String normalMapKey = i.SubItems[0].Text; Stream tex = KeyUtils.findKey(normalMapKey); renderWindow1.loadTexture(tex, "normalMap"); } } if ((casPartNew.typeFlag & 0x1) == 0x1) { renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingAmbient), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingSpecular), "specularTexture"); } else if ((casPartNew.typeFlag & 0x4) == 0x4) { renderWindow1.loadTexture(KeyUtils.findKey(details.faceOverlay), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.faceSpecular), "specularTexture"); } else { renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingAmbient), "ambientTexture"); renderWindow1.loadTexture(KeyUtils.findKey(details.ClothingSpecular), "specularTexture"); } renderWindow1.loadTexture(KeyUtils.findKey(details.Multiplier), "baseTexture"); renderWindow1.loadTexture(null, "stencilA"); //if ((casPartNew.typeFlag & 0x4) == 0x4) //{ //renderWindow1.shaderMode = 1; //} //else //{ //renderWindow1.shaderMode = 0; //} generate3DTexture(details); // We don't need this here since generate3DTexture resets the device anyway //renderWindow1.resetDevice(); } }
private Bitmap composeHair(xmlChunkDetails details) { Bitmap patterns = composeMultiplier(details); List<MadScience.Wrappers.ResourceKey> tempList = new List<MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.DiffuseMap)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.ControlMap)); List<Stream> textures = KeyUtils.findKey(tempList, 2); if (MadScience.Patterns.isEmptyTexture(details.DiffuseMap)) textures[0] = null; DateTime startTime = DateTime.Now; Bitmap hair = PatternProcessor.ProcessHairTexture(textures, MadScience.Colours.convertColour(details.hair.DiffuseColor), MadScience.Colours.convertColour(details.hair.RootColor), MadScience.Colours.convertColour(details.hair.HighlightColor), MadScience.Colours.convertColour(details.hair.TipColor)); if (patterns.Width < hair.Width) { using (Graphics g = Graphics.FromImage(hair)) { g.DrawImage(patterns, 0, 0, patterns.Width, patterns.Height); } return hair; } else { using (Graphics g = Graphics.FromImage(patterns)) { g.DrawImage(hair, 0, 0, patterns.Width, patterns.Height); } return patterns; } }
public void reload3D(xmlChunkDetails details) { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { // Get the Mesh links for the first LOD List<Stream> meshStreams = new List<Stream>(); // Use the VPXY to get the mesh lod Stream vpxyStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY], 0); if (StreamHelpers.isValidStream(vpxyStream)) { VPXYFile vpxyFile = new VPXYFile(vpxyStream); // Get the first VPXY internal link if (vpxyFile.vpxy.linkEntries.Count >= 1 && vpxyFile.vpxy.linkEntries[0].tgiList.Count >= 1) { for (int i = 0; i < vpxyFile.vpxy.linkEntries[0].tgiList.Count; i++) { meshStreams.Add(KeyUtils.findKey(vpxyFile.vpxy.linkEntries[0].tgiList[i], 0)); } } vpxyStream.Close(); } if (meshStreams.Count == 0) // || ((casPartSrc.typeFlag & 0x1) == 0x1)) { ResourceKey findKey = findDefaultMeshes(casPartNew.ageGenderFlag, casPartNew.typeFlag); if (findKey.groupId != 0 && findKey.instanceId != 0) { meshStreams.Add(KeyUtils.findKey(findKey, 0)); } } const uint cBody = 4; const uint cTop = 5; const uint cBottom = 6; const uint cFeet = 7; //Load missing meshes. For example if we show a bottom, load a nude top and nude feet switch(casPartNew.clothingType) { case cBody : meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); break; case cTop: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Bottom")); break; case cBottom: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Top")); break; case cFeet: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Top")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Bottom")); break; } if (meshStreams.Count > 0) { renderWindow1.BackgroundColour = MadScience.Colours.convertColour(MadScience.Helpers.getRegistryValue("renderBackgroundColour")); // For each model, go through, get the model info and send it to the render window for (int i = 0; i < meshStreams.Count; i++) { MadScience.Render.modelInfo newModel = MadScience.Render.Helpers.geomToModel(meshStreams[i]); newModel.name = txtMeshName.Text; //renderWindow1.loadDefaultTextures(); renderWindow1.setModel(newModel, i); } reloadTextures(details); renderWindow1.RenderEnabled = true; } else { renderWindow1.statusLabel.Text = "Sorry, we could not find a mesh!"; } } }
private void showCasPart(int chunkNo) { // Just takes the first XML chunk and uses that xmlChunkDetails chunk = (xmlChunkDetails)casPartNew.xmlChunk[chunkNo]; Console.WriteLine("Showing design " + chunkNo.ToString()); /* * chkStencilAEnabled.Enabled = true; * chkStencilBEnabled.Enabled = true; * chkStencilCEnabled.Enabled = true; * chkStencilDEnabled.Enabled = true; * chkStencilEEnabled.Enabled = true; * chkStencilFEnabled.Enabled = true; */ chkPatternAEnabled.Enabled = true; cmbPatternSelect.SelectedIndex = 0; showPatternDetails(chunkNo); //chkPatternBEnabled.Enabled = true; //chkPatternCEnabled.Enabled = true; chkLogoEnabled.Enabled = true; btnPatternStencil1Preview.Enabled = false; btnPatternStencil2Preview.Enabled = false; btnPatternStencil3Preview.Enabled = false; btnPatternStencil4Preview.Enabled = false; btnPatternStencil5Preview.Enabled = false; btnPatternStencil6Preview.Enabled = false; cmbPatternStencil1.Enabled = true; cmbPatternStencil2.Enabled = true; cmbPatternStencil3.Enabled = true; cmbPatternStencil4.Enabled = true; cmbPatternStencil5.Enabled = true; cmbPatternStencil6.Enabled = true; if (chunk.hasCustomThumbnail) { chkUseCustomThumbnail.Checked = true; if (newPNGfiles.Count > 0) { txtCustomThumbnailPath.Text = newPNGfiles[chunkNo]; } else { ResourceKey customThumb = MadScience.Package.Search.getKey(Helpers.currentPackageFile, 0x626F60CE, chunkNo, (long)this.loadedCasPart.instanceId); if (customThumb.ToString() == "00000000:00000000:0000000000000000") { customThumb = MadScience.Package.Search.getKey(this.filename, 0x626F60CE, (chunkNo + 1), (long)this.loadedCasPart.instanceId); } //Console.WriteLine(customThumb.ToString()); //picCustomThumbnail.Image = Image.FromStream(MadScience.Package.Search.getStream(Helpers.currentPackageFile, customThumb.ToString())); } } //ListViewItem item; // Stencil Details cmbPatternStencil1.SelectedIndex = 0; if (chunk.stencil.A.key != "" && chunk.stencil.A.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.A)) { cmbPatternStencil1.SelectedIndex = getStencilFromPool(chunk.stencil.A) + 1; } } cmbPatternStencil2.SelectedIndex = 0; if (chunk.stencil.B.key != "" && chunk.stencil.B.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.B)) { cmbPatternStencil2.SelectedIndex = getStencilFromPool(chunk.stencil.B) + 1; } } cmbPatternStencil3.SelectedIndex = 0; if (chunk.stencil.C.key != "" && chunk.stencil.C.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.C)) { cmbPatternStencil3.SelectedIndex = getStencilFromPool(chunk.stencil.C) + 1; } } cmbPatternStencil4.SelectedIndex = 0; if (chunk.stencil.D.key != "" && chunk.stencil.D.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.D)) { cmbPatternStencil4.SelectedIndex = getStencilFromPool(chunk.stencil.D) + 1; } } cmbPatternStencil5.SelectedIndex = 0; if (chunk.stencil.E.key != "" && chunk.stencil.E.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.E)) { cmbPatternStencil5.SelectedIndex = getStencilFromPool(chunk.stencil.E) + 1; } } cmbPatternStencil6.SelectedIndex = 0; if (chunk.stencil.F.key != "" && chunk.stencil.F.Enabled.ToLower() == "true") { if (inStencilList(chunk.stencil.F)) { cmbPatternStencil6.SelectedIndex = getStencilFromPool(chunk.stencil.F) + 1; } } // Pattern Details // Other Details lstOtherDetails.Items.Clear(); lstTextureDetails.Items.Clear(); List <bool> showSection = getHiddenSections(); if (showSection[0]) { addListHeader(lstTextureDetails, "Texture Details"); addListItem(lstTextureDetails, chunk.Multiplier, "Base Texture", "texture"); addListBlank(lstTextureDetails); } if (showSection[1]) { addListHeader(lstTextureDetails, "Clothing Details"); addListItem(lstTextureDetails, chunk.ClothingSpecular, "Clothing Specular", "texture"); addListItem(lstTextureDetails, chunk.ClothingAmbient, "Clothing Ambient", "texture"); addListBlank(lstTextureDetails); } if (showSection[3]) { addListHeader(lstTextureDetails, "Face Overlay Details"); if (checkedListClothingType.GetItemChecked(15) || checkedListClothingType.GetItemChecked(14) || checkedListClothingType.GetItemChecked(18)) // Eyeliner, Eyebrow, Eyeshadow { addListItem(lstTextureDetails, chunk.TintColor, "Tint Color", "color"); addListBlank(lstTextureDetails); } else { addListItem(lstTextureDetails, chunk.tint.A.color, "Tint Color A", "color"); addListItem(lstTextureDetails, chunk.tint.B.color, "Tint Color B", "color"); addListItem(lstTextureDetails, chunk.tint.C.color, "Tint Color C", "color"); addListItem(lstTextureDetails, chunk.tint.D.color, "Tint Color D", "color"); addListItem(lstTextureDetails, chunk.tint.A.enabled, "Tint Color A Enabled", "truefalse"); addListItem(lstTextureDetails, chunk.tint.B.enabled, "Tint Color B Enabled", "truefalse"); addListItem(lstTextureDetails, chunk.tint.C.enabled, "Tint Color C Enabled", "truefalse"); addListItem(lstTextureDetails, chunk.tint.D.enabled, "Tint Color D Enabled", "truefalse"); } addListBlank(lstTextureDetails); addListItem(lstTextureDetails, chunk.faceOverlay, "Face Overlay", "texture"); addListItem(lstTextureDetails, chunk.faceSpecular, "Face Specular", "texture"); addListBlank(lstTextureDetails); } addListHeader(lstTextureDetails, "Mask & Overlay Details"); addListItem(lstTextureDetails, chunk.Overlay, "Overlay", "texture"); addListItem(lstTextureDetails, chunk.ControlMap, "Control Map", "texture"); addListItem(lstTextureDetails, chunk.DiffuseMap, "Diffuse Map", "texture"); addListItem(lstTextureDetails, chunk.Mask, "Mask", "texture"); addListItem(lstTextureDetails, chunk.PartMask, "Part Mask", "texture"); addListBlank(lstTextureDetails); addListHeader(lstOtherDetails, "Mask & Overlay Details"); addListItem(lstOtherDetails, chunk.MaskHeight, "MaskHeight", ""); addListItem(lstOtherDetails, chunk.MaskWidth, "MaskWidth", ""); addListBlank(lstOtherDetails); // Hair details if (checkedListType.GetItemChecked(0)) { addListHeader(lstTextureDetails, "Hair Details"); addListItem(lstTextureDetails, chunk.hair.RootColor, "Root Color", "color"); addListItem(lstTextureDetails, chunk.hair.DiffuseColor, "Diffuse Color", "color"); addListItem(lstTextureDetails, chunk.hair.HighlightColor, "Highlight Color", "color"); addListItem(lstTextureDetails, chunk.hair.TipColor, "Tip Color", "color"); addListBlank(lstTextureDetails); addListItem(lstTextureDetails, chunk.hair.ScalpSpecularMap, "Scalp Specular Map", "texture"); addListItem(lstTextureDetails, chunk.hair.ScalpDiffuseMap, "Scalp Diffuse Map", "texture"); addListItem(lstTextureDetails, chunk.hair.ScalpSpecularMap, "Scalp Control Map", "texture"); addListItem(lstTextureDetails, chunk.hair.FaceSpecularMap, "Face Specular Map", "texture"); addListItem(lstTextureDetails, chunk.hair.FaceDiffuseMap, "Face Diffuse Map", "texture"); addListItem(lstTextureDetails, chunk.hair.FaceSpecularMap, "Face Control Map", "texture"); addListBlank(lstTextureDetails); addListHeader(lstOtherDetails, "Hair Details"); addListItem(lstOtherDetails, chunk.IsHat, "IsHat", "truefalse"); addListItem(lstOtherDetails, chunk.DrawsOnFace, "DrawsOnFace", "truefalse"); addListItem(lstOtherDetails, chunk.DrawsOnScalp, "DrawsOnScalp", "truefalse"); addListItem(lstOtherDetails, chunk.hair.ScalpAO, "Scalp AO", "texture"); addListItem(lstOtherDetails, chunk.hair.FaceAO, "Face AO", "texture"); addListBlank(lstTextureDetails); } if (showSection[2]) { addListHeader(lstTextureDetails, "Skin Details"); addListItem(lstTextureDetails, chunk.SkinAmbient, "Skin Ambient", "texture"); addListItem(lstTextureDetails, chunk.SkinSpecular, "Skin Specular", "texture"); } if (chunk.logo.enabled.ToLower() == "true") { chkLogoEnabled.Checked = true; } else { chkLogoEnabled.Checked = false; } txtLogoUpperLeft.Text = chunk.logo.upperLeft; txtLogoLowerRight.Text = chunk.logo.lowerRight; txtLogoFilename.Text = chunk.logo.filename; txtLogoKey.Text = chunk.logo.key; txtLogoName.Text = chunk.logo.name; addListHeader(lstOtherDetails, "CAS Details"); addListItem(lstOtherDetails, chunk.IsNaked, "IsNaked", "truefalse"); addListItem(lstOtherDetails, chunk.IsNotNaked, "IsNotNaked", "truefalse"); addListItem(lstOtherDetails, chunk.partType, "partType", ""); addListItem(lstOtherDetails, chunk.age, "age", ""); addListItem(lstOtherDetails, chunk.gender, "gender", ""); addListItem(lstOtherDetails, chunk.bodyType, "bodyType", ""); addListBlank(lstOtherDetails); addListHeader(lstOtherDetails, "Misc. Details"); addListItem(lstOtherDetails, chunk.name, "Name", ""); addListItem(lstOtherDetails, chunk.reskey, "reskey", ""); addListItem(lstOtherDetails, chunk.daeFileName, "daeFileName", ""); addListItem(lstOtherDetails, chunk.filename, "filename", ""); addListItem(lstOtherDetails, chunk.assetRoot, "assetRoot", ""); addListItem(lstOtherDetails, chunk.Rotation, "Rotation", ""); toolStripStatusLabel1.Text = "Initialising 3d view... please wait..."; statusStrip1.Refresh(); reloadTextures(); toolStripStatusLabel1.Text = ""; }
private void updateChunkFromLists(ListView lView, xmlChunkDetails chunk) { for (int i = 0; i < lView.Items.Count; i++) { ListViewItem item = lView.Items[i]; switch (item.SubItems[1].Text) { case "Name": chunk.name = item.Text; break; case "reskey": chunk.reskey = item.Text; break; case "assetRoot": chunk.assetRoot = item.Text; break; case "Overlay": chunk.Overlay = item.Text; break; case "Control Map": chunk.ControlMap = item.Text; break; case "Diffuse Map": chunk.DiffuseMap = item.Text; break; case "Mask": chunk.Mask = item.Text; break; case "MaskHeight": chunk.MaskHeight = item.Text; break; case "MaskWidth": chunk.MaskWidth = item.Text; break; case "Base Texture": case "Multiplier": chunk.Multiplier = item.Text; break; case "IsHat": chunk.IsHat = item.Text; break; case "DrawsOnFace": chunk.DrawsOnFace = item.Text; break; case "DrawsOnScalp": chunk.DrawsOnScalp = item.Text; break; case "IsNaked": chunk.IsNaked = item.Text; break; case "IsNotNaked": chunk.IsNotNaked = item.Text; break; case "Skin Specular": chunk.SkinSpecular = item.Text; break; case "Skin Ambient": chunk.SkinAmbient = item.Text; break; case "Clothing Specular": chunk.ClothingSpecular = item.Text; break; case "Clothing Ambient": chunk.ClothingAmbient = item.Text; break; case "Rotation": chunk.Rotation = item.Text; break; case "Root Color": chunk.hair.RootColor = item.Text; break; case "Diffuse Color": chunk.hair.DiffuseColor = item.Text; break; case "Highlight Color": chunk.hair.HighlightColor = item.Text; break; case "Tip Color": chunk.hair.TipColor = item.Text; break; case "Face Overlay": chunk.faceOverlay = item.Text; break; case "Face Specular": chunk.faceSpecular = item.Text; break; case "Tint Color": chunk.TintColor = item.Text; break; case "Tint Color A": chunk.tint.A.color = item.Text; break; case "Tint Color B": chunk.tint.B.color = item.Text; break; case "Tint Color C": chunk.tint.C.color = item.Text; break; case "Tint Color D": chunk.tint.D.color = item.Text; break; case "Tint Color A Enabled": chunk.tint.A.enabled = item.Text; break; case "Tint Color B Enabled": chunk.tint.B.enabled = item.Text; break; case "Tint Color C Enabled": chunk.tint.C.enabled = item.Text; break; case "Tint Color D Enabled": chunk.tint.D.enabled = item.Text; break; case "Scalp Diffuse Map": chunk.hair.ScalpDiffuseMap = item.Text; break; case "Scalp Control Map": chunk.hair.ScalpControlMap = item.Text; break; case "Scalp Specular Map": chunk.hair.ScalpSpecularMap = item.Text; break; case "Scalp AO": chunk.hair.ScalpAO = item.Text; break; case "Face Diffuse Map": chunk.hair.FaceDiffuseMap = item.Text; break; case "Face Control Map": chunk.hair.FaceControlMap = item.Text; break; case "Face Specular Map": chunk.hair.FaceSpecularMap = item.Text; break; case "Face AO": chunk.hair.FaceAO = item.Text; break; case "Part Mask": chunk.PartMask = item.Text; break; case "partType": chunk.partType = item.Text; break; case "age": chunk.age = item.Text; break; case "gender": chunk.gender = item.Text; break; case "bodyType": chunk.bodyType = item.Text; break; case "daeFileName": chunk.daeFileName = item.Text; break; case "filename": chunk.filename = item.Text; break; } } }
public void reload3D(xmlChunkDetails details) { if (listView1.SelectedItems.Count == 1 && cEnable3DPreview.Checked == true) { // Get the Mesh links for the first LOD List <Stream> meshStreams = new List <Stream>(); // Use the VPXY to get the mesh lod Stream vpxyStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY], 0); if (StreamHelpers.isValidStream(vpxyStream)) { VPXYFile vpxyFile = new VPXYFile(vpxyStream); // Get the first VPXY internal link if (vpxyFile.vpxy.linkEntries.Count >= 1 && vpxyFile.vpxy.linkEntries[0].tgiList.Count >= 1) { for (int i = 0; i < vpxyFile.vpxy.linkEntries[0].tgiList.Count; i++) { meshStreams.Add(KeyUtils.findKey(vpxyFile.vpxy.linkEntries[0].tgiList[i], 0)); } } vpxyStream.Close(); } if (meshStreams.Count == 0) // || ((casPartSrc.typeFlag & 0x1) == 0x1)) { ResourceKey findKey = findDefaultMeshes(casPartNew.ageGenderFlag, casPartNew.typeFlag); if (findKey.groupId != 0 && findKey.instanceId != 0) { meshStreams.Add(KeyUtils.findKey(findKey, 0)); } } const uint cBody = 4; const uint cTop = 5; const uint cBottom = 6; const uint cFeet = 7; //Load missing meshes. For example if we show a bottom, load a nude top and nude feet switch (casPartNew.clothingType) { case cBody: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); break; case cTop: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Bottom")); break; case cBottom: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Feet")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Top")); break; case cFeet: meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Top")); meshStreams.Add(findMesh(casPartNew.ageGenderFlag, "Bottom")); break; } if (meshStreams.Count > 0) { renderWindow1.BackgroundColour = MadScience.Colours.convertColour(MadScience.Helpers.getRegistryValue("renderBackgroundColour")); // For each model, go through, get the model info and send it to the render window for (int i = 0; i < meshStreams.Count; i++) { MadScience.Render.modelInfo newModel = MadScience.Render.Helpers.geomToModel(meshStreams[i]); newModel.name = txtMeshName.Text; //renderWindow1.loadDefaultTextures(); renderWindow1.setModel(newModel, i); } reloadTextures(details); renderWindow1.RenderEnabled = true; } else { renderWindow1.statusLabel.Text = "Sorry, we could not find a mesh!"; } } }
private Bitmap composeMultiplier(xmlChunkDetails details) { Bitmap[] myPatterns = new Bitmap[1]; DateTime startTime2 = DateTime.Now; List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>(); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Multiplier)); tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask)); List <Stream> textures = KeyUtils.findKey(tempList, 2); if (details.pattern[3].Enabled.ToLower() == "true" && details.filename == "CasRgbaMask") { myPatterns = new Bitmap[4]; } else if (details.pattern[2].Enabled.ToLower() == "true") { myPatterns = new Bitmap[3]; } else if (details.pattern[1].Enabled.ToLower() == "true") { myPatterns = new Bitmap[2]; } PointF[] tilings = new PointF[myPatterns.Length]; for (int i = 0; i < myPatterns.Length; i++) { if (details.pattern[i].Enabled.ToLower() == "true") { myPatterns[i] = (Bitmap)Patterns.makePatternThumb(details.pattern[i]);; tilings[i] = new PointF(1f, 1f); if (details.pattern[i].Tiling != null) { String[] s = details.pattern[i].Tiling.Split(','); if (s.Length == 2) { try { tilings[i].X = Convert.ToSingle(s[0], CultureInfo.InvariantCulture); tilings[i].Y = Convert.ToSingle(s[1], CultureInfo.InvariantCulture); } catch (Exception) { tilings[i] = new PointF(1f, 1f); } } } } } DateTime stopTime2 = DateTime.Now; TimeSpan duration2 = stopTime2 - startTime2; Console.WriteLine("Key search time: " + duration2.TotalMilliseconds); DateTime startTime = DateTime.Now; if (MadScience.Patterns.isEmptyTexture(details.Multiplier)) { textures[0] = null; } Bitmap output; if (MadScience.Patterns.isEmptyMask(details.Mask)) { output = PatternProcessor.ProcessSingleChannelTexture( textures, myPatterns[0], tilings[0]); } else { output = PatternProcessor.ProcessClothingTexture( textures, myPatterns, tilings); } DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Console.WriteLine("Total Multiplier Texture generation time: " + duration.TotalMilliseconds); return(output); }
private void updateChunkFromLists(ListView lView, xmlChunkDetails chunk) { for (int i = 0; i < lView.Items.Count; i++) { ListViewItem item = lView.Items[i]; switch (item.SubItems[1].Text) { case "Name": chunk.name = item.Text; break; case "reskey": chunk.reskey = item.Text; break; case "assetRoot": chunk.assetRoot = item.Text; break; case "Overlay": chunk.Overlay = item.Text; break; case "Control Map": chunk.ControlMap = item.Text; break; case "Diffuse Map": chunk.DiffuseMap = item.Text; break; case "Mask": chunk.Mask = item.Text; break; case "MaskHeight": chunk.MaskHeight = item.Text; break; case "MaskWidth": chunk.MaskWidth = item.Text; break; case "Base Texture": case "Multiplier": chunk.Multiplier = item.Text; break; case "IsHat": chunk.IsHat = item.Text; break; case "DrawsOnFace": chunk.DrawsOnFace = item.Text; break; case "DrawsOnScalp": chunk.DrawsOnScalp = item.Text; break; case "IsNaked": chunk.IsNaked = item.Text; break; case "IsNotNaked": chunk.IsNotNaked = item.Text; break; case "Skin Specular": chunk.SkinSpecular = item.Text; break; case "Skin Ambient": chunk.SkinAmbient = item.Text; break; case "Clothing Specular": chunk.ClothingSpecular = item.Text; break; case "Clothing Ambient": chunk.ClothingAmbient = item.Text; break; case "Rotation": chunk.Rotation = item.Text; break; case "Root Color": chunk.hair.RootColor = item.Text; break; case "Diffuse Color": chunk.hair.DiffuseColor = item.Text; break; case "Highlight Color": chunk.hair.HighlightColor = item.Text; break; case "Tip Color": chunk.hair.TipColor = item.Text; break; case "Face Overlay": chunk.faceOverlay = item.Text; break; case "Face Specular": chunk.faceSpecular = item.Text; break; case "Tint Color": chunk.TintColor = item.Text; break; case "Tint Color A": chunk.tint.A.color = item.Text; break; case "Tint Color B": chunk.tint.B.color = item.Text; break; case "Tint Color C": chunk.tint.C.color = item.Text; break; case "Tint Color D": chunk.tint.D.color = item.Text; break; case "Tint Color A Enabled": chunk.tint.A.enabled = item.Text; break; case "Tint Color B Enabled": chunk.tint.B.enabled = item.Text; break; case "Tint Color C Enabled": chunk.tint.C.enabled = item.Text; break; case "Tint Color D Enabled": chunk.tint.D.enabled = item.Text; break; case "Scalp Diffuse Map": chunk.hair.ScalpDiffuseMap = item.Text; break; case "Scalp Control Map": chunk.hair.ScalpControlMap = item.Text; break; case "Scalp Specular Map": chunk.hair.ScalpSpecularMap = item.Text; break; case "Scalp AO": chunk.hair.ScalpAO = item.Text; break; case "Face Diffuse Map": chunk.hair.FaceDiffuseMap = item.Text; break; case "Face Control Map": chunk.hair.FaceControlMap = item.Text; break; case "Face Specular Map": chunk.hair.FaceSpecularMap = item.Text; break; case "Face AO": chunk.hair.FaceAO = item.Text; break; case "Part Mask": chunk.PartMask = item.Text; break; case "partType": chunk.partType = item.Text; break; case "age": chunk.age = item.Text; break; case "gender": chunk.gender = item.Text; break; case "bodyType": chunk.bodyType = item.Text; break; case "daeFileName": chunk.daeFileName = item.Text; break; case "filename": chunk.filename = item.Text; break; } } }
private void showMeshDetails() { string meshName = ""; // Translate selection back into af am etc switch (cmbSimAge.Text) { case "Baby": meshName += "b"; break; case "Toddler": meshName += "p"; break; case "Child": meshName += "c"; break; case "Teen": meshName += "t"; break; case "Young Adult": meshName += "y"; break; case "Adult": meshName += "a"; break; case "Elder": meshName += "e"; break; case "All Ages": meshName += "u"; break; } switch (cmbSimGender.Text) { case "Female": meshName += "f"; break; case "Male": meshName += "m"; break; case "Unisex": meshName += "u"; break; } if (cmbMeshName.Text == "* Custom") { //if (this.isNew == false) //{ //meshName += casPartSrc.meshName; //} txtCasPartName.Text = casPartSrc.meshName; txtMeshName.Text = casPartSrc.meshName; txtCasPartInstance.Text = "0x" + MadScience.StringHelpers.HashFNV64(meshName).ToString("X16"); picMeshPreview.Image = null; picMeshPreview.Invalidate(); } else { if (cmbPartTypes.Text == "(none)") { meshName += cmbMeshName.Text; } else { meshName += cmbPartTypes.Text + cmbMeshName.Text; } txtCasPartName.Text = meshName; txtMeshName.Text = meshName; scrollPanelToThumb(meshName); for (int i = 0; i < this.lookupList.Items.Length; i++) { filesFile f = lookupList.Items[i]; if (f.fullCasPartname == meshName) { txtCasPartInstance.Text = f.instanceid; break; } } picMeshPreview.Image = null; picMeshPreview.Invalidate(); // Find thumbnail if (File.Exists(Path.Combine(Application.StartupPath, Path.Combine("cache", meshName + ".png")))) { Stream picMeshPreviewStream = File.OpenRead(Path.Combine(Application.StartupPath, Path.Combine("cache", meshName + ".png"))); picMeshPreview.Image = Image.FromStream(picMeshPreviewStream); picMeshPreviewStream.Close(); } else { extractCASThumbnail(meshName); } } if (this.isNew == true) { // Attempt to load the existing caspart into memory so we can extract data later. Stream casPartFile = File.Open(Path.Combine(Application.StartupPath, Path.Combine("casparts", txtCasPartName.Text + ".caspart")), FileMode.Open, FileAccess.Read, FileShare.Read); casPartFile cPartFile = new casPartFile(); this.casPartSrc = cPartFile.Load(casPartFile); casPartFile.Close(); } for (int i = 0; i < checkedListAge.Items.Count; i++) { checkedListAge.SetItemChecked(i, false); } for (int i = 0; i < checkedListCategory.Items.Count; i++) { checkedListCategory.SetItemChecked(i, false); } for (int i = 0; i < checkedListCategoryExtended.Items.Count; i++) { checkedListCategoryExtended.SetItemChecked(i, false); } for (int i = 0; i < checkedListGender.Items.Count; i++) { checkedListGender.SetItemChecked(i, false); } for (int i = 0; i < checkedListOther.Items.Count; i++) { checkedListOther.SetItemChecked(i, false); } for (int i = 0; i < checkedListType.Items.Count; i++) { checkedListType.SetItemChecked(i, false); } // Get the Mesh links for the first LOD Stream meshStream = Stream.Null; // Use the VPXY to get the mesh lod Stream vpxyStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY], 0); if (StreamHelpers.isValidStream(vpxyStream)) { VPXYFile vpxyFile = new VPXYFile(vpxyStream); // Get the first VPXY internal link if (vpxyFile.vpxy.linkEntries.Count >= 1 && vpxyFile.vpxy.linkEntries[0].tgiList.Count >= 1) { meshStream = KeyUtils.findKey(vpxyFile.vpxy.linkEntries[0].tgiList[0], 0); } vpxyStream.Close(); } if (StreamHelpers.isValidStream(meshStream)) { lstMeshTGILinks.Items.Clear(); SimGeomFile simgeomfile = new SimGeomFile(meshStream); // Always put the bumpmap in the first position and get it from the MTNF //int bumpmapPos = -1; //int tgiAddNo = 0; for (int i = 0; i < simgeomfile.simgeom.mtnfChunk.entries.Count; i++) { if (simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash == (uint)FieldTypes.NormalMap) { ListViewItem item = new ListViewItem(); item.SubItems.Add(Enum.GetName(typeof(FieldTypes), simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash)); item.Text = simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].ToString(); if (simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].typeId == 0x00B2D882) { item.Tag = "texture"; } else { item.Tag = ""; } //bumpmapPos = (int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]; lstMeshTGILinks.Items.Add(item); break; } } for (int i = 0; i < simgeomfile.simgeom.mtnfChunk.entries.Count; i++) { if (simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash != (uint)FieldTypes.NormalMap) { foreach (uint fieldHash in Enum.GetValues(typeof(FieldTypes))) { if (fieldHash == simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash) { if (simgeomfile.simgeom.mtnfChunk.entries[i].dwords.Count > 0) { ListViewItem item = new ListViewItem(); item.SubItems.Add(Enum.GetName(typeof(FieldTypes), fieldHash)); item.Text = simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].ToString(); if (simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].typeId == 0x00B2D882) { item.Tag = "texture"; } else { item.Tag = ""; } lstMeshTGILinks.Items.Add(item); } break; } } } } /* * if (bumpmapPos > -1) * { * ListViewItem item = new ListViewItem(); * item.SubItems.Add("Bump Map"); * item.Text = simgeomfile.simgeom.keytable.keys[bumpmapPos].ToString(); * if (simgeomfile.simgeom.keytable.keys[bumpmapPos].typeId == 0x00B2D882) * { * item.Tag = "texture"; * } * else * { * item.Tag = ""; * } * lstMeshTGILinks.Items.Add(item); * tgiAddNo++; * } * * for (int i = 0; i < simgeomfile.simgeom.keytable.keys.Count; i++) * { * if (i != bumpmapPos) * { * ListViewItem item = new ListViewItem(); * tgiAddNo++; * //item.SubItems.Add("TGI #" + tgiAddNo); * //item.SubItems.Add("TGI #" + (i + 1)); * item.Text = simgeomfile.simgeom.keytable.keys[i].ToString(); * if (simgeomfile.simgeom.keytable.keys[i].typeId == 0x00B2D882) * { * item.Tag = "texture"; * } * else * { * item.Tag = ""; * } * lstMeshTGILinks.Items.Add(item); * } * } */ } lstCasPartDetails.Items.Clear(); // Populate the CAS Part Details addCasPartItem("Mesh Name", casPartSrc.meshName); toolStripStatusLabel2.Text = casPartSrc.meshName; addCasPartItem("Clothing Order", casPartSrc.clothingOrder.ToString()); addCasPartItem("CAS Part Type", casPartSrc.clothingType.ToString() + " (0x" + casPartSrc.clothingType.ToString("X8") + ")"); addCasPartItem("Type", casPartSrc.typeFlag.ToString() + " (0x" + casPartSrc.typeFlag.ToString("X8") + ")"); addCasPartItem("Age/Gender", casPartSrc.ageGenderFlag.ToString() + " (0x" + casPartSrc.ageGenderFlag.ToString("X8") + ")"); addCasPartItem("Clothing Category", casPartSrc.clothingCategory.ToString() + " (0x" + casPartSrc.clothingCategory.ToString("X8") + ")"); addCasPartItem("Unk String", casPartSrc.unkString); addCasPartItem("Unk2", casPartSrc.unk2.ToString()); addCasPartItem("TGI Index Body Part 1", casPartSrc.tgiIndexBodyPart1.ToString()); addCasPartItem("TGI Index Body Part 2", casPartSrc.tgiIndexBodyPart2.ToString()); addCasPartItem("TGI Index Blend Info Fat", casPartSrc.tgiIndexBlendInfoFat.ToString()); addCasPartItem("TGI Index Blend Info Fit", casPartSrc.tgiIndexBlendInfoFit.ToString()); addCasPartItem("TGI Index Blend Info Thin", casPartSrc.tgiIndexBlendInfoThin.ToString()); addCasPartItem("TGI Index Blend Info Special", casPartSrc.tgiIndexBlendInfoSpecial.ToString()); addCasPartItem("Unk5", casPartSrc.unk5.ToString()); addCasPartItem("VPXY", casPartSrc.tgiIndexVPXY.ToString()); //tgi64 tempvpxy = (tgi64)casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY]; //txtVPXYPrimary.Text = "key:" + tempvpxy.typeid.ToString("X8") + ":" + tempvpxy.groupid.ToString("X8") + ":" + tempvpxy.instanceid.ToString("X16"); addCasPartItem("Count 2", casPartSrc.count2.ToString()); for (int i = 0; i < casPartSrc.count2; i++) { unkRepeat unk = (unkRepeat)casPartSrc.count2repeat[i]; addCasPartItem("#" + i.ToString() + ": unkNum ", unk.unkNum.ToString()); addCasPartItem("#" + i.ToString() + ": unk2", unk.unk2.ToString()); addCasPartItem("#" + i.ToString() + ": unkRepeatInner", unk.unkRepeatInnerCount.ToString()); for (int j = 0; j < unk.unkRepeatInnerCount; j++) { intTriple iT = (intTriple)unk.unkRepeatInnerLoop[j]; addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": One", iT.one.ToString()); addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": Two", iT.two.ToString()); addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": Three", iT.three.ToString()); } } addCasPartItem("TGI Index Diffuse", casPartSrc.tgiIndexDiffuse.ToString()); addCasPartItem("TGI Index Specular", casPartSrc.tgiIndexSpecular.ToString()); addCasPartItem("Diffuse Links", casPartSrc.count3.ToString()); for (int i = 0; i < casPartSrc.count3; i++) { byte cRepeat = (byte)casPartSrc.count3repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } addCasPartItem("Specular Links", casPartSrc.count4.ToString()); for (int i = 0; i < casPartSrc.count4; i++) { byte cRepeat = (byte)casPartSrc.count4repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } addCasPartItem("Count 5", casPartSrc.count5.ToString()); for (int i = 0; i < casPartSrc.count5; i++) { byte cRepeat = (byte)casPartSrc.count5repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } for (int i = 0; i < chkDesignType.Items.Count; i++) { chkDesignType.SetItemChecked(i, false); } for (int i = 0; i < casPartSrc.count6; i++) { MadScience.Wrappers.ResourceKey tgi = casPartSrc.tgi64list[i]; string tgiType = MadScience.Helpers.findMetaEntry(tgi.typeId).shortName; Console.WriteLine(tgi.typeId.ToString() + " " + tgiType); if (tgi.typeId == 0x0333406C) { if (tgi.instanceId == 0x52E8BE209C703561) { chkDesignType.SetItemChecked(0, true); } if (tgi.instanceId == 0xE37696463F6B2D6E) { chkDesignType.SetItemChecked(1, true); } if (tgi.instanceId == 0x01625DDC220C08C6) { chkDesignType.SetItemChecked(2, true); } } addCasPartItem("TGI #" + i.ToString() + " " + tgiType, tgi.ToString()); } // Category flags if ((casPartSrc.typeFlag & 0x1) == 0x1) { checkedListType.SetItemChecked(0, true); // Hair } if ((casPartSrc.typeFlag & 0x2) == 0x2) { checkedListType.SetItemChecked(1, true); // Scalp } if ((casPartSrc.typeFlag & 0x4) == 0x4) { checkedListType.SetItemChecked(2, true); // Face Overlay } if ((casPartSrc.typeFlag & 0x8) == 0x8) { checkedListType.SetItemChecked(3, true); // Body } if ((casPartSrc.typeFlag & 0x10) == 0x10) { checkedListType.SetItemChecked(4, true); // Accessory } switch (casPartSrc.clothingType) { case 1: checkedListClothingType.SetItemChecked(0, true); break; case 2: checkedListClothingType.SetItemChecked(1, true); break; case 3: checkedListClothingType.SetItemChecked(2, true); break; case 4: checkedListClothingType.SetItemChecked(3, true); break; case 5: checkedListClothingType.SetItemChecked(4, true); break; case 6: checkedListClothingType.SetItemChecked(5, true); break; case 7: checkedListClothingType.SetItemChecked(6, true); break; case 11: checkedListClothingType.SetItemChecked(7, true); break; case 12: checkedListClothingType.SetItemChecked(8, true); break; case 13: checkedListClothingType.SetItemChecked(9, true); break; case 14: checkedListClothingType.SetItemChecked(10, true); break; case 15: checkedListClothingType.SetItemChecked(11, true); break; case 16: checkedListClothingType.SetItemChecked(12, true); break; case 17: checkedListClothingType.SetItemChecked(13, true); break; case 18: checkedListClothingType.SetItemChecked(14, true); break; case 19: checkedListClothingType.SetItemChecked(15, true); break; case 20: checkedListClothingType.SetItemChecked(16, true); break; case 21: checkedListClothingType.SetItemChecked(17, true); break; case 22: checkedListClothingType.SetItemChecked(18, true); break; case 24: checkedListClothingType.SetItemChecked(19, true); break; case 25: checkedListClothingType.SetItemChecked(20, true); break; case 26: checkedListClothingType.SetItemChecked(21, true); break; case 29: checkedListClothingType.SetItemChecked(22, true); break; case 30: checkedListClothingType.SetItemChecked(23, true); break; case 31: checkedListClothingType.SetItemChecked(24, true); break; } if ((casPartSrc.ageGenderFlag & 0x1) == 0x1) { checkedListAge.SetItemChecked(0, true); // Baby } if ((casPartSrc.ageGenderFlag & 0x2) == 0x2) { checkedListAge.SetItemChecked(1, true); // Toddler } if ((casPartSrc.ageGenderFlag & 0x4) == 0x4) { checkedListAge.SetItemChecked(2, true); // Child } if ((casPartSrc.ageGenderFlag & 0x8) == 0x8) { checkedListAge.SetItemChecked(3, true); // Teen } if ((casPartSrc.ageGenderFlag & 0x10) == 0x10) { checkedListAge.SetItemChecked(4, true); // YoungAdult } if ((casPartSrc.ageGenderFlag & 0x20) == 0x20) { checkedListAge.SetItemChecked(5, true); // Adult } if ((casPartSrc.ageGenderFlag & 0x40) == 0x40) { checkedListAge.SetItemChecked(6, true); // Elder } if ((casPartSrc.ageGenderFlag & 0x1000) == 0x1000) { checkedListGender.SetItemChecked(0, true); // Male } if ((casPartSrc.ageGenderFlag & 0x2000) == 0x2000) { checkedListGender.SetItemChecked(1, true); // Female } if ((casPartSrc.ageGenderFlag & 0x100000) == 0x100000) { checkedListOther.SetItemChecked(0, true); // LeftHanded } if ((casPartSrc.ageGenderFlag & 0x200000) == 0x200000) { checkedListOther.SetItemChecked(1, true); // RightHanded } if ((casPartSrc.ageGenderFlag & 0x10000) == 0x10000) { checkedListOther.SetItemChecked(2, true); // Human } if ((casPartSrc.clothingCategory & 0x1) == 0x1) { checkedListCategory.SetItemChecked(0, true); // Naked } if ((casPartSrc.clothingCategory & 0x2) == 0x2) { checkedListCategory.SetItemChecked(1, true); // Everyday } if ((casPartSrc.clothingCategory & 0x4) == 0x4) { checkedListCategory.SetItemChecked(2, true); // Formalwear } if ((casPartSrc.clothingCategory & 0x8) == 0x8) { checkedListCategory.SetItemChecked(3, true); // Sleepwear } if ((casPartSrc.clothingCategory & 0x10) == 0x10) { checkedListCategory.SetItemChecked(4, true); // Swimwear } if ((casPartSrc.clothingCategory & 0x20) == 0x20) { checkedListCategory.SetItemChecked(5, true); // Athletic } if ((casPartSrc.clothingCategory & 0x40) == 0x40) { checkedListCategory.SetItemChecked(6, true); // Singed } if ((casPartSrc.clothingCategory & 0x100) == 0x100) { checkedListCategory.SetItemChecked(7, true); // Career } if ((casPartSrc.clothingCategory & 0xFFFF) == 0xFFFF) { checkedListCategory.SetItemChecked(8, true); // All } if ((casPartSrc.clothingCategory & 0x100000) == 0x100000) { checkedListCategoryExtended.SetItemChecked(0, true); // ValidForMaternity } if ((casPartSrc.clothingCategory & 0x200000) == 0x200000) { checkedListCategoryExtended.SetItemChecked(1, true); // ValidForRandom } if ((casPartSrc.clothingCategory & 0x400000) == 0x400000) { checkedListCategoryExtended.SetItemChecked(2, true); // IsHat } if ((casPartSrc.clothingCategory & 0x800000) == 0x800000) { checkedListCategoryExtended.SetItemChecked(3, true); // IsRevealing } if ((casPartSrc.clothingCategory & 0x1000000) == 0x1000000) { checkedListCategoryExtended.SetItemChecked(4, true); // IsHiddenInCas } saveAsToolStripMenuItem.Enabled = true; btnDumpFromFullbuild2.Enabled = true; lstStencilPool.Items.Clear(); // Default all stencil boxes to blank for (int i = 1; i <= 15; i++) { if (stencilPool.Count < i) { stencilPool.Add(new stencilDetails()); } //updateStencilBoxes(i, new stencilDetails()); } // Calculate all the stencils so we can build up the stencil pool int curStencilNum = 1; for (int i = 0; i < casPartSrc.xmlChunk.Count; i++) { if (debugModeToolStripMenuItem.Checked) { Helpers.logMessageToFile(casPartSrc.xmlChunkRaw[i].ToString().Replace("/><", "/>" + Environment.NewLine + "<")); } xmlChunkDetails chunk = (xmlChunkDetails)casPartSrc.xmlChunk[i]; if (!inStencilList(chunk.stencil.A)) { updateStencilBoxes(curStencilNum, chunk.stencil.A); curStencilNum++; } if (!inStencilList(chunk.stencil.B)) { updateStencilBoxes(curStencilNum, chunk.stencil.B); curStencilNum++; } if (!inStencilList(chunk.stencil.C)) { updateStencilBoxes(curStencilNum, chunk.stencil.C); curStencilNum++; } if (!inStencilList(chunk.stencil.D)) { updateStencilBoxes(curStencilNum, chunk.stencil.D); curStencilNum++; } if (!inStencilList(chunk.stencil.E)) { updateStencilBoxes(curStencilNum, chunk.stencil.E); curStencilNum++; } if (!inStencilList(chunk.stencil.F)) { updateStencilBoxes(curStencilNum, chunk.stencil.F); curStencilNum++; } } for (int i = curStencilNum; i <= 15; i++) { //if (stencilPool.Count < i) { stencilPool.Add(new stencilDetails()); } updateStencilBoxes(i, new stencilDetails()); } if (this.casPartSrc.xmlChunkRaw.Count == 0) { label8.Visible = true; listView1.Enabled = false; //btnDumpFromFullbuild2.Enabled = false; btnAddNewDesign.Enabled = false; btnDeleteDesign.Enabled = false; } else { label8.Visible = false; listView1.Enabled = true; //btnDumpFromFullbuild2.Enabled = true; btnAddNewDesign.Enabled = true; btnDeleteDesign.Enabled = true; this.casPartNew = (casPart)OX.Copyable.ObjectExtensions.Copy(casPartSrc); //this.casPartNew = (casPart)casPartSrc.Copy(); if (this.isNew) { this.casPartNew.xmlChunk.Clear(); this.casPartNew.xmlChunkRaw.Clear(); lastSelected = -1; listView1.Items.Clear(); lstTextureDetails.Items.Clear(); lstOtherDetails.Items.Clear(); //btnAddNewDesign_Click(this, null); } } }