@@ -226,6 +226,12 @@ static void ExportSection(GLTFExportContext& Context, const CBaseMeshLod& Lod, c
226
226
int NormalBufIndex = Context.Data .AddZeroed ();
227
227
int TangentBufIndex = Context.Data .AddZeroed ();
228
228
229
+ int ColorBufIndex = -1 ;
230
+ if (Lod.VertexColors )
231
+ {
232
+ ColorBufIndex = Context.Data .AddZeroed ();
233
+ }
234
+
229
235
int BonesBufIndex = -1 ;
230
236
int WeightsBufIndex = -1 ;
231
237
if (Context.IsSkeletal ())
@@ -245,6 +251,7 @@ static void ExportSection(GLTFExportContext& Context, const CBaseMeshLod& Lod, c
245
251
BufferData& NormalBuf = Context.Data [NormalBufIndex];
246
252
BufferData& TangentBuf = Context.Data [TangentBufIndex];
247
253
BufferData* UVBuf[MAX_MESH_UV_SETS];
254
+ BufferData* ColorBuf = NULL ;
248
255
BufferData* BonesBuf = NULL ;
249
256
BufferData* WeightsBuf = NULL ;
250
257
@@ -257,6 +264,12 @@ static void ExportSection(GLTFExportContext& Context, const CBaseMeshLod& Lod, c
257
264
UVBuf[i]->Setup (numLocalVerts, " VEC2" , BufferData::FLOAT, sizeof (CMeshUVFloat));
258
265
}
259
266
267
+ if (Lod.VertexColors )
268
+ {
269
+ ColorBuf = &Context.Data [ColorBufIndex];
270
+ ColorBuf->Setup (numLocalVerts, " VEC4" , BufferData::UNSIGNED_BYTE, 4 , /* InNormalized=*/ true );
271
+ }
272
+
260
273
if (Context.IsSkeletal ())
261
274
{
262
275
BonesBuf = &Context.Data [BonesBufIndex];
@@ -350,6 +363,15 @@ static void ExportSection(GLTFExportContext& Context, const CBaseMeshLod& Lod, c
350
363
appSprintf (ARRAY_ARG (buf), " [ %g, %g, %g ]" , VECTOR_ARG (Maxs));
351
364
PositionBuf.BoundsMax = buf;
352
365
366
+ if (Lod.VertexColors )
367
+ {
368
+ for (int i = 0 ; i < numLocalVerts; i++)
369
+ {
370
+ int vertIndex = revIndexMap[i];
371
+ ColorBuf->Put (Lod.VertexColors [vertIndex]);
372
+ }
373
+ }
374
+
353
375
if (Context.IsSkeletal ())
354
376
{
355
377
for (int i = 0 ; i < numLocalVerts; i++)
@@ -397,6 +419,13 @@ static void ExportSection(GLTFExportContext& Context, const CBaseMeshLod& Lod, c
397
419
" \" TANGENT\" : %d,\n " ,
398
420
PositionBufIndex, NormalBufIndex, TangentBufIndex
399
421
);
422
+ if (Lod.VertexColors )
423
+ {
424
+ Ar.Printf (
425
+ " \" COLOR_0\" : %d,\n " ,
426
+ ColorBufIndex
427
+ );
428
+ }
400
429
if (Context.IsSkeletal ())
401
430
{
402
431
Ar.Printf (
0 commit comments