mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-23 07:22:52 +08:00
YDR/YDD/XML conversion
This commit is contained in:
parent
9ed308df7a
commit
bec16ea42d
@ -111,11 +111,26 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ydd.Name);
|
ddsfolder = Path.Combine(outputFolder, ydd.Name);
|
||||||
|
|
||||||
|
bool hastxd = false;
|
||||||
|
if (ydd?.DrawableDict?.Drawables?.data_items != null)
|
||||||
|
{
|
||||||
|
foreach (var d in ydd.DrawableDict.Drawables.data_items)
|
||||||
|
{
|
||||||
|
if (d?.ShaderGroup?.TextureDictionary != null)
|
||||||
|
{
|
||||||
|
hastxd = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hastxd)
|
||||||
|
{
|
||||||
if (!Directory.Exists(ddsfolder))
|
if (!Directory.Exists(ddsfolder))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(ddsfolder);
|
Directory.CreateDirectory(ddsfolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ydd?.DrawableDict != null)
|
if (ydd?.DrawableDict != null)
|
||||||
{
|
{
|
||||||
|
@ -76,11 +76,14 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ydr.Name);
|
ddsfolder = Path.Combine(outputFolder, ydr.Name);
|
||||||
|
|
||||||
|
if (ydr?.Drawable?.ShaderGroup?.TextureDictionary != null)
|
||||||
|
{
|
||||||
if (!Directory.Exists(ddsfolder))
|
if (!Directory.Exists(ddsfolder))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(ddsfolder);
|
Directory.CreateDirectory(ddsfolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ydr?.Drawable != null)
|
if (ydr?.Drawable != null)
|
||||||
{
|
{
|
||||||
|
@ -80,11 +80,40 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, yft.Name);
|
ddsfolder = Path.Combine(outputFolder, yft.Name);
|
||||||
|
|
||||||
|
bool hastxd = false;
|
||||||
|
if (yft?.Fragment != null)
|
||||||
|
{
|
||||||
|
hastxd = hastxd || (yft.Fragment.Drawable?.ShaderGroup?.TextureDictionary != null);
|
||||||
|
hastxd = hastxd || (yft.Fragment.Drawable2?.ShaderGroup?.TextureDictionary != null);
|
||||||
|
if (yft.Fragment.DrawableArray?.data_items != null)
|
||||||
|
{
|
||||||
|
foreach (var d in yft.Fragment.DrawableArray?.data_items)
|
||||||
|
{
|
||||||
|
if (hastxd) break;
|
||||||
|
if (d?.ShaderGroup?.TextureDictionary != null)
|
||||||
|
{
|
||||||
|
hastxd = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yft.Fragment.PhysicsLODGroup?.PhysicsLOD1?.Children?.data_items != null)
|
||||||
|
{
|
||||||
|
foreach (var child in yft.Fragment.PhysicsLODGroup.PhysicsLOD1.Children.data_items)
|
||||||
|
{
|
||||||
|
if (hastxd) break;
|
||||||
|
hastxd = hastxd || (child.Drawable1?.ShaderGroup?.TextureDictionary != null);
|
||||||
|
hastxd = hastxd || (child.Drawable2?.ShaderGroup?.TextureDictionary != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hastxd)
|
||||||
|
{
|
||||||
if (!Directory.Exists(ddsfolder))
|
if (!Directory.Exists(ddsfolder))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(ddsfolder);
|
Directory.CreateDirectory(ddsfolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (yft?.Fragment != null)
|
if (yft?.Fragment != null)
|
||||||
{
|
{
|
||||||
|
@ -128,11 +128,26 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
ddsfolder = Path.Combine(outputFolder, ypt.Name);
|
ddsfolder = Path.Combine(outputFolder, ypt.Name);
|
||||||
|
|
||||||
|
bool hastxd = false;
|
||||||
|
if (ypt?.DrawableDict != null)
|
||||||
|
{
|
||||||
|
foreach (var d in ypt.DrawableDict.Values)
|
||||||
|
{
|
||||||
|
if (d?.ShaderGroup?.TextureDictionary != null)
|
||||||
|
{
|
||||||
|
hastxd = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hastxd)
|
||||||
|
{
|
||||||
if (!Directory.Exists(ddsfolder))
|
if (!Directory.Exists(ddsfolder))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(ddsfolder);
|
Directory.CreateDirectory(ddsfolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ypt?.PtfxList != null)
|
if (ypt?.PtfxList != null)
|
||||||
{
|
{
|
||||||
|
@ -4264,7 +4264,7 @@ namespace CodeWalker.GameFiles
|
|||||||
if (((vd.Flags >> i) & 1) == 1)
|
if (((vd.Flags >> i) & 1) == 1)
|
||||||
{
|
{
|
||||||
string typestr = "Unknown";
|
string typestr = "Unknown";
|
||||||
uint type = (uint)((vd.Types >> (4 * i)) & 0xF);
|
uint type = (uint)(((ulong)vd.Types >> (4 * i)) & 0xF);
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 0: typestr = "ushort"; break;// Data[i] = new ushort[1 * count]; break;
|
case 0: typestr = "ushort"; break;// Data[i] = new ushort[1 * count]; break;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -10,15 +10,15 @@ namespace CodeWalker.GameFiles
|
|||||||
public enum VertexComponentType : byte
|
public enum VertexComponentType : byte
|
||||||
{
|
{
|
||||||
Nothing = 0,
|
Nothing = 0,
|
||||||
Float16Two = 1,
|
Half2 = 1,
|
||||||
Float = 2,
|
Float = 2,
|
||||||
Float16Four = 3,
|
Half4 = 3,
|
||||||
Float_unk = 4,
|
FloatUnk = 4,
|
||||||
Float2 = 5,
|
Float2 = 5,
|
||||||
Float3 = 6,
|
Float3 = 6,
|
||||||
Float4 = 7,
|
Float4 = 7,
|
||||||
UByte4 = 8,
|
UByte4 = 8,
|
||||||
Color = 9,
|
Colour = 9,
|
||||||
Dec3N = 10,
|
Dec3N = 10,
|
||||||
Unk1 = 11,
|
Unk1 = 11,
|
||||||
Unk2 = 12,
|
Unk2 = 12,
|
||||||
@ -27,11 +27,53 @@ namespace CodeWalker.GameFiles
|
|||||||
Unk5 = 15,
|
Unk5 = 15,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class VertexComponentTypes
|
||||||
|
{
|
||||||
|
public static int GetSizeInBytes(VertexComponentType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case VertexComponentType.Nothing: return 0;
|
||||||
|
case VertexComponentType.Half2: return 4;
|
||||||
|
case VertexComponentType.Float: return 4;
|
||||||
|
case VertexComponentType.Half4: return 8;
|
||||||
|
case VertexComponentType.FloatUnk: return 0;
|
||||||
|
case VertexComponentType.Float2: return 8;
|
||||||
|
case VertexComponentType.Float3: return 12;
|
||||||
|
case VertexComponentType.Float4: return 16;
|
||||||
|
case VertexComponentType.UByte4: return 4;
|
||||||
|
case VertexComponentType.Colour: return 4;
|
||||||
|
case VertexComponentType.Dec3N: return 4;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetComponentCount(VertexComponentType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case VertexComponentType.Nothing: return 0;
|
||||||
|
case VertexComponentType.Half2: return 2;
|
||||||
|
case VertexComponentType.Float: return 1;
|
||||||
|
case VertexComponentType.Half4: return 4;
|
||||||
|
case VertexComponentType.FloatUnk: return 0;
|
||||||
|
case VertexComponentType.Float2: return 2;
|
||||||
|
case VertexComponentType.Float3: return 3;
|
||||||
|
case VertexComponentType.Float4: return 4;
|
||||||
|
case VertexComponentType.UByte4: return 4;
|
||||||
|
case VertexComponentType.Colour: return 4;
|
||||||
|
case VertexComponentType.Dec3N: return 3;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public enum VertexDeclarationTypes : ulong
|
public enum VertexDeclarationTypes : ulong
|
||||||
{
|
{
|
||||||
Types1 = 0x7755555555996996, // GTAV - used by most drawables
|
GTAV1 = 0x7755555555996996, // GTAV - used by most drawables
|
||||||
Types2 = 0x030000000199A006, // GTAV - used on cloth?
|
GTAV2 = 0x030000000199A006, // GTAV - used on cloth?
|
||||||
Types3 = 0x0300000001996006, // GTAV - used on cloth?
|
GTAV3 = 0x0300000001996006, // GTAV - used on cloth?
|
||||||
|
|
||||||
//Types4 = 0x0000000007097007, // Max Payne 3
|
//Types4 = 0x0000000007097007, // Max Payne 3
|
||||||
//Types5 = 0x0700000007097977, // Max Payne 3
|
//Types5 = 0x0700000007097977, // Max Payne 3
|
||||||
@ -40,6 +82,26 @@ namespace CodeWalker.GameFiles
|
|||||||
//Types8 = 0x0700007777997977, // Max Payne 3
|
//Types8 = 0x0700007777997977, // Max Payne 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum VertexSemantics : int
|
||||||
|
{
|
||||||
|
Position = 0,
|
||||||
|
BlendWeights = 1,
|
||||||
|
BlendIndices = 2,
|
||||||
|
Normal = 3,
|
||||||
|
Colour0 = 4,
|
||||||
|
Colour1 = 5,
|
||||||
|
TexCoord0 = 6,
|
||||||
|
TexCoord1 = 7,
|
||||||
|
TexCoord2 = 8,
|
||||||
|
TexCoord3 = 9,
|
||||||
|
TexCoord4 = 10,
|
||||||
|
TexCoord5 = 11,
|
||||||
|
TexCoord6 = 12,
|
||||||
|
TexCoord7 = 13,
|
||||||
|
Tangent = 14,
|
||||||
|
Binormal = 15,
|
||||||
|
}
|
||||||
|
|
||||||
public enum VertexType : uint
|
public enum VertexType : uint
|
||||||
{
|
{
|
||||||
Default = 89, //PNCT
|
Default = 89, //PNCT
|
||||||
@ -82,52 +144,47 @@ namespace CodeWalker.GameFiles
|
|||||||
PBBNCTTTX = 16863,
|
PBBNCTTTX = 16863,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct VertexTypeGTAV1 //0x7755555555996996
|
||||||
//0x7755555555996996
|
|
||||||
public struct VertexTypeGTAV1
|
|
||||||
{
|
{
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public uint BlendWeights;
|
public uint BlendWeights;
|
||||||
public uint BlendIndices;
|
public uint BlendIndices;
|
||||||
public Vector3 Normals;
|
public Vector3 Normal;
|
||||||
public uint Colour0;
|
public uint Colour0;
|
||||||
public uint Colour1;
|
public uint Colour1;
|
||||||
public Vector2 Texcoords0;
|
public Vector2 Texcoord0;
|
||||||
public Vector2 Texcoords1;
|
public Vector2 Texcoord1;
|
||||||
public Vector2 Texcoords2;
|
public Vector2 Texcoord2;
|
||||||
public Vector2 Texcoords3;
|
public Vector2 Texcoord3;
|
||||||
public Vector2 Texcoords4;
|
public Vector2 Texcoord4;
|
||||||
public Vector2 Texcoords5;
|
public Vector2 Texcoord5;
|
||||||
public Vector2 Texcoords6;
|
public Vector2 Texcoord6;
|
||||||
public Vector2 Texcoords7;
|
public Vector2 Texcoord7;
|
||||||
public Vector4 Tangents;
|
public Vector4 Tangent;
|
||||||
public Vector4 Binormals;
|
public Vector4 Binormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
//0x030000000199A006
|
public struct VertexTypeGTAV2 //0x030000000199A006
|
||||||
public struct VertexTypeGTAV2
|
|
||||||
{
|
{
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public uint Normals; // Packed as Dec3N
|
public uint Normal; // Packed as Dec3N
|
||||||
public uint Colour0;
|
public uint Colour0;
|
||||||
public uint Colour1;
|
public uint Colour1;
|
||||||
public Half2 Texcoords0;
|
public Half2 Texcoord0;
|
||||||
public Half4 Tangents;
|
public Half4 Tangent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//0x0300000001996006
|
public struct VertexTypeGTAV3 //0x0300000001996006
|
||||||
public struct VertexTypeGTAV3
|
|
||||||
{
|
{
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public Vector3 Normals;
|
public Vector3 Normal;
|
||||||
public uint Colour0;
|
public uint Colour0;
|
||||||
public uint Colour1;
|
public uint Colour1;
|
||||||
public Half2 Texcoords0;
|
public Half2 Texcoord0;
|
||||||
public Half4 Tangents;
|
public Half4 Tangent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//vertex data to be used by the editor. TODO: maybe move somewhere else.
|
public struct EditorVertex //vertex data to be used by the editor. TODO: maybe move somewhere else.
|
||||||
public struct EditorVertex
|
|
||||||
{
|
{
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public uint Colour;
|
public uint Colour;
|
||||||
|
@ -164,10 +164,6 @@ namespace CodeWalker
|
|||||||
d.LodDistMed = 9998;
|
d.LodDistMed = 9998;
|
||||||
d.LodDistLow = 9998;
|
d.LodDistLow = 9998;
|
||||||
d.LodDistVlow = 9998;
|
d.LodDistVlow = 9998;
|
||||||
d.Unknown_80h = 0;//TODO: figure these out! related to high/med/low/vlow 0xFF00 + ?
|
|
||||||
d.Unknown_84h = 0;
|
|
||||||
d.Unknown_88h = 0;
|
|
||||||
d.Unknown_8Ch = 0;
|
|
||||||
d.Unknown_9Ah = 33;//WTF is this???
|
d.Unknown_9Ah = 33;//WTF is this???
|
||||||
d.FileVFT = 1079446584;
|
d.FileVFT = 1079446584;
|
||||||
d.FileUnknown = 1;
|
d.FileUnknown = 1;
|
||||||
@ -175,31 +171,33 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
d.DrawableModelsHigh = new ResourcePointerList64<DrawableModel>();
|
d.DrawableModelsHigh = new ResourcePointerList64<DrawableModel>();
|
||||||
d.DrawableModelsHigh.data_items = mlHigh.ToArray();
|
d.DrawableModelsHigh.data_items = mlHigh.ToArray();
|
||||||
d.Unknown_80h = 65281;//WTF is this??? 0xFF00 + ?
|
d.FlagsHigh = 1;//what flags should be used??
|
||||||
}
|
}
|
||||||
if (mlMed.Count > 0)
|
if (mlMed.Count > 0)
|
||||||
{
|
{
|
||||||
d.DrawableModelsMedium = new ResourcePointerList64<DrawableModel>();
|
d.DrawableModelsMedium = new ResourcePointerList64<DrawableModel>();
|
||||||
d.DrawableModelsMedium.data_items = mlMed.ToArray();
|
d.DrawableModelsMedium.data_items = mlMed.ToArray();
|
||||||
d.LodDistHigh = bsRad * 2.0f; //when med models present, generate a high lod dist..
|
d.LodDistHigh = bsRad * 2.0f; //when med models present, generate a high lod dist..
|
||||||
d.Unknown_84h = 65281;//WTF is this??? 0xFF00 + ?
|
d.FlagsMed = 1;
|
||||||
}
|
}
|
||||||
if (mlLow.Count > 0)
|
if (mlLow.Count > 0)
|
||||||
{
|
{
|
||||||
d.DrawableModelsLow = new ResourcePointerList64<DrawableModel>();
|
d.DrawableModelsLow = new ResourcePointerList64<DrawableModel>();
|
||||||
d.DrawableModelsLow.data_items = mlLow.ToArray();
|
d.DrawableModelsLow.data_items = mlLow.ToArray();
|
||||||
d.LodDistMed = bsRad * 8.0f; //when low models present, generate a med lod dist..
|
d.LodDistMed = bsRad * 8.0f; //when low models present, generate a med lod dist..
|
||||||
d.Unknown_88h = 65281;//WTF is this??? 0xFF00 + ?
|
d.FlagsLow = 1;
|
||||||
}
|
}
|
||||||
if (mlVlow.Count > 0)
|
if (mlVlow.Count > 0)
|
||||||
{
|
{
|
||||||
d.DrawableModelsVeryLow = new ResourcePointerList64<DrawableModel>();
|
d.DrawableModelsVeryLow = new ResourcePointerList64<DrawableModel>();
|
||||||
d.DrawableModelsVeryLow.data_items = mlVlow.ToArray();
|
d.DrawableModelsVeryLow.data_items = mlVlow.ToArray();
|
||||||
d.LodDistLow = bsRad * 32.0f; //when vlow models present, generate a low lod dist..
|
d.LodDistLow = bsRad * 32.0f; //when vlow models present, generate a low lod dist..
|
||||||
d.Unknown_8Ch = 65281;//WTF is this??? 0xFF00 + ?
|
d.FlagsVlow = 1;
|
||||||
}
|
}
|
||||||
d.DrawableModelsX = d.DrawableModelsHigh;
|
d.DrawableModelsX = d.DrawableModelsHigh;
|
||||||
|
|
||||||
|
d.BuildRenderMasks();
|
||||||
|
|
||||||
d.LightAttributes = new ResourceSimpleList64_s<LightAttributes_s>();
|
d.LightAttributes = new ResourceSimpleList64_s<LightAttributes_s>();
|
||||||
//todo: light attributes?
|
//todo: light attributes?
|
||||||
|
|
||||||
@ -598,7 +596,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
|
|
||||||
var vData = new VertexData();
|
var vData = new VertexData();
|
||||||
vData.info = dVertDecl;
|
vData.Info = dVertDecl;
|
||||||
vData.VertexType = (VertexType)dVertDecl.Flags;
|
vData.VertexType = (VertexType)dVertDecl.Flags;
|
||||||
vData.VertexStride = dVertDecl.Stride;
|
vData.VertexStride = dVertDecl.Stride;
|
||||||
vData.VertexCount = vList.Count;
|
vData.VertexCount = vList.Count;
|
||||||
@ -817,7 +815,7 @@ namespace CodeWalker
|
|||||||
private VertexDeclaration GetVertexDeclaration(ShaderFX shader)
|
private VertexDeclaration GetVertexDeclaration(ShaderFX shader)
|
||||||
{
|
{
|
||||||
var d = new VertexDeclaration();
|
var d = new VertexDeclaration();
|
||||||
d.Types = 8598872888530528662;
|
d.Types = VertexDeclarationTypes.GTAV1;
|
||||||
d.Unknown_6h = 0;
|
d.Unknown_6h = 0;
|
||||||
|
|
||||||
switch (shader.Name)
|
switch (shader.Name)
|
||||||
|
@ -128,22 +128,22 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string GetVector2String(Vector2 v)
|
public static string GetVector2String(Vector2 v, string d = ", ")
|
||||||
{
|
{
|
||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return v.X.ToString(c) + ", " + v.Y.ToString(c);
|
return v.X.ToString(c) + d + v.Y.ToString(c);
|
||||||
}
|
}
|
||||||
public static string GetVector2XmlString(Vector2 v)
|
public static string GetVector2XmlString(Vector2 v)
|
||||||
{
|
{
|
||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return string.Format("x=\"{0}\" y=\"{1}\"", v.X.ToString(c), v.Y.ToString(c));
|
return string.Format("x=\"{0}\" y=\"{1}\"", v.X.ToString(c), v.Y.ToString(c));
|
||||||
}
|
}
|
||||||
public static string GetVector3String(Vector3 v)
|
public static string GetVector3String(Vector3 v, string d = ", ")
|
||||||
{
|
{
|
||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return v.X.ToString(c) + ", " + v.Y.ToString(c) + ", " + v.Z.ToString(c);
|
return v.X.ToString(c) + d + v.Y.ToString(c) + d + v.Z.ToString(c);
|
||||||
}
|
}
|
||||||
public static string GetVector3String(Vector3 v, string format)
|
public static string GetVector3StringFormat(Vector3 v, string format)
|
||||||
{
|
{
|
||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return v.X.ToString(format, c) + ", " + v.Y.ToString(format, c) + ", " + v.Z.ToString(format, c);
|
return v.X.ToString(format, c) + ", " + v.Y.ToString(format, c) + ", " + v.Z.ToString(format, c);
|
||||||
@ -153,6 +153,11 @@ namespace CodeWalker
|
|||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\"", v.X.ToString(c), v.Y.ToString(c), v.Z.ToString(c));
|
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\"", v.X.ToString(c), v.Y.ToString(c), v.Z.ToString(c));
|
||||||
}
|
}
|
||||||
|
public static string GetVector4String(Vector4 v, string d = ", ")
|
||||||
|
{
|
||||||
|
var c = CultureInfo.InvariantCulture;
|
||||||
|
return v.X.ToString(c) + d + v.Y.ToString(c) + d + v.Z.ToString(c) + d + v.W.ToString(c);
|
||||||
|
}
|
||||||
public static string GetVector4XmlString(Vector4 v)
|
public static string GetVector4XmlString(Vector4 v)
|
||||||
{
|
{
|
||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
@ -163,6 +168,23 @@ namespace CodeWalker
|
|||||||
var c = CultureInfo.InvariantCulture;
|
var c = CultureInfo.InvariantCulture;
|
||||||
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", q.X.ToString(c), q.Y.ToString(c), q.Z.ToString(c), q.W.ToString(c));
|
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", q.X.ToString(c), q.Y.ToString(c), q.Z.ToString(c), q.W.ToString(c));
|
||||||
}
|
}
|
||||||
|
public static string GetHalf2String(Half2 v, string d = ", ")
|
||||||
|
{
|
||||||
|
var c = CultureInfo.InvariantCulture;
|
||||||
|
var f = Half.ConvertToFloat(new[] { v.X, v.Y });
|
||||||
|
return f[0].ToString(c) + d + f[1].ToString(c);
|
||||||
|
}
|
||||||
|
public static string GetHalf4String(Half4 v, string d = ", ")
|
||||||
|
{
|
||||||
|
var c = CultureInfo.InvariantCulture;
|
||||||
|
var f = Half.ConvertToFloat(new[] { v.X, v.Y, v.Z, v.W });
|
||||||
|
return f[0].ToString(c) + d + f[1].ToString(c) + d + f[2].ToString(c) + d + f[3].ToString(c);
|
||||||
|
}
|
||||||
|
public static string GetColourString(Color v, string d = ", ")
|
||||||
|
{
|
||||||
|
var c = CultureInfo.InvariantCulture;
|
||||||
|
return v.R.ToString(c) + d + v.G.ToString(c) + d + v.B.ToString(c) + d + v.A.ToString(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Vector2 ParseVector2String(string s)
|
public static Vector2 ParseVector2String(string s)
|
||||||
@ -179,7 +201,6 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 ParseVector3String(string s)
|
public static Vector3 ParseVector3String(string s)
|
||||||
{
|
{
|
||||||
Vector3 p = new Vector3(0.0f);
|
Vector3 p = new Vector3(0.0f);
|
||||||
@ -198,14 +219,6 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string GetVector4String(Vector4 v)
|
|
||||||
{
|
|
||||||
var c = CultureInfo.InvariantCulture;
|
|
||||||
return v.X.ToString(c) + ", " + v.Y.ToString(c) + ", " + v.Z.ToString(c) + ", " + v.W.ToString(c);
|
|
||||||
}
|
|
||||||
public static Vector4 ParseVector4String(string s)
|
public static Vector4 ParseVector4String(string s)
|
||||||
{
|
{
|
||||||
Vector4 p = new Vector4(0.0f);
|
Vector4 p = new Vector4(0.0f);
|
||||||
|
@ -222,6 +222,30 @@ namespace CodeWalker
|
|||||||
return GetRawByteArray(cnode);
|
return GetRawByteArray(cnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ushort[] GetRawUshortArray(XmlNode node)
|
||||||
|
{
|
||||||
|
if (node == null) return new ushort[0];
|
||||||
|
var data = new List<ushort>();
|
||||||
|
var split = Regex.Split(node.InnerText, @"[\s\r\n\t]");
|
||||||
|
for (int i = 0; i < split.Length; i++)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(split[i]))
|
||||||
|
{
|
||||||
|
var str = split[i];
|
||||||
|
if (string.IsNullOrEmpty(str)) continue;
|
||||||
|
var val = (ushort)0;
|
||||||
|
ushort.TryParse(str, out val);
|
||||||
|
data.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data.ToArray();
|
||||||
|
}
|
||||||
|
public static ushort[] GetChildRawUshortArray(XmlNode node, string name)
|
||||||
|
{
|
||||||
|
var cnode = node.SelectSingleNode(name);
|
||||||
|
return GetRawUshortArray(cnode);
|
||||||
|
}
|
||||||
|
|
||||||
public static uint[] GetRawUintArray(XmlNode node)
|
public static uint[] GetRawUintArray(XmlNode node)
|
||||||
{
|
{
|
||||||
if (node == null) return new uint[0];
|
if (node == null) return new uint[0];
|
||||||
|
@ -256,7 +256,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
//supported layouts - requires Position, Normal, Colour, Texcoord
|
//supported layouts - requires Position, Normal, Colour, Texcoord
|
||||||
layouts.Add(VertexType.Default, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));
|
layouts.Add(VertexType.Default, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));
|
||||||
layouts.Add(VertexType.PNCH2, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.Types3)));//TODO?
|
layouts.Add(VertexType.PNCH2, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.GTAV3)));//TODO?
|
||||||
layouts.Add(VertexType.PNCTT, new InputLayout(device, vspncttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
|
layouts.Add(VertexType.PNCTT, new InputLayout(device, vspncttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
|
||||||
layouts.Add(VertexType.PNCTTT, new InputLayout(device, vspnctttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));
|
layouts.Add(VertexType.PNCTTT, new InputLayout(device, vspnctttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));
|
||||||
layouts.Add(VertexType.PNCCT, new InputLayout(device, vspncctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCT)));
|
layouts.Add(VertexType.PNCCT, new InputLayout(device, vspncctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCT)));
|
||||||
@ -267,7 +267,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
//normalmap layouts - requires Position, Normal, Colour, Texcoord, Tangent (X)
|
//normalmap layouts - requires Position, Normal, Colour, Texcoord, Tangent (X)
|
||||||
layouts.Add(VertexType.DefaultEx, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx)));
|
layouts.Add(VertexType.DefaultEx, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx)));
|
||||||
layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.Types2)));
|
layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.GTAV2)));
|
||||||
layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
|
layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
|
||||||
layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTX)));
|
layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTX)));
|
||||||
layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX)));
|
layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX)));
|
||||||
|
@ -113,8 +113,8 @@ namespace CodeWalker.Rendering
|
|||||||
layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTX)));
|
layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTX)));
|
||||||
layouts.Add(VertexType.PNCCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTT)));
|
layouts.Add(VertexType.PNCCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTT)));
|
||||||
layouts.Add(VertexType.PNCCTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
|
layouts.Add(VertexType.PNCCTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
|
||||||
layouts.Add(VertexType.PNCH2, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.Types3)));
|
layouts.Add(VertexType.PNCH2, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.GTAV3)));
|
||||||
layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.Types2)));
|
layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.GTAV2)));
|
||||||
layouts.Add(VertexType.PNCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
|
layouts.Add(VertexType.PNCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
|
||||||
layouts.Add(VertexType.PNCTTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));
|
layouts.Add(VertexType.PNCTTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));
|
||||||
|
|
||||||
|
@ -32,45 +32,26 @@ namespace CodeWalker.Rendering
|
|||||||
"BINORMAL",
|
"BINORMAL",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int GetVertexComponentTypeSizeInBytes(VertexComponentType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case VertexComponentType.Nothing: return 0;
|
|
||||||
case VertexComponentType.Float16Two: return 4;
|
|
||||||
case VertexComponentType.Float: return 4;
|
|
||||||
case VertexComponentType.Float16Four: return 8;
|
|
||||||
case VertexComponentType.Float_unk: return 0;
|
|
||||||
case VertexComponentType.Float2: return 8;
|
|
||||||
case VertexComponentType.Float3: return 12;
|
|
||||||
case VertexComponentType.Float4: return 16;
|
|
||||||
case VertexComponentType.UByte4: return 4;
|
|
||||||
case VertexComponentType.Color: return 4;
|
|
||||||
case VertexComponentType.Dec3N: return 4;
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Format GetDXGIFormat(VertexComponentType type)
|
public static Format GetDXGIFormat(VertexComponentType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case VertexComponentType.Nothing: return Format.Unknown;
|
case VertexComponentType.Nothing: return Format.Unknown;
|
||||||
case VertexComponentType.Float16Two: return Format.R16G16_Float;
|
case VertexComponentType.Half2: return Format.R16G16_Float;
|
||||||
case VertexComponentType.Float: return Format.R32_Float;
|
case VertexComponentType.Float: return Format.R32_Float;
|
||||||
case VertexComponentType.Float16Four: return Format.R16G16B16A16_Float;
|
case VertexComponentType.Half4: return Format.R16G16B16A16_Float;
|
||||||
case VertexComponentType.Float_unk: return Format.Unknown;
|
case VertexComponentType.FloatUnk: return Format.Unknown;
|
||||||
case VertexComponentType.Float2: return Format.R32G32_Float;
|
case VertexComponentType.Float2: return Format.R32G32_Float;
|
||||||
case VertexComponentType.Float3: return Format.R32G32B32_Float;
|
case VertexComponentType.Float3: return Format.R32G32B32_Float;
|
||||||
case VertexComponentType.Float4: return Format.R32G32B32A32_Float;
|
case VertexComponentType.Float4: return Format.R32G32B32A32_Float;
|
||||||
case VertexComponentType.UByte4: return Format.R8G8B8A8_UInt;
|
case VertexComponentType.UByte4: return Format.R8G8B8A8_UInt;
|
||||||
case VertexComponentType.Color: return Format.R8G8B8A8_UNorm;
|
case VertexComponentType.Colour: return Format.R8G8B8A8_UNorm;
|
||||||
case VertexComponentType.Dec3N: return Format.R10G10B10A2_UNorm;
|
case VertexComponentType.Dec3N: return Format.R10G10B10A2_UNorm;
|
||||||
default: return Format.Unknown;
|
default: return Format.Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InputElement[] GetLayout(VertexType componentsFlags, VertexDeclarationTypes componentsTypes = VertexDeclarationTypes.Types1)
|
public static InputElement[] GetLayout(VertexType componentsFlags, VertexDeclarationTypes componentsTypes = VertexDeclarationTypes.GTAV1)
|
||||||
{
|
{
|
||||||
List<InputElement> inputElements = new List<InputElement>();
|
List<InputElement> inputElements = new List<InputElement>();
|
||||||
|
|
||||||
@ -87,7 +68,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
if (componentType == VertexComponentType.Nothing) continue; // should never hit this
|
if (componentType == VertexComponentType.Nothing) continue; // should never hit this
|
||||||
|
|
||||||
var componentTypeSize = GetVertexComponentTypeSizeInBytes(componentType);
|
var componentTypeSize = VertexComponentTypes.GetSizeInBytes(componentType);
|
||||||
var format = GetDXGIFormat(componentType);
|
var format = GetDXGIFormat(componentType);
|
||||||
|
|
||||||
if (componentTypeSize == 0 || format == Format.Unknown) continue;
|
if (componentTypeSize == 0 || format == Format.Unknown) continue;
|
||||||
|
@ -5609,7 +5609,7 @@ namespace CodeWalker
|
|||||||
UpdateTimeOfDayLabel();
|
UpdateTimeOfDayLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraPositionTextBox.Text = FloatUtil.GetVector3String(camera.Position, "0.##");
|
CameraPositionTextBox.Text = FloatUtil.GetVector3StringFormat(camera.Position, "0.##");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WorldForm_Load(object sender, EventArgs e)
|
private void WorldForm_Load(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user