├── .gitignore ├── PS2LS ├── ps2ls.sln ├── ps2ls │ ├── Assets │ │ ├── Adr │ │ │ └── ActorDefinition.cs │ │ ├── Dma │ │ │ ├── Dma.cs │ │ │ └── Material.cs │ │ ├── Dme │ │ │ ├── BoneDrawCall.cs │ │ │ ├── Mesh.cs │ │ │ ├── Model.cs │ │ │ └── Vertex.cs │ │ ├── Mrn │ │ │ └── Mrn.cs │ │ └── Pack │ │ │ ├── Asset.cs │ │ │ ├── AssetManager.cs │ │ │ ├── NamelistGenerator.cs │ │ │ └── Pack.cs │ ├── Cameras │ │ ├── ArcBallCamera.cs │ │ └── Camera.cs │ ├── Cryptography │ │ └── Jenkins.cs │ ├── FMOD │ │ ├── fmod.cs │ │ ├── fmod.dll │ │ ├── fmodL.dll │ │ ├── fmod_dsp.cs │ │ └── fmod_errors.cs │ ├── Forms │ │ ├── AboutForm.Designer.cs │ │ ├── AboutForm.cs │ │ ├── AboutForm.resx │ │ ├── ActorBrowser.Designer.cs │ │ ├── ActorBrowser.cs │ │ ├── ActorBrowser.resx │ │ ├── AssetBrowser.Designer.cs │ │ ├── AssetBrowser.cs │ │ ├── AssetBrowser.resx │ │ ├── Controls │ │ │ ├── CustomListBox.cs │ │ │ ├── CustomListBox.resx │ │ │ └── GLModelVeiwerControl.cs │ │ ├── GenericLoadingForm.Designer.cs │ │ ├── GenericLoadingForm.cs │ │ ├── GenericLoadingForm.resx │ │ ├── ImageBrowser.Designer.cs │ │ ├── ImageBrowser.cs │ │ ├── ImageBrowser.resx │ │ ├── ImageExportForm.Designer.cs │ │ ├── ImageExportForm.cs │ │ ├── ImageExportForm.resx │ │ ├── MainForm.Designer.cs │ │ ├── MainForm.cs │ │ ├── MainForm.resx │ │ ├── MaterialBrowser.Designer.cs │ │ ├── MaterialBrowser.cs │ │ ├── MaterialBrowser.resx │ │ ├── MaterialBrowserGLControl.cs │ │ ├── ModelBrowser.Designer.cs │ │ ├── ModelBrowser.cs │ │ ├── ModelBrowser.resx │ │ ├── ModelBrowserGLControl.Designer.cs │ │ ├── ModelBrowserGLControl.cs │ │ ├── ModelBrowserGLControl.resx │ │ ├── ModelBrowserModelStats.Designer.cs │ │ ├── ModelBrowserModelStats.cs │ │ ├── ModelBrowserModelStats.resx │ │ ├── ModelExportForm.Designer.cs │ │ ├── ModelExportForm.cs │ │ ├── ModelExportForm.resx │ │ ├── SoundBrowser.Designer.cs │ │ ├── SoundBrowser.cs │ │ ├── SoundBrowser.resx │ │ ├── SoundExportForm.Designer.cs │ │ ├── SoundExportForm.cs │ │ ├── SoundExportForm.resx │ │ ├── TextureBrowser.Designer.cs │ │ ├── TextureBrowser.cs │ │ ├── TextureBrowser.resx │ │ └── TextureBrowserGLControl.cs │ ├── Graphics │ │ └── Materials │ │ │ ├── DrawStyle.cs │ │ │ ├── MaterialDefinition.cs │ │ │ ├── MaterialDefinitionManager.cs │ │ │ ├── ParameterGroup.cs │ │ │ └── VertexLayout.cs │ ├── IO │ │ ├── AssimpLIbraryTestStatic.cs │ │ ├── BinaryReaderBigEndian.cs │ │ ├── ColladaBuilderStatic.cs │ │ ├── ModelExporterStatic.cs │ │ ├── SoundExporterStatic.cs │ │ ├── TextureExporterStatic.cs │ │ └── collada_schema_1_4.cs │ ├── OpenTK.dll.config │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Resources │ │ ├── BastionAtDawn.png │ │ ├── DocumentWrite.png │ │ ├── FMOD Logo Black - White Background.png │ │ ├── Image-scaled.png │ │ ├── arrow-left.png │ │ ├── arrow-right.png │ │ ├── axes.png │ │ ├── bones.png │ │ ├── box--arrow.png │ │ ├── box--minus.png │ │ ├── box--plus.png │ │ ├── box-arrow-drive.png │ │ ├── box-document.png │ │ ├── box-search-result.png │ │ ├── box-small.png │ │ ├── box-zipper.png │ │ ├── box.png │ │ ├── bug--plus.png │ │ ├── bug.png │ │ ├── chain-small.png │ │ ├── chain.png │ │ ├── counter.png │ │ ├── cube-medium-12.png │ │ ├── cube-medium.png │ │ ├── cube.png │ │ ├── direction.png │ │ ├── document-arrow-drive.png │ │ ├── document-export.png │ │ ├── document-import.png │ │ ├── document-plus.png │ │ ├── document-search-result.png │ │ ├── document-tex.png │ │ ├── document-text.png │ │ ├── document-xaml.png │ │ ├── document.png │ │ ├── door-open.png │ │ ├── drive-download.png │ │ ├── folder-horizontal-open.png │ │ ├── folder-import.png │ │ ├── folder-small-horizontal.png │ │ ├── gear.png │ │ ├── grid.png │ │ ├── image.png │ │ ├── magnifier.png │ │ ├── materials_3.xml │ │ ├── music.png │ │ ├── ps2ls.png │ │ ├── question.png │ │ ├── robot.png │ │ ├── robotic-arm.png │ │ ├── smooth.png │ │ ├── sphere-aabb.png │ │ ├── sphere-aabb1.png │ │ ├── sphere-aabb2.png │ │ ├── sphere-wire-occluder.png │ │ ├── terminal.gif │ │ ├── textured.png │ │ ├── textured1.png │ │ ├── tree-magnifier.png │ │ ├── tree-small.png │ │ ├── tree.png │ │ ├── ui-text-field-clear-button.png │ │ └── wireframe.png │ ├── Shaders │ │ ├── blur_horizontal.frag │ │ ├── blur_vertical.frag │ │ ├── default.frag │ │ ├── default.vert │ │ ├── depth.frag │ │ ├── depth.vert │ │ ├── diffuse.frag │ │ ├── diffuse.vert │ │ ├── normals.frag │ │ ├── normals.vert │ │ ├── null.frag │ │ └── null.vert │ ├── TextureManager.cs │ ├── Utils.cs │ ├── app.config │ ├── packages.config │ ├── ps2ls.ico │ └── ps2ls2.csproj └── research │ └── file formats │ ├── adr │ └── Esamir_Props_Spires_Large_01.adr.txt │ ├── cnk0 │ └── Amerish_0_0.cnk0.txt │ ├── dma │ └── AimDummy_HeavyAssault_RifleKneelShoot_Hologram_Lod1.txt │ └── dme │ ├── Amerish_Flora_Radial_Daisy01_LOD0.dme │ └── Amerish_Flora_Radial_Daisy01_LOD0.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | bin 4 | lib 5 | out 6 | target 7 | *.com 8 | *.class 9 | *.exe 10 | *.o 11 | *.so 12 | 13 | # Git # 14 | ####### 15 | .git 16 | 17 | # Packages # 18 | ############ 19 | *.7z 20 | *.dmg 21 | *.gz 22 | *.iso 23 | *.jar 24 | *.rar 25 | *.tar 26 | *.zip 27 | 28 | # Logs and databases # 29 | ###################### 30 | *.log 31 | *.sql 32 | *.sqlite 33 | 34 | # OS generated files # 35 | ###################### 36 | .DS_Store 37 | ehthumbs.db 38 | Icon? 39 | Thumbs.db 40 | 41 | # Project Files # 42 | ################# 43 | bin 44 | obj 45 | *.suo 46 | *.v2 47 | *.user 48 | _ReSharper.* 49 | 50 | # Directories # 51 | ################# 52 | **/packages/**/* 53 | **/vs/**/* 54 | **/.vs/**/* 55 | **/Publish/**/* 56 | **/Extracts/**/* 57 | DiffTool/Diff.txt 58 | -------------------------------------------------------------------------------- /PS2LS/ps2ls.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32804.467 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ps2ls2", "ps2ls\ps2ls2.csproj", "{EA8DD307-8B70-4B76-A3E4-140D2A5ECB89}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EA8DD307-8B70-4B76-A3E4-140D2A5ECB89}.Debug|x64.ActiveCfg = Debug|x64 15 | {EA8DD307-8B70-4B76-A3E4-140D2A5ECB89}.Debug|x64.Build.0 = Debug|x64 16 | {EA8DD307-8B70-4B76-A3E4-140D2A5ECB89}.Release|x64.ActiveCfg = Release|x64 17 | {EA8DD307-8B70-4B76-A3E4-140D2A5ECB89}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6AB90EE2-5E3E-4335-B916-789B2D73E0D0} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Adr/ActorDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Xml; 5 | using System.Xml.XPath; 6 | 7 | namespace ps2ls.Assets 8 | { 9 | public class ActorDefinition 10 | { 11 | 12 | #region Animation 13 | public string animationNetworkFileName { get; private set; } 14 | public string animationNetworkSetName { get; private set; } 15 | public AnimationEnumeration[] animationEnumerations { get; private set; } 16 | public class AnimationEnumeration 17 | { 18 | public int hash { get; private set; } 19 | public int value { get; private set; } 20 | } 21 | public string animationValues { get; private set; } 22 | #endregion 23 | 24 | #region Base 25 | public string modelName { get; private set; } 26 | public string fileName { get; private set; } 27 | public string paletteName { get; private set; } 28 | public string materialName 29 | { 30 | get { return paletteName; } 31 | private set { paletteName = value; } 32 | } 33 | #endregion 34 | //updateRadius 35 | //waterDisplacementHeight 36 | //objectTerrainDataId 37 | 38 | public TextureAlias[] textureAliases { get; private set; } 39 | public class TextureAlias 40 | { 41 | public string aliasName { get; private set; } 42 | public string textureName { get; private set; } 43 | public int modelType { get; private set; } 44 | public int materialIndex { get; private set; } 45 | public int hash { get; private set; } 46 | public int defaultAlias { get; private set; } 47 | public int occlusionSlotBitmask { get; private set; } 48 | } 49 | public string tintAliases { get; private set; } 50 | public TintInheritance tintInheritance { get; private set; } 51 | public class TintInheritance 52 | { 53 | public int camo { get; private set; } 54 | public int decal { get; private set; } 55 | public int empire { get; private set; } 56 | public int extra { get; private set; } 57 | public int export { get; private set; } 58 | } 59 | public LOD[] lods { get; private set; } 60 | public class LOD 61 | { 62 | public string filename { get; private set; } 63 | public string palletName { get; private set; } 64 | public string materialName 65 | { 66 | get { return palletName; } 67 | private set { palletName = value; } 68 | } 69 | public int distance { get; private set; } 70 | } 71 | public LOD lodAuto { get; private set; } 72 | public Effect[] effectList { get; private set; } 73 | public class Effect 74 | { 75 | public string toolName { get; private set; } 76 | public string type { get; private set; } 77 | public string name { get; private set; } 78 | public int id { get; private set; } 79 | } 80 | 81 | #region Collision 82 | public int collisionType { get; private set; } 83 | public string collisionDataFile { get; private set; } 84 | public string simpleCollisionDataFile { get; private set; } 85 | #endregion 86 | 87 | #region Usage 88 | public int actorUsage { get; private set; } 89 | public bool borrowSkelleton { get; private set; } 90 | public string boneAttachmentName { get; private set; } 91 | public bool validatePcNpc { get; private set; } 92 | #endregion 93 | 94 | public string equippedSlotName { get; private set; } 95 | public string[] childAttachSLots { get; private set; } 96 | public Mountable mountable { get; private set; } 97 | public class Mountable 98 | { 99 | public int minOccupancy { get; private set; } 100 | public string animSlotPrifix { get; private set; } 101 | public string idleAnim { get; private set; } 102 | public string runAnim { get; private set; } 103 | public string runToIdleAnim { get; private set; } 104 | public Seat[] seatList { get; private set; } 105 | public class Seat 106 | { 107 | public string bone { get; private set; } 108 | public string animation { get; private set; } 109 | public int controller { get; private set; } 110 | public bool riderMimicsSeatAnim { get; private set; } 111 | public Bone entranceBone { get; private set; } 112 | public Bone exitBone { get; private set; } 113 | public class Bone 114 | { 115 | public string name { get; private set; } 116 | public string animation { get; private set; } 117 | public string location { get; private set; } 118 | } 119 | } 120 | } 121 | public string collusionFile { get; private set; } 122 | public int occlusionVisibility { get; private set; } 123 | public string materialType { get; private set; } 124 | public int invisibleValue { get; private set; } 125 | public bool loadedSuccessfully { get; private set; } 126 | public ActorDefinition(MemoryStream memoryStream, out bool loaded) 127 | { 128 | loadedSuccessfully = false; 129 | loaded = loadedSuccessfully; 130 | if (memoryStream == null) 131 | return; 132 | 133 | XPathDocument document; 134 | 135 | try 136 | { 137 | document = new XPathDocument(memoryStream); 138 | } 139 | catch (Exception) 140 | { 141 | return; 142 | } 143 | 144 | loadFromXPathNavigator(document.CreateNavigator()); 145 | 146 | loadedSuccessfully = true; 147 | loaded = loadedSuccessfully; 148 | } 149 | 150 | private void loadFromXPathNavigator(XPathNavigator baseNavigator) 151 | { 152 | XPathNavigator navigator = baseNavigator.Clone(); 153 | Console.WriteLine(navigator.LocalName); 154 | } 155 | 156 | 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dma/Dma.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace ps2ls.Assets 8 | { 9 | public class Dma 10 | { 11 | public uint length; 12 | public string[] textureStrings; 13 | public Material[] materials; 14 | public readonly bool isValid; 15 | public Dma(Stream stream) 16 | { 17 | BinaryReader binaryReader = new BinaryReader(stream); 18 | length = binaryReader.ReadUInt32(); 19 | //header 20 | byte[] magic = binaryReader.ReadBytes(4); 21 | 22 | if (magic[0] != 'D' || 23 | magic[1] != 'M' || 24 | magic[2] != 'A' || 25 | magic[3] != 'T') 26 | { 27 | 28 | Console.WriteLine("Magic Missmatch:" + Encoding.UTF8.GetString(magic)); 29 | return; 30 | } 31 | 32 | uint version = binaryReader.ReadUInt32(); 33 | 34 | //textures 35 | uint filenameLength = binaryReader.ReadUInt32(); 36 | char[] buffer = binaryReader.ReadChars(Convert.ToInt32(filenameLength)); 37 | int startIndex = 0; 38 | 39 | List texList = new List(); 40 | for (int i = 0; i < buffer.Count(); i++) 41 | { 42 | if (buffer[i] == '\0') 43 | { 44 | int length = i - startIndex; 45 | 46 | string textureName = new string(buffer, startIndex, length); 47 | startIndex = i + 1; 48 | 49 | texList.Add(textureName); 50 | } 51 | } 52 | textureStrings = texList.ToArray(); 53 | 54 | //materials 55 | uint materialCount = binaryReader.ReadUInt32(); 56 | materials = new Material[materialCount]; 57 | for (int i = 0; i < materialCount; i++) materials[i] = new Material(stream); 58 | 59 | isValid = true; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dma/Material.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using ps2ls.Graphics.Materials; 7 | 8 | namespace ps2ls.Assets 9 | { 10 | public class Material 11 | { 12 | public uint NameHash { get; private set; } 13 | public uint DataLength { get; private set; } 14 | public uint MaterialDefinitionHash { get; private set; } 15 | public string DefinitionName { get; private set; } 16 | public List Parameters { get; private set; } 17 | public Material(Stream stream) 18 | { 19 | BinaryReader binaryReader = new BinaryReader(stream); 20 | 21 | NameHash = binaryReader.ReadUInt32(); 22 | DataLength = binaryReader.ReadUInt32(); 23 | MaterialDefinitionHash = binaryReader.ReadUInt32(); 24 | uint parameterCount = binaryReader.ReadUInt32(); 25 | 26 | if (MaterialDefinitionManager.Instance.hasMaterialHash(MaterialDefinitionHash)) 27 | { 28 | DefinitionName = MaterialDefinitionManager.Instance.MaterialDefinitions[MaterialDefinitionHash].Name; 29 | } 30 | 31 | Parameters = new List(Convert.ToInt32(parameterCount)); 32 | for (uint j = 0; j < parameterCount; ++j) Parameters.Add(Parameter.LoadFromStream(stream)); 33 | } 34 | 35 | public class Parameter 36 | { 37 | //http://msdn.microsoft.com/en-us/library/windows/desktop/bb205378(v=vs.85).aspx 38 | public enum D3DXParameterClass 39 | { 40 | Scalar = 0, 41 | Vector, 42 | MatrixRows, 43 | MatrixColumns, 44 | Object, 45 | Struct, 46 | ForceDword = 0x7fffffff 47 | } 48 | 49 | //http://msdn.microsoft.com/en-us/library/windows/desktop/bb205380(v=vs.85).aspx 50 | public enum D3DXParameterType 51 | { 52 | Void = 0, 53 | Bool, 54 | Int, 55 | Float, 56 | String, 57 | Texture, 58 | Texture1D, 59 | Texture2D, 60 | Texture3D, 61 | TextureCube, 62 | Sampler, 63 | Sampler1D, 64 | Sampler2D, 65 | Sampler3D, 66 | SamplerCube, 67 | PixelShader, 68 | VertexShader, 69 | PixelFragment, 70 | VertexFrament, 71 | Unsupported, 72 | ForceDword = 0x7fffffff 73 | } 74 | 75 | public static Parameter LoadFromStream(Stream stream) 76 | { 77 | Parameter parameter = new Parameter(); 78 | BinaryReader binaryReader = new BinaryReader(stream); 79 | 80 | parameter.NameHash = binaryReader.ReadUInt32(); 81 | parameter.Class = (D3DXParameterClass)binaryReader.ReadUInt32(); 82 | parameter.Type = (D3DXParameterType)binaryReader.ReadUInt32(); 83 | parameter.dataLength = binaryReader.ReadUInt32(); 84 | parameter.Data = binaryReader.ReadBytes(Convert.ToInt32(parameter.dataLength)); 85 | return parameter; 86 | } 87 | 88 | public uint NameHash { get; private set; } 89 | public D3DXParameterClass Class { get; private set; } 90 | public D3DXParameterType Type { get; private set; } 91 | public uint dataLength; 92 | public byte[] Data { get; private set; } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dme/BoneDrawCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using OpenTK; 7 | 8 | namespace ps2ls.Assets 9 | { 10 | public struct BoneMapEntry 11 | { 12 | public ushort boneIndex; 13 | public ushort globalIndex; 14 | 15 | public BoneMapEntry(Stream stream) 16 | { 17 | BinaryReader binaryReader = new BinaryReader(stream); 18 | boneIndex = binaryReader.ReadUInt16(); 19 | globalIndex = binaryReader.ReadUInt16(); 20 | } 21 | } 22 | 23 | public struct Bone 24 | { 25 | public string name; 26 | public Matrix4 inverseBindPose; 27 | public Vector3 min; 28 | public Vector3 max; 29 | public ulong nameHash; 30 | } 31 | 32 | public struct BoneDrawCall 33 | { 34 | public uint Unknown0 { get; private set; } 35 | public uint BoneStart { get; private set; } 36 | public uint BoneCount { get; private set; } 37 | public uint Delta { get; private set; } 38 | public uint Unknown1 { get; private set; } 39 | public uint VertexOffset { get; private set; } 40 | public uint VertexCount { get; private set; } 41 | public uint IndexOffset { get; private set; } 42 | public uint IndexCount { get; private set; } 43 | 44 | public BoneDrawCall(Stream stream) 45 | { 46 | 47 | BinaryReader binaryReader = new BinaryReader(stream); 48 | Unknown0 = binaryReader.ReadUInt32();//max value 49 | BoneStart = binaryReader.ReadUInt32(); 50 | BoneCount = binaryReader.ReadUInt32(); 51 | Delta = binaryReader.ReadUInt32(); 52 | Unknown1 = binaryReader.ReadUInt32();//seems to match boneCount for first draw call? 53 | VertexOffset = binaryReader.ReadUInt32(); 54 | VertexCount = binaryReader.ReadUInt32(); 55 | IndexOffset = binaryReader.ReadUInt32(); 56 | IndexCount = binaryReader.ReadUInt32(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dme/Mesh.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using ps2ls.Cryptography; 7 | using OpenTK; 8 | using ps2ls.Graphics.Materials; 9 | 10 | namespace ps2ls.Assets 11 | { 12 | public class Mesh 13 | { 14 | public class VertexStream 15 | { 16 | public VertexStream(int getBytesPerVertex, byte[] getBytes) 17 | { 18 | bytesPerVertex = getBytesPerVertex; 19 | data = getBytes; 20 | } 21 | public int bytesPerVertex { get; private set; }//if 12, 3 floats. If 6, 3 halves. If 8, 2 floats. If 4, 2 halves (maybe) 22 | public byte[] data { get; private set; } 23 | 24 | public byte[] GetSlice(int offset, int legnth) 25 | { 26 | byte[] toReturn = new byte[legnth]; 27 | Buffer.BlockCopy(data, offset, toReturn, 0, legnth); 28 | return toReturn; 29 | } 30 | } 31 | 32 | 33 | public uint drawCallOffset { get; private set; } 34 | public uint drawCallCount { get; private set; } 35 | public uint boneTransformCount { get; private set; } 36 | public uint unknown3 { get; private set; } 37 | public uint vertexStreamCount { get; private set; } 38 | public VertexStream[] vertexStreams { get; private set; } 39 | public uint indexSize { get; private set; } 40 | public uint indexCount { get; private set; } 41 | public uint vertexCount { get; private set; } 42 | public byte[] indexData { get; private set; } 43 | public int indexByteLength { get; private set; } 44 | public Mesh(Stream stream) 45 | { 46 | BinaryReader binaryReader = new BinaryReader(stream); 47 | drawCallOffset = binaryReader.ReadUInt32(); 48 | drawCallCount = binaryReader.ReadUInt32(); 49 | boneTransformCount = binaryReader.ReadUInt32(); 50 | unknown3 = binaryReader.ReadUInt32();//is usually max value 51 | vertexStreamCount = binaryReader.ReadUInt32(); 52 | indexSize = binaryReader.ReadUInt16();//byte length of each index (2 if ushort, 4 if uint) 53 | binaryReader.ReadUInt16();//On new models this is way to large. just read it as 2 ushorts to mask out the offending bytes 54 | indexCount = binaryReader.ReadUInt32(); 55 | vertexCount = binaryReader.ReadUInt32(); 56 | 57 | vertexStreams = new VertexStream[vertexStreamCount]; 58 | 59 | // read vertex streams 60 | for (int j = 0; j < vertexStreamCount; ++j) 61 | { 62 | int bytesPerVertex = Convert.ToInt32(binaryReader.ReadUInt32());//is usually 12 for positions (3 floats - 4 bytes each), but doesn't have to be 63 | VertexStream vertexStream = new VertexStream(bytesPerVertex, binaryReader.ReadBytes(bytesPerVertex * Convert.ToInt32(vertexCount))); 64 | vertexStreams[j] = vertexStream; 65 | } 66 | 67 | // read indices 68 | indexByteLength = Convert.ToInt32(indexSize) * Convert.ToInt32(indexCount); 69 | indexData = binaryReader.ReadBytes(indexByteLength); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dme/Model.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Globalization; 7 | using OpenTK; 8 | using ps2ls.Graphics.Materials; 9 | using ps2ls.Cryptography; 10 | 11 | namespace ps2ls.Assets 12 | { 13 | public class Model 14 | { 15 | public string name { get; private set; } 16 | public uint version { get; private set; } 17 | public Dma dma; 18 | public uint unknown0 { get; private set; } 19 | public uint unknown1 { get; private set; } 20 | public uint unknown2 { get; private set; } 21 | public Vector3 min { get; private set; } 22 | public Vector3 max { get; private set; } 23 | public Mesh[] meshes { get; private set; } 24 | public uint boneDrawCallCount { get; private set; } 25 | public BoneDrawCall[] boneDrawCalls { get; private set; } 26 | public uint boneMapEntryCount { get; private set; } 27 | public BoneMapEntry[] boneMapEntries { get; private set; } 28 | public Dictionary boneMap1 = new Dictionary(); 29 | public Dictionary boneMap2 = new Dictionary(); 30 | public uint boneCount { get; private set; } 31 | public Bone[] bones { get; private set; } 32 | public uint vertexCount; 33 | public uint indexCount; 34 | public readonly bool isValid; 35 | public Model(string getName, Stream stream) 36 | { 37 | BinaryReader binaryReader = new BinaryReader(stream); 38 | 39 | //header 40 | byte[] magic = binaryReader.ReadBytes(4); 41 | 42 | if (magic[0] != 'D' || 43 | magic[1] != 'M' || 44 | magic[2] != 'O' || 45 | magic[3] != 'D') 46 | { 47 | 48 | Console.WriteLine("Magic Missmatch:" + Encoding.UTF8.GetString(magic)); 49 | return; 50 | } 51 | 52 | name = getName; 53 | 54 | #if DEBUG 55 | Console.WriteLine("~~~~~~~~Model~~~~~~~"); 56 | Console.WriteLine(getName); 57 | #endif 58 | version = binaryReader.ReadUInt32(); 59 | 60 | if (version != 4) 61 | { 62 | Console.WriteLine(name + " is an unsupported dmod file. v." + version); 63 | return; 64 | } 65 | 66 | //materials 67 | dma = new Dma(stream); 68 | if (!dma.isValid) return; 69 | 70 | //bounding box 71 | min = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); 72 | max = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); 73 | 74 | //meshes 75 | uint meshCount = binaryReader.ReadUInt32(); 76 | 77 | meshes = new Mesh[meshCount]; 78 | vertexCount = 0; 79 | indexCount = 0; 80 | for (int i = 0; i < meshCount; i++) 81 | { 82 | meshes[i] = new Mesh(binaryReader.BaseStream); 83 | vertexCount += meshes[i].vertexCount; 84 | indexCount += meshes[i].indexCount; 85 | } 86 | 87 | //bone maps 88 | boneDrawCallCount = binaryReader.ReadUInt32(); 89 | boneDrawCalls = new BoneDrawCall[boneDrawCallCount]; 90 | 91 | for (int i = 0; i < boneDrawCallCount; i++) 92 | { 93 | boneDrawCalls[i] = new BoneDrawCall(binaryReader.BaseStream); 94 | } 95 | 96 | 97 | //bone map entries 98 | boneMapEntryCount = binaryReader.ReadUInt32(); 99 | boneMapEntries = new BoneMapEntry[boneMapEntryCount]; 100 | 101 | for (int i = 0; i < boneMapEntryCount; ++i) 102 | { 103 | boneMapEntries[i] = new BoneMapEntry(binaryReader.BaseStream); 104 | if (boneMap1.ContainsKey(boneMapEntries[i].globalIndex)) 105 | { 106 | boneMap1.Add(boneMapEntries[i].globalIndex + 64, boneMapEntries[i].boneIndex); 107 | boneMap2.Add(boneMapEntries[i].globalIndex, boneMapEntries[i].boneIndex); 108 | } 109 | else 110 | { 111 | boneMap1.Add(boneMapEntries[i].globalIndex, boneMapEntries[i].boneIndex); 112 | } 113 | } 114 | 115 | //return; 116 | boneCount = binaryReader.ReadUInt32(); 117 | bones = new Bone[boneCount]; 118 | for (int i = 0; i < boneCount; i++) 119 | { 120 | float[] matrix = new float[12]; 121 | for (int j = 0; j < 12; j++) matrix[j] = binaryReader.ReadSingle(); 122 | 123 | bones[i] = new Bone() 124 | { 125 | inverseBindPose = new Matrix4( 126 | new Vector4(matrix[0], matrix[1], matrix[2], 0), 127 | new Vector4(matrix[3], matrix[4], matrix[5], 0), 128 | new Vector4(matrix[6], matrix[7], matrix[8], 0), 129 | new Vector4(matrix[9], matrix[10], matrix[11], 1)) 130 | }; 131 | } 132 | 133 | for (int i = 0; i < boneCount; i++) 134 | { 135 | bones[i].min = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); 136 | bones[i].max = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); 137 | } 138 | 139 | for (int i = 0; i < boneCount; i++) 140 | { 141 | bones[i].nameHash = binaryReader.ReadUInt32(); 142 | } 143 | 144 | isValid = true; 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Dme/Vertex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using OpenTK; 6 | 7 | namespace ps2ls.Assets 8 | { 9 | public class Vertex 10 | { 11 | public Vertex() 12 | { 13 | Data = new List(); 14 | } 15 | 16 | public Vector3 Position; 17 | public Vector3 Normal; 18 | public List Data; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Mrn/Mrn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ps2ls.Assets 9 | { 10 | public class MrnData 11 | { 12 | public static MrnData LoadFromStream(string name, Stream stream) 13 | { 14 | BinaryReader binaryReader = new BinaryReader(stream); 15 | Console.WriteLine("Reading " + name + "; Not Yet Implimented."); 16 | MrnData mrn = new MrnData(); 17 | return mrn; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Assets/Pack/Asset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.ComponentModel; 7 | using ps2ls.IO; 8 | using System.Buffers; 9 | 10 | namespace ps2ls.Assets 11 | { 12 | public class Asset 13 | { 14 | static readonly uint[] ZIPPED_FLAGS = new uint[] { 0x01, 0x11 }; 15 | static readonly uint[] UNZIPPED_FLAGS = new uint[] { 0x10, 0x00 }; 16 | public enum Types 17 | { 18 | ADR, 19 | AGR, 20 | CDT, 21 | CNK0, 22 | CNK1, 23 | CNK2, 24 | CNK3, 25 | CRC, 26 | DDS, 27 | DMA, 28 | DME, 29 | DMV, 30 | DSK, 31 | ECO, 32 | FSB, 33 | FXO, 34 | GFX, 35 | LST, 36 | NSA, 37 | TXT, 38 | XML, 39 | ZONE, 40 | PNG, 41 | JPG, 42 | MRN, 43 | Unknown 44 | }; 45 | 46 | private Asset(Pack pack) 47 | { 48 | Pack = pack; 49 | Name = String.Empty; 50 | NameHash = 0; 51 | Offset = 0; 52 | DataLength = 0; 53 | isZipped = false; 54 | dataHash = 0; 55 | UnzippedLength = 0; 56 | Type = Types.Unknown; 57 | } 58 | 59 | static Asset() 60 | { 61 | CreateTypeImages(); 62 | } 63 | 64 | public static Asset LoadBinary(Pack pack, Stream stream, Dictionary nameDict) 65 | { 66 | BinaryReader BinaryReaderLE = new BinaryReader(stream); 67 | BinaryReaderBigEndian BinaryReaderBE = new BinaryReaderBigEndian(stream); 68 | 69 | Asset asset = new Asset(pack); 70 | 71 | //read map to find metadata 72 | asset.NameHash = BinaryReaderLE.ReadUInt64(); 73 | asset.Offset = BinaryReaderLE.ReadUInt64(); 74 | asset.DataLength = BinaryReaderLE.ReadUInt64(); 75 | uint zippedflag = BinaryReaderLE.ReadUInt32(); 76 | asset.isZipped = TestZipped(zippedflag) && asset.DataLength > 0; 77 | asset.dataHash = BinaryReaderLE.ReadUInt32(); 78 | asset.UnzippedLength = 0; 79 | if (asset.isZipped) 80 | { 81 | long initialPosition = stream.Position; 82 | stream.Seek(Convert.ToInt64(asset.Offset), SeekOrigin.Begin); 83 | 84 | byte[] magicBytes = ArrayPool.Shared.Rent(sizeof(uint)); 85 | stream.Read(magicBytes, 0, 4); 86 | //TODO check magic matches a1b2c3d4 header 87 | ArrayPool.Shared.Return(magicBytes); 88 | 89 | asset.UnzippedLength = BinaryReaderBE.ReadUInt32(); 90 | stream.Seek(initialPosition, SeekOrigin.Begin); 91 | } 92 | 93 | if (nameDict.ContainsKey(asset.NameHash)) 94 | { 95 | asset.Name = nameDict[asset.NameHash]; 96 | } else 97 | { 98 | asset.Name = asset.NameHash + ".unknown"; 99 | } 100 | 101 | // Set the type of the asset based on the extension 102 | 103 | // First, check for an extension. Some pack file names don't, 104 | // have one, such as {NAMELIST} 105 | string extension = System.IO.Path.GetExtension(asset.Name); 106 | if (string.IsNullOrEmpty(extension)) 107 | { 108 | asset.Type = Types.Unknown; 109 | } 110 | else 111 | { 112 | // Remove the leading '.' and normalise any names that have 113 | // alternative spellings 114 | extension = extension.Substring(1); 115 | if (extension.Equals("jpeg")) 116 | extension = "jpg"; 117 | 118 | asset.Type = Enum.TryParse(extension, true, out Types parsedType) 119 | ? parsedType 120 | : Types.Unknown; 121 | } 122 | 123 | return asset; 124 | } 125 | 126 | public static bool TestZipped(uint flag) 127 | { 128 | foreach (uint zipped in ZIPPED_FLAGS) if (flag == zipped) return true; 129 | return false; 130 | } 131 | 132 | public override string ToString() 133 | { 134 | return Name; 135 | } 136 | 137 | private static Dictionary typeImages; 138 | 139 | public static System.Drawing.Image GetImageFromType(Asset.Types type) 140 | { 141 | return typeImages[type]; 142 | } 143 | 144 | private static void CreateTypeImages() 145 | { 146 | if (typeImages != null) 147 | return; 148 | 149 | typeImages = new Dictionary(); 150 | 151 | foreach (Types type in Enum.GetValues(typeof(Types))) 152 | { 153 | switch (type) 154 | { 155 | case Types.MRN: 156 | case Types.DME: 157 | typeImages[type] = Properties.Resources.tree; 158 | break; 159 | case Types.DDS: 160 | case Types.PNG: 161 | case Types.JPG: 162 | typeImages[type] = Properties.Resources.image; 163 | break; 164 | case Types.TXT: 165 | typeImages[type] = Properties.Resources.document_tex; 166 | break; 167 | case Types.XML: 168 | typeImages[type] = Properties.Resources.document_xaml; 169 | break; 170 | case Types.FSB: 171 | typeImages[type] = Properties.Resources.music; 172 | break; 173 | default: 174 | typeImages[type] = Properties.Resources.question; 175 | break; 176 | } 177 | } 178 | } 179 | 180 | [BrowsableAttribute(false)] 181 | public Pack Pack { get; private set; } 182 | public String Name { get; private set; } 183 | public String Path { get; private set; } 184 | public ulong NameHash { get; private set; } 185 | public ulong Offset { get; private set; } 186 | public ulong DataLength { get; private set; } 187 | public uint UnzippedLength { get; private set; } 188 | public bool isZipped { get; private set; } 189 | public uint dataHash { get; private set; } 190 | 191 | 192 | public Asset.Types Type { get; private set; } 193 | 194 | public class NameComparer : Comparer 195 | { 196 | public override int Compare(Asset x, Asset y) 197 | { 198 | return x.Name.CompareTo(y.Name); 199 | } 200 | } 201 | public class SizeComparer : Comparer 202 | { 203 | public override int Compare(Asset x, Asset y) 204 | { 205 | if (x.DataLength > y.DataLength) 206 | return -1; 207 | if (x.DataLength < y.DataLength) 208 | return 1; 209 | else 210 | return 0; 211 | } 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Cameras/ArcBallCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using OpenTK; 6 | 7 | namespace ps2ls.Cameras 8 | { 9 | public class ArcBallCamera : Camera 10 | { 11 | private Single distance; 12 | private Vector3 target; 13 | private Single desiredPitch = 0; 14 | 15 | public Single DesiredDistance { get; set; } 16 | public Vector3 DesiredTarget{ get; set; } 17 | public Single DesiredYaw { get; set; } 18 | public Single DesiredPitch 19 | { 20 | get { return desiredPitch; } 21 | set 22 | { 23 | if (value > MathHelper.DegreesToRadians(89.9f)) 24 | { 25 | desiredPitch = MathHelper.DegreesToRadians(89.9f); 26 | } 27 | else if (value < -MathHelper.DegreesToRadians(89.9f)) 28 | { 29 | desiredPitch = -MathHelper.DegreesToRadians(89.9f); 30 | } 31 | else 32 | { 33 | desiredPitch = value; 34 | } 35 | } 36 | } 37 | 38 | public ArcBallCamera() 39 | : base(Camera.Types.ArcBall) 40 | { 41 | DesiredYaw = Yaw = MathHelper.DegreesToRadians(-45.0f); 42 | DesiredPitch = Pitch = MathHelper.DegreesToRadians(45.0f); 43 | DesiredDistance = distance = 10.0f; 44 | } 45 | 46 | public override void Update() 47 | { 48 | distance = DesiredDistance; 49 | 50 | if (distance < 0.0f) 51 | { 52 | distance = 0.0f; 53 | } 54 | 55 | target = DesiredTarget; 56 | 57 | Yaw = DesiredYaw; 58 | 59 | Pitch = DesiredPitch; 60 | 61 | Matrix4 world = Matrix4.CreateRotationX(Pitch) * Matrix4.CreateRotationY(Yaw); 62 | Vector3 forward = Vector3.TransformNormal(Vector3.UnitZ, world); 63 | 64 | Position = target - (forward * distance); 65 | 66 | base.Update(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Cameras/Camera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using OpenTK; 6 | 7 | namespace ps2ls.Cameras 8 | { 9 | public class Camera 10 | { 11 | public enum Types 12 | { 13 | ArcBall, 14 | Free 15 | }; 16 | 17 | public Matrix4 View { get; protected set; } 18 | public Matrix4 Projection { get; protected set; } 19 | public Single AspectRatio { get; set; } 20 | public Single FieldOfView { get; set; } 21 | public Single NearPlaneDistance { get; set; } 22 | public Single FarPlaneDistance { get; set; } 23 | public Vector3 Position { get; set; } 24 | public Single Pitch { get; set; } 25 | public Single Yaw { get; set; } 26 | 27 | public Camera.Types CameraType { get; private set; } 28 | 29 | protected Camera(Camera.Types type) 30 | { 31 | CameraType = type; 32 | FieldOfView = MathHelper.DegreesToRadians(74.0f); 33 | NearPlaneDistance = (Single)Math.Pow(2, -8); 34 | FarPlaneDistance = (Single)Math.Pow(2, 8); 35 | } 36 | 37 | public virtual void Update() 38 | { 39 | Projection = Matrix4.CreatePerspectiveFieldOfView(FieldOfView, AspectRatio, NearPlaneDistance, FarPlaneDistance); 40 | 41 | Matrix4 world = Matrix4.CreateRotationX(Pitch) * Matrix4.CreateRotationY(Yaw); 42 | Vector3 forward = Vector3.TransformNormal(Vector3.UnitZ, world); 43 | 44 | View = Matrix4.LookAt(Position, Position + forward, Vector3.UnitY); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Cryptography/Jenkins.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ps2ls.Cryptography 7 | { 8 | public static class Jenkins 9 | { 10 | //http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time 11 | public static uint OneAtATime(String key) 12 | { 13 | //[4:56:55 AM] Herbert Harrison: Yeah, you need to use signed ints (so Int32) inside the function and cast to UInt32 on return 14 | //[4:57:45 AM] Herbert Harrison: And some places use uppercase for the hashes 15 | int hash = 0; 16 | 17 | for (int i = 0; i < key.Length; ++i) 18 | { 19 | hash += key[i]; 20 | hash += (hash << 10); 21 | hash ^= (hash >> 6); 22 | } 23 | 24 | hash += (hash << 3); 25 | hash ^= (hash >> 11); 26 | hash += (hash << 15); 27 | 28 | return (uint)hash; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/FMOD/fmod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/FMOD/fmod.dll -------------------------------------------------------------------------------- /PS2LS/ps2ls/FMOD/fmodL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/FMOD/fmodL.dll -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/AboutForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace ps2ls 11 | { 12 | partial class AboutBox : Form 13 | { 14 | #region Singleton 15 | private static AboutBox instance = null; 16 | 17 | public static void CreateInstance() 18 | { 19 | instance = new AboutBox(); 20 | } 21 | 22 | public static void DeleteInstance() 23 | { 24 | instance = null; 25 | } 26 | 27 | public static AboutBox Instance { get { return instance; } } 28 | #endregion 29 | 30 | public AboutBox() 31 | { 32 | InitializeComponent(); 33 | labelVersion.Text = "Version " + Assembly.GetEntryAssembly().GetName().Version.ToString(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ActorBrowser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using ps2ls.Assets; 10 | using System.Xml; 11 | using System.Xml.XPath; 12 | 13 | 14 | namespace ps2ls.Forms 15 | { 16 | public partial class ActorBrowser : UserControl 17 | { 18 | #region Singleton 19 | private static ActorBrowser instance = null; 20 | 21 | public static void CreateInstance() 22 | { 23 | instance = new ActorBrowser(); 24 | } 25 | 26 | public static void DeleteInstance() 27 | { 28 | instance = null; 29 | } 30 | 31 | public static ActorBrowser Instance { get { return instance; } } 32 | #endregion 33 | 34 | public ActorBrowser() 35 | { 36 | InitializeComponent(); 37 | 38 | actorListbox.Items.Clear(); 39 | 40 | Dock = DockStyle.Fill; 41 | } 42 | 43 | public void onEnter(object sender, EventArgs e) 44 | { 45 | actorListbox.LoadAndSortAssets(); 46 | refreshActorListBox(); 47 | } 48 | 49 | private void actorListbox_SelectedIndexChanged(object sender, EventArgs e) 50 | { 51 | Asset asset; 52 | 53 | try 54 | { 55 | asset = (Asset)actorListbox.SelectedItem; 56 | } 57 | catch (InvalidCastException) { return; } 58 | 59 | System.IO.MemoryStream memoryStream = asset.Pack.CreateAssetMemoryStreamByName(asset.Name); 60 | XmlDocument xmlDoc = new XmlDocument(); 61 | try 62 | { 63 | xmlDoc.Load(memoryStream); 64 | } 65 | catch (Exception) 66 | { 67 | return; 68 | } 69 | 70 | actorTreeView.Nodes.Clear(); 71 | ConvertXmlNodeToTreeNode(xmlDoc, actorTreeView.Nodes); 72 | actorTreeView.ExpandAll(); 73 | } 74 | 75 | private void ConvertXmlNodeToTreeNode(XmlNode xmlNode, TreeNodeCollection treeNodes) 76 | { 77 | TreeNode newTreeNode = treeNodes.Add(xmlNode.Name); 78 | 79 | switch (xmlNode.NodeType) 80 | { 81 | case XmlNodeType.ProcessingInstruction: 82 | case XmlNodeType.XmlDeclaration: 83 | newTreeNode.Text = ""; 84 | break; 85 | case XmlNodeType.Element: 86 | newTreeNode.Text = "<" + xmlNode.Name + ">"; 87 | break; 88 | case XmlNodeType.Attribute: 89 | newTreeNode.Text = xmlNode.Name + ": " + xmlNode.Value; 90 | return;//in this schema, attributes are allways the end of branch 91 | case XmlNodeType.Text: 92 | case XmlNodeType.CDATA: 93 | newTreeNode.Text = xmlNode.Value; 94 | break; 95 | case XmlNodeType.Comment: 96 | newTreeNode.Text = ""; 97 | break; 98 | } 99 | 100 | if (xmlNode.Attributes != null) 101 | { 102 | foreach (XmlAttribute attribute in xmlNode.Attributes) 103 | { 104 | ConvertXmlNodeToTreeNode(attribute, newTreeNode.Nodes); 105 | } 106 | } 107 | foreach (XmlNode childNode in xmlNode.ChildNodes) 108 | { 109 | ConvertXmlNodeToTreeNode(childNode, newTreeNode.Nodes); 110 | } 111 | } 112 | 113 | 114 | private void searchText_TextChanged(object sender, EventArgs e) 115 | { 116 | handleTextTimer(); 117 | } 118 | 119 | private void handleTextTimer() 120 | { 121 | searchTextTimer.Stop(); 122 | searchTextTimer.Start(); 123 | } 124 | 125 | 126 | private void searchTextTimer_Tick(object sender, EventArgs e) 127 | { 128 | if (searchText.Text.Length > 0) 129 | { 130 | searchText.BackColor = Color.Yellow; 131 | toolStripButton2.Enabled = true; 132 | 133 | } 134 | else 135 | { 136 | searchText.BackColor = Color.White; 137 | toolStripButton2.Enabled = false; 138 | } 139 | 140 | searchTextTimer.Stop(); 141 | refreshActorListBox(); 142 | } 143 | 144 | private int pageNumber = 0; 145 | private int pageSize = 1000; 146 | private void refreshActorListBox() 147 | { 148 | actorListbox.FilterBySearch(searchText.Text ?? ""); 149 | 150 | int filtered = actorListbox.MaxFilteredCount; 151 | 152 | int populateStart = pageNumber * pageSize; 153 | int populateEnd = populateStart + pageSize; 154 | if (populateEnd > filtered) populateEnd = filtered; 155 | actorListbox.PopulateBox(populateStart, populateEnd); 156 | 157 | filesListedLabel.Text = "Page " + (pageNumber + 1) 158 | + ": " + populateStart + " - " + populateEnd + " / " + filtered; 159 | } 160 | 161 | private void nextPageButton_Click(object sender, EventArgs e) 162 | { 163 | int maxPageIndex = actorListbox.MaxFilteredCount / pageSize; 164 | if (++pageNumber > maxPageIndex) pageNumber = maxPageIndex; 165 | refreshActorListBox(); 166 | } 167 | 168 | private void lastPageButton_Click(object sender, EventArgs e) 169 | { 170 | if (--pageNumber < 0) pageNumber = 0; 171 | refreshActorListBox(); 172 | } 173 | 174 | private void toolStripButton2_Click(object sender, EventArgs e) 175 | { 176 | searchText.Clear(); 177 | } 178 | 179 | private void toolStripButton3_Click(object sender, EventArgs e) 180 | { 181 | List fileNames = new List(); 182 | 183 | foreach (object selectedItem in actorListbox.SelectedItems) 184 | { 185 | Asset asset = null; 186 | 187 | try 188 | { 189 | asset = (Asset)selectedItem; 190 | } 191 | catch (InvalidCastException) { continue; } 192 | 193 | fileNames.Add(asset.Name); 194 | } 195 | 196 | foreach (string s in fileNames) 197 | { 198 | Console.WriteLine(s); 199 | } 200 | 201 | 202 | ImageExportForm modelExportForm = new ImageExportForm(); 203 | modelExportForm.FileNames = fileNames; 204 | modelExportForm.ShowDialog(); 205 | } 206 | 207 | 208 | private void ActorBrowser_Load(object sender, EventArgs e) 209 | { 210 | handleTextTimer(); 211 | } 212 | 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ActorBrowser.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 273, 17 122 | 123 | 124 | 17, 17 125 | 126 | 127 | 133, 17 128 | 129 | 130 | 378, 17 131 | 132 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/Controls/CustomListBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | using System.Drawing; 7 | using ps2ls.Assets; 8 | 9 | namespace ps2ls.Forms.Controls 10 | { 11 | public class CustomListBox : ListBox 12 | { 13 | public Image Image { get; set; } 14 | 15 | public Asset.Types[] AssetType; 16 | 17 | List assets = new List(); 18 | public int MaxCount { get; protected set; } 19 | public List filteredAssets = new List(); 20 | public int MaxFilteredCount { get; protected set; } 21 | public CustomListBox() 22 | { 23 | this.DrawItem += new DrawItemEventHandler(this.CustomListBox_DrawItem); 24 | 25 | DrawMode = DrawMode.OwnerDrawFixed; 26 | } 27 | 28 | private void CustomListBox_DrawItem(object sender, DrawItemEventArgs e) 29 | { 30 | if (e.Index < 0) 31 | { 32 | return; 33 | } 34 | 35 | e.DrawBackground(); 36 | 37 | String text = ((ListBox)sender).Items[e.Index].ToString(); 38 | Point point = new Point(0, e.Bounds.Y); 39 | 40 | if (Image != null) 41 | { 42 | e.Graphics.DrawImage(Image, point); 43 | point.X += Image.Width; 44 | } 45 | 46 | e.Graphics.DrawString(text, e.Font, new SolidBrush(Color.Black), point); 47 | e.DrawFocusRectangle(); 48 | } 49 | 50 | public void LoadAndSortAssets() 51 | { 52 | assets = new List(); 53 | 54 | foreach (Asset.Types type in AssetType) 55 | { 56 | AssetManager.Instance.AssetsByType.TryGetValue(type, out List getAssets); 57 | if (getAssets != null) assets.AddRange(getAssets); 58 | } 59 | 60 | assets.Sort(new Asset.NameComparer()); 61 | 62 | MaxCount = assets == null ? 0 : assets.Count; 63 | } 64 | 65 | public void FilterBySearch(string searchText) 66 | { 67 | filteredAssets = new List(); 68 | if (assets != null) foreach (Asset asset in assets) 69 | { 70 | if (asset.Name.IndexOf(searchText, 0, StringComparison.OrdinalIgnoreCase) >= 0) filteredAssets.Add(asset); 71 | } 72 | updateFilteredCount(); 73 | } 74 | 75 | public void updateFilteredCount() 76 | { 77 | MaxFilteredCount = filteredAssets == null ? 0 : filteredAssets.Count; 78 | } 79 | 80 | public void excludeFromFilter(string searchText) 81 | { 82 | for(int i = filteredAssets.Count - 1; i >= 0; i--) 83 | { 84 | if (filteredAssets[i].Name.IndexOf(searchText, 0, StringComparison.OrdinalIgnoreCase) >= 0) filteredAssets.RemoveAt(i); 85 | } 86 | updateFilteredCount(); 87 | } 88 | 89 | public void PopulateBox(int startIndex, int endIndex) 90 | { 91 | this.Items.Clear(); 92 | 93 | if (filteredAssets.Count < endIndex) endIndex = filteredAssets.Count; 94 | for (int i = startIndex; i < endIndex; i++) Items.Add(filteredAssets[i]); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/Controls/CustomListBox.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | False 122 | 123 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/Controls/GLModelVeiwerControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using OpenTK; 6 | 7 | namespace ps2ls.Forms.Controls 8 | { 9 | public class GLModelVeiwerControl : GLControl 10 | { 11 | 12 | 13 | public GLModelVeiwerControl() 14 | : base(new OpenTK.Graphics.GraphicsMode(32, 24, 8, 8), 2, 0, OpenTK.Graphics.GraphicsContextFlags.ForwardCompatible) 15 | { 16 | } 17 | 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/GenericLoadingForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ps2ls 2 | { 3 | partial class GenericLoadingForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GenericLoadingForm)); 32 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.SuspendLayout(); 35 | // 36 | // progressBar1 37 | // 38 | this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom; 39 | this.progressBar1.Location = new System.Drawing.Point(0, 51); 40 | this.progressBar1.Margin = new System.Windows.Forms.Padding(10); 41 | this.progressBar1.Name = "progressBar1"; 42 | this.progressBar1.Size = new System.Drawing.Size(334, 30); 43 | this.progressBar1.TabIndex = 0; 44 | // 45 | // label1 46 | // 47 | this.label1.Dock = System.Windows.Forms.DockStyle.Fill; 48 | this.label1.Location = new System.Drawing.Point(0, 0); 49 | this.label1.MinimumSize = new System.Drawing.Size(100, 0); 50 | this.label1.Name = "label1"; 51 | this.label1.Size = new System.Drawing.Size(334, 51); 52 | this.label1.TabIndex = 1; 53 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 54 | // 55 | // GenericLoadingForm 56 | // 57 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 58 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 59 | this.ClientSize = new System.Drawing.Size(334, 81); 60 | this.Controls.Add(this.label1); 61 | this.Controls.Add(this.progressBar1); 62 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 63 | this.HelpButton = true; 64 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 65 | this.MaximizeBox = false; 66 | this.Name = "GenericLoadingForm"; 67 | this.ShowInTaskbar = false; 68 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 69 | this.TopMost = true; 70 | this.ResumeLayout(false); 71 | 72 | } 73 | 74 | #endregion 75 | 76 | private System.Windows.Forms.ProgressBar progressBar1; 77 | private System.Windows.Forms.Label label1; 78 | } 79 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/GenericLoadingForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace ps2ls 11 | { 12 | public partial class GenericLoadingForm : Form 13 | { 14 | public GenericLoadingForm() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public void SetWindowTitle(string title) 20 | { 21 | Text = title; 22 | } 23 | 24 | public void SetProgressBarPercent(int percent) 25 | { 26 | progressBar1.Value = percent; 27 | } 28 | 29 | public void SetLabelText(string text) 30 | { 31 | label1.Text = text; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ImageBrowser.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 238, 17 125 | 126 | 127 | 354, 17 128 | 129 | 130 | 494, 17 131 | 132 | 133 | 37 134 | 135 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ImageExportForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ps2ls.Forms 2 | { 3 | partial class ImageExportForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageExportForm)); 33 | this.exportButton = new System.Windows.Forms.Button(); 34 | this.exportFolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); 35 | this.label7 = new System.Windows.Forms.Label(); 36 | this.textureFormatComboBox = new System.Windows.Forms.ComboBox(); 37 | this.packageToolTip = new System.Windows.Forms.ToolTip(this.components); 38 | this.SuspendLayout(); 39 | // 40 | // exportButton 41 | // 42 | this.exportButton.Location = new System.Drawing.Point(212, 39); 43 | this.exportButton.Name = "exportButton"; 44 | this.exportButton.Size = new System.Drawing.Size(75, 23); 45 | this.exportButton.TabIndex = 5; 46 | this.exportButton.Text = "Export"; 47 | this.exportButton.UseVisualStyleBackColor = true; 48 | this.exportButton.Click += new System.EventHandler(this.exportButton_Click); 49 | // 50 | // label7 51 | // 52 | this.label7.AutoSize = true; 53 | this.label7.Location = new System.Drawing.Point(11, 15); 54 | this.label7.Name = "label7"; 55 | this.label7.Size = new System.Drawing.Size(78, 13); 56 | this.label7.TabIndex = 7; 57 | this.label7.Text = "Texture Format"; 58 | // 59 | // textureFormatComboBox 60 | // 61 | this.textureFormatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 62 | this.textureFormatComboBox.FormattingEnabled = true; 63 | this.textureFormatComboBox.Items.AddRange(new object[] { 64 | "DirectDraw Surface (*.dds)", 65 | "Portal Network Graphics (*.png)", 66 | "Truevision TGA (*.tga)"}); 67 | this.textureFormatComboBox.Location = new System.Drawing.Point(95, 12); 68 | this.textureFormatComboBox.Name = "textureFormatComboBox"; 69 | this.textureFormatComboBox.Size = new System.Drawing.Size(192, 21); 70 | this.textureFormatComboBox.TabIndex = 6; 71 | this.textureFormatComboBox.SelectedIndexChanged += new System.EventHandler(this.textureFormatComboBox_SelectedIndexChanged); 72 | // 73 | // ImageExportForm 74 | // 75 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 76 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 77 | this.ClientSize = new System.Drawing.Size(299, 74); 78 | this.Controls.Add(this.label7); 79 | this.Controls.Add(this.textureFormatComboBox); 80 | this.Controls.Add(this.exportButton); 81 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 82 | this.MaximizeBox = false; 83 | this.MinimizeBox = false; 84 | this.Name = "ImageExportForm"; 85 | this.ShowInTaskbar = false; 86 | this.Text = "Texture Export"; 87 | this.TopMost = true; 88 | this.Load += new System.EventHandler(this.ImageExportForm_Load); 89 | this.ResumeLayout(false); 90 | this.PerformLayout(); 91 | 92 | } 93 | 94 | #endregion 95 | private System.Windows.Forms.Button exportButton; 96 | private System.Windows.Forms.FolderBrowserDialog exportFolderBrowserDialog; 97 | private System.Windows.Forms.Label label7; 98 | private System.Windows.Forms.ComboBox textureFormatComboBox; 99 | private System.Windows.Forms.ToolTip packageToolTip; 100 | } 101 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ImageExportForm.cs: -------------------------------------------------------------------------------- 1 | using ps2ls.Assets; 2 | using ps2ls.IO; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.IO; 7 | using System.Windows.Forms; 8 | 9 | 10 | namespace ps2ls.Forms 11 | { 12 | public partial class ImageExportForm : Form 13 | { 14 | public ImageExportForm() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public List FileNames { get; set; } 20 | 21 | private GenericLoadingForm loadingForm; 22 | private BackgroundWorker exportBackgroundWorker = new BackgroundWorker(); 23 | private ImageExportOptions imageExportOptions = new ImageExportOptions(); 24 | class ImageExportOptions 25 | { 26 | public TextureExporterStatic.TextureFormatInfo textureFormat; 27 | } 28 | 29 | private void exportDoWork(object sender, DoWorkEventArgs e) 30 | { 31 | e.Result = exportTextures(sender, e.Argument); 32 | } 33 | 34 | private void exportRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 35 | { 36 | loadingForm.Close(); 37 | 38 | Close(); 39 | 40 | MessageBox.Show("Successfully exported " + (Int32)e.Result + " textures."); 41 | } 42 | 43 | private void exportProgressChanged(object sender, ProgressChangedEventArgs e) 44 | { 45 | if (loadingForm != null) 46 | { 47 | loadingForm.SetLabelText((string)e.UserState); 48 | loadingForm.SetProgressBarPercent(e.ProgressPercentage); 49 | } 50 | } 51 | 52 | private int exportTextures(object sender, object argument) 53 | { 54 | List arguments = (List)argument; 55 | 56 | string directory = (string)arguments[0]; 57 | List fileNames = (List)arguments[1]; 58 | ImageExportOptions exportOptions = (ImageExportOptions)arguments[2]; 59 | 60 | int result = 0; 61 | 62 | foreach (string textureString in fileNames) 63 | if (TextureExporterStatic.exportTexture(textureString, directory, exportOptions.textureFormat)) result++; 64 | 65 | return result; 66 | } 67 | 68 | 69 | private void loadTextureFormatComboBox() 70 | { 71 | textureFormatComboBox.Items.Clear(); 72 | 73 | foreach (TextureExporterStatic.TextureFormatInfo textureFormat in TextureExporterStatic.TextureFormats) 74 | { 75 | textureFormatComboBox.Items.Add(textureFormat); 76 | } 77 | 78 | textureFormatComboBox.SelectedIndex = 0; 79 | } 80 | 81 | private void exportButton_Click(object sender, EventArgs e) 82 | { 83 | applyCurrentStateToExportOptions(); 84 | 85 | if (exportFolderBrowserDialog.ShowDialog() == DialogResult.OK) 86 | { 87 | ModelExporterStatic.outputDirectory = exportFolderBrowserDialog.SelectedPath; 88 | List argument = new List() 89 | { 90 | exportFolderBrowserDialog.SelectedPath, 91 | FileNames, 92 | imageExportOptions 93 | }; 94 | 95 | loadingForm = new GenericLoadingForm(); 96 | loadingForm.Show(); 97 | 98 | exportBackgroundWorker.RunWorkerAsync(argument); 99 | } 100 | } 101 | private void applyCurrentStateToExportOptions() 102 | { 103 | imageExportOptions.textureFormat = (TextureExporterStatic.TextureFormatInfo)textureFormatComboBox.SelectedItem; 104 | } 105 | 106 | private void ImageExportForm_Load(object sender, EventArgs e) 107 | { 108 | if (ModelExporterStatic.outputDirectory == null) ModelExporterStatic.outputDirectory = Application.StartupPath; 109 | exportFolderBrowserDialog.SelectedPath = ModelExporterStatic.outputDirectory; 110 | 111 | exportBackgroundWorker.WorkerReportsProgress = true; 112 | exportBackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(exportProgressChanged); 113 | exportBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(exportRunWorkerCompleted); 114 | exportBackgroundWorker.DoWork += new DoWorkEventHandler(exportDoWork); 115 | 116 | loadTextureFormatComboBox(); 117 | } 118 | 119 | private void textureFormatComboBox_SelectedIndexChanged(object sender, EventArgs e) 120 | { 121 | imageExportOptions.textureFormat = (TextureExporterStatic.TextureFormatInfo)textureFormatComboBox.SelectedItem; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.IO; 10 | using ps2ls.Properties; 11 | using OpenTK; 12 | using OpenTK.Input; 13 | using OpenTK.Graphics.OpenGL; 14 | using ps2ls.Assets; 15 | 16 | namespace ps2ls.Forms 17 | { 18 | public partial class MainForm : Form 19 | { 20 | #region Singleton 21 | private static MainForm instance = null; 22 | 23 | public static void CreateInstance() 24 | { 25 | instance = new MainForm(); 26 | } 27 | 28 | public static void DeleteInstance() 29 | { 30 | instance = null; 31 | } 32 | 33 | public static MainForm Instance { get { return instance; } } 34 | #endregion 35 | 36 | private MainForm() 37 | { 38 | InitializeComponent(); 39 | } 40 | 41 | private void exitToolStripMenuItem_Click(object sender, EventArgs e) 42 | { 43 | Application.Exit(); 44 | } 45 | 46 | private void aboutToolStripMenuItem_Click(object sender, EventArgs e) 47 | { 48 | AboutBox.Instance.ShowDialog(); 49 | } 50 | 51 | private void Form1_Load(object sender, EventArgs e) 52 | { 53 | AssetBrowser.CreateInstance(); 54 | ModelBrowser.CreateInstance(); 55 | MaterialBrowser.CreateInstance(); 56 | ImageBrowser.CreateInstance(); 57 | SoundBrowser.CreateInstance(); 58 | ActorBrowser.CreateInstance(); 59 | 60 | ImageList imageList = new ImageList(); 61 | imageList.Images.Add(Resources.box_small); 62 | imageList.Images.Add(Resources.tree_small); 63 | imageList.Images.Add(Resources.image); 64 | imageList.Images.Add(Resources.music); 65 | imageList.Images.Add(Resources.robot); 66 | tabControl1.ImageList = imageList; 67 | 68 | TabPage assetBrowserTabPage = new TabPage("Asset Browser"); 69 | assetBrowserTabPage.Controls.Add(AssetBrowser.Instance); 70 | assetBrowserTabPage.ImageIndex = 0; 71 | tabControl1.TabPages.Add(assetBrowserTabPage); 72 | 73 | TabPage modelBrowserTabPage = new TabPage("Model Browser"); 74 | modelBrowserTabPage.Controls.Add(ModelBrowser.Instance); 75 | modelBrowserTabPage.ImageIndex = 1; 76 | modelBrowserTabPage.Enter += ModelBrowser.Instance.onEnter; 77 | tabControl1.TabPages.Add(modelBrowserTabPage); 78 | 79 | TabPage imageBrowser = new TabPage("Image Browser"); 80 | imageBrowser.Controls.Add(ImageBrowser.Instance); 81 | imageBrowser.ImageIndex = 2; 82 | imageBrowser.Enter += ImageBrowser.Instance.onEnter; 83 | tabControl1.TabPages.Add(imageBrowser); 84 | 85 | TabPage soundBrowser = new TabPage("Sound Browser"); 86 | soundBrowser.Controls.Add(SoundBrowser.Instance); 87 | soundBrowser.ImageIndex = 3; 88 | soundBrowser.Enter += SoundBrowser.Instance.onEnter; 89 | tabControl1.TabPages.Add(soundBrowser); 90 | 91 | TabPage actorBrowser = new TabPage("Actor Browser"); 92 | actorBrowser.Controls.Add(ActorBrowser.Instance); 93 | actorBrowser.ImageIndex = 4; 94 | actorBrowser.Enter += ActorBrowser.Instance.onEnter; 95 | tabControl1.TabPages.Add(actorBrowser); 96 | 97 | } 98 | 99 | private void reportIssueToolStripMenuItem_Click(object sender, EventArgs e) 100 | { 101 | Console.WriteLine("no issue url found"); 102 | // System.Diagnostics.Process.Start(Settings.Default.ProjectNewIssueURL); 103 | } 104 | 105 | private void printAssetInfoMenuItem_Click(object sender, EventArgs e) 106 | { 107 | AssetManager.Instance.WriteAssetInfoToFile(AppDomain.CurrentDomain.BaseDirectory + "AssetInfo.txt"); 108 | } 109 | 110 | private void diffNamelistsMenuItem_Click(object sender, EventArgs e) 111 | { 112 | DialogResult result = namelistOpenFileDialog.ShowDialog(); 113 | if (result != DialogResult.OK) return; 114 | 115 | NamelistGenerator.DiffNameLists(namelistOpenFileDialog.FileNames); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/MaterialBrowserGLControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ps2ls.Forms.Controls; 6 | using ps2ls.Cameras; 7 | 8 | namespace ps2ls.Forms 9 | { 10 | public class MaterialBrowserGLControl : GLModelVeiwerControl 11 | { 12 | public ArcBallCamera Camera { get; set; } 13 | 14 | public MaterialBrowserGLControl() 15 | { 16 | Camera = new ArcBallCamera(); 17 | Camera.DesiredPitch = 0; 18 | Camera.DesiredYaw = 0; 19 | Camera.DesiredDistance = 2.0f; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ModelBrowserGLControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ps2ls.Forms 2 | { 3 | partial class ModelBrowserGLControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // ModelBrowserGLControl 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "ModelBrowserGLControl"; 38 | this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ModelBrowserGLControl_KeyDown); 39 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ModelBrowserGLControl_MouseDown); 40 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ModelBrowserGLControl_MouseMove); 41 | this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ModelBrowserGLControl_MouseUp); 42 | this.ResumeLayout(false); 43 | 44 | } 45 | 46 | #endregion 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ModelBrowserGLControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using ps2ls.Cameras; 10 | using ps2ls.Forms.Controls; 11 | using OpenTK; 12 | 13 | namespace ps2ls.Forms 14 | { 15 | public partial class ModelBrowserGLControl : GLModelVeiwerControl 16 | { 17 | private Point location; 18 | private bool rotating; 19 | private bool panning; 20 | private bool zooming; 21 | 22 | public ArcBallCamera Camera { get; set; } 23 | 24 | public ModelBrowserGLControl() 25 | { 26 | Camera = new ArcBallCamera(); 27 | 28 | InitializeComponent(); 29 | } 30 | 31 | private void ModelBrowserGLControl_MouseDown(object sender, MouseEventArgs e) 32 | { 33 | switch (e.Button) 34 | { 35 | case System.Windows.Forms.MouseButtons.Left: 36 | rotating = true; 37 | break; 38 | case System.Windows.Forms.MouseButtons.Right: 39 | panning = true; 40 | break; 41 | case System.Windows.Forms.MouseButtons.Middle: 42 | zooming = true; 43 | break; 44 | } 45 | } 46 | 47 | private void ModelBrowserGLControl_MouseUp(object sender, MouseEventArgs e) 48 | { 49 | switch (e.Button) 50 | { 51 | case System.Windows.Forms.MouseButtons.Left: 52 | rotating = false; 53 | break; 54 | case System.Windows.Forms.MouseButtons.Right: 55 | panning = false; 56 | break; 57 | case System.Windows.Forms.MouseButtons.Middle: 58 | zooming = false; 59 | break; 60 | } 61 | } 62 | 63 | private void ModelBrowserGLControl_MouseMove(object sender, MouseEventArgs e) 64 | { 65 | if (location.X == 0 && location.Y == 0) 66 | { 67 | location = e.Location; 68 | } 69 | 70 | Int32 deltaX = e.Location.X - location.X; 71 | Int32 deltaY = e.Location.Y - location.Y; 72 | 73 | if (panning) 74 | { 75 | Matrix4 world = Matrix4.CreateFromAxisAngle(Vector3.UnitX, Camera.Pitch) * Matrix4.CreateFromAxisAngle(Vector3.UnitY, Camera.Yaw); 76 | 77 | Vector3 forward = Vector3.TransformNormal(Vector3.UnitZ, world); 78 | forward.Y = 0; 79 | forward.Normalize(); 80 | 81 | Vector3 up = Vector3.UnitY; 82 | Vector3 left = Vector3.Cross(up, forward); 83 | 84 | Camera.DesiredTarget += (up * deltaY) * 0.00390625f; 85 | Camera.DesiredTarget += (left * deltaX) * 0.00390625f; 86 | } 87 | else if (rotating) 88 | { 89 | Camera.DesiredYaw -= MathHelper.DegreesToRadians(0.25f * deltaX); 90 | Camera.DesiredPitch += MathHelper.DegreesToRadians(0.25f * deltaY); 91 | } 92 | else if (zooming) 93 | { 94 | Camera.DesiredDistance += deltaY * 0.015625f; 95 | } 96 | 97 | location = e.Location; 98 | } 99 | 100 | private void ModelBrowserGLControl_KeyDown(object sender, KeyEventArgs e) 101 | { 102 | switch (e.KeyCode) 103 | { 104 | case Keys.Delete: 105 | { 106 | } 107 | break; 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ModelBrowserGLControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ModelBrowserModelStats.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using ps2ls.Assets; 10 | 11 | namespace ps2ls.Forms 12 | { 13 | public partial class ModelBrowserModelStats : UserControl 14 | { 15 | private Model model; 16 | 17 | public ModelBrowserModelStats() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | public Model Model 23 | { 24 | get { return model; } 25 | set 26 | { 27 | model = value; 28 | 29 | nameLabel.Text = model != null ? model.name : ""; 30 | meshCountLabel.Text = model != null ? model.meshes.Length.ToString() : "0"; 31 | modelVertexCountLabel.Text = model != null ? model.vertexCount.ToString() : "0"; 32 | modelTriangleCountLabel.Text = model != null ? (model.indexCount / 3).ToString() : "0"; 33 | materialCount.Text = model != null ? model.dma.materials.Length.ToString() : "0"; 34 | modelUnknown0Label.Text = model != null ? model.unknown0.ToString() : "0"; 35 | modelUnknown1Label.Text = model != null ? model.unknown1.ToString() : "0"; 36 | mdoelUnknown2Label.Text = model != null ? model.unknown2.ToString() : "0"; 37 | BoneDrawCallsLabel.Text = model != null ? model.boneDrawCalls.Length.ToString() : "0"; 38 | BoneMapCountLabel.Text = model != null ? model.boneMapEntries.Length.ToString() : "0"; 39 | modelVersionLabel.Text = model != null ? model.version.ToString() : "0"; 40 | 41 | meshesComboBox.Items.Clear(); 42 | textureComboBox1.Items.Clear(); 43 | texturesComboBox2.Items.Clear(); 44 | 45 | texturesComboBox2.Visible = false; 46 | label18.Visible = false; 47 | 48 | if (model != null) 49 | { 50 | for (int i = 0; i < model.meshes.Length; ++i) 51 | { 52 | meshesComboBox.Items.Add("Mesh " + i); 53 | textureComboBox1.Items.Add("" + i); 54 | } 55 | 56 | foreach(string s in model.dma.textureStrings) 57 | { 58 | texturesComboBox2.Items.Add(s); 59 | } 60 | } 61 | 62 | if (meshesComboBox.Items.Count > 0) 63 | { 64 | meshesComboBox.SelectedIndex = 0; 65 | } 66 | 67 | 68 | } 69 | } 70 | 71 | private void meshesComboBox_SelectedIndexChanged(object sender, EventArgs e) 72 | { 73 | Mesh mesh = null; 74 | 75 | if (model != null && meshesComboBox.SelectedIndex >= 0) 76 | { 77 | mesh = model.meshes[meshesComboBox.SelectedIndex]; 78 | } 79 | 80 | meshVertexCountLabel.Text = mesh != null ? mesh.vertexCount.ToString() : "0"; 81 | meshTriangleCountLabel.Text = mesh != null ? (mesh.indexCount / 3).ToString() : "0"; 82 | //meshBytesPerVertexLabel.Text = mesh != null ? mesh.BytesPerVertex.ToString() : "0"; 83 | meshIndexLabel.Text = mesh != null ? mesh.drawCallOffset.ToString() : "0"; 84 | meshUnknown1Label.Text = mesh != null ? mesh.drawCallCount.ToString() : "0"; 85 | meshUnknown2Label.Text = mesh != null ? mesh.boneTransformCount.ToString() : "0"; 86 | meshUnknown3Label.Text = mesh != null ? mesh.unknown3.ToString() : "0"; 87 | meshVertexBlockCountLabel.Text = mesh != null ? mesh.vertexStreams.Length.ToString() : "0"; 88 | } 89 | 90 | private void textureComboBox1_SelectedIndexChanged(object sender, EventArgs e) 91 | { 92 | texturesComboBox2.Visible = true; 93 | texturesComboBox2.SelectedItem = null; 94 | label18.Visible = true; 95 | } 96 | 97 | private void texturesComboBox2_SelectedIndexChanged(object sender, EventArgs e) 98 | { 99 | ModelBrowser.Instance.SetTextureForMesh(int.Parse((string)textureComboBox1.SelectedItem), (string)texturesComboBox2.SelectedItem); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/ModelBrowserModelStats.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/SoundBrowser.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 263, 17 122 | 123 | 124 | 147, 17 125 | 126 | 127 | 368, 17 128 | 129 | 130 | 17, 17 131 | 132 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/SoundExportForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ps2ls.Forms 2 | { 3 | partial class SoundExportForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SoundExportForm)); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.soundFormatComboBox = new System.Windows.Forms.ComboBox(); 34 | this.exportButton = new System.Windows.Forms.Button(); 35 | this.exportFolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); 36 | this.SuspendLayout(); 37 | // 38 | // label1 39 | // 40 | this.label1.AutoSize = true; 41 | this.label1.Location = new System.Drawing.Point(14, 15); 42 | this.label1.Name = "label1"; 43 | this.label1.Size = new System.Drawing.Size(50, 13); 44 | this.label1.TabIndex = 0; 45 | this.label1.Text = "File Type"; 46 | // 47 | // soundFormatComboBox 48 | // 49 | this.soundFormatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 50 | this.soundFormatComboBox.FormattingEnabled = true; 51 | this.soundFormatComboBox.Items.AddRange(new object[] { 52 | "WAV"}); 53 | this.soundFormatComboBox.Location = new System.Drawing.Point(70, 12); 54 | this.soundFormatComboBox.Name = "soundFormatComboBox"; 55 | this.soundFormatComboBox.Size = new System.Drawing.Size(217, 21); 56 | this.soundFormatComboBox.TabIndex = 1; 57 | this.soundFormatComboBox.SelectedIndexChanged += new System.EventHandler(this.soundFormatComboBox_SelectedIndexChanged); 58 | // 59 | // exportButton 60 | // 61 | this.exportButton.Location = new System.Drawing.Point(212, 48); 62 | this.exportButton.Name = "exportButton"; 63 | this.exportButton.Size = new System.Drawing.Size(75, 23); 64 | this.exportButton.TabIndex = 2; 65 | this.exportButton.Text = "Export"; 66 | this.exportButton.UseVisualStyleBackColor = true; 67 | this.exportButton.Click += new System.EventHandler(this.exportButton_Click); 68 | // 69 | // SoundExportForm 70 | // 71 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 72 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 73 | this.ClientSize = new System.Drawing.Size(299, 82); 74 | this.Controls.Add(this.soundFormatComboBox); 75 | this.Controls.Add(this.label1); 76 | this.Controls.Add(this.exportButton); 77 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 78 | this.MaximizeBox = false; 79 | this.MinimizeBox = false; 80 | this.Name = "SoundExportForm"; 81 | this.Text = "Export Sound"; 82 | this.Load += new System.EventHandler(this.SoundExportForm_Load); 83 | this.ResumeLayout(false); 84 | this.PerformLayout(); 85 | 86 | } 87 | 88 | #endregion 89 | 90 | private System.Windows.Forms.Label label1; 91 | private System.Windows.Forms.ComboBox soundFormatComboBox; 92 | private System.Windows.Forms.Button exportButton; 93 | private System.Windows.Forms.FolderBrowserDialog exportFolderBrowserDialog; 94 | } 95 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/TextureBrowser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using OpenTK.Graphics.OpenGL; 10 | using OpenTK; 11 | using ps2ls.Cameras; 12 | using ps2ls.Files.Dme; 13 | using ps2ls.Files.Pack; 14 | using System.Diagnostics; 15 | 16 | namespace ps2ls.Forms 17 | { 18 | public partial class TextureBrowser : UserControl 19 | { 20 | #region Singleton 21 | private static TextureBrowser instance = null; 22 | 23 | public static void CreateInstance() 24 | { 25 | instance = new TextureBrowser(); 26 | } 27 | 28 | public static void DeleteInstance() 29 | { 30 | instance = null; 31 | } 32 | 33 | public static TextureBrowser Instance { get { return instance; } } 34 | #endregion 35 | 36 | private Model model = null; 37 | 38 | private TextureBrowser() 39 | { 40 | InitializeComponent(); 41 | 42 | //HACK: Can't load TextureBrowser.cs in design mode unless we have at least one item for some reason. 43 | //Clear items after construction. 44 | texturesListBox.Items.Clear(); 45 | 46 | Dock = DockStyle.Fill; 47 | } 48 | 49 | private void TextureBrowserControl_Load(object sender, EventArgs e) 50 | { 51 | glControl1.CreateGraphics(); 52 | 53 | Application.Idle += applicationIdle; 54 | } 55 | 56 | private void applicationIdle(object sender, EventArgs e) 57 | { 58 | while (glControl1.Context != null && glControl1.IsIdle) 59 | { 60 | render(); 61 | } 62 | } 63 | 64 | private void glControl1_Resize(object sender, EventArgs e) 65 | { 66 | OpenTK.GLControl glControl = sender as OpenTK.GLControl; 67 | 68 | if (glControl.Height == 0) 69 | { 70 | glControl.ClientSize = new System.Drawing.Size(glControl.ClientSize.Width, 1); 71 | } 72 | 73 | GL.Viewport(0, 0, glControl.ClientSize.Width, glControl.ClientSize.Height); 74 | } 75 | 76 | private void glControl1_Paint(object sender, PaintEventArgs e) 77 | { 78 | render(); 79 | } 80 | 81 | private void render() 82 | { 83 | glControl1.MakeCurrent(); 84 | 85 | GL.ClearColor(Color.Black); 86 | GL.Clear(ClearBufferMask.ColorBufferBit); 87 | 88 | glControl1.SwapBuffers(); 89 | } 90 | 91 | public override void Refresh() 92 | { 93 | base.Refresh(); 94 | 95 | refreshTexturesListBox(); 96 | } 97 | 98 | private void refreshTexturesListBox() 99 | { 100 | texturesListBox.Items.Clear(); 101 | 102 | List files = new List(); 103 | List ddsFiles = null; 104 | 105 | PackBrowser.Instance.PacksByType.TryGetValue(PackFile.Types.DDS, out ddsFiles); 106 | 107 | if (ddsFiles != null) 108 | { 109 | files.AddRange(ddsFiles); 110 | } 111 | 112 | files.Sort(new PackFile.NameComparer()); 113 | 114 | if (files != null) 115 | { 116 | foreach (PackFile packFile in files) 117 | { 118 | if (packFile.Name.IndexOf(searchTexturesText.Text, 0, StringComparison.OrdinalIgnoreCase) >= 0) 119 | { 120 | texturesListBox.Items.Add(packFile); 121 | } 122 | } 123 | } 124 | 125 | Int32 count = texturesListBox.Items.Count; 126 | Int32 max = files != null ? files.Count : 0; 127 | 128 | modelsCountToolStripStatusLabel.Text = count + "/" + max; 129 | } 130 | 131 | private void searchModelsText_TextChanged(object sender, EventArgs e) 132 | { 133 | searchTexturesTimer.Stop(); 134 | searchTexturesTimer.Start(); 135 | } 136 | 137 | private void searchModelsTimer_Tick(object sender, EventArgs e) 138 | { 139 | if (searchTexturesText.Text.Length > 0) 140 | { 141 | searchTexturesText.BackColor = Color.Yellow; 142 | clearSearchTexturesText.Enabled = true; 143 | } 144 | else 145 | { 146 | searchTexturesText.BackColor = Color.White; 147 | clearSearchTexturesText.Enabled = false; 148 | } 149 | 150 | searchTexturesTimer.Stop(); 151 | 152 | refreshTexturesListBox(); 153 | } 154 | 155 | private void clearSearchModelsText_Click(object sender, EventArgs e) 156 | { 157 | searchTexturesText.Clear(); 158 | } 159 | 160 | private void modelsListBox_SelectedIndexChanged(object sender, EventArgs e) 161 | { 162 | } 163 | 164 | private void toolStripButton1_Click(object sender, EventArgs e) 165 | { 166 | } 167 | 168 | private void snapCameraToModel() 169 | { 170 | } 171 | 172 | private void showAxesButton_Click(object sender, EventArgs e) 173 | { 174 | glControl1.Invalidate(); 175 | } 176 | 177 | private void showWireframeButton_Click(object sender, EventArgs e) 178 | { 179 | glControl1.Invalidate(); 180 | } 181 | 182 | private void showAABBButton_Click(object sender, EventArgs e) 183 | { 184 | glControl1.Invalidate(); 185 | } 186 | 187 | private void renderModeWireframeButton_Click(object sender, EventArgs e) 188 | { 189 | } 190 | 191 | private void showBoundingBoxButton_Click(object sender, EventArgs e) 192 | { 193 | glControl1.Invalidate(); 194 | } 195 | 196 | private void glControl1_KeyDown(object sender, KeyEventArgs e) 197 | { 198 | } 199 | 200 | private void renderModeWireframeButton_CheckedChanged(object sender, EventArgs e) 201 | { 202 | } 203 | 204 | private void renderModeSmoothButton_CheckedChanged(object sender, EventArgs e) 205 | { 206 | } 207 | 208 | private void glControl1_MouseEnter(object sender, EventArgs e) 209 | { 210 | } 211 | 212 | private void showAutoLODModelsButton_CheckedChanged(object sender, EventArgs e) 213 | { 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/TextureBrowser.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 238, 63 122 | 123 | 124 | 354, 63 125 | 126 | 127 | 133, 102 128 | 129 | 130 | 187 131 | 132 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Forms/TextureBrowserGLControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ps2ls.Controls; 6 | 7 | namespace ps2ls.Forms 8 | { 9 | public class TextureBrowserGLControl : CustomGLControl 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Graphics/Materials/DrawStyle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.XPath; 6 | using ps2ls.Cryptography; 7 | 8 | namespace ps2ls.Graphics.Materials 9 | { 10 | public class DrawStyle 11 | { 12 | public string Name { get; private set; } 13 | public uint NameHash { get; private set; } 14 | public string Effect { get; private set; } 15 | public uint VertexLayoutNameHash { get; private set; } 16 | 17 | private DrawStyle() 18 | { 19 | Name = string.Empty; 20 | NameHash = 0; 21 | Effect = string.Empty; 22 | VertexLayoutNameHash = 0; 23 | } 24 | 25 | public static DrawStyle LoadFromXPathNavigator(XPathNavigator navigator) 26 | { 27 | if (navigator == null) 28 | { 29 | return null; 30 | } 31 | 32 | DrawStyle drawStyle = new DrawStyle(); 33 | 34 | //name 35 | drawStyle.Name = navigator.GetAttribute("Name", string.Empty); 36 | drawStyle.NameHash = Jenkins.OneAtATime(drawStyle.Name); 37 | 38 | //effect 39 | drawStyle.Effect = navigator.GetAttribute("Effect", String.Empty); 40 | 41 | //input layout 42 | String vertexLayout = navigator.GetAttribute("InputLayout", String.Empty); 43 | drawStyle.VertexLayoutNameHash = Jenkins.OneAtATime(vertexLayout); 44 | 45 | return drawStyle; 46 | } 47 | 48 | public override string ToString() 49 | { 50 | return Name; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Graphics/Materials/MaterialDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.XPath; 6 | using ps2ls.Cryptography; 7 | 8 | namespace ps2ls.Graphics.Materials 9 | { 10 | public class MaterialDefinition 11 | { 12 | public string Name { get; private set; } 13 | public uint NameHash { get; private set; } 14 | public string Type { get; private set; } 15 | public uint TypeHash { get; private set; } 16 | public List DrawStyles { get; private set; } 17 | 18 | private MaterialDefinition() 19 | { 20 | Name = string.Empty; 21 | NameHash = 0; 22 | Type = string.Empty; 23 | TypeHash = 0; 24 | DrawStyles = new List(); 25 | } 26 | 27 | public static MaterialDefinition LoadFromXPathNavigator(XPathNavigator navigator) 28 | { 29 | if (navigator == null) return null; 30 | 31 | MaterialDefinition materialDefinition = new MaterialDefinition(); 32 | 33 | //name 34 | materialDefinition.Name = navigator.GetAttribute("Name", string.Empty); 35 | materialDefinition.NameHash = Jenkins.OneAtATime(materialDefinition.Name); 36 | 37 | //type 38 | materialDefinition.Type = navigator.GetAttribute("Type", string.Empty); 39 | materialDefinition.TypeHash = Jenkins.OneAtATime(materialDefinition.Type); 40 | 41 | //draw styles 42 | XPathNodeIterator entries = navigator.Select("./Array[@Name='DrawStyles']/Object[@Class='DrawStyle']"); 43 | 44 | while (entries.MoveNext()) 45 | { 46 | DrawStyle drawStyle = DrawStyle.LoadFromXPathNavigator(entries.Current); 47 | if (drawStyle != null) materialDefinition.DrawStyles.Add(drawStyle); 48 | } 49 | 50 | return materialDefinition; 51 | } 52 | 53 | public override string ToString() 54 | { 55 | return Name; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Graphics/Materials/MaterialDefinitionManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Xml; 7 | using System.Xml.XPath; 8 | 9 | namespace ps2ls.Graphics.Materials 10 | { 11 | public class MaterialDefinitionManager 12 | { 13 | #region Singleton 14 | private static MaterialDefinitionManager instance = null; 15 | 16 | public static void CreateInstance() 17 | { 18 | instance = new MaterialDefinitionManager(); 19 | 20 | StringReader stringReader = new StringReader(Properties.Resources.materials_3); 21 | instance.loadFromStringReader(stringReader); 22 | } 23 | 24 | public static void DeleteInstance() 25 | { 26 | instance = null; 27 | } 28 | 29 | public static MaterialDefinitionManager Instance { get { return instance; } } 30 | #endregion 31 | 32 | public Dictionary MaterialDefinitions { get; private set; } 33 | public Dictionary ParameterGroups { get; private set; } 34 | public Dictionary VertexLayouts { get; private set; } 35 | 36 | MaterialDefinitionManager() 37 | { 38 | MaterialDefinitions = new Dictionary(); 39 | ParameterGroups = new Dictionary(); 40 | VertexLayouts = new Dictionary(); 41 | } 42 | 43 | private void loadFromStringReader(StringReader stringReader) 44 | { 45 | if (stringReader == null) 46 | return; 47 | 48 | XPathDocument document = null; 49 | 50 | try 51 | { 52 | document = new XPathDocument(stringReader); 53 | } 54 | catch (Exception) 55 | { 56 | return; 57 | } 58 | 59 | XPathNavigator navigator = document.CreateNavigator(); 60 | 61 | bool loadedSuccesfully = true; 62 | 63 | //vertex layouts 64 | loadedSuccesfully = loadVertexLayoutsByXPathNavigator(navigator.Clone()) && loadedSuccesfully; 65 | 66 | //parameter groups 67 | loadedSuccesfully = loadParameterGroupsByXPathNavigator(navigator.Clone()) && loadedSuccesfully; 68 | 69 | //material definitions 70 | loadedSuccesfully = loadMaterialDefinitionsByXPathNavigator(navigator.Clone()) && loadedSuccesfully; 71 | 72 | 73 | if (loadedSuccesfully) 74 | { 75 | Console.WriteLine("Material Data Loaded"); 76 | } 77 | else 78 | { 79 | Console.WriteLine("Error Loading Material Data"); 80 | } 81 | } 82 | 83 | private bool loadMaterialDefinitionsByXPathNavigator(XPathNavigator navigator) 84 | { 85 | XPathNodeIterator materialDefinitions = null; 86 | 87 | try 88 | { 89 | materialDefinitions = navigator.Select("/Object/Array[@Name='MaterialDefinitions']/Object[@Class='MaterialDefinition']"); 90 | } 91 | catch (Exception) 92 | { 93 | return false; 94 | } 95 | 96 | while (materialDefinitions.MoveNext()) 97 | { 98 | MaterialDefinition materialDefinition = MaterialDefinition.LoadFromXPathNavigator(materialDefinitions.Current); 99 | 100 | if (materialDefinition != null && !hasMaterialHash(materialDefinition.NameHash)) 101 | { 102 | MaterialDefinitions.Add(materialDefinition.NameHash, materialDefinition); 103 | } 104 | } 105 | return true; 106 | } 107 | 108 | 109 | private bool loadParameterGroupsByXPathNavigator(XPathNavigator navigator) 110 | { 111 | XPathNodeIterator parameterGroups = null; 112 | 113 | try 114 | { 115 | parameterGroups = navigator.Select("/Object/Array[@Name='ParameterGroups']/Object[@Class='ParameterGroup']"); 116 | } 117 | catch (Exception) 118 | { 119 | return false; 120 | } 121 | 122 | while (parameterGroups.MoveNext()) 123 | { 124 | ParameterGroup parameterGroup = ParameterGroup.LoadFromXPathNavigator(parameterGroups.Current); 125 | 126 | if (parameterGroup != null && !hasParameterGroupHash(parameterGroup.NameHash)) 127 | { 128 | ParameterGroups.Add(parameterGroup.NameHash, parameterGroup); 129 | } 130 | } 131 | return true; 132 | } 133 | 134 | private bool loadVertexLayoutsByXPathNavigator(XPathNavigator navigator) 135 | { 136 | //material definitions 137 | XPathNodeIterator vertexLayouts = null; 138 | 139 | try 140 | { 141 | vertexLayouts = navigator.Select("/Object/Array[@Name='InputLayouts']/Object[@Class='InputLayout']"); 142 | } 143 | catch (Exception) 144 | { 145 | return false; 146 | } 147 | 148 | while (vertexLayouts.MoveNext()) 149 | { 150 | VertexLayout vertexLayout = VertexLayout.LoadFromXPathNavigator(vertexLayouts.Current); 151 | 152 | if (vertexLayout != null && false == VertexLayouts.ContainsKey(vertexLayout.NameHash)) 153 | { 154 | VertexLayouts.Add(vertexLayout.NameHash, vertexLayout); 155 | } 156 | } 157 | return true; 158 | } 159 | 160 | public MaterialDefinition GetMaterialDefinitionFromHash(UInt32 materialDefinitionHash) 161 | { 162 | MaterialDefinition materialDefinition = null; 163 | 164 | try 165 | { 166 | MaterialDefinitions.TryGetValue(materialDefinitionHash, out materialDefinition); 167 | } 168 | catch (Exception) 169 | { 170 | throw new Exception("Material definition could not be found."); 171 | } 172 | 173 | return materialDefinition; 174 | } 175 | 176 | public bool hasMaterialHash(uint definitionHash) 177 | { 178 | return MaterialDefinitions.ContainsKey(definitionHash); 179 | } 180 | public bool hasParameterGroupHash(uint definitionHash) 181 | { 182 | return ParameterGroups.ContainsKey(definitionHash); 183 | } 184 | public bool hasVertexHash(uint definitionHash) 185 | { 186 | return VertexLayouts.ContainsKey(definitionHash); 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Graphics/Materials/ParameterGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Xml.XPath; 7 | using ps2ls.Cryptography; 8 | 9 | namespace ps2ls.Graphics.Materials 10 | { 11 | public class ParameterGroup 12 | { 13 | public string Name { get; private set; } 14 | public uint NameHash { get; private set; } 15 | public List Parameters { get; private set; } 16 | private ParameterGroup() 17 | { 18 | Name = string.Empty; 19 | NameHash = 0; 20 | Parameters = new List(); 21 | } 22 | 23 | public static ParameterGroup LoadFromXPathNavigator(XPathNavigator navigator) 24 | { 25 | if (navigator == null) return null; 26 | 27 | ParameterGroup parameterGroup = new ParameterGroup(); 28 | 29 | //name 30 | parameterGroup.Name = navigator.GetAttribute("Name", string.Empty); 31 | parameterGroup.NameHash = Jenkins.OneAtATime(parameterGroup.Name); 32 | 33 | //parameters 34 | XPathNodeIterator entries = navigator.Select("./Array[@Name='Parameters']/Object[@Class='IntParameter']"); //TODO, match with other parameters, floatparemeter, float4perameter etc... 35 | 36 | while (entries.MoveNext()) 37 | { 38 | Parameter parameter = Parameter.LoadFromXPathNavigator(entries.Current); 39 | if (parameter != null) parameterGroup.Parameters.Add(parameter); 40 | } 41 | 42 | return parameterGroup; 43 | } 44 | 45 | public class Parameter 46 | { 47 | public string Name { get; private set; } 48 | public uint NameHash { get; private set; } 49 | public string Variable { get; private set; } 50 | public uint VariableHash { get; private set; } 51 | 52 | public object defaultValue; 53 | 54 | private Parameter() 55 | { 56 | Name = string.Empty; 57 | NameHash = 0; 58 | Variable = string.Empty; 59 | VariableHash = 0; 60 | defaultValue = 0; 61 | } 62 | 63 | public static Parameter LoadFromXPathNavigator(XPathNavigator navigator) 64 | { 65 | if (navigator == null) return null; 66 | 67 | Parameter parameter = new Parameter(); 68 | 69 | //name 70 | parameter.Name = navigator.GetAttribute("Name", string.Empty); 71 | parameter.NameHash = Jenkins.OneAtATime(parameter.Name); 72 | 73 | //variable 74 | parameter.Variable = navigator.GetAttribute("Variable", string.Empty); 75 | parameter.VariableHash = Jenkins.OneAtATime(parameter.Variable); 76 | 77 | //value 78 | parameter.defaultValue = navigator.GetAttribute("Default", string.Empty); //TODO, parse to number 79 | 80 | return parameter; 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Graphics/Materials/VertexLayout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml; 6 | using ps2ls.Cryptography; 7 | using System.Xml.XPath; 8 | using System.IO; 9 | 10 | namespace ps2ls.Graphics.Materials 11 | { 12 | public class VertexLayout 13 | { 14 | public class Entry 15 | { 16 | public enum DataTypes 17 | { 18 | None = -1, 19 | Float3, 20 | D3dcolor, 21 | Float2, 22 | Float4, 23 | ubyte4n, 24 | float16_2, 25 | Short2, 26 | Float1, 27 | Short4, 28 | } 29 | 30 | private static String[] dataTypeStrings = 31 | { 32 | "Float3", 33 | "D3dcolor", 34 | "Float2", 35 | "Float4", 36 | "ubyte4n", 37 | "float16_2", 38 | "Short2", 39 | "Float1", 40 | "Short4" 41 | }; 42 | 43 | public static Int32[] dataTypeSizes = 44 | { 45 | 12, //Float3 46 | 4, //D3dcolor 47 | 8, //Float2 48 | 16, //Float4 49 | 4, //ubyte4n 50 | 8, //float16_2 51 | 4, //Short2 52 | 4, //Float1 53 | 8, //Short4 54 | }; 55 | 56 | public enum DataUsages 57 | { 58 | None = -1, 59 | Position, 60 | Color, 61 | Texcoord, 62 | Tangent, 63 | Binormal, 64 | BlendWeight, 65 | BlendIndices, 66 | Normal 67 | } 68 | 69 | private static String[] dataUsageStrings = 70 | { 71 | "Position", 72 | "Color", 73 | "Texcoord", 74 | "Tangent", 75 | "Binormal", 76 | "BlendWeight", 77 | "BlendIndices", 78 | "Normal" 79 | }; 80 | 81 | public UInt32 Stream; 82 | public DataTypes DataType; 83 | public DataUsages DataUsage; 84 | public UInt32 DataUsageIndex; 85 | 86 | public static void GetDataTypeFromString(String typeString, out DataTypes type) 87 | { 88 | for (Int32 i = 0; i < dataTypeStrings.Length; ++i) 89 | { 90 | if (String.Compare(typeString, dataTypeStrings[i], true) == 0) 91 | { 92 | type = (DataTypes)i; 93 | return; 94 | } 95 | } 96 | 97 | type = DataTypes.None; 98 | } 99 | 100 | public static void GetDataUsageFromString(String usageString, out DataUsages usage) 101 | { 102 | for (Int32 i = 0; i < dataUsageStrings.Length; ++i) 103 | { 104 | if (String.Compare(usageString, dataUsageStrings[i], true) == 0) 105 | { 106 | usage = (DataUsages)i; 107 | return; 108 | } 109 | } 110 | 111 | usage = DataUsages.None; 112 | } 113 | 114 | public static Int32 GetDataTypeSize(DataTypes type) 115 | { 116 | return dataTypeSizes[(Int32)type]; 117 | } 118 | } 119 | 120 | public String Name { get; private set; } 121 | public UInt32 NameHash { get; private set; } 122 | public List Entries { get; private set; } 123 | 124 | private VertexLayout() 125 | { 126 | Entries = new List(); 127 | } 128 | 129 | public static VertexLayout LoadFromXPathNavigator(XPathNavigator navigator) 130 | { 131 | if (navigator == null) 132 | { 133 | return null; 134 | } 135 | 136 | VertexLayout vertexLayout = new VertexLayout(); 137 | 138 | //name 139 | vertexLayout.Name = navigator.GetAttribute("Name", String.Empty); 140 | 141 | //name hash 142 | vertexLayout.NameHash = Jenkins.OneAtATime(vertexLayout.Name); 143 | 144 | //entries 145 | XPathNodeIterator entries = navigator.Select("./Array[@Name='Entries']/Object[@Class='LayoutEntry']"); 146 | 147 | while (entries.MoveNext()) 148 | { 149 | navigator = entries.Current; 150 | 151 | VertexLayout.Entry entry = new Entry(); 152 | 153 | //stream 154 | entry.Stream = UInt32.Parse(navigator.GetAttribute("Stream", String.Empty)); 155 | 156 | //data type 157 | String dataTypeString = navigator.GetAttribute("Type", String.Empty); 158 | Entry.GetDataTypeFromString(dataTypeString, out entry.DataType); 159 | 160 | //data usage 161 | String dataUsageString = navigator.GetAttribute("Usage", String.Empty); 162 | Entry.GetDataUsageFromString(dataUsageString, out entry.DataUsage); 163 | 164 | //data usage index 165 | entry.DataUsageIndex = UInt32.Parse(navigator.GetAttribute("UsageIndex", String.Empty)); 166 | 167 | vertexLayout.Entries.Add(entry); 168 | } 169 | 170 | return vertexLayout; 171 | } 172 | 173 | public override string ToString() 174 | { 175 | return Name; 176 | } 177 | 178 | public Boolean HasDataUsage(Entry.DataUsages usage) 179 | { 180 | return GetEntryCountByDataUsage(usage) > 0; 181 | } 182 | 183 | public Int32 GetEntryCountByDataUsage(Entry.DataUsages usage) 184 | { 185 | Int32 count = 0; 186 | 187 | foreach (Entry entry in Entries) 188 | { 189 | if (entry.DataUsage == usage) 190 | { 191 | ++count; 192 | } 193 | } 194 | 195 | return count; 196 | } 197 | public bool GetEntryInfoFromDataUsageAndUsageIndex(Entry.DataUsages dataUsage, int usageIndex, out Entry.DataTypes dataType, out int stream, out int offset) 198 | { 199 | dataType = Entry.DataTypes.None; 200 | stream = 0; 201 | offset = 0; 202 | 203 | uint previousStream = 0; 204 | 205 | foreach (Entry entry in Entries) 206 | { 207 | if (entry.Stream != previousStream) 208 | { 209 | offset = 0; 210 | } 211 | 212 | 213 | if (entry.DataUsage == dataUsage && entry.DataUsageIndex == usageIndex) 214 | { 215 | dataType = entry.DataType; 216 | stream = Convert.ToInt32(entry.Stream); 217 | return true; 218 | } 219 | 220 | //increment offset 221 | offset += Entry.GetDataTypeSize(entry.DataType); 222 | 223 | //set previous stream for next iteration 224 | previousStream = entry.Stream; 225 | } 226 | 227 | return false; 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/IO/AssimpLIbraryTestStatic.cs: -------------------------------------------------------------------------------- 1 | using Assimp; 2 | using OpenTK; 3 | using ps2ls.Assets; 4 | using ps2ls.Graphics.Materials; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Globalization; 8 | using System.IO; 9 | 10 | namespace ps2ls.IO 11 | { 12 | public static class AssimpLIbraryTestStatic 13 | { 14 | public static void TestWork(Model model, string directory, ModelExporterStatic.ExportOptions options) 15 | { 16 | ModelExporterStatic.PackageDirectory(model.name, ref directory, options); 17 | 18 | //ModelExporterStatic.ExportLinkedTextures(model, directory, options); 19 | 20 | string path = directory + @"\" + Path.GetFileNameWithoutExtension(model.name) + ".gltf2"; 21 | 22 | AssimpContext context = new AssimpContext(); 23 | Scene scene = new Scene(); 24 | scene.RootNode = new Node("Root"); 25 | for (int i = 0; i < model.meshes.Length; i++) 26 | { 27 | Assimp.Mesh aMesh = new Assimp.Mesh(model.name + "_Mesh" + i, PrimitiveType.Triangle); 28 | Assets.Mesh mesh = model.meshes[i]; 29 | VertexLayout vertexLayout = ModelExporterStatic.GetVertexLayoutFromMaterialHash(model.dma.materials[(int)mesh.drawCallOffset].MaterialDefinitionHash); 30 | Vector3[] positionBuffer = ModelExporterStatic.GetPositionBuffer(mesh, vertexLayout, options, out bool _, out int _); 31 | aMesh.Vertices.AddRange(VectorTKToAVector(positionBuffer)); 32 | int[] indexBuffer = ModelExporterStatic.GetIndexBuffer(mesh); 33 | if (!aMesh.SetIndices(indexBuffer, 3)) Console.WriteLine("Failed To Set Indices"); 34 | scene.Meshes.Add(aMesh); 35 | } 36 | Console.WriteLine(path); 37 | context.ExportFile(scene, path, "gltf2"); 38 | } 39 | 40 | private static Vector3D[] VectorTKToAVector(Vector3[] list) 41 | { 42 | Vector3D[] toReturn = new Vector3D[list.Length]; 43 | for(int i = 0; i < list.Length; i++) 44 | { 45 | toReturn[i] = new Vector3D(list[i].X, list[i].Y, list[i].Z); 46 | } 47 | return toReturn; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/IO/BinaryReaderBigEndian.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace ps2ls.IO 8 | { 9 | public class BinaryReaderBigEndian : BinaryReader 10 | { 11 | public BinaryReaderBigEndian(Stream stream) 12 | : base(stream) 13 | { 14 | } 15 | 16 | public override int Read(byte[] buffer, int index, int count) 17 | { 18 | return base.Read(buffer, index, count); 19 | } 20 | 21 | public override Int16 ReadInt16() 22 | { 23 | byte[] bytes = base.ReadBytes(2); 24 | Array.Reverse(bytes); 25 | return BitConverter.ToInt16(bytes, 0); 26 | } 27 | 28 | public override UInt16 ReadUInt16() 29 | { 30 | byte[] bytes = base.ReadBytes(2); 31 | Array.Reverse(bytes); 32 | return BitConverter.ToUInt16(bytes, 0); 33 | } 34 | 35 | public override Int32 ReadInt32() 36 | { 37 | byte[] bytes = base.ReadBytes(4); 38 | Array.Reverse(bytes); 39 | return BitConverter.ToInt32(bytes, 0); 40 | } 41 | 42 | public override UInt32 ReadUInt32() 43 | { 44 | byte[] bytes = base.ReadBytes(4); 45 | Array.Reverse(bytes); 46 | return BitConverter.ToUInt32(bytes, 0); 47 | } 48 | 49 | public override Int64 ReadInt64() 50 | { 51 | byte[] bytes = base.ReadBytes(8); 52 | Array.Reverse(bytes); 53 | return BitConverter.ToInt64(bytes, 0); 54 | } 55 | 56 | public override UInt64 ReadUInt64() 57 | { 58 | byte[] bytes = base.ReadBytes(8); 59 | Array.Reverse(bytes); 60 | return BitConverter.ToUInt64(bytes, 0); 61 | } 62 | 63 | public override Single ReadSingle() 64 | { 65 | byte[] bytes = base.ReadBytes(4); 66 | Array.Reverse(bytes); 67 | return BitConverter.ToSingle(bytes, 0); 68 | } 69 | 70 | public override Double ReadDouble() 71 | { 72 | byte[] bytes = base.ReadBytes(8); 73 | Array.Reverse(bytes); 74 | return BitConverter.ToDouble(bytes, 0); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/IO/TextureExporterStatic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SDI = System.Drawing.Imaging; 6 | using ps2ls.Assets; 7 | using ps2ls.IO; 8 | using System.ComponentModel; 9 | using System.IO; 10 | using System.Windows.Forms; 11 | using SD = System.Drawing; 12 | 13 | 14 | namespace ps2ls.IO 15 | { 16 | public static class TextureExporterStatic 17 | { 18 | public class TextureFormatInfo 19 | { 20 | public string Name { get; internal set; } 21 | public string Extension { get; internal set; } 22 | public SDI.ImageFormat ImageFormat { get; internal set; } 23 | 24 | internal TextureFormatInfo() 25 | { 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return Name + @" (*." + Extension + @")"; 31 | } 32 | } 33 | 34 | public static TextureFormatInfo[] TextureFormats; 35 | 36 | static TextureExporterStatic() 37 | { 38 | createTextureFormats(); 39 | } 40 | 41 | private static void createTextureFormats() 42 | { 43 | List textureFormats = new List(); 44 | 45 | //Portable Network Graphics (*.png) 46 | TextureFormatInfo textureFormat = new TextureFormatInfo(); 47 | textureFormat.Name = "Portable Network Graphics"; 48 | textureFormat.Extension = "png"; 49 | textureFormat.ImageFormat = SDI.ImageFormat.Png; 50 | textureFormats.Add(textureFormat); 51 | 52 | //Microsoft Windows Bitmap (*.bmp) 53 | textureFormat = new TextureFormatInfo(); 54 | textureFormat.Name = "Windows Bitmap"; 55 | textureFormat.Extension = "bmp"; 56 | textureFormat.ImageFormat = SDI.ImageFormat.Bmp; 57 | textureFormats.Add(textureFormat); 58 | 59 | //Tagged Image File Format (*.tiff) 60 | textureFormat = new TextureFormatInfo(); 61 | textureFormat.Name = "Tagged Image File Format"; 62 | textureFormat.Extension = "tiff"; 63 | textureFormat.ImageFormat = SDI.ImageFormat.Tiff; 64 | textureFormats.Add(textureFormat); 65 | 66 | //Joint Photographic Experts Group (*.jpeg) 67 | textureFormat = new TextureFormatInfo(); 68 | textureFormat.Name = "Joint Photographic Experts Group"; 69 | textureFormat.Extension = "jpeg"; 70 | textureFormat.ImageFormat = SDI.ImageFormat.Jpeg; 71 | textureFormats.Add(textureFormat); 72 | 73 | TextureFormats = textureFormats.ToArray(); 74 | } 75 | 76 | public static bool exportTexture(string textureString, string directory, TextureFormatInfo textureFormat) 77 | { 78 | MemoryStream textureMemoryStream = AssetManager.Instance.CreateAssetMemoryStreamByName(textureString); 79 | 80 | if (textureMemoryStream == null) 81 | return false; 82 | 83 | SD.Image image; 84 | switch (Path.GetExtension(textureString).ToLower()) 85 | { 86 | case ".png": 87 | case ".jpeg": 88 | case ".jpg": 89 | image = TextureManager.CommonStreamToBitmap(textureMemoryStream); 90 | break; 91 | default: 92 | image = TextureManager.DDSStreamToBitmap(textureMemoryStream); 93 | break; 94 | } 95 | 96 | 97 | if (image == null) 98 | return false; 99 | string path = directory + @"\" + Path.GetFileNameWithoutExtension(textureString) + '.' + textureFormat.Extension; 100 | Console.WriteLine(path); 101 | image.Save(path, textureFormat.ImageFormat); 102 | 103 | return true; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/OpenTK.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Windows.Forms; 4 | using ps2ls.Assets; 5 | using ps2ls.Forms; 6 | using ps2ls.Graphics.Materials; 7 | using Microsoft.Win32; 8 | 9 | namespace ps2ls 10 | { 11 | static class Program 12 | { 13 | /// 14 | /// The main entry point for the application. 15 | /// 16 | [STAThread] 17 | static void Main() 18 | { 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | 22 | // Setup the asset location 23 | if (Properties.Settings.Default.AssetDirectory == String.Empty) 24 | { 25 | // No valid location, try to work it out from the registry 26 | Properties.Settings.Default.AssetDirectory = getDefaultAssetDirectory(); 27 | Properties.Settings.Default.Save(); 28 | } 29 | else 30 | { 31 | // Make sure the saved asset location still exists 32 | if (!Directory.Exists(Properties.Settings.Default.AssetDirectory)) 33 | { 34 | // Directory doesn't exist, wipe the setting. 35 | Properties.Settings.Default.AssetDirectory = ""; 36 | Properties.Settings.Default.Save(); 37 | } 38 | } 39 | 40 | AssetManager.CreateInstance(); 41 | 42 | AboutBox.CreateInstance(); 43 | MainForm.CreateInstance(); 44 | 45 | 46 | MaterialDefinitionManager.CreateInstance(); 47 | 48 | Application.Run(MainForm.Instance); 49 | } 50 | 51 | /// 52 | /// Try to get the Planetside 2 asset directory by looking in the registry for Planetside 2 installation directories. 53 | /// 54 | private static string getDefaultAssetDirectory() 55 | { 56 | RegistryKey key = null; 57 | 58 | // non-steam install 59 | key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\LaunchPad.exe"); 60 | 61 | if (key != null && key.GetValue("") != null) 62 | { 63 | String defaultDirectory; 64 | defaultDirectory = key.GetValue("").ToString(); 65 | defaultDirectory = Path.GetDirectoryName(defaultDirectory) + @"\Resources\Assets"; 66 | 67 | if (Directory.Exists(defaultDirectory)) 68 | { 69 | return defaultDirectory; 70 | } 71 | } 72 | 73 | // steam install 74 | key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 218230"); 75 | 76 | if (key != null && key.GetValue("InstallLocation") != null) 77 | { 78 | String defaultDirectory; 79 | defaultDirectory = key.GetValue("InstallLocation").ToString(); 80 | defaultDirectory += @"\Resources\Assets"; 81 | 82 | if (Directory.Exists(defaultDirectory)) 83 | { 84 | return defaultDirectory; 85 | } 86 | } 87 | 88 | return String.Empty; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ps2ls2")] 9 | [assembly: AssemblyDescription("ps2ls2 is a small program that allows you to browse and extract Planetside 2 pack2 files and model files.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("NatCracken")] 12 | [assembly: AssemblyProduct("ps2ls2")] 13 | [assembly: AssemblyCopyright("ps2ls 2012-2013 Colin Basnett, Roy Awesome. ps2ls2 2020-2023 Various Contributors")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("73cfcb94-c51c-47f6-8b03-0a6bf9074614")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.0.3")] 36 | [assembly: AssemblyFileVersion("2.0.3")] 37 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ps2ls.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string AssetDirectory { 30 | get { 31 | return ((string)(this["AssetDirectory"])); 32 | } 33 | set { 34 | this["AssetDirectory"] = value; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/BastionAtDawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/BastionAtDawn.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/DocumentWrite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/DocumentWrite.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/FMOD Logo Black - White Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/FMOD Logo Black - White Background.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/Image-scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/Image-scaled.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/arrow-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/arrow-left.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/arrow-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/arrow-right.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/axes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/axes.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/bones.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/bones.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box--arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box--arrow.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box--minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box--minus.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box--plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box--plus.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box-arrow-drive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box-arrow-drive.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box-document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box-document.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box-search-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box-search-result.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box-small.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box-zipper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box-zipper.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/box.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/bug--plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/bug--plus.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/bug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/bug.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/chain-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/chain-small.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/chain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/chain.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/counter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/counter.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/cube-medium-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/cube-medium-12.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/cube-medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/cube-medium.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/cube.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/direction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/direction.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-arrow-drive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-arrow-drive.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-export.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-import.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-plus.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-search-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-search-result.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-tex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-tex.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-text.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document-xaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document-xaml.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/document.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/door-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/door-open.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/drive-download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/drive-download.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/folder-horizontal-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/folder-horizontal-open.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/folder-import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/folder-import.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/folder-small-horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/folder-small-horizontal.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/gear.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/grid.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/image.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/magnifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/magnifier.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/music.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/ps2ls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/ps2ls.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/question.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/robot.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/robotic-arm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/robotic-arm.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/smooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/smooth.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/sphere-aabb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/sphere-aabb.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/sphere-aabb1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/sphere-aabb1.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/sphere-aabb2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/sphere-aabb2.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/sphere-wire-occluder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/sphere-wire-occluder.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/terminal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/terminal.gif -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/textured.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/textured.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/textured1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/textured1.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/tree-magnifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/tree-magnifier.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/tree-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/tree-small.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/tree.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/ui-text-field-clear-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/ui-text-field-clear-button.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Resources/wireframe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/Resources/wireframe.png -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/blur_horizontal.frag: -------------------------------------------------------------------------------- 1 | void main(void) 2 | { 3 | vec4 color = vec4(0.0); 4 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/blur_vertical.frag: -------------------------------------------------------------------------------- 1 | void main(void) 2 | { 3 | vec4 color = vec4(0.0); 4 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/default.frag: -------------------------------------------------------------------------------- 1 | varying vec3 normal; 2 | varying vec3 lightDirection; 3 | varying vec2 texcood; 4 | 5 | void main() 6 | { 7 | const vec4 ambientColor = vec4(0.25, 0.25, 0.25, 1.0); 8 | const vec4 diffuseColor = vec4(1.0, 1.0, 1.0, 1.0); 9 | 10 | vec3 normalizedNormal = normalize(normal); 11 | vec3 noralizedLightDirection = normalize(lightDirection); 12 | 13 | float diffuseTerm = clamp(dot(normalizedNormal, noralizedLightDirection), 0.0, 1.0); 14 | 15 | gl_FragColor = gl_Color * (ambientColor + (diffuseColor * diffuseTerm)); 16 | 17 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/default.vert: -------------------------------------------------------------------------------- 1 | varying vec3 normal; 2 | varying vec3 lightDirection; 3 | 4 | varying vec2 texcoord; 5 | 6 | void main() 7 | { 8 | gl_Position = ftransform(); 9 | 10 | gl_FrontColor = gl_Color; 11 | 12 | texcoord = gl_MultiTexcoord0; 13 | 14 | vec3 eyeVec = vec3(gl_ModelViewProjectionMatrix * gl_Vertex); 15 | 16 | normal = gl_NormalMatrix * gl_Normal; 17 | 18 | lightDirection = -eyeVec; 19 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/depth.frag: -------------------------------------------------------------------------------- 1 |  2 | void main(void) 3 | { 4 | vec3 color = 1.0 / vec3(gl_FragCoord.z); 5 | 6 | gl_FragColor = vec4(color, 1.0); 7 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/depth.vert: -------------------------------------------------------------------------------- 1 |  2 | void main(void) 3 | { 4 | gl_Position = ftransform(); 5 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/diffuse.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D colorMap; 2 | 3 | void main(void) 4 | { 5 | 6 | gl_FragColor = texture2D(colorMap, gl_TexCoord[0].st); 7 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/diffuse.vert: -------------------------------------------------------------------------------- 1 | void main(void) 2 | { 3 | gl_Position = ftransform(); 4 | 5 | gl_TexCoord[0] = gl_MultiTexCoord0; 6 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/normals.frag: -------------------------------------------------------------------------------- 1 | varying vec4 color; 2 | 3 | void main(void) 4 | { 5 | gl_FragColor = color; 6 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/normals.vert: -------------------------------------------------------------------------------- 1 | varying vec4 color; 2 | 3 | void main(void) 4 | { 5 | gl_Position = ftransform(); 6 | 7 | color.xyz = (-gl_Normal * 0.5) + 0.5; 8 | color.w = 1.0; 9 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/null.frag: -------------------------------------------------------------------------------- 1 | void main(void) 2 | { 3 | gl_FragColor = vec4(0.0); 4 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/Shaders/null.vert: -------------------------------------------------------------------------------- 1 | void main(void) 2 | { 3 | gl_Position = ftransform(); 4 | } -------------------------------------------------------------------------------- /PS2LS/ps2ls/TextureManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using OpenTK.Graphics.OpenGL; 7 | using System.Runtime.InteropServices; 8 | using SD = System.Drawing; 9 | using SDI = System.Drawing.Imaging; 10 | using Pfim; 11 | 12 | namespace ps2ls 13 | { 14 | public class TextureManager 15 | { 16 | public static int LoadFromStream(Stream stream) 17 | { 18 | if (stream == null) 19 | return 0; 20 | 21 | IImage image = Pfim.Pfim.FromStream(stream); 22 | IntPtr dataPtr = Marshal.UnsafeAddrOfPinnedArrayElement(image.Data, 0); 23 | 24 | int glTextureHandle = GL.GenTexture(); 25 | 26 | GL.Enable(EnableCap.Texture2D); 27 | GL.BindTexture(TextureTarget.Texture2D, glTextureHandle); 28 | GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); 29 | GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); 30 | GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, image.Width, image.Height, 0, PixelFormat.Bgra, PixelType.UnsignedInt8888Reversed, dataPtr); 31 | GL.BindTexture(TextureTarget.Texture2D, 0); 32 | GL.Disable(EnableCap.Texture2D); 33 | 34 | return glTextureHandle; 35 | } 36 | 37 | public static SD.Image CommonStreamToBitmap(Stream stream) 38 | { 39 | return SD.Image.FromStream(stream); 40 | } 41 | 42 | public static SD.Image DDSStreamToBitmap(Stream stream) 43 | { 44 | IImage image = Pfim.Pfim.FromStream(stream); 45 | 46 | SDI.PixelFormat format; 47 | 48 | // Convert from Pfim's backend agnostic image format into GDI+'s image format 49 | switch (image.Format) 50 | { 51 | case ImageFormat.Rgba32: 52 | format = SDI.PixelFormat.Format32bppArgb; 53 | break; 54 | default: 55 | // see the sample for more details 56 | throw new NotImplementedException(); 57 | } 58 | 59 | IntPtr dataPtr = Marshal.UnsafeAddrOfPinnedArrayElement(image.Data, 0); 60 | SD.Bitmap bitmap = new SD.Bitmap(image.Width, image.Height, image.Stride, format, dataPtr); 61 | 62 | SDI.BitmapData bdata = bitmap.LockBits(new SD.Rectangle(0, 0, image.Width, image.Height), 63 | SDI.ImageLockMode.WriteOnly, SDI.PixelFormat.Format32bppArgb); 64 | bitmap.UnlockBits(bdata); 65 | 66 | image.Dispose(); 67 | 68 | return bitmap; 69 | 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | using System.IO; 7 | 8 | namespace ps2ls 9 | { 10 | public static class Utils 11 | { 12 | public static Color GenerateRandomColor(Random random, Color mix) 13 | { 14 | Int32 red = random.Next(256); 15 | Int32 green = random.Next(256); 16 | Int32 blue = random.Next(256); 17 | 18 | red = (red + mix.R) / 2; 19 | green = (green + mix.R) / 2; 20 | blue = (blue + mix.R) / 2; 21 | 22 | return Color.FromArgb(red, green, blue); 23 | } 24 | 25 | static int[] knownLocations = { 0x44, 0x0b74, 0x0868, 0x250, 0x354, 0x96c, 0x660, 0x1088, 0x55c, 0x458, 0x764 }; 26 | 27 | public static MemoryStream FixSoundHeader(MemoryStream stream) 28 | { 29 | 30 | for (int i = 0; i < knownLocations.Length; i++) 31 | { 32 | int loc = knownLocations[i]; 33 | stream.Seek(loc + 0x03, SeekOrigin.Begin); 34 | byte c = (byte)stream.ReadByte(); 35 | 36 | if (c == 0x16) 37 | { 38 | stream.Seek(loc, SeekOrigin.Begin); 39 | byte b = (byte)stream.ReadByte(); 40 | b = (byte)(b - 1); 41 | stream.Seek(loc, SeekOrigin.Begin); 42 | stream.WriteByte(b); 43 | break; 44 | } 45 | } 46 | 47 | return stream; 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PS2LS/ps2ls/ps2ls.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatCracken/ps2ls2/d025262e046c877715c2997d2535a1b11fcb6968/PS2LS/ps2ls/ps2ls.ico -------------------------------------------------------------------------------- /PS2LS/research/file formats/adr/Esamir_Props_Spires_Large_01.adr.txt: -------------------------------------------------------------------------------- 1 | 02 50 2 | 01 26 3 | Esamir_Props_Spires_Large_01_LOD0.dme 4 | 5 | 02 26 6 | Esamir_Props_Spires_Large_01_Lod0.dma 7 | 8 | 05 8C 8E FE 9 | 03 01 01 44 10 | 01 29 03 04 11 | 66 4E 66 B8 12 | 13 | 04 - index? 14 | 09 - string length (!) 15 | default0 16 | 17 | 05 - index 18 | 16 - string length 19 | medium_slate_blue.dds 20 | 21 | 01 29 03 04 22 | F8 82 E6 4B 23 | 24 | 04 09 25 | default0 26 | 27 | 05 16 28 | Shared_Natural_DN.dds 29 | 30 | 01 1C 03 04 31 | B4 E3 25 E8 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /PS2LS/research/file formats/cnk0/Amerish_0_0.cnk0.txt: -------------------------------------------------------------------------------- 1 | CNK0 2 | 01 00 00 00 - version 3 | C5 B3 - 46021 (?) 4 | 15 00 - 21 (?) 5 | 59 25 0A 00 - length of file, from next byte offset -------------------------------------------------------------------------------- /PS2LS/research/file formats/dma/AimDummy_HeavyAssault_RifleKneelShoot_Hologram_Lod1.txt: -------------------------------------------------------------------------------- 1 | AimDummy_HeavyAssault_RifleKneelShoot_Hologram_Lod1.dma 2 | 3 | DMAT 4 | 01 00 00 00 - 1 (version) 5 | 45 00 00 00 - 69 (length of texture names) 6 | 7 | cyan.dds 8 | grey.dds 9 | Shared_Characters_TR.dds 10 | Armor_TR_Shared_All_N.dds 11 | 12 | 01 00 00 00 - 1 13 | 1A 9D 78 48 - 14 | A4 01 00 00 - 420 (length of rest of file relative to next byte offset) 15 | 16 | 0F AE BB 50 - 17 | 14 00 00 00 - 20 (entries?) (or bytes per entry) 18 | EB FE DE 27 - 19 | 04 00 00 00 - 4 20 | 05 00 00 00 - 5 21 | 04 00 00 00 - 4 22 | 8F FB D1 A4 - 23 | 91 04 6E 02 - 24 | 01 00 00 00 - 1 25 | 03 00 00 00 - 3 26 | 10 00 00 00 - 16 27 | 00 00 00 00 - 0 28 | E3 DF 5F 3F - 29 | 00 00 80 3F - 30 | 00 00 80 3F - 31 | BB 1E 86 65 - 32 | 00 00 00 00 - 0 33 | 03 00 00 00 - 3 34 | 04 00 00 00 - 4 35 | 3D 0A 57 3E - 36 | 85 15 F7 6F - 37 | 00 00 00 00 - 0 38 | 03 00 00 00 - 3 39 | 04 00 00 00 - 4 40 | 71 3D CA 40 - 41 | F0 9E 85 20 - 42 | 00 00 00 00 - 0 43 | 03 00 00 00 - 3 44 | 04 00 00 00 - 4 45 | 00 00 C0 40 - 46 | 4F E3 24 D1 - 47 | 00 00 00 00 - 0 48 | 03 00 00 00 - 3 49 | 04 00 00 00 - 4 50 | 00 00 A0 40 - 51 | BE 14 72 E1 - 52 | 00 00 00 00 - 0 53 | 03 00 00 00 - 3 54 | 04 00 00 00 - 4 55 | A4 70 BD 3E - 56 | 9D 3D 23 81 - 57 | 00 00 00 00 - 0 58 | 03 00 00 00 - 3 59 | 04 00 00 00 - 4 60 | 66 66 86 3F - 61 | 98 2B 35 D4 - 62 | 00 00 00 00 - 0 63 | 03 00 00 00 - 3 64 | 04 00 00 00 - 4 65 | 66 66 A6 40 - 66 | 9A 1F 25 3E - 67 | 00 00 00 00 - 0 68 | 03 00 00 00 - 3 69 | 04 00 00 00 - 4 70 | 8F C2 75 3D - 71 | 3F 25 A0 9D - 72 | 00 00 00 00 - 0 73 | 03 00 00 00 - 3 74 | 04 00 00 00 - 4 75 | 00 00 A0 42 - 76 | BF 00 89 FA - 77 | 00 00 00 00 - 0 78 | 03 00 00 00 - 3 79 | 04 00 00 00 - 4 80 | 66 66 66 BF - 81 | 1E 60 36 25 - 82 | 00 00 00 00 - 0 83 | 03 00 00 00 - 3 84 | 04 00 00 00 - 4 85 | 0A D7 A3 3D - 86 | 97 92 70 06 - 87 | 00 00 00 00 - 0 88 | 03 00 00 00 - 3 89 | 04 00 00 00 - 4 90 | 00 00 20 40 - 91 | A0 77 D2 5B - 92 | 00 00 00 00 - 0 93 | 03 00 00 00 - 3 94 | 04 00 00 00 - 4 95 | 00 00 00 00 - 0 96 | FB 98 9A DE - 97 | 00 00 00 00 - 0 98 | 03 00 00 00 - 3 99 | 04 00 00 00 - 4 100 | 00 00 A0 41 - 101 | B8 66 4E 66 - 102 | 04 00 00 00 - 4 103 | 05 00 00 00 - 5 104 | 04 00 00 00 - 4 105 | 39 BC 5C 25 - 106 | F7 B1 53 91 - 107 | 04 00 00 00 - 4 108 | 05 00 00 00 - 5 109 | 04 00 00 00 - 4 110 | AB F9 85 40 - 111 | 8D 5A 6C 28 - 112 | 04 00 00 00 - 4 113 | 05 00 00 00 - 5 114 | 04 00 00 00 - 4 115 | 4F 63 A5 35 - 116 | 4F 03 BC 87 - 117 | 00 00 00 00 - 0 118 | 02 00 00 00 - 2 119 | 04 00 00 00 - 4 120 | 00 00 00 00 - 0 -------------------------------------------------------------------------------- /PS2LS/research/file formats/dme/Amerish_Flora_Radial_Daisy01_LOD0.dme: -------------------------------------------------------------------------------- 1 | Amerish_Flora_Radial_Daisy01_LOD0.dme 2 | DME Version = 4 3 | Bytes Per Vertex = 44 4 | Vertex Blocks = 1 <- this seems to be the deciding factor of the format of the vertex data, perhaps this is more of a 'vertex data type' flag. 5 | 6 | Vertex 56 (last one) 7 | 8 | 1. 0.8267132 ; 0.8267132^2 = 0.68345471505424 9 | 2. 0.1515246 ; 0.1515246^2 = 0.02295970440516 10 | 3. -0.5418369 ; -0.5418369^2 = 0.29358722620161 11 | 12 | L = 0.68345471505424 + 0.02295970440516 + 0.29358722620161 = ~1.0 13 | 14 | first 12 bytes are a unit vector normal! 15 | 16 | 4. -0.04840409 ; 0.0023429559287281 = 17 | 5. 0.9786358 ; 0.95772802904164 = 18 | 6. 0.1998224 ; 0.03992899154176 = 19 | 20 | 0.0023429559287281 + 0.95772802904164 + 0.03992899154176 = ~1.0 21 | 22 | v1 ( 0.82671320, 0.1515246, -0.5418369) 23 | v2 (-0.04840409, 0.9786358, 0.1998224) 24 | 25 | second 12 bytes is another unit vector normal and appears to be some sort of tangent as it is perpendicular to the first one. 26 | 27 | dot product of vertex 1 and vertex 2: 28 | 29 | acos(-0.040016300136988 + 0.14828739814068 + -0.10827114976656) = ~90.0 degrees 30 | PROOF RIGHT THERE^^ 31 | 32 | hope to science the next ones are UVs... -------------------------------------------------------------------------------- /PS2LS/research/file formats/dme/Amerish_Flora_Radial_Daisy01_LOD0.txt: -------------------------------------------------------------------------------- 1 | Amerish_Flora_Radial_Daisy01_LOD0.dme 2 | DME Version = 4 3 | Bytes Per Vertex = 44 4 | Vertex Blocks = 1 <- this seems to be the deciding factor of the format of the vertex data, perhaps this is more of a 'vertex data type' flag. 5 | 6 | Vertex 56 (last one) 7 | 8 | 1. 0.8267132 ; 0.8267132^2 = 0.68345471505424 9 | 2. 0.1515246 ; 0.1515246^2 = 0.02295970440516 10 | 3. -0.5418369 ; -0.5418369^2 = 0.29358722620161 11 | 12 | L = 0.68345471505424 + 0.02295970440516 + 0.29358722620161 = ~1.0 13 | 14 | first 12 bytes are a unit vector normal! 15 | 16 | 4. -0.04840409 ; 0.0023429559287281 = 17 | 5. 0.9786358 ; 0.95772802904164 = 18 | 6. 0.1998224 ; 0.03992899154176 = 19 | 20 | 0.0023429559287281 + 0.95772802904164 + 0.03992899154176 = ~1.0 21 | 22 | v1 ( 0.82671320, 0.1515246, -0.5418369) 23 | v2 (-0.04840409, 0.9786358, 0.1998224) 24 | 25 | second 12 bytes is another unit vector normal and appears to be some sort of tangent as it is perpendicular to the first one. 26 | 27 | dot product of vertex 1 and vertex 2: 28 | 29 | acos(-0.040016300136988 + 0.14828739814068 + -0.10827114976656) = ~90.0 degrees 30 | PROOF RIGHT THERE^^ 31 | 32 | hope to science the next 8 bytes are UVs... -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PS2LS 2 | ===== 3 | 4 | A toolkit for inspecting Planetside 2 files. It should work on other Forgelight files with the same structure, but they're not a priority. 5 | 6 | I can be contacted on discord NatCracken#1770. 7 | 8 | Building 9 | ===== 10 | Project was created with Visual Studio 2012. I am working on this iteration in VS 2019 11 | 12 | Dependant on OpenTK 3.3.2 and OpenTK.GLControl 3.1.0, Zlib Portable 1.11.0, and Pfim 0.10.1. (NuGet) 13 | 14 | 15 | Using 16 | ===== 17 | .pack2 files do not contain the names of assets anymore. Thus you will first have to build a namelist using the Build Namelist button in the Asset Browser 18 | 19 | Once completed, point ps2ls2 to the namelist using the Add Namelist button and add .pack2 files using the Add Packs button. 20 | 21 | Credits 22 | ===== 23 | Colin Basnett - Original Author of ps2ls 24 | 25 | https://github.com/RoyAwesome - Currently Maintains ps2ls 26 | 27 | https://github.com/brhumphe - DBG-Pack 28 | 29 | https://github.com/RhettVX - Forgelight-Toolbox 30 | --------------------------------------------------------------------------------