コード例 #1
0
 public void SetMaterialAsset(int materialIndex, CAssetReference <CMaterialAsset> materialAsset)
 {
     m_materialAssets.SetMinSize(materialIndex + 1);
     m_materialAssets[materialIndex] = materialAsset;
     if (m_renderNodes.Length < materialIndex)
     {
         m_renderNodes[materialIndex].SetMaterialOverride(materialAsset);
     }
 }
コード例 #2
0
        public object ToMaterialValue(object editorValue)
        {
            if (editorValue == null)
            {
                return(null);
            }

            CAssetReference <CTextureAsset> assetReference = (CAssetReference <CTextureAsset>)editorValue;

            return(CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CTextureSampler>(assetReference.GetAsset()));
        }
コード例 #3
0
        public static CEntity SpawnEntityFromAsset(CAssetReference <CEntityAsset <CEntity> > entityAsset)
        {
            if (entityAsset != null && entityAsset.GetAsset() != null)
            {
                CEntity newEntity = entityAsset.GetAsset().GetEntity();
                GetCurrentWorld().InitWithWorld(newEntity);
                return(newEntity);
            }

            return(null);
        }
コード例 #4
0
        public object ToEditorValue(object materialValue)
        {
            if (materialValue == null)
            {
                return(null);
            }

            CTextureSampler textureValue = (CTextureSampler)materialValue;
            CAssetReference <CTextureAsset> assetReference = CAssetRegistry.Instance.GetAsset <CTextureAsset>(textureValue.Guid);

            return(assetReference);
        }
コード例 #5
0
        public static CEntity SpawnEntityAssetAtPosition(CAssetReference <CEntityAsset <CEntity> > entityAsset, Vector3 worldPosition, Quaternion worldRotation)
        {
            if (entityAsset != null && entityAsset.GetAsset() != null)
            {
                CEntity newEntity = entityAsset.GetAsset().GetEntity();
                newEntity.SetWorldPosition(in worldPosition);
                newEntity.SetWorldRotation(in worldRotation);
                GetCurrentWorld().InitWithWorld(newEntity);
                return(newEntity);
            }

            return(null);
        }
コード例 #6
0
        internal override void InitFromAsset(Device device, CAsset asset)
        {
            CMaterialAsset materialAsset = (CMaterialAsset)asset;

            System.Diagnostics.Debug.Assert(materialAsset != null && materialAsset.IsLoaded);

            if (materialAsset.Shader != null)
            {
                ShaderResource = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CShaderResource>(materialAsset.Shader);
            }
            else
            {
                ShaderResource = CRenderer.Instance.ResourceManager.DefaultShader;
            }

            SetColorParameter(new SHashedName("tintColor"), Vector4.One);
            SetColorParameter(new SHashedName("specularColor"), Vector4.One);
            SetScalarParameter(new SHashedName("specularPower"), 10);
            for (int i = 0; i < materialAsset.MaterialParameters.Count; i++)
            {
                var parameterDesc = materialAsset.MaterialParameters[i];
                if (parameterDesc.parameter.parameterData == null)
                {
                    continue;
                }
                if (parameterDesc.parameter.parameterType == EShaderParameterType.Texture)
                {
                    CAssetReference <CTextureAsset> textureReference = (CAssetReference <CTextureAsset>)parameterDesc.parameter.parameterData;
                    if (textureReference.GetAsset() != null)
                    {
                        CTextureSampler  sampler         = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CTextureSampler>(textureReference.GetAsset());
                        SShaderParameter activeParameter = new SShaderParameter()
                        {
                            parameterData = sampler,
                            parameterType = EShaderParameterType.Texture
                        };
                        m_activeParameters[parameterDesc.name] = activeParameter;
                    }
                }
                else
                {
                    m_activeParameters[parameterDesc.name] = parameterDesc.parameter;
                }
            }
        }
コード例 #7
0
ファイル: Workspace.cs プロジェクト: HenningAx/KlaxGameEngine
 public void PostLevelLoad(CAssetReference <CLevelAsset> levelAsset)
 {
     OpenedLevelAsset = levelAsset;
 }