public void CreateBabylonMaterial(BabylonScene scene)
        {
            var babylonMaterial = new BabylonMaterial();
            scene.MaterialsList.Add(babylonMaterial);

            // Guid
            babylonMaterial.id = ID.ToString();

            // Name
            babylonMaterial.name = Name;

            // Data
            babylonMaterial.backFaceCulling = BackFaceCulling;
            babylonMaterial.diffuse = Diffuse.ToArray();
            babylonMaterial.emissive = Emissive.ToArray();
            babylonMaterial.specular = Specular.ToArray();
            babylonMaterial.specularPower = SpecularPower;
            babylonMaterial.alpha = Alpha;

            if (string.IsNullOrEmpty(DiffuseTexture))
            {
                babylonMaterial.diffuseTexture = null;
                return;
            }

            babylonMaterial.diffuseTexture = new BabylonTexture();
            babylonMaterial.diffuseTexture.name = Path.GetFileName(DiffuseTexture);

            scene.AddTexture(DiffuseTexture);
        }
Example #2
0
        public static Guid CreateBabylonMesh(string name, BabylonScene scene)
        {
            var babylonMesh = new BabylonMesh();
            scene.MeshesList.Add(babylonMesh);

            // Guid
            var id = Guid.NewGuid();
            babylonMesh.id = id.ToString();

            // Name
            babylonMesh.name = name;

            // Parent
            babylonMesh.parentId = "";

            // Visible
            babylonMesh.isVisible = false;

            // Material ID
            babylonMesh.materialId = "";

            // Position
            babylonMesh.position = Vector3.Zero.ToArray();

            // Vertices
            babylonMesh.positions = null;

            // Faces
            babylonMesh.indices = null;

            return id;
        }