diff options
| author | johann nadalutti <[email protected]> | 2024-02-29 18:28:51 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-29 18:28:51 +0100 |
| commit | 53221eb799de037eaaae4accbfc5ef6f6c2fe1bb (patch) | |
| tree | 2f71f84d75ec63a36f1bdff8e03ecbe854db2189 /src/external | |
| parent | 077ab6d56bea4fc464cd5c07e02071e911eac64a (diff) | |
| download | raylib-53221eb799de037eaaae4accbfc5ef6f6c2fe1bb.tar.gz raylib-53221eb799de037eaaae4accbfc5ef6f6c2fe1bb.zip | |
feat: vox_loader normals and new voxels shader (#3843)
Diffstat (limited to 'src/external')
| -rw-r--r-- | src/external/vox_loader.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/external/vox_loader.h b/src/external/vox_loader.h index 6df10b51..0d328c07 100644 --- a/src/external/vox_loader.h +++ b/src/external/vox_loader.h @@ -123,6 +123,7 @@ typedef struct { // Arrays for mesh build ArrayVector3 vertices; + ArrayVector3 normals; ArrayUShort indices; ArrayColor colors; @@ -292,6 +293,16 @@ const VoxVector3 SolidVertex[] = { {1, 1, 1} //7 }; +const VoxVector3 FacesPerSideNormal[] = { + { -1, 0, 0 }, //-X + {1, 0, 0 }, //+X + {0,-1, 0}, //-Y + {0, 1, 0}, //+Y + {0, 0, -1}, //-Z + {0, 0, 1}, //+Z +}; + + // Allocated VoxArray3D size static void Vox_AllocArray(VoxArray3D* pvoxarray, int _sx, int _sy, int _sz) { @@ -508,6 +519,11 @@ static void Vox_Build_Voxel(VoxArray3D* pvoxArray, int x, int y, int z, int matI insertArrayVector3(&pvoxArray->vertices, vertComputed[v2]); insertArrayVector3(&pvoxArray->vertices, vertComputed[v3]); + insertArrayVector3(&pvoxArray->normals, FacesPerSideNormal[i]); + insertArrayVector3(&pvoxArray->normals, FacesPerSideNormal[i]); + insertArrayVector3(&pvoxArray->normals, FacesPerSideNormal[i]); + insertArrayVector3(&pvoxArray->normals, FacesPerSideNormal[i]); + VoxColor col = pvoxArray->palette[matID]; insertArrayColor(&pvoxArray->colors, col); @@ -653,6 +669,7 @@ int Vox_LoadFromMemory(unsigned char* pvoxData, unsigned int voxDataSize, VoxArr // Init Arrays initArrayVector3(&pvoxarray->vertices, 3 * 1024); + initArrayVector3(&pvoxarray->normals, 3 * 1024); initArrayUShort(&pvoxarray->indices, 3 * 1024); initArrayColor(&pvoxarray->colors, 3 * 1024); |
