Problem defining Image Asset in code
by Eero Karvonen · in Torque 2D Beginner · 10/24/2013 (2:32 pm) · 3 replies
Hi,
I bumped into an Asset Manager behavior the reason of which I do not quite follow:
When I run this,
In the asset file I get this content,
So, what is the Asset Manager doing here, I'm wondering? And how can I tell it not to try to guess the absolute path and just work with relative ones, as it's already clearly stated in the documentation?
By the way, is there any info on when the writing of the T2D MIT documentation will be continued?
EK
I bumped into an Asset Manager behavior the reason of which I do not quite follow:
When I run this,
$ASSET_DIR = "/my/relative/asset/path/"; %source = "tileset.png"; %asset.ImageFile = %source; TamlWrite( %asset, $ASSET_DIR @ "TilesetTest.asset.taml" );
In the asset file I get this content,
<ImageAsset
ImageFile="@assetFile=/path/to/Torque2D-2.0/tileset.png />"which is the directory of the executable itself.So, what is the Asset Manager doing here, I'm wondering? And how can I tell it not to try to guess the absolute path and just work with relative ones, as it's already clearly stated in the documentation?
By the way, is there any info on when the writing of the T2D MIT documentation will be continued?
EK
#2
I'm creating some assets live because I'm working on an external map format importer. And there's no logical reason, since now that I reconsider it, it doesn't seem to be a necessary course of action to write out volatile assets. Run-time Private Asset seems to be better suited to the purpose.
10/25/2013 (10:12 am)
Thank you for a quick reply! It will certainly help.I'm creating some assets live because I'm working on an external map format importer. And there's no logical reason, since now that I reconsider it, it doesn't seem to be a necessary course of action to write out volatile assets. Run-time Private Asset seems to be better suited to the purpose.
#3
10/25/2013 (10:08 pm)
I posted a resource that will let you generate basic asset definitions just by pointing it at the right directory. You then have to edit them if they're celled sprite sheets, and you have to create animations by hand - but it saves a ton of typing if you have a large number of assets. It is what I used to create the original asset definitions for T2D.
Associate Mike Lilligreen
Retired T2Der
In any case, as mentioned in the asset manager guide, internally Torque needs to work with absolute file paths when working with live assets. Only when the asset is persisted do we want a relative path. When specifying just "tileset.png", Torque thinks this file is in the root folder where the executable is located. You would have to change the string to something like this:
depending on where the asset is located in your module.
I did a bit of testing and when writing an asset out with TAML, it doesn't look like the absolute file path is properly collapsed with collapseAssetFilePath() in the onTamlPreWrite callback. This could be a bug but I would need someone with better C++ knowledge to look over the code to confirm.
As for more documentation, as a open source project we are dependent on the community to write/submit tutorials and guides - nobody gets professionally paid to do this. Hopefully there are people out there willing to contribute.