I wrote a Bash script to generate an XML file for each tile. They (of course) all have different file paths (Materials/Tile.xml
, Materials/6/0/0.xml
, Materials/6/0/1.xml
, etc).
Tile.xml
, 0.xml
, 1.xml
, etc:
<material>
<technique name="Techniques/Diff.xml" quality="0" />
</material>
I create the grid of tiles, each using a different XML file (Materials/6/0/0.xml
, Materials/6/0/1.xml
, etc). I then create a test floating block using Materials/Tile.xml
and programmatically assign it a texture. They all change to that texture.
Here is my “floating test block”:
auto cache = GetSubsystem< Urho3D::ResourceCache >();
const char* tileData = tileString.c_str();
Urho3D::MemoryBuffer tileMemoryBuffer( (void*)tileData, tileString.size() );
Urho3D::SharedPtr< Urho3D::Texture2D > tileTexture2D;
tileTexture2D = new Urho3D::Texture2D( context_ );
tileTexture2D->Load( tileMemoryBuffer );
Urho3D::SharedPtr< Urho3D::Node > tileNode_;
Urho3D::SharedPtr< Urho3D::StaticModel > tileObject;
Urho3D::SharedPtr< Urho3D::Material > tileMaterial;
tileNode_ = scene_->CreateChild( "tile" );
tileNode_->SetPosition( Urho3D::Vector3( 0, 4, 0 ) );
tileNode_->SetRotation( Urho3D::Quaternion( 0, 90, 0 ) );
tileNode_->SetScale( Urho3D::Vector3( MAP_TILE_MULTIPLIER, 1, MAP_TILE_MULTIPLIER ) );
tileObject = tileNode_->CreateComponent< Urho3D::StaticModel >();
tileObject->SetModel( cache->GetResource< Urho3D::Model >( "Models/Box.mdl" ) );
tileMaterial = cache->GetResource< Urho3D::Material >( "Materials/6/0/0.xml" );
tileMaterial->SetTexture( Urho3D::TU_DIFFUSE, tileTexture2D );
tileObject->SetMaterial( tileMaterial );
It is my understanding that ResourceCache
caches based on file hashes/file paths. Does it instead cache on something else and that is why they are all changing, not just the “floating test block”?