Skip to content

Commit

Permalink
Implement remaining model drawing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m-r-hunt committed Apr 22, 2023
1 parent e8d1e0c commit 1bf1ee1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@
[x] void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
[x] void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
[x] void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
[ ] void DrawBoundingBox(BoundingBox box, Color color)
[ ] void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
[ ] void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint)
[ ] void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
[x] void DrawBoundingBox(BoundingBox box, Color color)
[x] void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
[x] void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint)
[x] void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)

// Collision detection functions
[ ] bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB)
Expand Down
61 changes: 61 additions & 0 deletions src/3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,55 @@ static Janet cfun_DrawModelWiresEx(int32_t argc, Janet *argv) {
return janet_wrap_nil();
}

static Janet cfun_DrawBoundingBox(int32_t argc, Janet *argv) {
janet_fixarity(argc, 2);
JanetView bbox = janet_getindexed(argv, 0);
BoundingBox raw_bbox;
raw_bbox.min = jaylib_getvec3(bbox.items, 0);
raw_bbox.max = jaylib_getvec3(bbox.items, 1);
Color color = jaylib_getcolor(argv, 1);
DrawBoundingBox(raw_bbox, color);
return janet_wrap_nil();
}

static Janet cfun_DrawBillboard(int32_t argc, Janet *argv) {
janet_fixarity(argc, 5);
Camera* camera = jaylib_getcamera3d(argv, 0);
Texture2D* texture = jaylib_gettexture2d(argv, 1);
Vector3 position = jaylib_getvec3(argv, 2);
float size = (float) janet_getnumber(argv, 3);
Color tint = jaylib_getcolor(argv, 4);
DrawBillboard(*camera, *texture, position, size, tint);
return janet_wrap_nil();
}

static Janet cfun_DrawBillboardRec(int32_t argc, Janet *argv) {
janet_fixarity(argc, 6);
Camera* camera = jaylib_getcamera3d(argv, 0);
Texture2D* texture = jaylib_gettexture2d(argv, 1);
Rectangle source = jaylib_getrect(argv, 2);
Vector3 position = jaylib_getvec3(argv, 3);
Vector2 size = jaylib_getvec2(argv, 4);
Color tint = jaylib_getcolor(argv, 5);
DrawBillboardRec(*camera, *texture, source, position, size, tint);
return janet_wrap_nil();
}

static Janet cfun_DrawBillboardPro(int32_t argc, Janet *argv) {
janet_fixarity(argc, 9);
Camera* camera = jaylib_getcamera3d(argv, 0);
Texture2D* texture = jaylib_gettexture2d(argv, 1);
Rectangle source = jaylib_getrect(argv, 2);
Vector3 position = jaylib_getvec3(argv, 3);
Vector3 up = jaylib_getvec3(argv, 4);
Vector2 size = jaylib_getvec2(argv, 5);
Vector2 origin = jaylib_getvec2(argv, 6);
float rotation = (float) janet_getnumber(argv, 7);
Color tint = jaylib_getcolor(argv, 8);
DrawBillboardPro(*camera, *texture, source, position, up, size, origin, rotation, tint);
return janet_wrap_nil();
}

static JanetReg threed_cfuns[] = {
{"draw-line-3d", cfun_DrawLine3D,
"(draw-line-3d [start-x start-y start-z] [end-x end-y end-z] color)\n\n"
Expand Down Expand Up @@ -785,5 +834,17 @@ static JanetReg threed_cfuns[] = {
"(draw-model-wires-ex model position rotation-axis rotation-angle scale tint)\n\n"
"Draw a model wires (with texture if set) with extended parameters"
},
{"draw-billboard", cfun_DrawBillboard,
"(draw-billboard camera texture position size tint)\n\n"
"Draw a billboard texture"
},
{"draw-billboard-rec", cfun_DrawBillboardRec,
"(draw-billboard-rec camera texture source position size tint)\n\n"
"Draw a billboard texture defined by source"
},
{"draw-billboard-pro", cfun_DrawBillboardPro,
"(draw-billboard-pro camera texture source position up size origin rotation tint)\n\n"
"Draw a billboard texture defined by source and rotation"
},
{NULL, NULL, NULL}
};

0 comments on commit 1bf1ee1

Please sign in to comment.