|
|
@ -706,7 +706,7 @@ void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int |
|
|
|
Vector3 capCenter = endPos; |
|
|
|
|
|
|
|
float baseSliceAngle = (2.0f*PI)/slices; |
|
|
|
float baseRingAngle = PI * 0.5f / rings; |
|
|
|
float baseRingAngle = PI*0.5f/rings; |
|
|
|
|
|
|
|
rlBegin(RL_TRIANGLES); |
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a); |
|
|
@ -725,34 +725,34 @@ void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int |
|
|
|
// as we iterate through the rings they must get smaller by the cos(angle(i)) |
|
|
|
|
|
|
|
// compute the four vertices |
|
|
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
Vector3 w1 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z)*radius |
|
|
|
}; |
|
|
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
Vector3 w2 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z)*radius |
|
|
|
}; |
|
|
|
|
|
|
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
Vector3 w3 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z)*radius |
|
|
|
}; |
|
|
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
Vector3 w4 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z)*radius |
|
|
|
}; |
|
|
|
|
|
|
|
// Make sure cap triangle normals are facing outwards |
|
|
@ -849,7 +849,7 @@ void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices |
|
|
|
Vector3 capCenter = endPos; |
|
|
|
|
|
|
|
float baseSliceAngle = (2.0f*PI)/slices; |
|
|
|
float baseRingAngle = PI * 0.5f / rings; |
|
|
|
float baseRingAngle = PI*0.5f/rings; |
|
|
|
|
|
|
|
rlBegin(RL_LINES); |
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a); |
|
|
@ -868,34 +868,34 @@ void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices |
|
|
|
// as we iterate through the rings they must get smaller by the cos(angle(i)) |
|
|
|
|
|
|
|
// compute the four vertices |
|
|
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
Vector3 w1 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z)*radius |
|
|
|
}; |
|
|
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 )); |
|
|
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 )); |
|
|
|
Vector3 w2 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z)*radius |
|
|
|
}; |
|
|
|
|
|
|
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
Vector3 w3 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z)*radius |
|
|
|
}; |
|
|
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 )); |
|
|
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 )); |
|
|
|
Vector3 w4 = (Vector3){ |
|
|
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius |
|
|
|
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x)*radius, |
|
|
|
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y)*radius, |
|
|
|
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z)*radius |
|
|
|
}; |
|
|
|
|
|
|
|
rlVertex3f(w1.x, w1.y, w1.z); |
|
|
@ -1105,7 +1105,7 @@ Model LoadModelFromMesh(Mesh mesh) |
|
|
|
bool IsModelReady(Model model) |
|
|
|
{ |
|
|
|
bool result = false; |
|
|
|
|
|
|
|
|
|
|
|
if ((model.meshes != NULL) && // Validate model contains some mesh |
|
|
|
(model.materials != NULL) && // Validate model contains some material (at least default one) |
|
|
|
(model.meshMaterial != NULL) && // Validate mesh-material linkage |
|
|
@ -1113,7 +1113,7 @@ bool IsModelReady(Model model) |
|
|
|
(model.materialCount > 0)) result = true; // Validate material count |
|
|
|
|
|
|
|
// NOTE: This is a very general model validation, many elements could be validated from a model... |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -1966,18 +1966,18 @@ static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, i |
|
|
|
materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; |
|
|
|
|
|
|
|
if (mats[m].diffuse_texname != NULL) materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = LoadTexture(mats[m].diffuse_texname); //char *diffuse_texname; // map_Kd |
|
|
|
else materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(mats[m].diffuse[0]*255.0f), (unsigned char)(mats[m].diffuse[1]*255.0f), (unsigned char)(mats[m].diffuse[2] * 255.0f), 255 }; //float diffuse[3]; |
|
|
|
else materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(mats[m].diffuse[0]*255.0f), (unsigned char)(mats[m].diffuse[1]*255.0f), (unsigned char)(mats[m].diffuse[2]*255.0f), 255 }; //float diffuse[3]; |
|
|
|
materials[m].maps[MATERIAL_MAP_DIFFUSE].value = 0.0f; |
|
|
|
|
|
|
|
if (mats[m].specular_texname != NULL) materials[m].maps[MATERIAL_MAP_SPECULAR].texture = LoadTexture(mats[m].specular_texname); //char *specular_texname; // map_Ks |
|
|
|
materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(mats[m].specular[0]*255.0f), (unsigned char)(mats[m].specular[1]*255.0f), (unsigned char)(mats[m].specular[2] * 255.0f), 255 }; //float specular[3]; |
|
|
|
materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(mats[m].specular[0]*255.0f), (unsigned char)(mats[m].specular[1]*255.0f), (unsigned char)(mats[m].specular[2]*255.0f), 255 }; //float specular[3]; |
|
|
|
materials[m].maps[MATERIAL_MAP_SPECULAR].value = 0.0f; |
|
|
|
|
|
|
|
if (mats[m].bump_texname != NULL) materials[m].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture(mats[m].bump_texname); //char *bump_texname; // map_bump, bump |
|
|
|
materials[m].maps[MATERIAL_MAP_NORMAL].color = WHITE; |
|
|
|
materials[m].maps[MATERIAL_MAP_NORMAL].value = mats[m].shininess; |
|
|
|
|
|
|
|
materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(mats[m].emission[0]*255.0f), (unsigned char)(mats[m].emission[1]*255.0f), (unsigned char)(mats[m].emission[2] * 255.0f), 255 }; //float emission[3]; |
|
|
|
materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(mats[m].emission[0]*255.0f), (unsigned char)(mats[m].emission[1]*255.0f), (unsigned char)(mats[m].emission[2]*255.0f), 255 }; //float emission[3]; |
|
|
|
|
|
|
|
if (mats[m].displacement_texname != NULL) materials[m].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture(mats[m].displacement_texname); //char *displacement_texname; // disp |
|
|
|
} |
|
|
@ -2038,10 +2038,10 @@ Material LoadMaterialDefault(void) |
|
|
|
bool IsMaterialReady(Material material) |
|
|
|
{ |
|
|
|
bool result = false; |
|
|
|
|
|
|
|
|
|
|
|
if ((material.maps != NULL) && // Validate material contain some map |
|
|
|
(material.shader.id > 0)) result = true; // Validate material shader is valid |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -2349,7 +2349,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) |
|
|
|
for (int face = 0; face < numFaces; face++) |
|
|
|
{ |
|
|
|
// Retrieve lower left corner from face ind |
|
|
|
int i = face + face / (resX - 1); |
|
|
|
int i = face + face/(resX - 1); |
|
|
|
|
|
|
|
triangles[t++] = i + resX; |
|
|
|
triangles[t++] = i + 1; |
|
|
@ -3038,7 +3038,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) |
|
|
|
Color *pixels = LoadImageColors(cubicmap); |
|
|
|
|
|
|
|
// NOTE: Max possible number of triangles numCubes*(12 triangles by cube) |
|
|
|
int maxTriangles = cubicmap.width * cubicmap.height * 12; |
|
|
|
int maxTriangles = cubicmap.width*cubicmap.height*12; |
|
|
|
|
|
|
|
int vCounter = 0; // Used to count vertices |
|
|
|
int tcCounter = 0; // Used to count texcoords |
|
|
@ -3588,6 +3588,8 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector |
|
|
|
DrawBillboardPro(camera, texture, source, position, up, size, Vector2Zero(), 0.0f, tint); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw a billboard with additional parameters |
|
|
|
// NOTE: Size defines the destination rectangle size, stretching the source texture as required |
|
|
|
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint) |
|
|
|
{ |
|
|
|
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width |
|
|
@ -3657,7 +3659,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector |
|
|
|
rlBegin(RL_QUADS); |
|
|
|
rlColor4ub(tint.r, tint.g, tint.b, tint.a); |
|
|
|
|
|
|
|
if (sizeRatio.x * sizeRatio.y >= 0.0f) |
|
|
|
if (sizeRatio.x*sizeRatio.y >= 0.0f) |
|
|
|
{ |
|
|
|
// Bottom-left corner for texture and quad |
|
|
|
rlTexCoord2f((float)source.x/texture.width, (float)source.y/texture.height); |
|
|
@ -5278,7 +5280,7 @@ static Model LoadGLTF(const char *fileName) |
|
|
|
} |
|
|
|
else TRACELOG(LOG_WARNING, "MODEL: [%s] Color attribute data format not supported", fileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// NOTE: Attributes related to animations are processed separately |
|
|
@ -5405,7 +5407,7 @@ static Model LoadGLTF(const char *fileName) |
|
|
|
{ |
|
|
|
// Init raylib mesh boneIds to copy glTF attribute data |
|
|
|
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char)); |
|
|
|
|
|
|
|
|
|
|
|
// Load attribute: vec4, u8 (unsigned char) |
|
|
|
LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds) |
|
|
|
} |
|
|
@ -6310,7 +6312,7 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCou |
|
|
|
|
|
|
|
for (unsigned int a = 0; a < m3d->numaction; a++) |
|
|
|
{ |
|
|
|
animations[a].frameCount = m3d->action[a].durationmsec / M3D_ANIMDELAY; |
|
|
|
animations[a].frameCount = m3d->action[a].durationmsec/M3D_ANIMDELAY; |
|
|
|
animations[a].boneCount = m3d->numbone + 1; |
|
|
|
animations[a].bones = RL_MALLOC((m3d->numbone + 1)*sizeof(BoneInfo)); |
|
|
|
animations[a].framePoses = RL_MALLOC(animations[a].frameCount*sizeof(Transform *)); |
|
|
|