|
|
@ -4511,23 +4511,23 @@ char *EncodeBase64(const unsigned char *data, int inputLength, int *outputLength |
|
|
|
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
|
|
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const int modTable[] = { 0, 2, 1 }; |
|
|
|
|
|
|
|
|
|
|
|
*outputLength = 4*((inputLength + 2)/3); |
|
|
|
|
|
|
|
|
|
|
|
char *encodedData = RL_MALLOC(*outputLength); |
|
|
|
|
|
|
|
|
|
|
|
if (encodedData == NULL) return NULL; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0, j = 0; i < inputLength;) |
|
|
|
{ |
|
|
|
unsigned int octetA = (i < inputLength)? (unsigned char)data[i++] : 0; |
|
|
|
unsigned int octetB = (i < inputLength)? (unsigned char)data[i++] : 0; |
|
|
|
unsigned int octetC = (i < inputLength)? (unsigned char)data[i++] : 0; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int triple = (octetA << 0x10) + (octetB << 0x08) + octetC; |
|
|
|
|
|
|
|
|
|
|
|
encodedData[j++] = base64encodeTable[(triple >> 3*6) & 0x3F]; |
|
|
|
encodedData[j++] = base64encodeTable[(triple >> 2*6) & 0x3F]; |
|
|
|
encodedData[j++] = base64encodeTable[(triple >> 1*6) & 0x3F]; |
|
|
@ -4535,7 +4535,7 @@ char *EncodeBase64(const unsigned char *data, int inputLength, int *outputLength |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < modTable[inputLength%3]; i++) encodedData[*outputLength - 1 - i] = '='; |
|
|
|
|
|
|
|
|
|
|
|
return encodedData; |
|
|
|
} |
|
|
|
|
|
|
@ -4544,11 +4544,11 @@ static unsigned char *DecodeBase64(char *data, int *outputLength) |
|
|
|
{ |
|
|
|
static const unsigned char base64decodeTable[] = { |
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
|
|
0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
|
|
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
|
|
|
0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
|
|
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
|
|
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Get output size of Base64 input data |
|
|
|
int outLength = 0; |
|
|
|
for (int i = 0; data[4*i] != 0; i++) |
|
|
@ -4625,7 +4625,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *image, const char *texPath, Co |
|
|
|
|
|
|
|
int size = 0; |
|
|
|
unsigned char *data = DecodeBase64(image->uri + i + 1, &size); // TODO: Use cgltf_load_buffer_base64() |
|
|
|
|
|
|
|
|
|
|
|
rimage = LoadImageFromMemory(".png", data, size); |
|
|
|
RL_FREE(data); |
|
|
|
|
|
|
@ -5596,7 +5596,7 @@ void LoadGLTFMesh(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix cu |
|
|
|
{ |
|
|
|
cgltf_accessor *acc = mesh->primitives[p].attributes[j].data; |
|
|
|
outModel->meshes[(*primitiveIndex)].vertexCount = (int)acc->count; |
|
|
|
|
|
|
|
|
|
|
|
int bufferSize = outModel->meshes[(*primitiveIndex)].vertexCount*3*sizeof(float); |
|
|
|
outModel->meshes[(*primitiveIndex)].animVertices = RL_MALLOC(bufferSize); |
|
|
|
|
|
|
@ -5657,7 +5657,7 @@ void LoadGLTFMesh(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix cu |
|
|
|
unsigned int totalBoneWeights = boneCount*4; |
|
|
|
outModel->meshes[(*primitiveIndex)].boneIds = RL_MALLOC(totalBoneWeights*sizeof(int)); |
|
|
|
short *bones = ReadGLTFValuesAs(acc, cgltf_component_type_r_16, false); |
|
|
|
|
|
|
|
|
|
|
|
// Find skin joint |
|
|
|
for (unsigned int a = 0; a < totalBoneWeights; a++) |
|
|
|
{ |
|
|
@ -5667,7 +5667,7 @@ void LoadGLTFMesh(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix cu |
|
|
|
unsigned int skinJointId = skinJoint - data->nodes; |
|
|
|
outModel->meshes[(*primitiveIndex)].boneIds[a] = skinJointId; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RL_FREE(bones); |
|
|
|
} |
|
|
|
else if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_weights) |
|
|
|