[WEB] php 3D skin render (png/svg)

Discussion in 'Bukkit Tools' started by SuperMamie, Apr 17, 2012.

  1. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hi everybody,

    I just made a script for the minecraft server where I play (esperia) to display 3D avatars in the forum/wiki.

    Here are all the arguments actually used by the script, and then some examples (and finally the php script itself)

    Feel free to ask any question about it.

    [IMG]

    [IMG]
    (note : the vertical line at the right is fixed)

    [IMG]
    [IMG]
    [IMG]
    [IMG]
    [IMG]

    and even HD skins:
    [IMG]

    All you need to use this script on your server is to have GD2 activated in php.
    Then put this script anywhere on your web server and you can call it with something like http://your-server.com/3dRender.php?a=-25&w=35&wt=-45&abg=0&abd=-30&ajg=-25&ajd=30&ratio=20&format=png&displayHairs=true&headOnly=false&login=supermamie


    the code it too long to be embedded in a post, so it is linked
    https://github.com/supermamie/php-Minecraft-3D-skin

    Some comments are in french, as the name of the variables (like 'abd' mean "angle Alpha pour le Bras Droit" (alpha angle for right angle))

    I know this script is not really really easy to use but you can easily limit some parameters, you can only use "a", "w", "ratio" and "login" and you'll still have a pretty good result.

    PS : I still have a problem with skin without a transparent background, if someone have a fix for that, for now I just use "displayHairs=false" to solve this.

    This post has been edited 10 times. It was last edited by SuperMamie Jan 12, 2013.
  2. Offline

    Antariano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hello! This looks like a great piece of code, I will definetly have a look at it tomorrow, when I am not a half-dead zombie of "not enough sleep".

    I can't find a license in your code, though... Is this public domain?
  3. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I don't know which license is the best for "do whatever you want with this, modify it, publish it elsewhere, torture it, but please, just keep my name in the header"

    edit : license updated with a BSD license

    This post has been edited 1 time. It was last edited by SuperMamie Apr 17, 2012.
  4. Offline

    Bertware

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Really nice!
    One hint:
    Could you add something to load the default skin for not registered users?
    So if you would use this somewhere, and a username is not registered with minecraft (e.g. A user hasn't linked with his minecraft username) the default face/skin is shown?
    Otherwise, it's really great! (I guess it outperforms minotar. My GUI player list is going to get an upgrade :D )
  5. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Currently there is no default skin loaded, I'll add this whenever I'll have some time to code. For now, if a wrong username is set, a full dark avatar will be rendered. If no avatar is set, it will search for a skin called "tmp.png" on the server (and load a full dark skin if not found) I just found a bug when arms or legs are raised at more than 90° And I have a question : how does minecraft treat transparent pixels in skins ? for example, if the face is transparent but not the other faces of the head, are all other faces visibles inside the head or no ? (if "backside" faces are not visible, I will remove them from the script so the rendering whould become nearly twice as fast)
  6. Offline

    rmsy

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is freaking sweet. Nice job.
  7. Offline

    FabianN

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is great, I was just looking for a new skin render script. One thing that the old one I had been using that had been nice is a settable border, if you think you could add that, that would be awesome.

    In the previous script I had been using you could choose the thickness and color of the border (or not have one at all).
    I can try to dig the old one up for you to look at if that'd help.


    Edit:
    One other thing that would make this great for my uses, finer-grained sizing, along with a smaller minimum.

    This post has been edited 1 time. It was last edited by FabianN Apr 23, 2012.
  8. Offline

    Bertware

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

    This post has been edited 1 time. It was last edited by Bertware Apr 23, 2012.
  9. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I really didn't had any time to update the script but I'll add a border, it will be quite easy I think.
    For the sizing, I'll search for an easy way to be able to define the size of the output in the parameters, I'll just need to find time ^^
    But I really think it's a bad idea to render a smaller skin, with ratio=2 the rendered image is really small :/ (but as it is a limitation I set, I can remove it)

    (and if someone have time, go ahead and branch the code, I'll be more than happy to include your fixes/upgrades)
  10. Offline

    FabianN

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Sweet.

    Mostly it's that I'd like to just use one skin render script if possible, and for my map markers I use the flat images, but your script doesn't make them small enough for my map. For the 3-D renders I'd agree that much smaller would be ugly and just not work well.

    And with finer grained sizing controls I could then also set it up so that the image size increases/decreases a bit depending on player height. The one script I found that had some nice sizing options used a percentage based sizing method.
  11. Offline

    mmuziek

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    its sweet
    btw i did not read that it was answered.
    minecraft treats transparant as black so anything that is transparant is black
  12. Offline

    Jacob Marshall

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is seriously wicked, I would love to be able to find a use for this, but not right now anyways... cheers for sharing :D
  13. Offline

    connorcpu

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks for this! I'll credit you on the website I'm using these on!
  14. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks a lot :)
    If you have some time to edit it, I've received requests to modify the script to be able to handle HD skins but I don't really have time now so maybe you can have a look for this.
    Don't forget to send me a link to your site, I'll be very happy to se that this can be usefull for someone :D

    This post has been edited 1 time. It was last edited by md_5 Sep 14, 2012.
  15. Offline

    TNTUP

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hehe nice a french speaker! I am!

    Je vais la tester sur mon serv maison :D

    This post has been edited 2 times. It was last edited by TNTUP Sep 15, 2012.
  16. Offline

    TNTUP

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  17. Offline

    connorcpu

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Well, I'm not really a php man myself, but I'm using these on player profiles and then on the forum I'm creating :) my website is connorcpu.net, and you can see how I'm using it here :)
  18. Online

    Chlorek

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Oh man! It is amazing! That's so cool that there are great programmers like you! :)
  19. Offline

    eneroth3

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    First of all, great script. I use it a lot at my server website.

    There are however 2 things I changed in it and thought I could share :)

    The images are quite slow to render so I added some cache headers just by the content-type:png header like this:
    PHP:
    $seconds_to_cache 60*60*24*7;
    $ts gmdate("D, d M Y H:i:s"time() + $seconds_to_cache) . ' GMT';
    header('Expires: ' $ts);
    header('Pragma: cache');
    header('Cache-Control: max-age=' $seconds_to_cache);
    Also I found it a bit annoying that skins were rendered black for people without their own skins so after trying to load the image from amazon I added 2 lines to load the tmp.png skin if skin had previously failed to load:
    PHP:
    if(!$imgPng)
            
    $imgPng imageCreateFromPng('tmp.png');
  20. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    En fait c'est un soucis dans l'ordre du rendu des membres.
    Il n'y a pas de gestion de collision, et vu que le bras droit passe dans ton image au travers de la tête, ben ça gère pas ^^

    EN :
    This is a problem with the order in which members are rendered. In your case, the right arm go inside the head, this is not supported, so it is displayed as it is usually (arm under head) => look weird :(

    Seems I havn't updated the script on github, I have exactly these same 2 lines on my server ^^

    (using this awesome tmp.png : [IMG] which render like this (usefull to test angles and transparence rendering :p
    [IMG]

    I'll try to find some time home to update on github, thanks :)
  21. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  22. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    And now, the script can handle HD skins (128*64, 256*128, etc...)
    Be aware that it is quite ressource consuming.
    On my server (a raspberry Pi) it takes more than 30sec to render from a 256*128 skin.

    Here is a bad example of a 128*64 skin (just my standard skin upscaled)
    [IMG]
    compared to the normal skin
    [IMG]

    Script updated here : https://github.com/supermamie/php-Minecraft-3D-skin

    edit : No particular configuration is needed, the script will calculate itself the size of the skin

    This post has been edited 2 times. It was last edited by SuperMamie Jan 12, 2013.
  23. Offline

    bearbear12345

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hey, could you give the parameters for each of the images in the OP.
    I'm not sure what values to enter
  24. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    wow, I have no idea but I can re-create some of them if you want (and I'll have the parameters)
    But the best thing is to try by yourself and you'll find some that please you :)
    All I can tell is that these parameters render this :
    [IMG]
    a=-25&w=-30&login=supermamie&ratio=15&format=png

    And these this :
    [IMG]
    a=-25&w=35&wt=-45&abg=0&abd=-30&ajg=-25&ajd=30&ratio=20&format=png&login=supermamie

    (I have these in my browser history ^^ )
  25. Offline

    baggyrabbit

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Great work on this script. I have some ideas for using it, so thanks :)
    I seem to have a problem when loading the username - "char".
    The colors don't seem right? Is this the same for you?

    This post has been edited 2 times. It was last edited by TnT Mar 4, 2013.
  26. Offline

    SuperMamie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I have exactly the same problem and I have no idea why :confused:
    I'm currently at work so I can't debug but can you try to see what skin your server download to check if it is OK ?
    And then download the skin and use it as the default skin to check what happens ?
    baggyrabbit likes this.
  27. Offline

    baggyrabbit

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    It seems to be ok. Server is pointing to http://s3.amazonaws.com/MinecraftSkins/char.png
    It's really odd. I might take a look tomorrow although I'm a fairly novice PHP dev.
    The default skin I had worked. But when I downloaded the above skin and used as default like you suggested I get the odd colour result...

    When I open the image an editor and just save straight away the size difference is way different and the larger one then works fine.

    This post has been edited 3 times. It was last edited by TnT Mar 23, 2013.
  28. Offline

    hellboyPS

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is a really cool script. Thank you!
  29. Offline

    trustyo

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Anyone know a fix for the dark blue colored skin bug? Some skins appear in their normal colors while others got like a transparent dark blue layer over them.
  30. Offline

    iMeta95

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Any updates on this? :(

    This post has been edited 1 time. It was last edited by Jade Sep 26, 2013.

Share This Page