Exemple #1
0
        unsafe public override void Render(Component_RenderingPipeline pipeline, ViewportRenderingContext context, Component_RenderingPipeline.IFrameData frameData)
        {
            UpdateProcessedCubemaps();

            if (mesh != null)
            {
                var pass = GetMaterialPass();
                if (pass != null)
                {
                    ////!!!!
                    //CreatedCubemapUpdate();

                    //!!!!double
                    Matrix4F worldMatrix = Matrix4.FromTranslate(context.Owner.CameraSettings.Position).ToMatrix4F();

                    foreach (var item in mesh.Result.MeshData.RenderOperations)
                    {
                        ParameterContainer generalContainer = new ParameterContainer();
                        generalContainer.Set("multiplier", Multiplier.Value.ToColorValue());
                        GetRotationMatrix(out var rotation);
                        generalContainer.Set("rotation", rotation);                          // Matrix3.FromRotateByZ( Rotation.Value.InRadians() ).ToMatrix3F() );

                        Component_Image tex = null;

                        //!!!!сделать GetResultEnvironmentCubemap()?
                        //!!!!!!где еще его использовать
                        if (processedEnvironmentCubemap != null)
                        {
                            tex = processedEnvironmentCubemap;
                        }
                        //else if( AnyCubemapSideIsSpecified() )
                        //	tex = createdCubemap;
                        else
                        {
                            tex = Cubemap;
                        }
                        if (tex == null)
                        {
                            tex = ResourceUtility.BlackTextureCube;
                        }

                        if (tex.Result != null && tex.Result.TextureType == Component_Image.TypeEnum.Cube)
                        {
                            var addressingMode = TextureAddressingMode.Clamp;

                            context.BindTexture(new ViewportRenderingContext.BindTextureData(0 /*"skyboxTexture"*/, tex, addressingMode, FilterOption.Linear, FilterOption.Linear, FilterOption.Linear));

                            var containers = new List <ParameterContainer>();
                            containers.Add(generalContainer);

                            Bgfx.SetTransform((float *)&worldMatrix);
                            ((Component_RenderingPipeline_Basic)pipeline).RenderOperation(context, item, pass, containers);
                        }
                    }
                }
            }
        }