Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTXNORMS chunk for ActorX (vertex normals) #277

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Exporters/ExportPsk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,29 @@ static void ExportExtraUV
unguard;
}

static void ExportVertexNormals(FArchive &Ar, const TArray<CPackedNormal> &Normals)
{
guard(ExportVertexNormals);

static VChunkHeader NormalHdr;
NormalHdr.DataCount = Normals.Num();
NormalHdr.DataSize = sizeof(CVec3);

SAVE_CHUNK(NormalHdr, "VTXNORMS");
for (int i = 0; i < Normals.Num(); i++)
{
CVec3 Normal;
Unpack(Normal, Normals[i]);
Normal.Normalize();
#if MIRROR_MESH
Normal.Y = -Normal.Y;
#endif
Ar << Normal.X << Normal.Y << Normal.Z;
}

unguard;
}

static void CopyBoneName(char* Dst, int DstLen, const char* Src)
{
int NameLength = strlen(Src);
Expand Down Expand Up @@ -445,6 +468,7 @@ static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod

ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
ExportVertexNormals(Ar, Share.Normals);

/* if (!GExportPskx) // nothing more to write
return;
Expand Down Expand Up @@ -884,6 +908,7 @@ static void ExportStaticMeshLod(const CStaticMeshLod &Lod, FArchive &Ar)

ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
ExportVertexNormals(Ar, Share.Normals);

unguard;
}
Expand Down
2 changes: 1 addition & 1 deletion Exporters/Psk.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __PSK_H__


#define PSK_VERSION 20100422
#define PSK_VERSION 20210917 // VTXNORMS chunk
#define PSA_VERSION 20100422

/******************************************************************************
Expand Down