Closed mgerhardy closed 8 months ago
found in voxel_section_editor HVA.pas
// This function converts the Westwood coordinates into OpenGL's
// (x,y,z) becomes (y,z,x)
procedure THVA.WestwoodToOpenGLCoordinates;
var
i : integer;
Temp: single;
begin
for i := Low(TransformMatrices) to High(TransformMatrices) do
begin
Temp := TransformMatrices[i][1][1];
TransformMatrices[i][1][1] := TransformMatrices[i][2][2];
TransformMatrices[i][2][2] := TransformMatrices[i][3][3];
TransformMatrices[i][3][3] := Temp;
Temp := TransformMatrices[i][1][2];
TransformMatrices[i][1][2] := TransformMatrices[i][2][3];
TransformMatrices[i][2][3] := TransformMatrices[i][3][1];
TransformMatrices[i][3][1] := Temp;
Temp := TransformMatrices[i][1][3];
TransformMatrices[i][1][3] := TransformMatrices[i][2][1];
TransformMatrices[i][2][1] := TransformMatrices[i][3][2];
TransformMatrices[i][3][2] := Temp;
Temp := TransformMatrices[i][1][4];
TransformMatrices[i][1][4] := TransformMatrices[i][2][4];
TransformMatrices[i][2][4] := TransformMatrices[i][3][4];
TransformMatrices[i][3][4] := Temp;
end;
end;
// This function converts the OpenGL coordinates into Westwood's
// (x,y,z) becomes (z,x,y)
procedure THVA.OpenGLToWestwoodCoordinates;
var
i : integer;
Temp: single;
begin
for i := Low(TransformMatrices) to High(TransformMatrices) do
begin
Temp := TransformMatrices[i][1][1];
TransformMatrices[i][1][1] := TransformMatrices[i][3][3];
TransformMatrices[i][3][3] := TransformMatrices[i][2][2];
TransformMatrices[i][2][2] := Temp;
Temp := TransformMatrices[i][1][2];
TransformMatrices[i][1][2] := TransformMatrices[i][3][1];
TransformMatrices[i][3][1] := TransformMatrices[i][2][3];
TransformMatrices[i][2][3] := Temp;
Temp := TransformMatrices[i][1][3];
TransformMatrices[i][1][3] := TransformMatrices[i][3][2];
TransformMatrices[i][3][2] := TransformMatrices[i][2][1];
TransformMatrices[i][2][1] := Temp;
Temp := TransformMatrices[i][1][4];
TransformMatrices[i][1][4] := TransformMatrices[i][3][4];
TransformMatrices[i][3][4] := TransformMatrices[i][2][4];
TransformMatrices[i][2][4] := Temp;
end;
end;
TVoxelSection.WestwoodToOpenGLCoordinates
file: hva.hexpat
struct vec4_s {
float x [[color("FF0000")]];
float y [[color("00FF00")]];
float z [[color("0000FF")]];
float w [[color("FFFF00")]];
};
struct mat3x4_s {
vec4_s row[3];
};
struct name_s {
char buffer[16] [[color("EECCCC")]];
};
struct hva_s {
name_s name;
u32 numFrames;
u32 numNodes;
name_s nodeNames[numNodes];
};
struct frame_s {
mat3x4_s mat[hva.numNodes];
};
hva_s hva @0x00;
frame_s frames[hva.numFrames] @sizeof(hva);
imhex hva pattern.
https://github.com/OpenRA/OpenRA/issues/4113
// Min/MaxBounds Fixed! - Stucuk
procedure TVoxelSection.DefaultTransforms;
const
C_WWDET = 1/12;
var
i, j: integer;
begin
Tailer.Det := C_WWDET;
for i := 1 to 3 do
for j := 1 to 3 do // from memory, don't think this transform is ever used.
if i = j then
Tailer.Transform[i,j] := 1
else
Tailer.Transform[i,j] := 0;
Tailer.MaxBounds[1] := (Tailer.XSize / 2);
Tailer.MaxBounds[3] := (Tailer.ZSize / 2);
Tailer.MinBounds[1] := 0 - (Tailer.XSize / 2);
Tailer.MinBounds[3] := 0 - (Tailer.ZSize / 2);
if VoxelType = vtAir then
begin
Tailer.MaxBounds[2] := (Tailer.YSize / 2);
Tailer.MinBounds[2] := 0 - (Tailer.YSize / 2);
end
else
begin
Tailer.MaxBounds[2] := Tailer.YSize;
Tailer.MinBounds[2] := 0;
end;
end;
TEST_F(ConvertTest, DISABLED_testVengiToVXL)
was added in bb3791b37c7385858dc73a37b8f9368e251cb812
loading of hmec is working now - saving still has issues left. and even though hmec is loading and animating fine, there are other models that are still shifted (maybe again pivot related...)
cd3eb2a491f287b50c5336c076b2498e59973883 and a few around this one fixed the issue
Code is in https://github.com/mgerhardy/vengi/tree/master/src/modules/voxelformat/private/commandconquer
—-
from the c&c mod haven discord:
i see in code you have matrix[col][row], Westwood's Matrix3D is Vector4 Row[3];, so row col
it's z up, x forward, y left (3dsmax coord system)
when the game draws a voxel it does this scaling for hva matrixes
not that min max stuff you had, scale is always Scale from layer info
also in case you would want to display ingame preview: https://github.com/secsome/CncVxlRenderText
this is YR VXL code