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); } }
public object ToMaterialValue(object editorValue) { if (editorValue == null) { return(null); } CAssetReference <CTextureAsset> assetReference = (CAssetReference <CTextureAsset>)editorValue; return(CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CTextureSampler>(assetReference.GetAsset())); }
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); }
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); }
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); }
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; } } }
public void PostLevelLoad(CAssetReference <CLevelAsset> levelAsset) { OpenedLevelAsset = levelAsset; }