Ejemplo n.º 1
0
        void Render(BrushMaterial brushMaterial, Unity_RenderPrimitive renderPrimitive)
        {
            if (brushMaterial == null ||
                renderPrimitive == null)
            {
                return;
            }

            if (renderPrimitive.PreRender())
            {
                Material material = (brushMaterial as IUnity_BrushMaterial).GetMaterial(renderPrimitive);
                if (material != null)
                {
                    ColorR color = ColorR.White;
                    if (brushMaterial is SolidColorBrushMaterial)
                    {
                        color = (brushMaterial as SolidColorBrushMaterial).Color;
                    }

                    double alpha = color.A * brushMaterial.Opacity * brushMaterial.RenderContext.Opacity;
                    color.A        = alpha;
                    material.color = new UnityEngine.Color((float)color.R, (float)color.G, (float)color.B, (float)color.A);


                    Alt.Sketch.Matrix4 mat = brushMaterial.FinalTransform;
                    //bool matIsIdentity = mat.IsIdentity;
                    //if (!matIsIdentity)
                    {
                        GL.PushMatrix();

                        //NoNeed	SizeI renderTargetSize = RenderTargetSize;
                        if (renderPrimitive.PrimitiveTypeIsLines)
                        {
                            mat = mat * m_WorldMatrixLines;
                        }
                        else
                        {
                            mat = mat * m_WorldMatrix;
                        }
                        mat.Transpose();

                        GL.MultMatrix(Unity_RenderManager.ToMatrix(mat));
                    }


                    try
                    {
                        if (m_CurrentUnityEngineRenderer != null)
                        {
                            m_CurrentUnityEngineRenderer.material = material;

                            //	material already setted, so we passed null
                            renderPrimitive.Render(null);
                        }
                        else
                        {
                            renderPrimitive.Render(material);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        //if (!matIsIdentity)
                        {
                            GL.PopMatrix();
                        }
                    }
                }
            }
            renderPrimitive.PostRender();
        }
Ejemplo n.º 2
0
 protected override void Render(BrushMaterial brushMaterial, RenderPrimitive renderPrimitive)
 {
     Render(brushMaterial, renderPrimitive as Unity_RenderPrimitive);
 }