public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file) { this.file = file; id = reader.ReadInt32(); int size = reader.ReadInt32(); if (size == 4) { data = reader.ReadInt32(); return; } else if (size > 4) { int strlen = reader.ReadInt32(); if (size - 4 == strlen) { data = reader.ReadPSSGString(strlen); return; } else { reader.Seek(-4, System.IO.SeekOrigin.Current); } } data = reader.ReadBytes(size); }
public CNode(EndianBinaryReaderEx reader, CPSSGFile file) { this.file = file; id = reader.ReadInt32(); int size = reader.ReadInt32(); long end = reader.BaseStream.Position + size; int attributeSize = reader.ReadInt32(); long attributeEnd = reader.BaseStream.Position + attributeSize; // Each attr is at least 8 bytes (id + size), so take a conservative guess attributes = new Dictionary <string, CAttribute>(); CAttribute attr; while (reader.BaseStream.Position < attributeEnd) { attr = new CAttribute(reader, file); attributes.Add(attr.name, attr); } switch (name) { case "BOUNDINGBOX": case "DATA": case "DATABLOCKDATA": case "DATABLOCKBUFFERED": case "INDEXSOURCEDATA": case "INVERSEBINDMATRIX": case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT": case "NeAnimPacketData_B1": case "NeAnimPacketData_B4": case "RENDERINTERFACEBOUNDBUFFERED": case "SHADERINPUT": case "TEXTUREIMAGEBLOCKDATA": case "TRANSFORM": isDataNode = true; break; } if (isDataNode) { data = reader.ReadBytes((int)(end - reader.BaseStream.Position)); } else { // Each node at least 12 bytes (id + size + arg size) subNodes = new CNode[(end - reader.BaseStream.Position) / 12]; int nodeCount = 0; while (reader.BaseStream.Position < end) { subNodes[nodeCount] = new CNode(reader, file); nodeCount++; } Array.Resize(ref subNodes, nodeCount); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PSSG files|*.pssg|All files|*.*"; dialog.Title = "Select a PSSG file"; if (dialog.ShowDialog() == DialogResult.OK) { closeFile(); StreamReader sr = new StreamReader(dialog.FileName); CPSSGFile f = new CPSSGFile(sr.BaseStream); pssgFile = f; treeView.Nodes.Add(createTreeViewNode(f.rootNode)); listBoxModels.Items.Clear(); Model[] models = new Model[f.findNodes("MATRIXPALETTEJOINTRENDERINSTANCE").Count]; modelView1.renderDataSources = new Dictionary <string, RenderDataSource>(); int i = 0; List <CNode> mpbnNodes = f.findNodes("MATRIXPALETTEBUNDLENODE"); foreach (CNode mpbnNode in mpbnNodes) { List <CNode> mpjnNodes = mpbnNode.findNodes("MATRIXPALETTEJOINTNODE"); foreach (CNode mpjnNode in mpjnNodes) { Matrix transform = getTransform((byte[])mpjnNode.subNodes[0].data); foreach (CNode mpjriNode in mpjnNode.findNodes("MATRIXPALETTEJOINTRENDERINSTANCE")) { string rdsId = mpjriNode.attributes["indices"].value.Substring(1); RenderDataSource renderDataSource; if (!modelView1.renderDataSources.TryGetValue(rdsId, out renderDataSource)) { CNode rdsNode = f.findNodes("RENDERDATASOURCE", "id", rdsId)[0]; CNode dbNode = f.findNodes("DATABLOCK", "id", rdsNode.subNodes[1].attributes["dataBlock"].value.Substring(1))[0]; renderDataSource = createRenderDataSourceFromNodes(rdsNode, dbNode); modelView1.renderDataSources.Add(rdsNode.attributes["id"].value, renderDataSource); } models[i] = new Model(mpjnNode.attributes["id"].ToString() + mpjriNode.attributes["shader"].ToString(), renderDataSource, transform, (int)mpjriNode.attributes["streamOffset"].data, (int)mpjriNode.attributes["elementCountFromOffset"].data, (int)mpjriNode.attributes["indexOffset"].data, (int)mpjriNode.attributes["indicesCountFromOffset"].data); listBoxModels.Items.Add(models[i]); i++; } } } createTreeViewTexturesList(f.rootNode); } else { } }
private void closeFile() { if (this.pssgFile == null) return; // All tab treeView.Nodes.Clear(); dataGridViewAttributes.Rows.Clear(); // Models tab listBoxModels.Items.Clear(); // Textures tab treeViewTextures.Nodes.Clear(); pictureBoxTextures.Image = null; pssgFile = null; }
public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file) { attributeInfo = new Dictionary <int, CAttributeInfo>(); id = reader.ReadInt32(); name = reader.ReadPSSGString(); int attributeInfoCount = reader.ReadInt32(); CAttributeInfo ai; for (int i = 0; i < attributeInfoCount; i++) { ai = new CAttributeInfo(reader); attributeInfo.Add(ai.id, ai); file.attributeInfo[ai.id - 1] = ai; } }
private void closeFile() { if (this.pssgFile == null) { return; } // All tab treeView.Nodes.Clear(); dataGridViewAttributes.Rows.Clear(); // Models tab listBoxModels.Items.Clear(); // Textures tab treeViewTextures.Nodes.Clear(); pictureBoxTextures.Image = null; pssgFile = null; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PSSG files|*.pssg|All files|*.*"; dialog.Title = "Select a PSSG file"; if (dialog.ShowDialog() == DialogResult.OK) { closeFile(); StreamReader sr = new StreamReader(dialog.FileName); CPSSGFile f = new CPSSGFile(sr.BaseStream); pssgFile = f; treeView.Nodes.Add(createTreeViewNode(f.rootNode)); listBoxModels.Items.Clear(); Model[] models = new Model[f.findNodes("MATRIXPALETTEJOINTRENDERINSTANCE").Count]; modelView1.renderDataSources = new Dictionary<string,RenderDataSource>(); int i = 0; List<CNode> mpbnNodes = f.findNodes("MATRIXPALETTEBUNDLENODE"); foreach (CNode mpbnNode in mpbnNodes) { List<CNode> mpjnNodes = mpbnNode.findNodes("MATRIXPALETTEJOINTNODE"); foreach (CNode mpjnNode in mpjnNodes) { Matrix transform = getTransform((byte[])mpjnNode.subNodes[0].data); foreach (CNode mpjriNode in mpjnNode.findNodes("MATRIXPALETTEJOINTRENDERINSTANCE")) { string rdsId = mpjriNode.attributes["indices"].value.Substring(1); RenderDataSource renderDataSource; if (!modelView1.renderDataSources.TryGetValue(rdsId, out renderDataSource)) { CNode rdsNode = f.findNodes("RENDERDATASOURCE", "id", rdsId)[0]; CNode dbNode = f.findNodes("DATABLOCK", "id", rdsNode.subNodes[1].attributes["dataBlock"].value.Substring(1))[0]; renderDataSource = createRenderDataSourceFromNodes(rdsNode, dbNode); modelView1.renderDataSources.Add(rdsNode.attributes["id"].value, renderDataSource); } models[i] = new Model(mpjnNode.attributes["id"].ToString() + mpjriNode.attributes["shader"].ToString(), renderDataSource, transform, (int)mpjriNode.attributes["streamOffset"].data, (int)mpjriNode.attributes["elementCountFromOffset"].data, (int)mpjriNode.attributes["indexOffset"].data, (int)mpjriNode.attributes["indicesCountFromOffset"].data); listBoxModels.Items.Add(models[i]); i++; } } } createTreeViewTexturesList(f.rootNode); } else { } }
public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file) { attributeInfo = new Dictionary<int, CAttributeInfo>(); id = reader.ReadInt32(); name = reader.ReadPSSGString(); int attributeInfoCount = reader.ReadInt32(); CAttributeInfo ai; for (int i = 0; i < attributeInfoCount; i++) { ai = new CAttributeInfo(reader); attributeInfo.Add(ai.id, ai); file.attributeInfo[ai.id - 1] = ai; } }
public CNode(EndianBinaryReaderEx reader, CPSSGFile file) { this.file = file; id = reader.ReadInt32(); int size = reader.ReadInt32(); long end = reader.BaseStream.Position + size; int attributeSize = reader.ReadInt32(); long attributeEnd = reader.BaseStream.Position + attributeSize; // Each attr is at least 8 bytes (id + size), so take a conservative guess attributes = new Dictionary<string, CAttribute>(); CAttribute attr; while (reader.BaseStream.Position < attributeEnd) { attr = new CAttribute(reader, file); attributes.Add(attr.name, attr); } switch (name) { case "BOUNDINGBOX": case "DATABLOCKDATA": case "DATABLOCKBUFFERED": case "INDEXSOURCEDATA": case "INVERSEBINDMATRIX": case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT": case "RENDERINTERFACEBOUNDBUFFERED": case "SHADERINPUT": case "TEXTUREIMAGEBLOCKDATA": case "TRANSFORM": isDataNode = true; break; } if (isDataNode) { data = reader.ReadBytes((int)(end - reader.BaseStream.Position)); } else { // Each node at least 12 bytes (id + size + arg size) subNodes = new CNode[(end - reader.BaseStream.Position) / 12]; int nodeCount = 0; while (reader.BaseStream.Position < end) { subNodes[nodeCount] = new CNode(reader, file); nodeCount++; } Array.Resize(ref subNodes, nodeCount); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PSSG files|*.pssg|All files|*.*"; dialog.Title = "Select a PSSG file"; if (dialog.ShowDialog() == DialogResult.OK) { closeFile(); StreamReader sr = new StreamReader(dialog.FileName); CPSSGFile f = new CPSSGFile(sr.BaseStream); pssgFile = f; treeView.Nodes.Add(createTreeViewNode(f.rootNode)); createTreeViewTexturesList(f.rootNode); } else { } }