Skip to content

Commit

Permalink
Сделал код приятнее
Browse files Browse the repository at this point in the history
  • Loading branch information
VaIeroK committed Nov 16, 2022
1 parent bc5d576 commit 5726743
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
18 changes: 18 additions & 0 deletions OGF tool/Classes/FVec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ static public float[] MirrorZ(float[] v)
return vec;
}

static public float[] RotateXYZ(float[] v, float[] rot, float[] center)
{
float yaw = rot[0] * (float)(Math.PI / 180.0f);
float pitch = rot[1] * (float)(Math.PI / 180.0f);
float roll = rot[2] * (float)(Math.PI / 180.0f);

return RotateYPR(v, yaw, pitch, roll, center);
}

static public float[] RotateXYZ(float[] v, float[] rot)
{
float yaw = rot[0] * (float)(Math.PI / 180.0f);
float pitch = rot[1] * (float)(Math.PI / 180.0f);
float roll = rot[2] * (float)(Math.PI / 180.0f);

return RotateYPR(v, yaw, pitch, roll, new float[3]);
}

static public float[] RotateXYZ(float[] v, float x, float y, float z, float[] center)
{
float yaw = z * (float)(Math.PI / 180.0f);
Expand Down
12 changes: 0 additions & 12 deletions OGF tool/Classes/OGF Chunks/Children.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,6 @@ public void SetLinks(uint count)
links = count;
}

public void RotateMesh(float x, float y, float z)
{
for (int i = 0; i < Vertices.Count; i++)
{
Vertices[i].offs = FVec.RotateXYZ(Vertices[i].offs, x, y, z);
Vertices[i].local_offset = FVec.RotateXYZ(Vertices[i].local_offset, x, y, z);
Vertices[i].norm = FVec.RotateXYZ(Vertices[i].norm, x, y, z);
Vertices[i].tang = FVec.RotateXYZ(Vertices[i].tang, x, y, z);
Vertices[i].binorm = FVec.RotateXYZ(Vertices[i].binorm, x, y, z);
}
}

public void MeshNormalize(bool generate_normal = true)
{
SSkelVert.GenerateNormals(ref Vertices, Faces, generate_normal);
Expand Down
16 changes: 8 additions & 8 deletions OGF tool/Classes/OGF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,26 @@ public SSkelVert()
public float[] Offset()
{
float[] offset = FVec.Add(offs, local_offset);
offset = FVec.RotateXYZ(offset, local_rotation2[0], local_rotation2[1], local_rotation2[2]);
return FVec.RotateXYZ(offset, local_rotation[0], local_rotation[1], local_rotation[2], rotation_local ? center : new float[3]);
offset = FVec.RotateXYZ(offset, local_rotation2);
return FVec.RotateXYZ(offset, local_rotation, rotation_local ? center : new float[3]);
}

public float[] Norm()
{
float[] vec = FVec.RotateXYZ(norm, local_rotation2[0], local_rotation2[1], local_rotation2[2]);
return FVec.RotateXYZ(vec, local_rotation[0], local_rotation[1], local_rotation[2]);
float[] vec = FVec.RotateXYZ(norm, local_rotation2);
return FVec.RotateXYZ(vec, local_rotation);
}

public float[] Tang()
{
float[] vec = FVec.RotateXYZ(tang, local_rotation2[0], local_rotation2[1], local_rotation2[2]);
return FVec.RotateXYZ(vec, local_rotation[0], local_rotation[1], local_rotation[2]);
float[] vec = FVec.RotateXYZ(tang, local_rotation2);
return FVec.RotateXYZ(vec, local_rotation);
}

public float[] Binorm()
{
float[] vec = FVec.RotateXYZ(binorm, local_rotation2[0], local_rotation2[1], local_rotation2[2]);
return FVec.RotateXYZ(vec, local_rotation[0], local_rotation[1], local_rotation[2]);
float[] vec = FVec.RotateXYZ(binorm, local_rotation2);
return FVec.RotateXYZ(vec, local_rotation);
}

public static void GenerateNormals(ref List<SSkelVert> Vertices, List<SSkelFace> Faces, bool generate_normal = true)
Expand Down

0 comments on commit 5726743

Please sign in to comment.