[DONE] Raw Item to image conversion

Added by vl over 9 years ago

Could be nice, as for the guild icon, to be able to display an item based on the parameter.

Something like:

http://www.example.com/item.php?sheetid=icfm2ss_2.sitem

that will return the image of the item.


Replies (16)

RE: Raw Item to image conversion - Added by nimetu over 9 years ago

hmm.. http://bmsite.net/?p=items&sheetid=icfm2ss_2.sitem
armor/jewels/ammo/temple items not included

RE: Raw Item to image conversion - Added by vl over 9 years ago

That's nice ideed,
In fact, I thought of the icon of the item with the decoration, like we see them in the inventory.
That will be the main tool to be able to display the inventories and equipment/hands

RE: Raw Item to image conversion - Added by vl over 9 years ago

I added the stack in this page:

http://atys.ryzom.com/characters/example.php?key=1224Z0ZD418CFF7

Colors for items in the backup are id from 0 to N so I think there's a conversion table colorId=>colorRGB.
I don't find the quality in the item backup.

Example of a raw item:

           <_Item>
                <_ItemId type="UINT64" value="7290603103772716950"/>
                <_SheetId type="SHEET_ID" value="icfahs_3.sitem"/>
                <_LocSlot type="UINT32" value="97"/>
                <_HP type="UINT32" value="520"/>
                <_Recommended type="UINT32" value="220"/>
                <_CreatorId type="ENTITY_ID" value="(0x0000047200:00:00:90)"/>
                <_PhraseId type="STRING" value=""/>
                <_CraftParameters>
                    <Durability type="FLOAT" value="1.600001"/>
                    <Weight type="FLOAT" value="0.860000"/>
                    <StatEnergy type="FLOAT" value="0.800002"/>
                    <DodgeModifier type="FLOAT" value="0.770000"/>
                    <ParryModifier type="FLOAT" value="1.200000"/>
                    <ProtectionFactor type="FLOAT" value="1.130000"/>
                    <MaxSlashingProtection type="FLOAT" value="1.200000"/>
                    <MaxBluntProtection type="FLOAT" value="1.016000"/>
                    <MaxPiercingProtection type="FLOAT" value="0.824000"/>
                    <Color type="UINT32" value="0"/>
                    <HpBuff type="SINT32" value="110"/>
                    <Protection type="STRING" value="None"/>
                    <Protection1 type="STRING" value="None"/>
                    <Protection2 type="STRING" value="None"/>
                    <Protection3 type="STRING" value="None"/>
                </_CraftParameters>
                <_UseNewSystemRequirement type="SINT32" value="1"/>
                <_RequiredSkillLevel type="UINT32" value="195"/>
                <_RequiredCharac type="STRING" value="Constitution"/>
                <_RequiredCharacLevel type="UINT32" value="210"/>
                <_CustomText type="STRING" value=""/>
            </_Item>

RE: Raw Item to image conversion - Added by vl over 9 years ago

Ok,

I integrated the quality and quantity.

Just need to find the colorid=>rgb table.

RE: Raw Item to image conversion - Added by barbaros over 9 years ago

The color mapping of the client

<define id="armour_color_0" value="233 22 0 255"/>
<define id="armour_color_1" value="220 140 50 255"/>
<define id="armour_color_2" value="170 250 0 255"/>
<define id="armour_color_3" value="0 215 120 255"/>
<define id="armour_color_4" value="50 100 255 255"/>
<define id="armour_color_5" value="170 55 110 255"/>
<define id="armour_color_6" value="250 250 250 255"/>
<define id="armour_color_7" value="80 80 120 255"/>

To have it complete, equipments/hands do miss the qualitiy, color and weight attributes.
It would be nice to add the enchant/sap load to weapons.

RE: Raw Item to image conversion - Added by barbaros over 9 years ago

Patch 1.4.0 did fix some of the sheets, as far as I remember the NPC Boss armors do have a background image now and the NPC range ammos as well.

Such a web service will need an image cache or it will eat up the servers cpu time as soon as people start using it.

Compare the load times of both sites:
http://atys.ryzom.com/characters/example.php?key=1224Z0ZD418CFF7
http://www.waechterderduenen.de/example.php?key=1224Z0ZD418CFF7

PS: Because the content is gzip compressed, this example will not work for most users.

<?
$xml = simplexml_load_file('http://atys.ryzom.com/characters/index.php?key=<apikey>');
echo "Name: ".$xml->name;
?>

RE: Raw Item to image conversion - Added by nimetu over 9 years ago

added the color mapping, sap load and 'destroyed' item marker

full URL for imaginary item is like this
http://bmsite.net/api/item.php?sheetid=iczalb_3.sitem&color=4&q=300&stack=1&sap=9&destroyed=1

item_icon.tgz (680.1 kB)

RE: Raw Item to image conversion - Added by barbaros over 9 years ago

Sap needs to be adjusted to match Ryzoms database.

sap=0 should have no crystal icon
sap=1 needs a cyrstal icon and 0 as the load
and so on..

RE: Raw Item to image conversion - Added by nimetu over 9 years ago

sap value is fixed, cache is added. needs '.cache' folder and cache is c/a/cache.png style (file name is md5 from url params)
ofcourse now cache fills entire disk space hehe (~7400 items takes around 30M)

strangely, bmsite.net webserver dies when i use '304 Not Modified' cache. possible because script does not output anything and is related to webhost.
that code is commented out. it uses passthru instead.

item db should be from current ryzom sitem.packed_sheets file.
i created greyish background to build image on, so maybe it's better now.

item_icon.tgz (693.5 kB)

RE: Raw Item to image conversion - Added by vl over 9 years ago

barbaros wrote:

PS: Because the content is gzip compressed, this example will not work for most users.
[...]

I fixed the example that now use curl to get the gz file

RE: [DONE] Raw Item to image conversion - Added by vl over 9 years ago

Applied in the official api ItemIcon.

RE: [DONE] Raw Item to image conversion - Added by Zerotacg about 9 years ago

Did something similar, first approch was php implementation that produced a real image, but it's quite slow, same goes for current api.
To solve the problem of the speed I choose to take the normal textures and overlap them, since I currently use png files for transparency it won't work in IE 6.
I converted the .tga + .txt files for interface textrues to .png + .css [1] for web use. I did choose png + css as I read somewhere that it would be faster then thousands of lil images, but first aproach was with the textures all sliced up into single images, not sure what's better.
The actual Item is generated by javascript [2] (line 730 - 809) since I wanted to make it client side but could also be done with some php script.
It generates the layers of the texures and overlayes them transparency does the rest, similar with the texts. Doesn't work with texture blending so for coloring items I'd need to create the colored overlays but therefor it should be quite fast.
Since I didn't need it the sap icon wasn't implemented.

[1] http://zerocraft.mine.nu/textures/
[2] http://zerocraft.mine.nu/zero_craft.js

(1-16/16)