Jump to content

Force guid for materials


photo

Recommended Posts

Hello,
I have rewrited a big part of my materials functions for the 2.15.1 version of Unigine.
I would like to know how to force the guid of a loaded material because I need to reuse the previous material's guid to get compatibility with my previous scene format.
Thanks.

Link to comment

In that case I think you can use Material::inherit(const UGUID&guid) method. For some reason it's not documented (we will fix this ASAP).

So if you already have some material you can do the following:

MaterialPtr m = Materials::findManualMaterial("Unigine::mesh_base"); // loading
UGUID new_guid;

// different ways for GUIDs generation
new_guid.generate(); 		// 1 - random guid
new_guid.generate("seed"); 	// 2 - seed-based guid generation

new_guid("50beb449ed1431141cf7696393a7bf66432c4f8d");				 // 3 - construct from string
new_guid.setFileSystemString("guid://50beb449ed1431141cf7696393a7bf66432c4f8d"); // 4 - construct from fs string

// setting new guid to inherited material
MaterialPtr m2 = m->inherit(new_guid);

Hope that helps.

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...