-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from MilchRatchet/dev-branch
Mobyload Models
- Loading branch information
Showing
15 changed files
with
476 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (C) 2018-2023, The Replanetizer Contributors. | ||
// Replanetizer is free software: you can redistribute it | ||
// and/or modify it under the terms of the GNU General Public | ||
// License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// Please see the LICENSE.md file for more details. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using static LibReplanetizer.DataFunctions; | ||
|
||
namespace LibReplanetizer.Headers | ||
{ | ||
public class MobyloadHeader | ||
{ | ||
public int mobyCount; | ||
public int textureCount; | ||
public int texturePointer; | ||
public int textureDataPointer; | ||
public List<Tuple<int, int>> modelData = new List<Tuple<int, int>>(); | ||
|
||
public MobyloadHeader(FileStream mobyloadFile) | ||
{ | ||
byte[] headerBytes = ReadBlock(mobyloadFile, 0x00, 0x10); | ||
|
||
mobyCount = ReadInt(headerBytes, 0x00); | ||
textureCount = ReadInt(headerBytes, 0x04); | ||
texturePointer = ReadInt(headerBytes, 0x08); | ||
textureDataPointer = ReadInt(headerBytes, 0x0C); | ||
|
||
byte[] pointerBlock = ReadBlock(mobyloadFile, 0x10, mobyCount * 0x0C); | ||
|
||
for (int i = 0; i < mobyCount; i++) | ||
{ | ||
int modelPointer = ReadInt(pointerBlock, 0x00 + i * 0x0C); | ||
int modelID = ReadInt(pointerBlock, 0x04 + i * 0x0C); | ||
|
||
modelData.Add(new Tuple<int, int>(modelPointer, modelID)); | ||
} | ||
} | ||
|
||
public static string? FindMobyloadFile(GameType game, string enginePath, int id) | ||
{ | ||
string? folder = Path.GetDirectoryName(enginePath); | ||
|
||
switch (game.num) | ||
{ | ||
case 3: | ||
case 4: | ||
string? path = Path.Join(folder, "mobyload" + id + ".ps3"); | ||
if (File.Exists(path)) return path; | ||
break; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public byte[] Serialize() | ||
{ | ||
byte[] bytes = new byte[0x10]; | ||
|
||
return bytes; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2018-2023, The Replanetizer Contributors. | ||
// Replanetizer is free software: you can redistribute it | ||
// and/or modify it under the terms of the GNU General Public | ||
// License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// Please see the LICENSE.md file for more details. | ||
|
||
using LibReplanetizer.Headers; | ||
using LibReplanetizer.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace LibReplanetizer.Parsers | ||
{ | ||
public class MobyloadParser : RatchetFileParser, IDisposable | ||
{ | ||
MobyloadHeader mobyloadHead; | ||
GameType game; | ||
|
||
public MobyloadParser(GameType game, string mobyloadFile) : base(mobyloadFile) | ||
{ | ||
this.game = game; | ||
mobyloadHead = new MobyloadHeader(fileStream); | ||
} | ||
|
||
public List<Texture> GetTextures() | ||
{ | ||
return GetTexturesMobyload(mobyloadHead.texturePointer, mobyloadHead.textureDataPointer, mobyloadHead.textureCount); | ||
} | ||
|
||
public List<MobyModel> GetMobyModels() | ||
{ | ||
List<MobyModel> models = new List<MobyModel>(); | ||
|
||
foreach (Tuple<int, int> model in mobyloadHead.modelData) | ||
{ | ||
// ID of zero implies that something wrong and this model is to be ignored. | ||
if (model.Item2 != 0) | ||
{ | ||
models.Add(new MobyModel(fileStream, game, (short) model.Item2, model.Item1)); | ||
} | ||
} | ||
|
||
return models; | ||
|
||
} | ||
|
||
public void Dispose() | ||
{ | ||
fileStream.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.