Skip to content

Commit 054eecd

Browse files
Several changes made to various programs in the SA Tools suite.
-SAEditorCommon: --Reworked GC Model Data Editor to be more in-line with how Chunk Model Data Editor works; vertex and parameter data can now be viewed, with the latter having in-depth editing capabilities. --Fixed a bug with editing textures in the Chunk Model Data Editor; the maximum texture ID now reaches 255 instead of 100, fixing a crash that occurs when a model's texture ID exceeded 100. -SAModel: GC (Ginja) model rendering now reads and applies UV scaling data stored within the model's mesh data; this fixes incorrect texture tiling across all editors. More information was added to allow for proper model cloning of this model type. -SA2 Event Viewer: The program can now use .pak files found in the same directory as the event data for playback, with .prs and .pvm files being fallback options.
1 parent cac9a9e commit 054eecd

23 files changed

+4426
-764
lines changed

Libraries/SAEditorCommon/UI/ChunkModelDataEditor.cs

+129-15
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void editStripAlphaToolStripMenuItem_Click(object sender, EventArgs e)
100100
PolyChunkStrip pcs;
101101
List<PolyChunk> selectedObj = ((ChunkAttach)editedModel).Poly;
102102
PolyChunk selectedMesh = selectedObj[listViewMeshes.SelectedIndices[0]];
103-
int index = selectedObj.IndexOf(selectedMesh);
103+
//int index = selectedObj.IndexOf(selectedMesh);
104104
if (polytype.StartsWith("Strip"))
105105
{
106106
using (ChunkModelStripDataEditor de = new ChunkModelStripDataEditor(selectedObj[matID]))
@@ -296,11 +296,12 @@ private void BuildNodeList()
296296
private void BuildVertexDataList()
297297
{
298298
listViewVertices.Items.Clear();
299-
groupBoxVertList.Enabled = editedModel != null;
299+
groupBoxVertList.Enabled = false;
300300
if (editedModel is ChunkAttach catt)
301301
{
302302
if (catt.Vertex != null)
303303
{
304+
groupBoxVertList.Enabled = true;
304305
Dictionary<int, VertexChunk> chunks = new Dictionary<int, VertexChunk>();
305306
for (int i = 0; i < catt.Vertex.Count; i++)
306307
{
@@ -398,13 +399,14 @@ private void BuildVertexDataList()
398399
private void BuildPolyChunkList()
399400
{
400401
listViewMeshes.Items.Clear();
401-
groupBoxMeshList.Enabled = editedModel != null;
402+
groupBoxMeshList.Enabled = false;
402403
if (editedModel is ChunkAttach catt)
403404
{
404405
//editedHierarchy.StripPolyCache();
405406
Dictionary<int, PolyChunk> chunks = new Dictionary<int, PolyChunk>();
406407
if (catt.Poly != null)
407408
{
409+
groupBoxMeshList.Enabled = true;
408410
for (int i = 0; i < catt.Poly.Count; i++)
409411
{
410412
chunks.Add(i, catt.Poly[i]);
@@ -710,9 +712,9 @@ private void listViewMeshes_SelectedIndexChanged(object sender, System.EventArgs
710712
buttonCloneMesh.Enabled = false;
711713
else
712714
buttonCloneMesh.Enabled = true;
713-
editPCMatToolStripMenuItem.Enabled = polytype.Contains("Material");
714-
editTextureIDToolStripMenuItem.Enabled = polytype.StartsWith("Tiny");
715-
editStripAlphaToolStripMenuItem.Enabled = polytype.StartsWith("Strip");
715+
editPCMatToolStripMenuItem.Enabled = editPCMatToolStripMenuItem.Visible = polytype.Contains("Material");
716+
editTextureIDToolStripMenuItem.Enabled = editTextureIDToolStripMenuItem.Visible = polytype.StartsWith("Tiny");
717+
editStripAlphaToolStripMenuItem.Enabled = editStripAlphaToolStripMenuItem.Visible = polytype.StartsWith("Strip");
716718
buttonDeleteMesh.Enabled = selectedObj.Count > 1;
717719
buttonMoveMeshUp.Enabled = selectedObj.IndexOf(selectedMesh) > 0;
718720
if (prevmatstart.StartsWith("Bits"))
@@ -728,10 +730,110 @@ private void listViewMeshes_SelectedIndexChanged(object sender, System.EventArgs
728730
}
729731
pdata += listViewMeshes.SelectedItems[0].SubItems[2].Text;
730732
}
733+
string ptype = selectedMesh.Type.ToString();
734+
string pdata2 = "";
735+
switch (selectedMesh)
736+
{
737+
case PolyChunkMaterial pcm:
738+
if (pcm.Diffuse.HasValue)
739+
pdata2 += ", D(" + pcm.Diffuse.Value.A + ", " + pcm.Diffuse.Value.R + ", " + pcm.Diffuse.Value.G + ", " + pcm.Diffuse.Value.B + ")";
740+
if (pcm.Ambient.HasValue)
741+
{
742+
pdata2 += ", A(" + pcm.Ambient.Value.A + ", " + pcm.Ambient.Value.R + ", " + pcm.Ambient.Value.G + ", " + pcm.Ambient.Value.B + ")";
743+
}
744+
if (pcm.Specular.HasValue)
745+
{
746+
pdata2 += ", S(" + pcm.Specular.Value.A + ", " + pcm.Specular.Value.R + ", " + pcm.Specular.Value.G + ", " + pcm.Specular.Value.B + ")" + ", Exp " + pcm.SpecularExponent.ToString();
747+
}
748+
pdata2 += ", Src Alpha:" + pcm.SourceAlpha.ToString() + ", ";
749+
pdata2 += "Dst Alpha:" + pcm.DestinationAlpha.ToString();
750+
break;
751+
case PolyChunkTinyTextureID pct:
752+
float mip = pct.MipmapDAdjust;
753+
string clamp = ", Clamp ";
754+
string flip = ", Flip ";
755+
string mipd = ", Mipmap 'D' Adjust ";
756+
pdata2 += ", Tex ID " + pct.TextureID;
757+
switch (pct.Flags & 0xF)
758+
{
759+
case 0:
760+
default:
761+
mipd += "000";
762+
break;
763+
case 1:
764+
mipd += "025";
765+
break;
766+
case 2:
767+
mipd += "050";
768+
break;
769+
case 3:
770+
mipd += "075";
771+
break;
772+
case 4:
773+
mipd += "100";
774+
break;
775+
case 5:
776+
mipd += "125";
777+
break;
778+
case 6:
779+
mipd += "150";
780+
break;
781+
case 7:
782+
mipd += "175";
783+
break;
784+
case 8:
785+
mipd += "200";
786+
break;
787+
case 9:
788+
mipd += "225";
789+
break;
790+
case 10:
791+
mipd += "250";
792+
break;
793+
case 11:
794+
mipd += "275";
795+
break;
796+
case 12:
797+
mipd += "300";
798+
break;
799+
case 13:
800+
mipd += "325";
801+
break;
802+
case 14:
803+
mipd += "350";
804+
break;
805+
case 15:
806+
mipd += "375";
807+
break;
808+
}
809+
if ((pct.Flags & 0xF) != 0)
810+
pdata2 += mipd;
811+
pdata2 += pct.SuperSample ? ", SuperSample" : "";
812+
clamp += pct.ClampU ? "U" : "";
813+
clamp += pct.ClampV ? "V" : "";
814+
if (pct.ClampU || pct.ClampV)
815+
pdata2 += clamp;
816+
flip += pct.FlipU ? "U" : "";
817+
flip += pct.FlipV ? "V" : "";
818+
if (pct.FlipU || pct.FlipV)
819+
pdata2 += flip;
820+
pdata2 += ", " + pct.FilterMode.ToString();
821+
break;
822+
case PolyChunkStrip pcs:
823+
string stripflags = "";
824+
stripflags += pcs.UseAlpha ? ", Use Alpha" : "";
825+
stripflags += pcs.DoubleSide ? ", Double Side" : "";
826+
stripflags += pcs.EnvironmentMapping ? ", Environment Map" : "";
827+
stripflags += pcs.FlatShading ? ", Flat Shading" : "";
828+
stripflags += pcs.IgnoreLight ? ", Ignore Light" : "";
829+
stripflags += pcs.IgnoreAmbient ? ", Ignore Ambient" : "";
830+
stripflags += pcs.IgnoreSpecular ? ", Ignore Specular" : "";
831+
pdata2 += stripflags;
832+
break;
833+
}
731834
// Status bar
732-
string bardata = polytype;
733-
if (pdata != null || pdata != "")
734-
bardata += pdata;
835+
string bardata = ptype;
836+
bardata += pdata2;
735837
StringBuilder sb = new StringBuilder();
736838
sb.Append("Attributes: ");
737839
sb.Append(bardata);
@@ -815,14 +917,26 @@ private void listViewVertices_SelectedIndexChanged(object sender, EventArgs e)
815917
return;
816918
}
817919
showVertexCollectionToolStripMenuItem.Enabled = true;
818-
string verttype = listViewVertices.SelectedItems[0].SubItems[1].Text;
819-
string vdata = listViewVertices.SelectedItems[0].SubItems[2].Text;
820-
string bardata = verttype;
821-
if (vdata != null)
822-
bardata += ", " + vdata;
920+
VertexChunk vchunk = ((ChunkAttach)editedModel).Vertex[listViewVertices.SelectedIndices[0]];
921+
string verttype = vchunk.Type.ToString();
922+
string vflags = vchunk.Flags.ToString();
923+
string vweight = vchunk.WeightStatus.ToString();
924+
string vsize = vchunk.Size.ToString();
925+
string vcount = vchunk.VertexCount.ToString();
823926
StringBuilder sb = new StringBuilder();
824927
sb.Append("Attributes: ");
825-
sb.Append(bardata);
928+
sb.Append(verttype);
929+
sb.Append(", Flags:");
930+
sb.Append(vflags);
931+
if (vchunk.HasWeight)
932+
{
933+
sb.Append(", Weight Status:");
934+
sb.Append(vweight);
935+
}
936+
sb.Append(", Size:");
937+
sb.Append(vsize);
938+
sb.Append(", Count:");
939+
sb.Append(vcount);
826940
toolStripStatusLabelInfo.Text = sb.ToString();
827941
}
828942
}

Libraries/SAEditorCommon/UI/ChunkModelMaterialDataEditor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,19 @@ private void SetControls(PolyChunk poly)
5353
diffuseRUpDown.Value = pcm.Diffuse.Value.R;
5454
diffuseGUpDown.Value = pcm.Diffuse.Value.G;
5555
diffuseBUpDown.Value = pcm.Diffuse.Value.B;
56-
//diffuseColorBox.BackColor = pcm.Diffuse.Value;
5756
alphaDiffuseNumeric.Value = pcm.Diffuse.Value.A;
5857
}
5958
if (pcm.Ambient.HasValue)
6059
{
6160
ambientRUpDown.Value = pcm.Ambient.Value.R;
6261
ambientGUpDown.Value = pcm.Ambient.Value.G;
6362
ambientBUpDown.Value = pcm.Ambient.Value.B;
64-
//ambientColorBox.BackColor = pcm.Ambient.Value;
6563
}
6664
if (pcm.Specular.HasValue)
6765
{
6866
specularRUpDown.Value = pcm.Specular.Value.R;
6967
specularGUpDown.Value = pcm.Specular.Value.G;
7068
specularBUpDown.Value = pcm.Specular.Value.B;
71-
//specColorBox.BackColor = pcm.Specular.Value;
7269
alphaSpecularNumeric.Value = pcm.Specular.Value.A;
7370
exponentTextBox.Text = pcm.SpecularExponent.ToString();
7471
}
@@ -239,7 +236,6 @@ private void label1_Click(object sender, EventArgs e)
239236

240237
void SetDiffuseFromNumerics()
241238
{
242-
PolyChunkMaterial pcm = (PolyChunkMaterial)PolyData;
243239
diffuseColorBox.BackColor = Color.FromArgb((int)alphaDiffuseNumeric.Value, (int)diffuseRUpDown.Value, (int)diffuseGUpDown.Value, (int)diffuseBUpDown.Value);
244240
//diffuseColorBox.BackColor = pcm.Diffuse.Value;
245241
RaiseFormUpdated();

Libraries/SAEditorCommon/UI/ChunkModelTextureDataEditor.Designer.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)