forked from mortany/OGF-tool
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Фикс непонятной поломки моделей, фикс поломки статических моделей пос…
…ле удаления мешей
- Loading branch information
Showing
11 changed files
with
797 additions
and
1,368 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,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace OGF_tool | ||
{ | ||
public class BBox | ||
{ | ||
public float[] min; | ||
public float[] max; | ||
|
||
public BBox() | ||
{ | ||
min = new float[3]; | ||
max = new float[3]; | ||
} | ||
|
||
public void Load(XRayLoader xr_loader) | ||
{ | ||
min = xr_loader.ReadVector(); | ||
max = xr_loader.ReadVector(); | ||
} | ||
|
||
public byte[] data() | ||
{ | ||
List<byte> temp = new List<byte>(); | ||
|
||
temp.AddRange(FVec.GetBytes(min)); | ||
temp.AddRange(FVec.GetBytes(max)); | ||
|
||
return temp.ToArray(); | ||
} | ||
}; | ||
|
||
public class BSphere | ||
{ | ||
public float[] c; | ||
public float r; | ||
|
||
public BSphere() | ||
{ | ||
c = new float[3]; | ||
r = 0.0f; | ||
} | ||
|
||
public void Load(XRayLoader xr_loader) | ||
{ | ||
c = xr_loader.ReadVector(); | ||
r = xr_loader.ReadFloat(); | ||
} | ||
|
||
public byte[] data() | ||
{ | ||
List<byte> temp = new List<byte>(); | ||
|
||
temp.AddRange(FVec.GetBytes(c)); | ||
temp.AddRange(BitConverter.GetBytes(r)); | ||
|
||
return temp.ToArray(); | ||
} | ||
}; | ||
} |
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,141 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace OGF_tool | ||
{ | ||
public class OGF_Header | ||
{ | ||
public byte format_version; | ||
public byte type; | ||
public short shader_id; | ||
public BBox bb; | ||
public BSphere bs; | ||
|
||
public OGF_Header() | ||
{ | ||
bb = new BBox(); | ||
bs = new BSphere(); | ||
format_version = 4; | ||
type = 0; | ||
shader_id = 0; | ||
} | ||
|
||
public void Load(XRayLoader xr_loader) | ||
{ | ||
format_version = xr_loader.ReadByte(); | ||
type = xr_loader.ReadByte(); | ||
shader_id = (short)xr_loader.ReadUInt16(); | ||
|
||
if (format_version == 4) | ||
{ | ||
bb.Load(xr_loader); | ||
bs.Load(xr_loader); | ||
} | ||
} | ||
|
||
public byte[] data() | ||
{ | ||
List<byte> temp = new List<byte>(); | ||
|
||
temp.AddRange(BitConverter.GetBytes((uint)OGF.OGF_HEADER)); | ||
temp.AddRange(BitConverter.GetBytes((format_version == 4 ? 44 : 4))); | ||
|
||
temp.Add(format_version); | ||
temp.Add(type); | ||
temp.AddRange(BitConverter.GetBytes(shader_id)); | ||
|
||
if (format_version == 4) | ||
{ | ||
temp.AddRange(bb.data()); | ||
temp.AddRange(bs.data()); | ||
} | ||
|
||
return temp.ToArray(); | ||
} | ||
|
||
public bool IsProgressive() | ||
{ | ||
if (format_version == 4) | ||
return type == (byte)ModelType.MT4_PROGRESSIVE || type == (byte)ModelType.MT4_SKELETON_GEOMDEF_PM; | ||
else | ||
return type == (byte)ModelType.MT3_PROGRESSIVE || type == (byte)ModelType.MT3_SKELETON_GEOMDEF_PM; | ||
} | ||
|
||
public bool IsSkeleton() | ||
{ | ||
if (format_version == 4) | ||
return type == (byte)ModelType.MT4_SKELETON_ANIM || type == (byte)ModelType.MT4_SKELETON_RIGID; | ||
else | ||
return type == (byte)ModelType.MT3_SKELETON_ANIM || type == (byte)ModelType.MT3_SKELETON_RIGID; | ||
} | ||
|
||
public bool IsAnimated() | ||
{ | ||
if (format_version == 4) | ||
return type == (byte)ModelType.MT4_SKELETON_ANIM; | ||
else | ||
return type == (byte)ModelType.MT3_SKELETON_ANIM; | ||
} | ||
|
||
public bool IsStatic() | ||
{ | ||
if (format_version == 4) | ||
return type == (byte)ModelType.MT4_HIERRARHY; | ||
else | ||
return type == (byte)ModelType.MT3_HIERRARHY; | ||
} | ||
|
||
public bool IsStaticSingle() | ||
{ | ||
if (format_version == 4) | ||
return type == (byte)ModelType.MT4_NORMAL || type == (byte)ModelType.MT4_PROGRESSIVE; | ||
else | ||
return type == (byte)ModelType.MT3_NORMAL || type == (byte)ModelType.MT3_PROGRESSIVE || type == (byte)ModelType.MT3_PROGRESSIVE2; | ||
} | ||
|
||
public byte Skeleton() | ||
{ | ||
if (format_version == 4) | ||
return (byte)ModelType.MT4_SKELETON_RIGID; | ||
else | ||
return (byte)ModelType.MT3_SKELETON_RIGID; | ||
} | ||
|
||
|
||
public void Animated() | ||
{ | ||
if (format_version == 4) | ||
type = (byte)ModelType.MT4_SKELETON_ANIM; | ||
else | ||
type = (byte)ModelType.MT3_SKELETON_ANIM; | ||
} | ||
|
||
public void Static(List<OGF_Child> childs) | ||
{ | ||
if (childs.Count == 1) | ||
{ | ||
StaticSingle(childs); | ||
return; | ||
} | ||
|
||
if (format_version == 4) | ||
type = (byte)ModelType.MT4_HIERRARHY; | ||
else | ||
type = (byte)ModelType.MT3_HIERRARHY; | ||
} | ||
|
||
public void StaticSingle(List<OGF_Child> childs) | ||
{ | ||
if (childs.Count > 1) | ||
{ | ||
Static(childs); | ||
return; | ||
} | ||
|
||
if (format_version == 4) | ||
type = (childs[0].SWI.Count > 0) ? (byte)ModelType.MT4_PROGRESSIVE : (byte)ModelType.MT4_NORMAL; | ||
else | ||
type = (childs[0].SWI.Count > 0) ? (byte)ModelType.MT3_PROGRESSIVE : (byte)ModelType.MT3_NORMAL; | ||
} | ||
}; | ||
} |
Oops, something went wrong.