Esempio n. 1
0
        public void RenderImposters(Matrix transform, RenderView view, bool performCulling)
        {
            if (useInstancing && !addedToView)
            {
                view.AddMeshToRender(this);
                addedToView = true;
            }

            if (performCulling)
            {
                BoundingFrustum frustum = view.GetFrustum();
                Matrix oldMat = frustum.Matrix;
                frustum.Matrix = transform * view.GetViewProjection();
                if (imposterGeometry != null && frustum.Contains(meshBounds) != ContainmentType.Disjoint)
                {
                    Matrix tempTransform = imposterGeometry.Scale * transform;
                    if (useInstancing)
                    {
                        imposterGeometry.transforms.Add(tempTransform);
                        //InjectTransform(ref tempTransform, ref imposterInstanceTemp, ref imposterInstanceCount, ref imposterInstanceTexture);
                    }
                    else
                    {
                        imposterGeometry.Element.Transform = new Matrix[1] {tempTransform};
                        view.AddElement(imposterGeometry.ImposterMaterial, imposterGeometry.Element);
                    }
                }
                frustum.Matrix = oldMat;
            }
            else if (imposterGeometry != null)
            {
                Matrix tempTransform = imposterGeometry.Scale * transform;
                if (useInstancing)
                {
                    imposterGeometry.transforms.Add(tempTransform);
                    //InjectTransform(ref transform, ref imposterInstanceTemp, ref imposterInstanceCount, ref imposterInstanceTexture);
                }
                else
                {
                    imposterGeometry.Element.Transform = new Matrix[1] {tempTransform};
                    view.AddElement(imposterGeometry.ImposterMaterial, imposterGeometry.Element);
                }
            }
        }
Esempio n. 2
0
        public void Render(Matrix transform, RenderView view, bool performCulling)
        {
            if (useInstancing && !addedToView)
            {
                view.AddMeshToRender(this);
                addedToView = true;
            }

            if (performCulling)
            {
                BoundingFrustum frustum = view.GetFrustum();
                Matrix oldMat = frustum.Matrix;
                frustum.Matrix = transform * view.GetViewProjection();
                if (frustum.Contains(meshBounds) != ContainmentType.Disjoint)
                {
                    if (useInstancing)
                    {
                        transforms.Add(transform);
                        //InjectTransform(ref transform, ref instanceTemp, ref instanceCount, ref instanceTexture);
                    }
                    else
                    {
                        for (int i = 0; i < parts.Length; i++)
                        {
                            if (frustum.Contains(parts[i].bounds) != ContainmentType.Disjoint)
                            {
                                parts[i].renderElement.Transform = new Matrix[1] {transform};
                                view.AddElement(parts[i].material, parts[i].renderElement);
                            }
                        }
                    }

                }
                frustum.Matrix = oldMat;
            }
            else
            {
                if (useInstancing)
                {
                    transforms.Add(transform);
                    //InjectTransform(ref transform, ref instanceTemp, ref instanceCount, ref instanceTexture);
                }
                else
                {
                    for (int i = 0; i < parts.Length; i++)
                    {
                        parts[i].renderElement.Transform = new Matrix[1] { transform };
                        view.AddElement(parts[i].material, parts[i].renderElement);
                    }
                }
            }
        }