progress3D - Create progress bars in 3D space -
Manyula - 03.09.2018
progress3D.inc
After the 2D textdraw-based version of progress bars, here now comes the
3D version. This library lets you create progress bars in 3D space. It's basically just two overlapping 3D text labels, one being moved slightly to the right to fill in those gaps between the characters. Have fun with it!
Repository
Functions
- Bar3D:CreateProgressBar3D(Float:x, Float:y, Float:z, layout, fill_color, background_color, Float:max_value, Float:init_value, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_3D_TEXT_LABEL_SD, areaid = -1, priority = 0)
- Creates a 3D progress bar.
- DestroyProgressBar3D(Bar3D:barid)
- Destroys a 3D progress bar.
- GetProgressBar3DValue(Bar3D:barid)
- Returns the current progress value.
- SetProgressBar3DValue(Bar3D:barid, Float:value)
- Updates the value of the specified 3D progress bar.
- GetProgressBar3DFillColor(Bar3D:barid)
- Returns the fill color of the specified 3D progress bar.
- SetProgressBar3DFillColor(Bar3D:barid, fill_color)
- Updates the fill color of the specified 3D progress bar.
- GetProgressBar3DBackgroundColor(Bar3D:barid)
- Returns the background color of the specified 3D progress bar.
- SetProgressBar3DBackgroundColor(Bar3D:barid, background_color)
- Updates the background color of the specified 3D progress bar.
- GetProgressBar3DMaxValue(Bar3D:barid)
- Returns the maximum value of the specified 3D progress bar.
- SetProgressBar3DMaxValue(Bar3D:barid, Float:max_value)
- Updates the maximum value of the specified 3D progress bar.
- GetProgressBar3DLayout(Bar3D:barid)
- Returns the layout of the specified 3D progress bar.
- SetProgressBar3DLayout(Bar3D:barid, layout)
- Updates the layout of the specified 3D progress bar.
- IsValidProgressBar3D(Bar3D:barid)
- Returns true, if the specified 3D progress bar ID is valid and exists.
Changelog
v2.0- Update to YSI 5
- Added compatibility for streamer version 2.9.4
- Fixed a bug in SetProgressBar3DLayout(...) which caused the wrong layout to be applied
- Minor code refactoring
v1.3.1- Moved the position parameters x, y, z to the front of Bar3D:CreateProgressBar3D(...)
- Slightly improved code readability
v1.3- Added a new parameter layout with three new bar layout options
- BAR_3D_LAYOUT_THIN
- BAR_3D_LAYOUT_NORMAL
- BAR_3D_LAYOUT_THICK
- Added GetProgressBar3DLayout(Bar3D:barid) and SetProgressBar3DLayout(Bar3D:barid, layout)
v1.2.1- Fixed getter functions (forgot to add "_:" to the returned value)
v1.2- Added the parameter Float:max_value to Bar3D:CreateProgressBar3D(...)
- Added GetProgressBar3DMaxValue(Bar3D:barid)
- Added SetProgressBar3DMaxValue(Bar3D:barid, Float:max_value)
- Updated the testing script
v1.1- Code optimizations
- Internal check if value ranges from 0 to 100.
v1.0
Re: progress3D - Create progress bars in 3D space -
Pottus - 03.09.2018
Код:
static Bar3D:Bars3D[MAX_3D_BARS][BAR_3D_DATA],
Text3D:Bars1[MAX_3D_BARS],
Text3D:Bars2[MAX_3D_BARS];
new Iterator:Bars3D_Index<MAX_3D_BARS>,
Iterator:Bars1_Index<MAX_3D_BARS>,
Iterator:Bars2_Index<MAX_3D_BARS>;
Create one iterator, one variable and one enum instead of this disaster.
Re: progress3D - Create progress bars in 3D space -
Alteh - 03.09.2018
It looks interesting but it improves the code please.
Good release
Re: progress3D - Create progress bars in 3D space -
Kemula - 03.09.2018
I'm taking this!
Nice work.
Re: progress3D - Create progress bars in 3D space -
Manyula - 03.09.2018
First of all, thank you for the constructive feedback!
Quote:
Originally Posted by [HLF]Southclaw
Another thing I noticed was a lot of copy-paste code, bar1/bar2 could be globally allocated as `static const` to remove the need to allocate on the stack. And the code that calculates and manipulates the label text could be delegated to a separate function because currently it's copied into three places, if you had to fix a bug you'd have to fix it three times, which increases the chances of typos introducing more bugs!
Aside from that, the code is pretty good. There might be some string manipulation optimisations to be done but it's probably unnecessary. Good work!
|
In the first pass, I usually prioritize functional over optimized code - the latter is something I bother about in the second pass, so delegating the progress calculation to a separate function is definitely something I'll do, thanks!
About the stack allocation: So, you're saying that I should just do this?
PHP код:
static const bar1[] = "IIIIIIIIIIIIIIIIIIIIIIIII",
bar2[] = " IIIIIIIIIIIIIIIIIIIIIIIII";
Re: progress3D - Create progress bars in 3D space -
KinderClans - 03.09.2018
So if for example i have a timer of 20 seconds, how i can set the progress bar to fill completely in 20 seconds?
Re: progress3D - Create progress bars in 3D space -
Manyula - 03.09.2018
For now, the progress is calculated in percent, so 0.0 is the minimum and 100.0 is the maximum value.
So, if 20 seconds are 100%, then 1 seconds equals 100/20 = 5%. So, each second, you would have to increase the value by 5.0.
I realize, this might be a bit inconvenient to use. I might add "min_value" and "max_value" parameters and let the function do the calculations for you in the near future.
Re: progress3D - Create progress bars in 3D space -
SyS - 03.09.2018
Nice release.
Re: progress3D - Create progress bars in 3D space -
coool - 03.09.2018
Good release
Re: progress3D - Create progress bars in 3D space -
Manyula - 06.09.2018
Quote:
Originally Posted by Manyula
For now, the progress is calculated in percent, so 0.0 is the minimum and 100.0 is the maximum value.
|
I've now added a 'max_value' parameter and three new layout options for bar thickness. Thanks for the feedback!
Re: progress3D - Create progress bars in 3D space -
Unrea1 - 28.09.2018
I don't see the download link...
Re: progress3D - Create progress bars in 3D space -
CantBeJohn - 28.09.2018
Quote:
Originally Posted by Unrea1
I don't see the download link...
|
https://github.com/TheManyula/progress3D/releases
(It's currently missing from the main post for some reason)
Re: progress3D - Create progress bars in 3D space -
tonmgdamamg3 - 22.01.2019
Please update this for support streamer plugin v2.9.4, i've found many error for streamer v.2.9.4
Re: progress3D - Create progress bars in 3D space -
RenanMsV - 22.01.2019
The test pwn is just crashing my pawncc. cant compile it :B 0.3.7
Re: progress3D - Create progress bars in 3D space -
Manyula - 23.01.2019
Quote:
Originally Posted by tonmgdamamg3
Please update this for support streamer plugin v2.9.4, i've found many error for streamer v.2.9.4
|
The errors are caused by the 2.9.4 version of the streamer plugin.
EDIT: The issue was a tag that got removed in the new streamer version. progress3D version 2.0 is now compatible with streamer version 2.9.4.
Quote:
Originally Posted by RenanMsV
The test pwn is just crashing my pawncc. cant compile it :B 0.3.7
|
Are you using sampctl? Which compiler version are you using?
Re: progress3D - Create progress bars in 3D space -
Kar - 23.01.2019
Awesome, no border?
Re: progress3D - Create progress bars in 3D space -
Manyula - 24.01.2019
Quote:
Originally Posted by Kar
Awesome, no border?
|
Unfortunately no border. Adding outlines to the characters themselves also adds their outlines to the center of the progress bar.
In order to add a border that only surrounds the bar would require four entirely black bars covering all four edges, so eight additional 3D text labels. I don't think that's worth it.
Quite some time ago, I suggested adding variable font sizes and letter spacing to 3D text labels which would drastically reduce the amount of labels required. Since that hasn't happened, there's nothing I can do.