private void CollectSubAssets(Subassets subassets, OpenVDBStream stream, OpenVDBStreamDescriptor descriptor)
        {
            var     go      = stream.gameObject;
            Texture texture = null;

            if (descriptor.settings.extractTextures)
            {
                texture = descriptor.settings.textures.First();
                AddRemap(new SourceAssetIdentifier(typeof(Texture), texture.name), texture);
            }
            else
            {
                if (stream.texture3D != null)
                {
                    texture = stream.texture3D;
                    subassets.Add(stream.texture3D.name, stream.texture3D);
                }
            }

            var meshFilter = go.GetOrAddComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.sharedMesh      = stream.mesh;
                meshFilter.sharedMesh.name = go.name;
                subassets.Add(meshFilter.sharedMesh.name, meshFilter.sharedMesh);
            }
            var renderer = go.GetOrAddComponent <MeshRenderer>();

            if (renderer == null)
            {
                return;
            }
            if (!descriptor.settings.importMaterials)
            {
                return;
            }
            if (descriptor.settings.extractMaterials)
            {
                var material = descriptor.settings.materials.First();
                AddRemap(new SourceAssetIdentifier(typeof(Material), material.name), material);
                renderer.sharedMaterial = material;
            }
            else
            {
                renderer.sharedMaterial = subassets.defaultMaterial;
            }

            if (texture == null)
            {
                return;
            }
            renderer.sharedMaterial.SetTexture("_Volume", texture);
            renderer.sharedMaterial.name = texture.name;
        }
Exemplo n.º 2
0
 public OpenVDBStream(GameObject go, OpenVDBStreamDescriptor mStreamDesc)
 {
     m_go = go;
     m_streamDescriptor = mStreamDesc;
 }
 private void GenerateSubAssets(Subassets subassets, OpenVDBStream stream, OpenVDBStreamDescriptor descriptor)
 {
     CollectSubAssets(subassets, stream, descriptor);
 }