Customize Non-PBR إلى aterateraterالمواد ononedition قبل aving aving 3D cencenes إلى GLTF 2.0 orormat في C#

Non-PBR إلى PBateraterateron

Tله C# رمز مثال يوضح كيفية تحويل المواد إلى المواد PBR ، ومن ثم يوفر 3D المشهد في تنسيق GLTF مع C# 3D ملف التلاعب والتحويل API:

C#

 // initialize a new 3D scene

var s = new Scene();

var box = new Box();

s.RootNode.CreateChildNode("box1", box).Material = new PhongMaterial() {DiffuseColor = new Vector3(1, 0, 1)};

GLTFSaveOptions opt = new GLTFSaveOptions(FileFormat.GLTF2);

//Custom material converter to convert PhongMaterial to PbrMaterial

opt.MaterialConverter = delegate(Material material)

{

    PhongMaterial m = (PhongMaterial) material;

    return new PbrMaterial() {Albedo = new Vector3(m.DiffuseColor.x, m.DiffuseColor.y, m.DiffuseColor.z)};

};

// save in GLTF 2.0 format

s.Save("test.gltf", opt);