Esempio n. 1
0
 public override void OnRender(RenderView view)
 {
     List<Matrix>[] transforms = new List<Matrix>[grassHighDetail.Length];
     BoundingFrustum frustum  = view.GetFrustum();
     for (int i = 0; i < grassTransforms.Keys.Count; i++)
     {
         int key = grassTransforms.Keys[i];
         //if (frustum.Contains(grassTransforms[key].Bounds) != ContainmentType.Disjoint)
         {
             int index = grassTransforms[key].GrassGeometryIndex;
             if(transforms[index] == null)
                 transforms[index] = new List<Matrix>();
             transforms[index].Add(grassTransforms[key].Transform);
         }
     }
     for (int i = 0; i < grassHighDetail.Length; i++)
     {
         if (transforms[i] != null)
         {
             grassHighDetail[i].Transform = transforms[i].ToArray();
             view.AddElement(grassMaterial, grassHighDetail[i]);
         }
     }
     base.OnRender(view);
 }
Esempio n. 2
0
 public override void OnRender(RenderView view)
 {
     SkyElementManager s = (SkyElementManager)view.GetRenderElementManager(RenderPass.Sky);
     if (s != null)
         s.Elements.Add(renderElement);
     base.OnRender(view);
 }
Esempio n. 3
0
 public void OnRender(RenderView view, bool performCulling)
 {
     if (rootNodes != null && rootNodes.Length > 0)
         mesh.Render(transform.GetTransform(), vertexBuffer, view, performCulling);
     else
         mesh.Render(transform.GetTransform(), view, performCulling);
 }
Esempio n. 4
0
        public override void OnRender(RenderView view)
        {
            base.OnRender(view);

            int zStart = camZ - CloudBlocksH;
            int zEnd = camZ + CloudBlocksH;
            int yStart = camY - CloudBlocksV;
            int yEnd = camY + CloudBlocksV;
            int xStart = camX - CloudBlocksH;
            int xEnd = camX + CloudBlocksH;
            Vector3 camPos = view.GetPosition();
            BoundingFrustum camFrustum = view.GetFrustum();
            for (int z = zStart; z <= zEnd; z++)
            {
                long zOff = sliceArea * (long)z;
                for (int y = yStart; y <= yEnd; y++)
                {
                    long yOff = width * (long)y;

                    for (int x = xStart; x <= xEnd; x++)
                    {
                        long idx = (long)x + yOff + zOff;
                        if (clusterCollection.ContainsKey(idx))
                        {
                            ForestManager currCluster = clusterCollection[idx];
                            clusterCollection[idx].OnRender(view);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 public LightElementManager(RenderView renderView)
     : base(renderView)
 {
     directionalLightShader = ResourceManager.Inst.GetShader("DirectionalLightShader");
     directionalLightShadowsShader = ResourceManager.Inst.GetShader("DirectionalLightShadowShader");
     pointLightShader = ResourceManager.Inst.GetShader("PointLightShader");
     spotLightShader = ResourceManager.Inst.GetShader("PointLightShader");
 }
Esempio n. 6
0
        public override void OnRender(RenderView view)
        {
            BoundingFrustum frustum = view.GetFrustum();
            if (frustum.Contains(boundingBox) != ContainmentType.Disjoint && !collected)
            {

            }
            base.OnRender(view);
        }
Esempio n. 7
0
 public override void OnRender(RenderView view)
 {
     if (view.GetRenderType() == RenderViewType.SHADOWS)
         return;
     SkyElementManager s = (SkyElementManager)view.GetRenderElementManager(RenderPass.Sky);
     if (s != null)
         s.Elements.Add(renderElement);
     base.OnRender(view);
 }
Esempio n. 8
0
 public override void OnRender(RenderView view)
 {
     BoundingFrustum frustum = view.GetFrustum();
     if (frustum.Contains(bounds) != ContainmentType.Disjoint)
     {
         view.AddElement(gateMaterial, gateGeometry.renderElement);
     }
     base.OnRender(view);
 }
Esempio n. 9
0
        public SkyElementManager(RenderView renderView)
            : base(renderView)
        {
            skyShaderPrepass = ResourceManager.Inst.GetShader("SkyShaderPrepass");
            skyShader = ResourceManager.Inst.GetShader("SkyShader");

            nightTexture = ResourceManager.Inst.GetTexture("Textures/Sky/StarrySky.dds");

            skyTexture = new RenderTarget2D(GFX.Device, 64, 64, 1, SurfaceFormat.Color);
        }
Esempio n. 10
0
        public override void OnRender(RenderView view)
        {
            BoundingFrustum frustum = view.GetFrustum();
            if (frustum.Contains(boundingBox) != ContainmentType.Disjoint)
            {
                int barkNum = varyTreeNum / 2;

                view.AddElement(treeMaterials[8 + barkNum], Voxels[0]);
                view.AddElement(treeMaterials[varyTreeNum], Voxels[1]);
            }
            base.OnRender(view);
        }
Esempio n. 11
0
 public override void OnRender(RenderView view)
 {
     base.OnRender(view);
     if (view.GetRenderType() == RenderViewType.MAIN)
     {
         if (view.GetFrustum().Contains(bounds) != ContainmentType.Disjoint)
         {
             MainRenderView renderView = (MainRenderView)view;
             renderView.AddDecalElement(material, transform);
         }
     }
 }
Esempio n. 12
0
 public override void OnRender(RenderView view)
 {
     BoundingFrustum frustm = view.GetFrustum();
     for (int i = 0; i < Voxels.Count; i++)
     {
         if(Voxels.Values[i].CanRender)//if (frustm.Contains(VoxelBounds.Values[i]) != ContainmentType.Disjoint && Voxels.Values[i].CanRender)
         {
             view.AddElement(terrainMaterial, Voxels.Values[i].renderElement);
         }
     }
     base.OnRender(view);
 }
Esempio n. 13
0
        public void OnRender(RenderView view, bool performCulling)
        {
            if (performCulling && view.GetFrustum().Contains(hitBounds) == ContainmentType.Disjoint)
                return;

            if (rootNodes != null && rootNodes.Length > 0)
            {
                //mesh.Render(worldMat, vertexBuffer, view, performCulling);
                mesh.Render(transforms, view, performCulling);
            }
            else
                mesh.Render(worldMat, view, performCulling);
        }
        public SkyElementManager(RenderView renderView)
            : base(renderView)
        {
            skyShaderPrepass = ResourceManager.Inst.GetShader("SkyShaderPrepass");
            skyShader = ResourceManager.Inst.GetShader("SkyShader");
            cloudShader = ResourceManager.Inst.GetShader("CloudShader");

            nightTexture = ResourceManager.Inst.GetTexture("Textures/Sky/StarrySky.dds");

            skyTexture = new RenderTarget2D(GFX.Device, 16, 16, 1, SurfaceFormat.Color);

            cloudMatrix = Matrix.CreateRotationX(MathHelper.PiOver2);
            cloudMatrix.Translation = Vector3.Up * 0.09f;
        }
Esempio n. 15
0
 public WaterElementManager(RenderView view)
     : base(view)
 {
     waterShader = ResourceManager.Inst.GetShader("WaterShader");
     generic2DShader = ResourceManager.Inst.GetShader("Generic2D");
     noiseTexture = ResourceManager.Inst.GetTexture("Textures/Water/noise02.dds");
     bumpCoords = new Vector4[]
     {
         new Vector4(0.264000f,0.178000f, 0.2f, 0.1f),
         new Vector4(-2.06840f, -1.52640f, -1.0f, 0.23f),
         new Vector4(1.87920f, 1.9232f, 0.2f, 0.15f),
         new Vector4(0.096000f, 0.04f, -0.3f, 0.1f),
     };
     waterMatrix = Matrix.CreateScale(Vector3.One * 4096)*Matrix.CreateRotationX(MathHelper.Pi);
 }
Esempio n. 16
0
        public void Render()
        {
            int renderViewCount = RenderViews.Count;
            RenderView[] views = new RenderView[renderViewCount];

            for (int i = 0; i < renderViewCount; i++)
            {
                RenderView renderView = RenderViews.ExtractMin();
                for (int j = 0; j < Entities.Count; j++)
                {
                    Entities[j].OnRender(renderView);
                }
                views[i] = renderView;
            }
            for (int i = 0; i < views.Length; i++)
            {
                views[i].Render();
                RenderViews.Enqueue(views[i], (int)views[i].GetRenderType());
            }
        }
 public override void OnRender(RenderView view)
 {
     BoundingFrustum frustum = view.GetFrustum();
     for (int i = 0; i < clusterCollection.Values.Count; i++)
     {
         ShapeCluster currCluster = clusterCollection.Values[i];
         if (currCluster != null && frustum.Contains(currCluster.Bounds) != ContainmentType.Disjoint)
         {
             for (int j = 0; j < currCluster.Transforms.Count; j++)
             {
                 int currKey = currCluster.Transforms.Keys[j];
                 for (int l = 0; l < currCluster.Transforms[currKey].Count; l++)
                 {
                     meshSets[currKey].Render(currCluster.Transforms[currKey][l], view, true);
                 }
             }
         }
     }
     base.OnRender(view);
 }
 public ParticleElementManager(RenderView renderView)
     : base(renderView)
 {
 }
Esempio n. 19
0
 public void OnRender(RenderView view)
 {
     fpsModel.OnRender(view, false);
     if (view.GetRenderType() == RenderViewType.MAIN && !datablock.IsMelee)
     {
         GUIElementManager elemManager = GFX.Inst.GetGUI();
         int ammoRatio = (int)((float)ReserveAmmo / (float)AmmoPerClip);
         GUITextElement elem = new GUITextElement(new Vector2(0.85f, -0.85f), ammo.ToString() + "/"+ammoRatio);
         elemManager.AddElement(elem);
     }
 }
Esempio n. 20
0
 public void AddRenderView(RenderView view)
 {
     RenderViews[(int)view.GetRenderType()].Add(view);
 }
Esempio n. 21
0
 public void RemoveRenderView(RenderView view)
 {
     int index = RenderViews[(int)view.GetRenderType()].IndexOf(view);
     if (index >= 0)
         RenderViews[(int)view.GetRenderType()].RemoveAt(index);
 }
Esempio n. 22
0
 public SceneElementManager(RenderView renderView)
     : base(renderView)
 {
 }
 public void OnRender(RenderView renderView)
 {
     BoundingFrustum frustum = renderView.GetFrustum();
     for (int j = 0; j < patches.Count; j++)
     {
         if (patches.Values[j].CanRender && frustum.Contains(patches.Values[j].Bounds) != ContainmentType.Disjoint)
         {
             for (int i = 0; i < patches.Values[j].Elements.Length; i++)
                 renderView.AddElement(patches.Values[j].Materials[i], patches.Values[j].Elements[i]);
         }
     }
 }
Esempio n. 24
0
        void ComputeFrustum(float minZ, float maxZ, RenderView cameraRenderView, int split)
        {
            // Shorten the view frustum according to the shadow view distance
            Matrix cameraMatrix = cameraRenderView.GetWorldMatrix();

            Vector4 camPos = cameraRenderView.GetEyePosShader();

            for (int i = 0; i < 4; i++)
                splitFrustumCornersVS[i] = frustumCornersVS[i + 4] * (minZ / camPos.W);

            for (int i = 4; i < 8; i++)
                splitFrustumCornersVS[i] = frustumCornersVS[i] * (maxZ / camPos.W);

            Vector3.Transform(splitFrustumCornersVS, ref cameraMatrix, frustumCornersWS);

            // Position the shadow-caster camera so that it's looking at the centroid,
            // and backed up in the direction of the sunlight
            BoundingBox sceneBounds = scene.GetSceneDimensions();
            Vector3 sceneCenter = (sceneBounds.Min + sceneBounds.Max) * 0.5f;
            Vector3 sceneExtents = (sceneBounds.Max - sceneBounds.Min) * 0.5f;
            Vector3 lightDir = -this.Transformation.GetPosition();
            lightDir.Normalize();
            Matrix viewMatrix = Matrix.CreateLookAt(sceneCenter - (lightDir * sceneExtents.Length()), sceneCenter, new Vector3(0, 1, 0));

            // Determine the position of the frustum corners in light space
            Vector3.Transform(frustumCornersWS, ref viewMatrix, frustumCornersLS);

            // Calculate an orthographic projection by sizing a bounding box
            // to the frustum coordinates in light space
            Vector3 mins = frustumCornersLS[0];
            Vector3 maxes = frustumCornersLS[0];
            for (int i = 0; i < 8; i++)
            {
                maxes = Vector3.Max(frustumCornersLS[i], maxes);
                mins = Vector3.Min(frustumCornersLS[i], mins);
            }

            // Create an orthographic camera for use as a shadow caster
            //const float nearClipOffset = 380.0f;

            float nearPlane = -maxes.Z-sceneExtents.Length();
            float farPlane = -mins.Z;

            renderViews[split].SetPosition(viewMatrix.Translation);
            renderViews[split].SetView(viewMatrix);
            renderViews[split].SetNearPlane(nearPlane);
            renderViews[split].SetFarPlane(farPlane);
            renderViews[split].SetProjection(Matrix.CreateOrthographicOffCenter(mins.X, maxes.X, mins.Y, maxes.Y, nearPlane, farPlane));
            lightViewProjectionMatrices[split] = renderViews[split].GetViewProjection();
            lightClipPositions[split] = renderViews[split].GetEyePosShader();
        }
 public ClutterPlacement(TerrainHeightmap terrain, RenderView renderView)
 {
     this.terrain = terrain;
     this.view = renderView;
     this.climate = terrain.GetClimate();
     BuildPlantSpots();
 }
Esempio n. 26
0
        void RecursivelyRenderDebug(KDNode<VoxelElement> node, RenderView view, int depth, bool isLeft)
        {
            if (node == null)// || view.GetFrustum().Contains(node.bounds) == ContainmentType.Disjoint)
                return;

            {

                Gaia.Rendering.DebugElementManager debugMgr = (Gaia.Rendering.DebugElementManager)view.GetRenderElementManager(Gaia.Rendering.RenderPass.Debug);
                Color currColor = (isLeft) ? nodeColorsLeft[depth % nodeColorsLeft.Length] : nodeColors[depth % nodeColors.Length];
                if (depth == maxDepth)
                    debugMgr.AddElements(DebugHelper.GetVerticesFromBounds(node.bounds, currColor));

                if (node.element != null)
                {
                    debugMgr.AddElements(DebugHelper.GetVerticesFromBounds(node.element.bounds, Color.White));
                }
            }
            depth++;
            //if (depth < maxDepth)
            {
                RecursivelyRenderDebug(node.leftChild, view, depth, true);
                RecursivelyRenderDebug(node.rightChild, view, depth, false);
            }
        }
Esempio n. 27
0
 public override void OnRender(RenderView view)
 {
     bool canRender = (view.GetFrustum().Contains(Transformation.GetBounds()) != ContainmentType.Disjoint);
     canRender |= (type == LightType.Directional);
     if (canRender)
     {
         LightElementManager lightMgr = (LightElementManager)view.GetRenderElementManager(RenderPass.Light);
         if (lightMgr != null)
         {
             switch (type)
             {
                 case LightType.Directional:
                     if (castsShadows)
                         lightMgr.DirectionalShadowLights.Enqueue(this);
                     else
                         lightMgr.DirectionalLights.Enqueue(this);
                     break;
                 case LightType.Point:
                     lightMgr.PointLights.Enqueue(this);
                     break;
                 case LightType.Spot:
                     lightMgr.SpotLights.Enqueue(this);
                     break;
             }
         }
     }
     base.OnRender(view);
 }
Esempio n. 28
0
        public override void OnRender(RenderView view)
        {
            BoundingFrustum frustum = view.GetFrustum();
            view.AddElement(terrainQuadMaterial, giantQuadElement);
            RecursivelyRender(voxelKDTree.GetRoot(), view);
            /*
            if (view.GetRenderType() == RenderViewType.MAIN)
            {
                RecursivelyRenderDebug(voxelKDTree.GetRoot(), view, 0, false);
                GUIElementManager guiElem = GFX.Inst.GetGUI();
                guiElem.AddElement(new GUITextElement(new Vector2(-0.85f, 0.95f), "Depth: " + maxDepth));
            }

            for (int i = 0; i < Voxels.Length; i++)
            {
                if (Voxels[i].CanRender && frustum.Contains(VoxelBounds[i]) != ContainmentType.Disjoint)
                {
                    view.AddElement(terrainMaterial, Voxels[i].renderElement);
                }
            }
            */
            base.OnRender(view);
        }
 public TransparentElementManager(RenderView renderView)
     : base(renderView)
 {
 }
Esempio n. 30
0
        void RecursivelyRender(KDNode<VoxelElement> node, RenderView view)
        {
            if (node == null || (view.GetFrustum().Contains(node.bounds) == ContainmentType.Disjoint))// && node.bounds.Contains(view.GetPosition()) == ContainmentType.Disjoint))
                return;

            if (node.element != null && (view.GetFrustum().Contains(node.element.bounds) != ContainmentType.Disjoint))
            {
                view.AddElement(terrainMaterial, node.element.geometry.renderElement);
            }
            RecursivelyRender(node.leftChild, view);
            RecursivelyRender(node.rightChild, view);
        }