Beispiel #1
0
        private RenderableObject ConvertToObject(SceneFormat.SceneObject parsedObject, Dictionary <string, Material> materials)
        {
            var tran     = ConvertTransform(parsedObject.Transform);
            var mesh     = GetMesh(parsedObject);
            var material = GetMaterial(parsedObject, materials);

            return(new RenderableObject()
            {
                id = parsedObject.Id,
                transform = tran,
                mesh = mesh,
                material = material,
            });
        }
Beispiel #2
0
        private Mesh GetMesh(SceneFormat.SceneObject parsedObject)
        {
            switch (parsedObject.MeshCase)
            {
            case SceneFormat.SceneObject.MeshOneofCase.Sphere:
                return(new Sphere((float)parsedObject.Sphere.Radius));

            case SceneFormat.SceneObject.MeshOneofCase.Cube:
                return(new Box(ConvertVector(parsedObject.Cube.Size) * 0.5f));

            case SceneFormat.SceneObject.MeshOneofCase.Plane:
                return(new Plane());

            case SceneFormat.SceneObject.MeshOneofCase.Disk:
                return(new Disk((float)parsedObject.Disk.Radius));

            case SceneFormat.SceneObject.MeshOneofCase.MeshedObject:
                return(ObjWorker.Parse(parsedObject.MeshedObject.Reference));

            default:
                throw new Exception("Unsupported mesh");
            }
        }