diff options
| author | bohonghuang <[email protected]> | 2024-07-08 02:27:51 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-07 20:27:51 +0200 |
| commit | 6dd2a0e64554a37c9ab8c0a6204cb5bb1badc970 (patch) | |
| tree | 340e9df039afc91e92355cdbba4277eebb58a948 /examples/models/models_billboard.c | |
| parent | b61303244c2731b88d93fe5bc976f5e8e6ff72e3 (diff) | |
| download | raylib-6dd2a0e64554a37c9ab8c0a6204cb5bb1badc970.tar.gz raylib-6dd2a0e64554a37c9ab8c0a6204cb5bb1badc970.zip | |
[rmodels] Consistent `DrawBillboardPro` with `DrawTexturePro` (#4132)
* [rmodels] Re-implement `DrawBillboardPro`
* [rmodels] Add comments to `DrawBillboardPro`
* [rmodels] Make `DrawBillboardPro` consistent with `DrawTexturePro`
* Update raylib_api.* by CI
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'examples/models/models_billboard.c')
| -rw-r--r-- | examples/models/models_billboard.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c index 237e1b69..7ad28513 100644 --- a/examples/models/models_billboard.c +++ b/examples/models/models_billboard.c @@ -44,10 +44,12 @@ int main(void) // NOTE: Billboard locked on axis-Y Vector3 billUp = { 0.0f, 1.0f, 0.0f }; + // Set the height of the rotating billboard to 1.0 with the aspect ratio fixed + Vector2 size = { source.width / source.height, 1.0f }; + // Rotate around origin // Here we choose to rotate around the image center - // NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture - Vector2 rotateOrigin = { 0.0f }; + Vector2 origin = Vector2Scale(size, 0.5f); // Distance is needed for the correct billboard draw order // Larger distance (further away from the camera) should be drawn prior to smaller distance. @@ -84,11 +86,11 @@ int main(void) if (distanceStatic > distanceRotating) { DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE); - DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, (Vector2) {1.0f, 1.0f}, rotateOrigin, rotation, WHITE); + DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE); } else { - DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, (Vector2) {1.0f, 1.0f}, rotateOrigin, rotation, WHITE); + DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE); DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE); } @@ -108,4 +110,4 @@ int main(void) //-------------------------------------------------------------------------------------- return 0; -}
\ No newline at end of file +} |
