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

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

Thread Status:
Not open for further replies.
  1. Offline

    SuperMamie

    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.
     
  2. Offline

    Antariano

    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

    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
     
  4. Offline

    Bertware

    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

    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

    This is freaking sweet. Nice job.
     
  7. Offline

    FabianN

    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.
     
  8. Offline

    Bertware

     
  9. Offline

    SuperMamie

    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

    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

    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

    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

    Thanks for this! I'll credit you on the website I'm using these on!
     
  14. Offline

    SuperMamie

    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
     
  15. Offline

    TNTUP

    Last edited by a moderator: May 25, 2016
  16. Offline

    connorcpu

    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 :)
     
  17. Offline

    Chlorek

    Oh man! It is amazing! That's so cool that there are great programmers like you! :)
     
  18. Offline

    eneroth3

    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');
     
  19. Offline

    SuperMamie

    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 :)

    And done, thanks to the online edition in github ^^

    (problem : not tested at all)
    https://github.com/supermamie/php-Minecraft-3D-skin/blob/master/3d.php

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  20. Offline

    SuperMamie

    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
     
  21. Offline

    bearbear12345

    Hey, could you give the parameters for each of the images in the OP.
    I'm not sure what values to enter
     
  22. Offline

    SuperMamie

    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 ^^ )
     
  23. Offline

    baggyrabbit

    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?
     
  24. Offline

    SuperMamie

    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.
  25. Offline

    baggyrabbit

    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.
     
  26. Offline

    hellboyPS

    This is a really cool script. Thank you!
     
  27. Offline

    trustyo

    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.
     
  28. Offline

    iMeta95

    Any updates on this? :(
     
  29. Offline

    SuperMamie

    I haven't played minecraft in ages so I didn't spent many time on this, sorry :(
    I'm pretty sure one of the forks fixed this but I received no pull request to merge any fix :(
     
  30. Offline

    Mister_Fix

    Any chance of you separating the HeadOnly feature from the rest of the script and posting it here?
     
Thread Status:
Not open for further replies.

Share This Page