* improve ase export compatibility
write normals after faces write vertex normals right after their face normal
This commit is contained in:
parent
9cf755dfab
commit
427ef0874b
|
|
@ -366,7 +366,7 @@ ___q3map2
|
||||||
?support non vertex anim frames
|
?support non vertex anim frames
|
||||||
test failed model loading
|
test failed model loading
|
||||||
?is PicoFixSurfaceNormals needed?
|
?is PicoFixSurfaceNormals needed?
|
||||||
shaderlab_terrain.ase great error spam
|
shaderlab_terrain.ase great error spam, table2.ase
|
||||||
split to smaller meshes
|
split to smaller meshes
|
||||||
aiProcess_SplitLargeMeshes is inefficient
|
aiProcess_SplitLargeMeshes is inefficient
|
||||||
handle nodes transformations; or aiProcess_PreTransformVertices -> applies them (but also removes animations)
|
handle nodes transformations; or aiProcess_PreTransformVertices -> applies them (but also removes animations)
|
||||||
|
|
|
||||||
|
|
@ -93,27 +93,6 @@ static void ConvertSurface( FILE *f, bspModel_t *model, int modelNum, bspDrawSur
|
||||||
}
|
}
|
||||||
fprintf( f, "\t\t}\r\n" );
|
fprintf( f, "\t\t}\r\n" );
|
||||||
|
|
||||||
/* export vertex normals */
|
|
||||||
fprintf( f, "\t\t*MESH_NORMALS\t{\r\n" );
|
|
||||||
for ( i = 0; i < ds->numIndexes; i += 3 )
|
|
||||||
{
|
|
||||||
face = ( i / 3 );
|
|
||||||
a = bspDrawIndexes[ i + ds->firstIndex ];
|
|
||||||
b = bspDrawIndexes[ i + ds->firstIndex + 1 ];
|
|
||||||
c = bspDrawIndexes[ i + ds->firstIndex + 2 ];
|
|
||||||
Vector3 normal = bspDrawVerts[ a ].normal + bspDrawVerts[ b ].normal + bspDrawVerts[ c ].normal;
|
|
||||||
if ( VectorNormalize( normal ) != 0 ) {
|
|
||||||
fprintf( f, "\t\t\t*MESH_FACENORMAL\t%d\t%f\t%f\t%f\r\n", face, normal[ 0 ], normal[ 1 ], normal[ 2 ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ( i = 0; i < ds->numVerts; i++ )
|
|
||||||
{
|
|
||||||
v = i + ds->firstVert;
|
|
||||||
dv = &bspDrawVerts[ v ];
|
|
||||||
fprintf( f, "\t\t\t*MESH_VERTEXNORMAL\t%d\t%f\t%f\t%f\r\n", i, dv->normal[ 0 ], dv->normal[ 1 ], dv->normal[ 2 ] );
|
|
||||||
}
|
|
||||||
fprintf( f, "\t\t}\r\n" );
|
|
||||||
|
|
||||||
/* export faces */
|
/* export faces */
|
||||||
fprintf( f, "\t\t*MESH_FACE_LIST\t{\r\n" );
|
fprintf( f, "\t\t*MESH_FACE_LIST\t{\r\n" );
|
||||||
for ( i = 0; i < ds->numIndexes; i += 3 )
|
for ( i = 0; i < ds->numIndexes; i += 3 )
|
||||||
|
|
@ -156,6 +135,23 @@ static void ConvertSurface( FILE *f, bspModel_t *model, int modelNum, bspDrawSur
|
||||||
}
|
}
|
||||||
fprintf( f, "\t\t}\r\n" );
|
fprintf( f, "\t\t}\r\n" );
|
||||||
|
|
||||||
|
/* export vertex normals */
|
||||||
|
fprintf( f, "\t\t*MESH_NORMALS\t{\r\n" );
|
||||||
|
for ( i = 0; i < ds->numIndexes; i += 3 )
|
||||||
|
{
|
||||||
|
face = ( i / 3 );
|
||||||
|
a = bspDrawIndexes[ i + ds->firstIndex ];
|
||||||
|
b = bspDrawIndexes[ i + ds->firstIndex + 1 ];
|
||||||
|
c = bspDrawIndexes[ i + ds->firstIndex + 2 ];
|
||||||
|
const Vector3 normal = VectorNormalized( bspDrawVerts[ a ].normal + bspDrawVerts[ b ].normal + bspDrawVerts[ c ].normal );
|
||||||
|
fprintf( f, "\t\t\t*MESH_FACENORMAL\t%d\t%f\t%f\t%f\r\n", face, normal[ 0 ], normal[ 1 ], normal[ 2 ] );
|
||||||
|
for( const auto idx : { a, b, c } ){
|
||||||
|
dv = &bspDrawVerts[ idx ];
|
||||||
|
fprintf( f, "\t\t\t\t*MESH_VERTEXNORMAL\t%d\t%f\t%f\t%f\r\n", idx, dv->normal[ 0 ], dv->normal[ 1 ], dv->normal[ 2 ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf( f, "\t\t}\r\n" );
|
||||||
|
|
||||||
/* print mesh footer */
|
/* print mesh footer */
|
||||||
fprintf( f, "\t}\r\n" );
|
fprintf( f, "\t}\r\n" );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user