Skip to content

Commit

Permalink
Update for second preview
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed May 11, 2018
1 parent cbf4434 commit 3587856
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 79 deletions.
39 changes: 36 additions & 3 deletions IndustrialPark/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ public RenderableAsset(int assetID, string name, byte[] data) : base(assetID, na
public abstract void Draw(SharpDevice device, SharpShader shader, SharpDX.Direct3D11.Buffer buffer, Matrix viewProjection);
}

public class AssetBSP : RenderableAsset
{
public AssetBSP(int assetID, string name, byte[] data) : base(assetID, name, data) { }

RenderWareModelFile model;

public override void Setup()
{
model = new RenderWareModelFile(Name)
{
rwChunkList = RenderWareFile.ReadFileMethods.ReadRenderWareFile(Data)
};
model.SetForRendering();
HipHopFunctions.renderableAssetList.Add(this);
}

public override void Draw(SharpDevice device, SharpShader shader, SharpDX.Direct3D11.Buffer buffer, Matrix viewProjection)
{
model.Render(device, shader, buffer, viewProjection);
}
}

public class AssetJSP : RenderableAsset
{
public AssetJSP(int assetID, string name, byte[] data) : base(assetID, name, data) { }
Expand Down Expand Up @@ -169,11 +191,22 @@ public override void Setup()

public override void Draw(SharpDevice device, SharpShader shader, SharpDX.Direct3D11.Buffer buffer, Matrix viewProjection)
{
if (AssetPICK.pick.pickEntries.ContainsKey(pickEntryID))
if (AssetPICK.pick != null)
{
if (HipHopFunctions.assetDictionary.ContainsKey(AssetPICK.pick.pickEntries[pickEntryID].unknown4))
if (AssetPICK.pick.pickEntries.ContainsKey(pickEntryID))
{
if (HipHopFunctions.assetDictionary.ContainsKey(AssetPICK.pick.pickEntries[pickEntryID].unknown4))
{
(HipHopFunctions.assetDictionary[AssetPICK.pick.pickEntries[pickEntryID].unknown4] as AssetMODL).Draw(device, shader, buffer, world * viewProjection);
}
else
{
SharpRenderer.DrawCube(world);
}
}
else
{
(HipHopFunctions.assetDictionary[AssetPICK.pick.pickEntries[pickEntryID].unknown4] as AssetMODL).Draw(device, shader, buffer, world * viewProjection);
SharpRenderer.DrawCube(world);
}
}
else
Expand Down
34 changes: 31 additions & 3 deletions IndustrialPark/HipHopFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ public static void openFilePair()
else if (i is Section_STRM strm) hipSTRM = strm;
else throw new Exception();
}
else currentlyOpenHip = null;
else
{
currentlyOpenHip = null;
hipHIPA = null;
hipPACK = null;
hipDICT = null;
hipSTRM = null;
}

if (File.Exists(currentlyOpenHop))
foreach (HipSection i in HipFileToHipArray(currentlyOpenHop))
Expand All @@ -82,7 +89,14 @@ public static void openFilePair()
else if (i is Section_STRM strm) hopSTRM = strm;
else throw new Exception();
}
else currentlyOpenHop = null;
else
{
currentlyOpenHop = null;
hopHIPA = null;
hopPACK = null;
hopDICT = null;
hopSTRM = null;
}

if (File.Exists(currentlyOpenBoot))
foreach (HipSection i in HipFileToHipArray(currentlyOpenBoot))
Expand All @@ -93,7 +107,14 @@ public static void openFilePair()
else if (i is Section_STRM strm) bootSTRM = strm;
else throw new Exception();
}
else currentlyOpenBoot = null;
else
{
currentlyOpenBoot = null;
bootHIPA = null;
bootPACK = null;
bootDICT = null;
bootSTRM = null;
}

foreach (SharpMesh mesh in RenderWareModelFile.completeMeshList)
mesh.Dispose();
Expand Down Expand Up @@ -122,6 +143,13 @@ private static void AddAssetToDictionary(Section_AHDR AHDR)

switch (AHDR.fileType)
{
case "BSP ":
{
AssetBSP newAsset = new AssetBSP(AHDR.assetID, AHDR.ADBG.assetName, AHDR.containedFile);
newAsset.Setup();
assetDictionary.Add(AHDR.assetID, newAsset);
}
break;
case "JSP ":
{
AssetJSP newAsset = new AssetJSP(AHDR.assetID, AHDR.ADBG.assetName, AHDR.containedFile);
Expand Down
5 changes: 3 additions & 2 deletions IndustrialPark/IndustrialPark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HipHopFile">
<HintPath>..\..\HipHopTool\HipHopFile\bin\Debug\HipHopFile.dll</HintPath>
<Reference Include="HipHopFile, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\HipHopTool\HipHopFile\bin\Release\HipHopFile.dll</HintPath>
</Reference>
<Reference Include="RenderWareFile">
<HintPath>..\..\RenderWareBSP\RenderWareFile\bin\Debug\RenderWareFile.dll</HintPath>
Expand Down
102 changes: 67 additions & 35 deletions IndustrialPark/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions IndustrialPark/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ private void MainForm_KeyDown(object sender, KeyEventArgs e)
ToggleCulling();
else if (e.KeyCode == Keys.F)
ToggleWireFrame();
else if (e.KeyCode == Keys.X)
ToggleLevelModel();
else if (e.KeyCode == Keys.G)
ToggleObjects();

if (e.KeyCode == Keys.F1)
Program.viewConfig.Show();
Expand Down Expand Up @@ -196,5 +200,28 @@ private void viewConfigToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.viewConfig.Show();
}

private void levelModelToolStripMenuItem_Click(object sender, EventArgs e)
{
ToggleLevelModel();
}

private void ToggleLevelModel()
{
levelModelToolStripMenuItem.Checked = !levelModelToolStripMenuItem.Checked;
SharpRenderer.SetLevelModel(levelModelToolStripMenuItem.Checked);
}

private void objectModelsToolStripMenuItem_Click(object sender, EventArgs e)
{
ToggleObjects();
}

private void ToggleObjects()
{
objectModelsToolStripMenuItem.Checked = !objectModelsToolStripMenuItem.Checked;
SharpRenderer.SetObjects(objectModelsToolStripMenuItem.Checked);
}

}
}
2 changes: 2 additions & 0 deletions IndustrialPark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ static class Program
[STAThread]
static void Main()
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-us");

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Expand Down
Loading

0 comments on commit 3587856

Please sign in to comment.