Esempio n. 1
0
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.SkinnedMeshRenderer uSkinnedMeshRenderer) =>
            {
                var sharedMaterials    = uSkinnedMeshRenderer.sharedMaterials;
                UnityEngine.Mesh uMesh = uSkinnedMeshRenderer.sharedMesh;
                var meshEntity         = GetPrimaryEntity(uMesh);

                for (int i = 0; i < uMesh.subMeshCount; i++)
                {
                    // Find the target material entity to be used for this submesh
                    Entity targetMaterial = MeshRendererConversion.FindTargetMaterialEntity(this, sharedMaterials, i);
                    if (DstEntityManager.HasComponent <LitMaterial>(targetMaterial))
                    {
                        DstEntityManager.AddComponent <LitMeshRenderData>(meshEntity);
                        DstEntityManager.RemoveComponent <SimpleMeshRenderData>(meshEntity);
                    }
                    else if (DstEntityManager.HasComponent <SimpleMaterial>(targetMaterial))
                    {
                        if (!DstEntityManager.HasComponent <LitMeshRenderData>(meshEntity))
                        {
                            DstEntityManager.AddComponent <SimpleMeshRenderData>(meshEntity);
                        }
                    }
                }
            });
        }
Esempio n. 2
0
        private static Entity GenerateMeshRendererEntity(GameObjectConversionSystem gsys,
                                                         UnityEngine.SkinnedMeshRenderer uSkinnedMeshRenderer, Entity meshEntity, Entity materialEntity, int startIndex,
                                                         int indexCount, bool createAdditionlEntity, bool canUseGPUSkinning, bool canUseCPUSkinning)
        {
            Entity primarySkinnedMeshRenderer = gsys.GetPrimaryEntity(uSkinnedMeshRenderer);
            Entity meshRendererEntity         = primarySkinnedMeshRenderer;

            if (createAdditionlEntity)
            {
                meshRendererEntity = gsys.CreateAdditionalEntity(uSkinnedMeshRenderer);
                MeshRendererConversion.AddTransformComponent(gsys, primarySkinnedMeshRenderer, meshRendererEntity);
            }

            Unity.Tiny.Rendering.SkinnedMeshRenderer smr = new Unity.Tiny.Rendering.SkinnedMeshRenderer();
            smr.sharedMesh        = meshEntity;
            smr.material          = materialEntity;
            smr.startIndex        = startIndex;
            smr.indexCount        = indexCount;
            smr.canUseGPUSkinning = canUseGPUSkinning;
            smr.canUseCPUSkinning = canUseCPUSkinning;
            smr.shadowCastingMode = (Unity.Tiny.Rendering.ShadowCastingMode)uSkinnedMeshRenderer.shadowCastingMode;
            smr.skinQuality       = ConvertSkinQuality(uSkinnedMeshRenderer);
            gsys.DstEntityManager.AddComponentData(meshRendererEntity, smr);

            gsys.DstEntityManager.AddComponentData(meshRendererEntity, new WorldBounds());
            return(meshRendererEntity);
        }
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.SkinnedMeshRenderer uSkinnedMeshRenderer) =>
            {
                var sharedMaterials    = uSkinnedMeshRenderer.sharedMaterials;
                UnityEngine.Mesh uMesh = uSkinnedMeshRenderer.sharedMesh;
                var meshEntity         = GetPrimaryEntity(uMesh);

                for (int i = 0; i < uMesh.subMeshCount; i++)
                {
                    // Find the target material entity to be used for this submesh
                    Entity targetMaterial = MeshRendererConversion.FindTargetMaterialEntity(this, sharedMaterials, i);

                    var isLit    = DstEntityManager.HasComponent <LitMaterial>(targetMaterial);
                    var isSimple = DstEntityManager.HasComponent <SimpleMaterial>(targetMaterial);
                    if (isSimple)
                    {
                        Debug.Log("Unlit material was not supported in SkinnedMeshRenderer:" + uMesh.name);
                        continue;
                    }

                    if (isLit)
                    {
                        if (uSkinnedMeshRenderer.bones.Length > MeshSkinningConfig.GPU_SKINNING_MAX_BONES)
                        {
                            DstEntityManager.AddComponent <NeedGenerateGPUSkinnedMeshRenderer>(meshEntity);
                        }
                        DstEntityManager.AddComponent <LitMeshRenderData>(meshEntity);
                        // Remove simple data if it was there, we don't need it
                        DstEntityManager.RemoveComponent <SimpleMeshRenderData>(meshEntity);
                    }
                }
            });
        }
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.SkinnedMeshRenderer uSkinnedMeshRenderer) =>
            {
                var sharedMaterials    = uSkinnedMeshRenderer.sharedMaterials;
                UnityEngine.Mesh uMesh = uSkinnedMeshRenderer.sharedMesh;
                var meshEntity         = GetPrimaryEntity(uMesh);

                List <Entity> subSkinnedMeshRenderers = new List <Entity>();
                for (int i = 0; i < uMesh.subMeshCount; i++)
                {
                    // Find the target material entity to be used for this submesh
                    Entity targetMaterial = MeshRendererConversion.FindTargetMaterialEntity(this, sharedMaterials, i);

                    var isLit    = DstEntityManager.HasComponent <LitMaterial>(targetMaterial);
                    var isSimple = DstEntityManager.HasComponent <SimpleMaterial>(targetMaterial);
                    if (isSimple)
                    {
                        Debug.Log("Unlit material was not supported in SkinnedMeshRenderer:" + uMesh.name);
                        continue;
                    }

                    if (isLit)
                    {
                        Entity subSkinnedMeshRendererEntity =
                            ConvertOriginalSubMesh(this, uSkinnedMeshRenderer, uMesh, meshEntity, i, targetMaterial);
                        subSkinnedMeshRenderers.Add(subSkinnedMeshRendererEntity);
                    }
                }

                List <Entity> ret = ConvertGPUSkinnedSubMesh(this, uSkinnedMeshRenderer, uMesh, meshEntity);
                if (ret != null)
                {
                    subSkinnedMeshRenderers.AddRange(ret);
                }
                for (int j = 0; j < subSkinnedMeshRenderers.Count; j++)
                {
                    Entity subSkinnedMeshRenderer = subSkinnedMeshRenderers[j];
                    DstEntityManager.AddComponent <LitMeshRenderer>(subSkinnedMeshRenderer);
                }

                ConvertSkinnedMeshBoneInfoToTransformEntity(this, uSkinnedMeshRenderer);
            });
        }
Esempio n. 5
0
        protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.SkinnedMeshRenderer uSkinnedMeshRenderer) =>
            {
                var sharedMaterials    = uSkinnedMeshRenderer.sharedMaterials;
                UnityEngine.Mesh uMesh = uSkinnedMeshRenderer.sharedMesh;
                var meshEntity         = GetPrimaryEntity(uMesh);

                for (int i = 0; i < uMesh.subMeshCount; i++)
                {
                    Entity targetMaterial = MeshRendererConversion.FindTargetMaterialEntity(this, sharedMaterials, i);
                    ConvertOriginalSubMesh(this, uSkinnedMeshRenderer, uMesh, meshEntity, i, targetMaterial);
                }

                if (DstEntityManager.HasComponent <GPUSkinnedMeshDrawRange>(meshEntity))
                {
                    ConvertGPUSkinnedSubMesh(this, uSkinnedMeshRenderer, uMesh, meshEntity);
                }

                ConvertSkinnedMeshBoneInfoToTransformEntity(this, uSkinnedMeshRenderer);
            });
        }