fix: fix fatal layout issue about VxColor.

- fix wrong memory layout of VxColor.
This commit is contained in:
yyc12345 2024-11-01 13:31:03 +08:00
parent 33dc9a54be
commit 73f1a1f829
2 changed files with 41 additions and 41 deletions

View File

@ -52,7 +52,7 @@ namespace BMapSharp.VirtoolsTypes {
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct VxColor {
[MarshalAs(UnmanagedType.R4)]
public float A, R, G, B;
public float R, G, B, A;
public VxColor(float _r, float _g, float _b, float _a) {
A = _a; R = _r; G = _g; B = _b;

View File

@ -42,49 +42,49 @@ namespace BMapSharpTestbench {
// Console.WriteLine($"\tMatrix: {obj.GetWorldMatrix().ToManaged()}");
// }
Console.WriteLine("===== Meshes =====");
foreach (var mesh in reader.GetMeshes()) {
Console.WriteLine(mesh.GetName());
// Console.WriteLine("===== Meshes =====");
// foreach (var mesh in reader.GetMeshes()) {
// Console.WriteLine(mesh.GetName());
Console.WriteLine($"\tLit Mode: {mesh.GetLitMode()}");
Console.WriteLine($"\tVertex Count: {mesh.GetVertexCount()}");
Console.WriteLine($"\tFace Count: {mesh.GetFaceCount()}");
Console.WriteLine($"\tMaterial Slot Count: {mesh.GetMaterialSlotCount()}");
}
// Console.WriteLine("===== Materials =====");
// foreach (var mtl in reader.GetMaterials()) {
// Console.WriteLine(mtl.GetName());
// Console.WriteLine($"\tDiffuse: {mtl.GetDiffuse().ToManagedRGBA()}");
// Console.WriteLine($"\tAmbient: {mtl.GetAmbient().ToManagedRGBA()}");
// Console.WriteLine($"\tSpecular: {mtl.GetSpecular().ToManagedRGBA()}");
// Console.WriteLine($"\tEmissive: {mtl.GetEmissive().ToManagedRGBA()}");
// Console.WriteLine($"\tSpecular Power: {mtl.GetSpecularPower()}");
// Console.WriteLine($"\tTexture Border Color: {mtl.GetTextureBorderColor().ToManagedRGBA()}");
// Console.WriteLine($"\tTexture Blend Mode: {mtl.GetTextureBlendMode()}");
// Console.WriteLine($"\tTexture Min Mode: {mtl.GetTextureMinMode()}");
// Console.WriteLine($"\tTexture Mag Mode: {mtl.GetTextureMagMode()}");
// Console.WriteLine($"\tSource Blend: {mtl.GetSourceBlend()}");
// Console.WriteLine($"\tDest Blend: {mtl.GetDestBlend()}");
// Console.WriteLine($"\tFill Mode: {mtl.GetFillMode()}");
// Console.WriteLine($"\tShade Mode: {mtl.GetShadeMode()}");
// Console.WriteLine($"\tAlpha Test Enabled: {mtl.GetAlphaTestEnabled()}");
// Console.WriteLine($"\tAlpha Blend Enabled: {mtl.GetAlphaBlendEnabled()}");
// Console.WriteLine($"\tPerspective Correction Enabled: {mtl.GetPerspectiveCorrectionEnabled()}");
// Console.WriteLine($"\tZ Write Enabled: {mtl.GetZWriteEnabled()}");
// Console.WriteLine($"\tTwo Sided Enabled: {mtl.GetTwoSidedEnabled()}");
// Console.WriteLine($"\tAlpha Ref: {mtl.GetAlphaRef()}");
// Console.WriteLine($"\tAlpha Func: {mtl.GetAlphaFunc()}");
// Console.WriteLine($"\tZ Func: {mtl.GetZFunc()}");
// Console.WriteLine($"\tLit Mode: {mesh.GetLitMode()}");
// Console.WriteLine($"\tVertex Count: {mesh.GetVertexCount()}");
// Console.WriteLine($"\tFace Count: {mesh.GetFaceCount()}");
// Console.WriteLine($"\tMaterial Slot Count: {mesh.GetMaterialSlotCount()}");
// }
Console.WriteLine("===== Materials =====");
foreach (var mtl in reader.GetMaterials()) {
Console.WriteLine(mtl.GetName());
Console.WriteLine($"\tDiffuse: {mtl.GetDiffuse().ToManagedRGBA()}");
Console.WriteLine($"\tAmbient: {mtl.GetAmbient().ToManagedRGBA()}");
Console.WriteLine($"\tSpecular: {mtl.GetSpecular().ToManagedRGBA()}");
Console.WriteLine($"\tEmissive: {mtl.GetEmissive().ToManagedRGBA()}");
Console.WriteLine($"\tSpecular Power: {mtl.GetSpecularPower()}");
Console.WriteLine($"\tTexture Border Color: {mtl.GetTextureBorderColor().ToManagedRGBA()}");
Console.WriteLine($"\tTexture Blend Mode: {mtl.GetTextureBlendMode()}");
Console.WriteLine($"\tTexture Min Mode: {mtl.GetTextureMinMode()}");
Console.WriteLine($"\tTexture Mag Mode: {mtl.GetTextureMagMode()}");
Console.WriteLine($"\tSource Blend: {mtl.GetSourceBlend()}");
Console.WriteLine($"\tDest Blend: {mtl.GetDestBlend()}");
Console.WriteLine($"\tFill Mode: {mtl.GetFillMode()}");
Console.WriteLine($"\tShade Mode: {mtl.GetShadeMode()}");
Console.WriteLine($"\tAlpha Test Enabled: {mtl.GetAlphaTestEnabled()}");
Console.WriteLine($"\tAlpha Blend Enabled: {mtl.GetAlphaBlendEnabled()}");
Console.WriteLine($"\tPerspective Correction Enabled: {mtl.GetPerspectiveCorrectionEnabled()}");
Console.WriteLine($"\tZ Write Enabled: {mtl.GetZWriteEnabled()}");
Console.WriteLine($"\tTwo Sided Enabled: {mtl.GetTwoSidedEnabled()}");
Console.WriteLine($"\tAlpha Ref: {mtl.GetAlphaRef()}");
Console.WriteLine($"\tAlpha Func: {mtl.GetAlphaFunc()}");
Console.WriteLine($"\tZ Func: {mtl.GetZFunc()}");
}
// Console.WriteLine("===== Textures =====");
// foreach (var tex in reader.GetTextures()) {
// Console.WriteLine(tex.GetName());